diff --git a/superset-frontend/src/explore/components/ExploreChartHeader.jsx b/superset-frontend/src/explore/components/ExploreChartHeader.jsx index ca8842b9645b9..fdcf7d275569c 100644 --- a/superset-frontend/src/explore/components/ExploreChartHeader.jsx +++ b/superset-frontend/src/explore/components/ExploreChartHeader.jsx @@ -148,13 +148,15 @@ export class ExploreChartHeader extends React.PureComponent { {this.props.slice && ( - + {this.props.userId && ( + + )} { form_data={props.form_data} timeout={props.timeout} chart={props.chart} + userId={props.userId} /> ); diff --git a/superset-frontend/src/explore/components/ExploreViewContainer.jsx b/superset-frontend/src/explore/components/ExploreViewContainer.jsx index b1dee2e3710b6..7444f767261e9 100644 --- a/superset-frontend/src/explore/components/ExploreViewContainer.jsx +++ b/superset-frontend/src/explore/components/ExploreViewContainer.jsx @@ -592,6 +592,7 @@ function mapStateToProps(state) { timeout: explore.common.conf.SUPERSET_WEBSERVER_TIMEOUT, ownState: dataMask[form_data.slice_id]?.ownState, impressionId, + userId: explore.user_id, }; } diff --git a/superset-frontend/src/views/CRUD/chart/ChartList.tsx b/superset-frontend/src/views/CRUD/chart/ChartList.tsx index 64e4cc5e334fa..cf7d29ce7cf27 100644 --- a/superset-frontend/src/views/CRUD/chart/ChartList.tsx +++ b/superset-frontend/src/views/CRUD/chart/ChartList.tsx @@ -42,6 +42,7 @@ import SubMenu, { SubMenuProps } from 'src/components/Menu/SubMenu'; import FaveStar from 'src/components/FaveStar'; import ListView, { ListViewProps, + Filter, Filters, SelectOption, FilterOperator, @@ -195,23 +196,27 @@ function ChartList(props: ChartListProps) { const columns = useMemo( () => [ - { - Cell: ({ - row: { - original: { id }, - }, - }: any) => ( - - ), - Header: '', - id: 'id', - disableSortBy: true, - size: 'xs', - }, + ...(props.user.userId + ? [ + { + Cell: ({ + row: { + original: { id }, + }, + }: any) => ( + + ), + Header: '', + id: 'id', + disableSortBy: true, + size: 'xs', + }, + ] + : []), { Cell: ({ row: { @@ -377,7 +382,12 @@ function ChartList(props: ChartListProps) { hidden: !canEdit && !canDelete, }, ], - [canEdit, canDelete, canExport, favoriteStatus], + [ + canEdit, + canDelete, + canExport, + ...(props.user.userId ? [favoriteStatus] : []), + ], ); const filters: Filters = [ @@ -465,18 +475,22 @@ function ChartList(props: ChartListProps) { ), paginate: false, }, - { - Header: t('Favorite'), - id: 'id', - urlDisplay: 'favorite', - input: 'select', - operator: FilterOperator.chartIsFav, - unfilteredLabel: t('Any'), - selects: [ - { label: t('Yes'), value: true }, - { label: t('No'), value: false }, - ], - }, + ...(props.user.userId + ? [ + { + Header: t('Favorite'), + id: 'id', + urlDisplay: 'favorite', + input: 'select', + operator: FilterOperator.chartIsFav, + unfilteredLabel: t('Any'), + selects: [ + { label: t('Yes'), value: true }, + { label: t('No'), value: false }, + ], + } as Filter, + ] + : []), { Header: t('Search'), id: 'slice_name', diff --git a/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx b/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx index 65fb349d9b657..0a27ca39759dd 100644 --- a/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx +++ b/superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx @@ -32,6 +32,7 @@ import ConfirmStatusChange from 'src/components/ConfirmStatusChange'; import SubMenu, { SubMenuProps } from 'src/components/Menu/SubMenu'; import ListView, { ListViewProps, + Filter, Filters, FilterOperator, } from 'src/components/ListView'; @@ -189,23 +190,27 @@ function DashboardList(props: DashboardListProps) { const columns = useMemo( () => [ - { - Cell: ({ - row: { - original: { id }, - }, - }: any) => ( - - ), - Header: '', - id: 'id', - disableSortBy: true, - size: 'xs', - }, + ...(props.user.userId + ? [ + { + Cell: ({ + row: { + original: { id }, + }, + }: any) => ( + + ), + Header: '', + id: 'id', + disableSortBy: true, + size: 'xs', + }, + ] + : []), { Cell: ({ row: { @@ -357,7 +362,12 @@ function DashboardList(props: DashboardListProps) { disableSortBy: true, }, ], - [canEdit, canDelete, canExport, favoriteStatus], + [ + canEdit, + canDelete, + canExport, + ...(props.user.userId ? [favoriteStatus] : []), + ], ); const filters: Filters = [ @@ -414,18 +424,22 @@ function DashboardList(props: DashboardListProps) { { label: t('Draft'), value: false }, ], }, - { - Header: t('Favorite'), - id: 'id', - urlDisplay: 'favorite', - input: 'select', - operator: FilterOperator.dashboardIsFav, - unfilteredLabel: t('Any'), - selects: [ - { label: t('Yes'), value: true }, - { label: t('No'), value: false }, - ], - }, + ...(props.user.userId + ? [ + { + Header: t('Favorite'), + id: 'id', + urlDisplay: 'favorite', + input: 'select', + operator: FilterOperator.dashboardIsFav, + unfilteredLabel: t('Any'), + selects: [ + { label: t('Yes'), value: true }, + { label: t('No'), value: false }, + ], + } as Filter, + ] + : []), { Header: t('Search'), id: 'dashboard_title',