You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by yj...@apache.org on 2020/10/29 05:44:53 UTC
[incubator-superset] 10/33: more updates
This is an automated email from the ASF dual-hosted git repository.
yjc pushed a commit to branch home-screen-mvp
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
commit 97c21c9cdc7a86f047e13f2cd2ca6280cdb59bbf
Author: Phillip Kelley-Dotson <pk...@yahoo.com>
AuthorDate: Tue Oct 6 15:28:42 2020 -0700
more updates
---
.../views/CRUD/welcome/SavedQueries_spec.tsx | 0
.../views/CRUD/welcome/Welcome_spec.tsx | 7 +-
.../src/components/ListViewCard/index.tsx | 8 +-
superset-frontend/src/components/Menu/SubMenu.tsx | 14 +-
.../src/views/CRUD/chart/ChartCard.tsx | 162 +++++++++++++++++++++
.../src/views/CRUD/chart/ChartList.tsx | 5 +-
.../src/views/CRUD/dashboard/DashboardCard.tsx | 31 +---
superset-frontend/src/views/CRUD/types.ts | 36 +++++
.../src/views/CRUD/welcome/ActivityTable.tsx | 63 ++++----
.../src/views/CRUD/welcome/ChartTable.tsx | 55 +++----
.../src/views/CRUD/welcome/SavedQueries.tsx | 129 +++++++++-------
.../src/views/CRUD/welcome/Welcome.tsx | 31 ++--
superset/queries/saved_queries/api.py | 2 +-
13 files changed, 355 insertions(+), 188 deletions(-)
diff --git a/superset-frontend/spec/javascripts/views/CRUD/welcome/SavedQueries_spec.tsx b/superset-frontend/spec/javascripts/views/CRUD/welcome/SavedQueries_spec.tsx
new file mode 100644
index 0000000..e69de29
diff --git a/superset-frontend/spec/javascripts/views/CRUD/welcome/Welcome_spec.tsx b/superset-frontend/spec/javascripts/views/CRUD/welcome/Welcome_spec.tsx
index bf23ef1..5db15b9 100644
--- a/superset-frontend/spec/javascripts/views/CRUD/welcome/Welcome_spec.tsx
+++ b/superset-frontend/spec/javascripts/views/CRUD/welcome/Welcome_spec.tsx
@@ -17,7 +17,6 @@
* under the License.
*/
import React from 'react';
-import { Panel, Row, Tab } from 'react-bootstrap';
import { shallow } from 'enzyme';
import Welcome from 'src/views/CRUD/welcome/Welcome';
@@ -37,10 +36,8 @@ describe('Welcome', () => {
it('is valid', () => {
expect(React.isValidElement(<Welcome {...mockedProps} />)).toBe(true);
});
- it('renders 3 Tab, Panel, and Row components', () => {
+ it('renders 3 submenu components', () => {
const wrapper = shallow(<Welcome {...mockedProps} />);
- expect(wrapper.find(Tab)).toHaveLength(3);
- expect(wrapper.find(Panel)).toHaveLength(3);
- expect(wrapper.find(Row)).toHaveLength(3);
+ expect(wrapper.find('SubMenu')).toHaveLength(4);
});
});
diff --git a/superset-frontend/src/components/ListViewCard/index.tsx b/superset-frontend/src/components/ListViewCard/index.tsx
index eb2bbab..7fb69c0 100644
--- a/superset-frontend/src/components/ListViewCard/index.tsx
+++ b/superset-frontend/src/components/ListViewCard/index.tsx
@@ -151,10 +151,11 @@ interface CardProps {
titleRight?: React.ReactNode;
coverLeft?: React.ReactNode;
coverRight?: React.ReactNode;
- actions: React.ReactNode;
+ actions: React.ReactNode | null;
showImg?: boolean;
rows?: number | string;
avatar?: string;
+ isRecent?: boolean;
}
function ListViewCard({
@@ -167,7 +168,7 @@ function ListViewCard({
coverLeft,
coverRight,
actions,
- avatar = 'nav-dashboard',
+ avatar,
loading,
imgPosition = 'top',
showImg = true,
@@ -255,7 +256,8 @@ function ListViewCard({
</>
}
description={description}
- avatar={<IconComponent />}
+ // @ts-ignore
+ avatar={avatar ? <Icon name={avatar} /> : null}
/>
)}
</StyledCard>
diff --git a/superset-frontend/src/components/Menu/SubMenu.tsx b/superset-frontend/src/components/Menu/SubMenu.tsx
index 93df81c..0144a20 100644
--- a/superset-frontend/src/components/Menu/SubMenu.tsx
+++ b/superset-frontend/src/components/Menu/SubMenu.tsx
@@ -53,12 +53,24 @@ const StyledHeader = styled.header`
li.active > a,
li.active > div,
li > a:hover,
+ li > a:focus,
li > div:hover {
- background-color: ${({ theme }) => theme.colors.secondary.light4};
+ background: ${({ theme }) => theme.colors.secondary.light4};
border-bottom: none;
border-radius: 4px;
}
}
+ .navbar-inverse {
+ .navbar-nav {
+ & > .active > a {
+ background: ${({ theme }) => theme.colors.secondary.light4};
+ &:hover,
+ &:focus {
+ background: ${({ theme }) => theme.colors.secondary.light4};
+ }
+ }
+ }
+ }
`;
type MenuClickHandler = React.MouseEventHandler<MenuItem>;
diff --git a/superset-frontend/src/views/CRUD/chart/ChartCard.tsx b/superset-frontend/src/views/CRUD/chart/ChartCard.tsx
new file mode 100644
index 0000000..a8a123c
--- /dev/null
+++ b/superset-frontend/src/views/CRUD/chart/ChartCard.tsx
@@ -0,0 +1,162 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import { useFavoriteStatus } from 'src/views/CRUD/hooks';
+// import { createFetchRelated, createErrorHandler } from 'src/views/CRUD/utils';
+import { SupersetClient, t } from '@superset-ui/core';
+import ConfirmStatusChange from 'src/components/ConfirmStatusChange';
+import AvatarIcon from 'src/components/AvatarIcon';
+import Icon from 'src/components/Icon';
+import Chart from 'src/types/Chart';
+import ListViewCard from 'src/components/ListViewCard';
+import Label from 'src/components/Label';
+import { Dropdown, Menu } from 'src/common/components';
+import FaveStar from 'src/components/FaveStar';
+
+const FAVESTAR_BASE_URL = '/superset/favstar/slice';
+
+interface ChartCardProps {
+ chart: Chart;
+ hasPerm: (perm: string) => boolean;
+ openChartEditModal: (chart: Chart) => void;
+ bulkSelectEnabled: boolean;
+ addDangerToast: (msg: string) => void;
+ addSuccessToast: (msg: string) => void;
+ refreshData: () => void;
+ loading: boolean;
+}
+
+export default function ChartCard({
+ chart,
+ hasPerm,
+ openChartEditModal,
+ bulkSelectEnabled,
+ addDangerToast,
+ addSuccessToast,
+ refreshData,
+ loading,
+}: ChartCardProps) {
+ const canEdit = hasPerm('can_edit');
+ const canDelete = hasPerm('can_delete');
+ const [favoriteStatusRef, fetchFaveStar, saveFaveStar] = useFavoriteStatus(
+ {},
+ FAVESTAR_BASE_URL,
+ addDangerToast,
+ );
+
+ function openChartEditModal(chart: Chart) {
+ setSliceCurrentlyEditing({
+ slice_id: chart.id,
+ slice_name: chart.slice_name,
+ description: chart.description,
+ cache_timeout: chart.cache_timeout,
+ });
+ }
+
+ function handleChartDelete({ id, slice_name: sliceName }: Chart) {
+ SupersetClient.delete({
+ endpoint: `/api/v1/chart/${id}`,
+ }).then(
+ () => {
+ refreshData();
+ addSuccessToast(t('Deleted: %s', sliceName));
+ },
+ () => {
+ addDangerToast(t('There was an issue deleting: %s', sliceName));
+ },
+ );
+ }
+
+ const menu = (
+ <Menu>
+ {canDelete && (
+ <Menu.Item>
+ <ConfirmStatusChange
+ title={t('Please Confirm')}
+ description={
+ <>
+ {t('Are you sure you want to delete')} <b>{chart.slice_name}</b>
+ ?
+ </>
+ }
+ onConfirm={() => handleChartDelete(chart)}
+ >
+ {confirmDelete => (
+ <div
+ role="button"
+ tabIndex={0}
+ className="action-button"
+ onClick={confirmDelete}
+ >
+ <ListViewCard.MenuIcon name="trash" /> Delete
+ </div>
+ )}
+ </ConfirmStatusChange>
+ </Menu.Item>
+ )}
+ {canEdit && (
+ <Menu.Item
+ role="button"
+ tabIndex={0}
+ onClick={() => openChartEditModal(chart)}
+ >
+ <ListViewCard.MenuIcon name="edit-alt" /> Edit
+ </Menu.Item>
+ )}
+ </Menu>
+ );
+ return (
+ <ListViewCard
+ loading={loading}
+ title={chart.slice_name}
+ url={bulkSelectEnabled ? undefined : chart.url}
+ imgURL={chart.thumbnail_url ?? ''}
+ imgFallbackURL="/static/assets/images/chart-card-fallback.png"
+ description={t('Last modified %s', chart.changed_on_delta_humanized)}
+ coverLeft={(chart.owners || []).slice(0, 5).map(owner => (
+ <AvatarIcon
+ key={owner.id}
+ uniqueKey={`${owner.username}-${chart.id}`}
+ firstName={owner.first_name}
+ lastName={owner.last_name}
+ iconSize={24}
+ textSize={9}
+ />
+ ))}
+ coverRight={
+ <Label bsStyle="secondary">{chart.datasource_name_text}</Label>
+ }
+ actions={
+ <ListViewCard.Actions>
+ <FaveStar
+ itemId={chart.id}
+ fetchFaveStar={fetchFaveStar}
+ saveFaveStar={saveFaveStar}
+ isStarred={!!favoriteStatusRef.current[chart.id]}
+ height={20}
+ width={20}
+ />
+ <Dropdown overlay={menu}>
+ <Icon name="more-horiz" />
+ </Dropdown>
+ </ListViewCard.Actions>
+ }
+ />
+ );
+}
diff --git a/superset-frontend/src/views/CRUD/chart/ChartList.tsx b/superset-frontend/src/views/CRUD/chart/ChartList.tsx
index 0586267..d326db7 100644
--- a/superset-frontend/src/views/CRUD/chart/ChartList.tsx
+++ b/superset-frontend/src/views/CRUD/chart/ChartList.tsx
@@ -430,7 +430,10 @@ function ChartList(props: ChartListProps) {
hasPerm={hasPerm}
openChartEditModal={openChartEditModal}
bulkSelectEnabled={bulkSelectEnabled}
- renderFaveStar={renderFaveStar}
+ addDangerToast={props.addDangerToast}
+ addSuccessToast={addSuccessToast}
+ refreshData={refreshData}
+ loading={loading}
/>
);
}
diff --git a/superset-frontend/src/views/CRUD/dashboard/DashboardCard.tsx b/superset-frontend/src/views/CRUD/dashboard/DashboardCard.tsx
index f42de20..e2e3b1f 100644
--- a/superset-frontend/src/views/CRUD/dashboard/DashboardCard.tsx
+++ b/superset-frontend/src/views/CRUD/dashboard/DashboardCard.tsx
@@ -8,39 +8,12 @@ import Icon from 'src/components/Icon';
import Label from 'src/components/Label';
import FacePile from 'src/components/FacePile';
import FaveStar from 'src/components/FaveStar';
-import Owner from 'src/types/Owner';
-
+import { DashboardCardProps, Dashboard } from 'src/views/CRUD/types';
import { createErrorHandler } from 'src/views/CRUD/utils';
import { useFavoriteStatus } from 'src/views/CRUD/hooks';
const FAVESTAR_BASE_URL = '/superset/favstar/Dashboard';
-interface Dashboard {
- changed_by_name: string;
- changed_by_url: string;
- changed_on_delta_humanized: string;
- changed_by: string;
- dashboard_title: string;
- slice_name?: string;
- id: number;
- published: boolean;
- url: string;
- thumbnail_url: string;
- owners: Owner[];
- loading: boolean;
-}
-
-interface DashboardCardProps {
- isChart?: boolean;
- dashboard: Dashboard;
- hasPerm: (name: string) => boolean;
- bulkSelectEnabled: boolean;
- refreshData: () => void;
- addDangerToast: (msg: string) => void;
- addSuccessToast: (msg: string) => void;
- openDashboardEditModal?: (d: Dashboard) => void;
-}
-
function DashboardCard({
isChart,
dashboard,
@@ -132,7 +105,7 @@ function DashboardCard({
openDashboardEditModal && openDashboardEditModal(dashboard)
}
>
- <ListViewCard.MenuIcon name="pencil" /> Edit
+ <ListViewCard.MenuIcon name="edit-alt" /> Edit
</Menu.Item>
)}
</Menu>
diff --git a/superset-frontend/src/views/CRUD/types.ts b/superset-frontend/src/views/CRUD/types.ts
index 91d88a3..7f5fce5 100644
--- a/superset-frontend/src/views/CRUD/types.ts
+++ b/superset-frontend/src/views/CRUD/types.ts
@@ -16,7 +16,43 @@
* specific language governing permissions and limitations
* under the License.
*/
+import { User } from 'src/types/bootstrapTypes';
+import Owner from 'src/types/Owner';
export type FavoriteStatus = {
[id: number]: boolean;
};
+
+export interface DashboardTableProps {
+ addDangerToast: (message: string) => void;
+ addSuccessToast: (message: string) => void;
+ search: string;
+ dashboardFilter?: string;
+ user?: User;
+}
+
+interface Dashboard {
+ changed_by_name: string;
+ changed_by_url: string;
+ changed_on_delta_humanized: string;
+ changed_by: string;
+ dashboard_title: string;
+ slice_name?: string;
+ id: number;
+ published: boolean;
+ url: string;
+ thumbnail_url: string;
+ owners: Owner[];
+ loading: boolean;
+}
+
+export interface DashboardCardProps {
+ isChart?: boolean;
+ dashboard: Dashboard;
+ hasPerm: (name: string) => boolean;
+ bulkSelectEnabled: boolean;
+ refreshData: () => void;
+ addDangerToast: (msg: string) => void;
+ addSuccessToast: (msg: string) => void;
+ openDashboardEditModal?: (d: Dashboard) => void;
+}
diff --git a/superset-frontend/src/views/CRUD/welcome/ActivityTable.tsx b/superset-frontend/src/views/CRUD/welcome/ActivityTable.tsx
index ae496f2..b4c941c 100644
--- a/superset-frontend/src/views/CRUD/welcome/ActivityTable.tsx
+++ b/superset-frontend/src/views/CRUD/welcome/ActivityTable.tsx
@@ -17,34 +17,29 @@
* under the License.
*/
import React, { useEffect, useState } from 'react';
-import { styled, SupersetClient, t } from '@superset-ui/core';
-import Icon from 'src/components/Icon';
+import { SupersetClient, t } from '@superset-ui/core';
import rison from 'rison';
import moment from 'moment';
import ListViewCard from 'src/components/ListViewCard';
import { addDangerToast } from 'src/messageToasts/actions';
-import { MenuItem } from 'react-bootstrap';
import { createBatchMethod, createErrorHandler } from '../utils';
interface MapProps {
- action: string;
- item_title: string;
+ action?: string;
+ item_title?: string;
slice_name: string;
time: string;
changed_on_utc: string;
+ item_url: string;
+}
+
+interface ActivityProps {
user: {
userId: string | number;
};
activityFilter: string;
- item_url: string;
}
-const Cards = styled.div`
- width: 200px;
- padding: 15px;
- border: 1px solid #f0f0f0;
-`;
-
const filters = {
// Chart and dashbaord uses same filters
// for edited and created
@@ -64,33 +59,34 @@ const filters = {
],
};
-export default function ActivityTable({ user, activityFilter }: MapProps) {
+export default function ActivityTable({ user, activityFilter }: ActivityProps) {
const [active, setActiveState] = useState([]);
+ const [loading, setLoading] = useState(false);
const recent = `/superset/recent_activity/${user.userId}/?limit=10`;
const setData = (endpoint: string) => {
- SupersetClient.get(endpoint)
+ setLoading(true);
+ SupersetClient.get({ endpoint })
.then(({ json }) => {
+ setLoading(false);
setActiveState(json);
})
- .catch(e => {
- createErrorHandler(err =>
+ .catch(() => {
+ setLoading(false);
+ createErrorHandler(() =>
addDangerToast(t('There was an issue fetching your resource')),
);
});
};
const setBatchData = (q: string) => {
- createBatchMethod(q).then((res: Array<object>) => {
- setActiveState(res);
- });
+ createBatchMethod(q).then((res: Array<object>) => setActiveState(res));
};
- const getIconName = (name: string): string => {
- console.log('name', name)
+ const getIconName = (name: string | undefined) => {
if (name === 'explore_json') return 'sql';
if (name === 'dashboard') return 'nav-dashboard';
- if (name === 'log') return 'nav-chart';
- return 'sql';
+ if (name === 'log') return 'nav-charts';
+ return '';
};
const getData = () => {
@@ -102,7 +98,7 @@ export default function ActivityTable({ user, activityFilter }: MapProps) {
filters: activityFilter !== 'Created' ? filters.edited : filters.created,
});
if (activityFilter === 'Viewed') {
- setData({ endpoint: recent });
+ setData(recent);
}
if (activityFilter === 'Edited') {
setBatchData(queryParams);
@@ -117,31 +113,22 @@ export default function ActivityTable({ user, activityFilter }: MapProps) {
}, [activityFilter]);
const renderActivity = () => {
- console.log('e', active)
return active.map((e: MapProps) => (
<ListViewCard
- isRecent={true}
+ isRecent
+ loading={loading}
+ imgURL={null}
+ imgFallbackURL={null}
url={e.item_url}
title={activityFilter === 'Viewed' ? e.item_title : e.slice_name}
description={moment
.utc(activityFilter === 'Viewd' ? e.time : e.changed_on_utc)
.fromNow()}
avatar={getIconName(e.action)}
+ actions={null}
/>
));
};
return <> {renderActivity()} </>;
}
-/*
- <a href={e.item_url}>
- <Cards>
- <div>{activityFilter === 'Viewed' ? e.item_title : e.slice_name}</div>
- <div>
- {moment
- .utc(activityFilter === 'Viewd' ? e.time : e.changed_on_utc)
- .fromNow()}
- </div>
- </Cards>
- </>
- */
\ No newline at end of file
diff --git a/superset-frontend/src/views/CRUD/welcome/ChartTable.tsx b/superset-frontend/src/views/CRUD/welcome/ChartTable.tsx
index 1958f88..e1223cb 100644
--- a/superset-frontend/src/views/CRUD/welcome/ChartTable.tsx
+++ b/superset-frontend/src/views/CRUD/welcome/ChartTable.tsx
@@ -18,18 +18,13 @@
*/
import React, { useEffect } from 'react';
import { t } from '@superset-ui/core';
-import { debounce } from 'lodash';
-import ListView, { FetchDataConfig } from 'src/components/ListView';
import { useListViewResource, useFavoriteStatus } from 'src/views/CRUD/hooks';
import withToasts from 'src/messageToasts/enhancers/withToasts';
import { User } from 'src/types/bootstrapTypes';
-import ListViewCard from 'src/components/ListViewCard';
-import { Dropdown, Menu } from 'src/common/components';
-import Icon from 'src/components/Icon';
-import Label from 'src/components/Label';
import Owner from 'src/types/Owner';
-import ConfirmStatusChange from 'src/components/ConfirmStatusChange';
-import DashboardCard from '../dashboard/DashboardCard';
+import ChartCard from 'src/views/CRUD/chart/ChartCard';
+import Chart from 'src/types/Chart';
+
const PAGE_SIZE = 3;
interface ChartTableProps {
@@ -61,16 +56,6 @@ interface ChartTableState {
loading: boolean;
}
-export interface FilterValue {
- col: string;
- operator: string;
- value: string | boolean | number | null | undefined;
-}
-
-export interface FetchDataConfig {
- filters: FilterValue[];
-}
-
function ChartTable({
chartFilter,
user,
@@ -82,15 +67,14 @@ function ChartTable({
hasPerm,
refreshData,
fetchData,
- } = useListViewResource<Dashboard>('chart', t('chart'), addDangerToast);
- console.log('dashboardFilter', chartFilter);
+ } = useListViewResource<Chart>('chart', t('chart'), addDangerToast);
const getFilters = () => {
const filters = [];
if (chartFilter === 'Mine') {
filters.push({
- id: 'owners',
- operator: 'rel_m_m',
+ id: 'created_by',
+ operator: 'rel_o_m',
value: `${user?.userId}`,
});
} else {
@@ -98,10 +82,6 @@ function ChartTable({
id: 'id',
operator: 'chart_is_fav',
value: true,
- /* id: 'favorite', // API currently can't filter by favorite
- operator: 'eq',
- value: true,
- */
});
}
// Do we need search?
@@ -129,20 +109,19 @@ function ChartTable({
filters: getFilters(),
});
}, [chartFilter]);
- console.log("----charts: ", charts);
+
return (
<>
- {charts.map(e => (
- <DashboardCard
- {...{
- dashboard: e,
- hasPerm,
- bulkSelectEnabled,
- refreshData,
- addDangerToast,
- addSuccessToast,
- }}
- isChart
+ {charts.map((e, i) => (
+ <ChartCard
+ key={`${i}`}
+ loading={loading}
+ chart={e}
+ hasPerm={hasPerm}
+ bulkSelectEnabled={bulkSelectEnabled}
+ refreshData={refreshData}
+ addDangerToast={addDangerToast}
+ addSuccessToast={addSuccessToast}
/>
))}
</>
diff --git a/superset-frontend/src/views/CRUD/welcome/SavedQueries.tsx b/superset-frontend/src/views/CRUD/welcome/SavedQueries.tsx
index cab929e..73c7547 100644
--- a/superset-frontend/src/views/CRUD/welcome/SavedQueries.tsx
+++ b/superset-frontend/src/views/CRUD/welcome/SavedQueries.tsx
@@ -16,70 +16,97 @@
* specific language governing permissions and limitations
* under the License.
*/
-import React from 'react';
+import React, { useEffect, useState } from 'react';
import { t, SupersetClient } from '@superset-ui/core';
import withToasts from 'src/messageToasts/enhancers/withToasts';
import { Dropdown, Menu } from 'src/common/components';
+import { useListViewResource } from 'src/views/CRUD/hooks';
import ListViewCard from 'src/components/ListViewCard';
-// import FaveStar from 'src/components/FaveStar';
import Icon from 'src/components/Icon';
+import { addDangerToast } from 'src/messageToasts/actions';
-interface StateProps {
- queries: Array<object>;
+const PAGE_SIZE = 3;
+
+interface Query {
+ database: {
+ database_name: string;
+ };
+ rows: string;
+ description: string;
+ end_time: string;
+ addDangerToast: () => void;
}
-class SavedQueries extends React.PureComponent {
- constructor(props: StateProps) {
- super(props);
- this.state = {
- queries: [],
- };
- }
+interface StateProps {
+ queries: Array<Query>;
+}
- componentDidMount() {
- this.fetchData();
- }
+const SavedQueries = ({ user, queryFilter }) => {
+ const {
+ state: { loading, resourceCollection: queries },
+ fetchData,
+ } = useListViewResource<Query>('query', t('query'), addDangerToast);
+ const getFilters = () => {
+ const filters = [];
- // eslint-disable-next-line consistent-return
- fetchData = async () => {
- try {
- const { json } = await SupersetClient.get({
- endpoint: `/api/v1/query/`,
+ if (queryFilter === 'Mine') {
+ filters.push({
+ id: 'created_by',
+ operator: 'rel_o_m',
+ value: `${user?.userId}`,
+ });
+ } else {
+ filters.push({
+ id: 'id',
+ operator: 'saved_query_is_fav',
+ value: true,
});
- this.setState({ queries: json.result });
- } catch (e) {
- return console.log(e);
}
+ return filters;
};
- render() {
- const menu = (
- <Menu>
- <Menu.Item>Delete</Menu.Item>
- </Menu>
- );
- // console.log('queries', this.state.queries)
- return (
- <>
- {this.state.queries.map(q => (
- <ListViewCard
- title={q.database.database_name}
- rows={q.rows}
- loading={false}
- description={t('Last run ', q.end_time)}
- showImg={false}
- actions={
- <ListViewCard.Actions>
- <Dropdown overlay={menu}>
- <Icon name="more-horiz" />
- </Dropdown>
- </ListViewCard.Actions>
- }
- />
- ))}
- </>
- );
- }
-}
+ useEffect(() => {
+ fetchData({
+ pageIndex: 0,
+ pageSize: PAGE_SIZE,
+ sortBy: [
+ {
+ id: 'changed_on_delta_humanized',
+ desc: true,
+ },
+ ],
+ filters: getFilters(),
+ });
+ }, [queryFilter]);
+
+ const menu = (
+ <Menu>
+ <Menu.Item>Delete</Menu.Item>
+ </Menu>
+ );
+
+ return (
+ <>
+ {queries.map(q => (
+ <ListViewCard
+ imgFallbackURL={null}
+ imgURL={null}
+ title={q.database.database_name}
+ rows={q.rows}
+ loading={loading}
+ description={t('Last run ', q.end_time)}
+ showImg={false}
+ actions={
+ <ListViewCard.Actions>
+ <Dropdown overlay={menu}>
+ <Icon name="more-horiz" />
+ </Dropdown>
+ </ListViewCard.Actions>
+ }
+ />
+ ))}
+ </>
+ );
+};
export default withToasts(SavedQueries);
diff --git a/superset-frontend/src/views/CRUD/welcome/Welcome.tsx b/superset-frontend/src/views/CRUD/welcome/Welcome.tsx
index f4f1e7d..b4326fc 100644
--- a/superset-frontend/src/views/CRUD/welcome/Welcome.tsx
+++ b/superset-frontend/src/views/CRUD/welcome/Welcome.tsx
@@ -24,11 +24,11 @@ import { Collapse } from 'src/common/components';
import { useQueryParam, StringParam, QueryParamConfig } from 'use-query-params';
import { User } from 'src/types/bootstrapTypes';
import Icon from 'src/components/Icon';
+
import ActivityTable from './ActivityTable';
import ChartTable from './ChartTable';
import SavedQueries from './SavedQueries';
import DashboardTable from './DashboardTable';
-import Icon from 'src/components/Icon';
const { Panel } = Collapse;
@@ -79,11 +79,6 @@ function useSyncQueryState(
}
export default function Welcome({ user }: WelcomeProps) {
- const [activeTab, setActiveTab] = useSyncQueryState(
- 'activeTab',
- StringParam,
- 'all',
- );
const [queryFilter, setQueryFilter] = useState('Favorite');
const [activityFilter, setActivityFilter] = useState('Viewed');
const [dashboardFilter, setDashboardFilter] = useState('Favorite');
@@ -93,21 +88,13 @@ export default function Welcome({ user }: WelcomeProps) {
StringParam,
'',
);
- console.log('user', user);
-
function ExpandIcon(): React.ReactNode {
- return (
- <Icon name="caret-right" />
- )
+ return <Icon name="caret-right" />;
}
return (
- <Collapse
- defaultActiveKey={['1']}
- expandIcon={ExpandIcon}
- ghost
- >
+ <Collapse defaultActiveKey={['1']} expandIcon={ExpandIcon} ghost>
<Panel header={t('Recents')} key="1">
<SubMenu
activeChild={activityFilter}
@@ -130,10 +117,6 @@ export default function Welcome({ user }: WelcomeProps) {
onClick: () => setActivityFilter('Created'),
},
]}
- links={{
- link: `/chart/list`,
- linkTitle: 'View All',
- }}
/>
<ActivityContainer>
<ActivityTable user={user} activityFilter={activityFilter} />
@@ -166,6 +149,7 @@ export default function Welcome({ user }: WelcomeProps) {
),
buttonStyle: 'tertiary',
onClick: () => {
+ // @ts-ignore
window.location = '/dashboard/new';
},
},
@@ -173,6 +157,7 @@ export default function Welcome({ user }: WelcomeProps) {
name: 'View All',
buttonStyle: 'link',
onClick: () => {
+ // @ts-ignore
window.location = '/dashboard/list/';
},
},
@@ -221,6 +206,7 @@ export default function Welcome({ user }: WelcomeProps) {
),
buttonStyle: 'tertiary',
onClick: () => {
+ // @ts-ignore
window.location = '/superset/sqllab';
},
},
@@ -228,13 +214,14 @@ export default function Welcome({ user }: WelcomeProps) {
name: 'View All',
buttonStyle: 'link',
onClick: () => {
+ // @ts-ignore
window.location = 'superset/sqllab#search';
},
},
]}
/>
<CardContainer>
- <SavedQueries />
+ <SavedQueries user={user} queryFilter={queryFilter} />
</CardContainer>
</Panel>
<Panel header={t('Charts')} key="4">
@@ -263,6 +250,7 @@ export default function Welcome({ user }: WelcomeProps) {
),
buttonStyle: 'tertiary',
onClick: () => {
+ // @ts-ignore
window.location = '/chart/add';
},
},
@@ -270,6 +258,7 @@ export default function Welcome({ user }: WelcomeProps) {
name: 'View All',
buttonStyle: 'link',
onClick: () => {
+ // @ts-ignore
window.location = '/chart/list';
},
},
diff --git a/superset/queries/saved_queries/api.py b/superset/queries/saved_queries/api.py
index 794ab25..b37fc7d 100644
--- a/superset/queries/saved_queries/api.py
+++ b/superset/queries/saved_queries/api.py
@@ -106,7 +106,7 @@ class SavedQueryRestApi(BaseSupersetModelRestApi):
"last_run_delta_humanized",
]
- search_columns = ["id", "database", "label", "schema"]
+ search_columns = ["id", "database", "label", "schema", "created_by"]
search_filters = {
"id": [SavedQueryFavoriteFilter],
"label": [SavedQueryAllTextFilter],