Skip to content

Commit

Permalink
fix(dashboard): draft dashboards should be viewable (#14207)
Browse files Browse the repository at this point in the history
* fix(dashboard): draft dashboards should have open access

* Remove a duplicate test
  • Loading branch information
ktmud authored Apr 21, 2021
1 parent 852e840 commit 2dd20df
Show file tree
Hide file tree
Showing 23 changed files with 126 additions and 158 deletions.
24 changes: 1 addition & 23 deletions superset-frontend/src/components/ListView/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,6 @@ export interface CardSortSelectOption {
value: any;
}

type FilterOperator =
| 'sw'
| 'ew'
| 'ct'
| 'eq'
| 'nsw'
| 'new'
| 'nct'
| 'neq'
| 'gt'
| 'lt'
| 'rel_m_m'
| 'rel_o_m'
| 'title_or_slug'
| 'name_or_description'
| 'all_text'
| 'chart_all_text'
| 'dataset_is_null_or_empty'
| 'between'
| 'dashboard_is_favorite'
| 'chart_is_favorite';

export interface Filter {
Header: ReactNode;
id: string;
Expand Down Expand Up @@ -104,7 +82,7 @@ export interface InternalFilter extends FilterValue {
Header?: string;
}

export enum FilterOperators {
export enum FilterOperator {
startsWith = 'sw',
endsWith = 'ew',
contains = 'ct',
Expand Down
10 changes: 5 additions & 5 deletions superset-frontend/src/views/CRUD/alert/AlertList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import Button from 'src/components/Button';
import FacePile from 'src/components/FacePile';
import { Tooltip } from 'src/components/Tooltip';
import ListView, {
FilterOperators,
FilterOperator,
Filters,
ListViewProps,
} from 'src/components/ListView';
Expand Down Expand Up @@ -84,7 +84,7 @@ function AlertList({
() => [
{
id: 'type',
operator: FilterOperators.equals,
operator: FilterOperator.equals,
value: isReportEnabled ? 'Report' : 'Alert',
},
],
Expand Down Expand Up @@ -373,7 +373,7 @@ function AlertList({
Header: t('Created by'),
id: 'created_by',
input: 'select',
operator: FilterOperators.relationOneMany,
operator: FilterOperator.relationOneMany,
unfilteredLabel: 'All',
fetchSelects: createFetchRelated(
'report',
Expand All @@ -389,7 +389,7 @@ function AlertList({
Header: t('Status'),
id: 'last_state',
input: 'select',
operator: FilterOperators.equals,
operator: FilterOperator.equals,
unfilteredLabel: 'Any',
selects: [
{ label: t(`${AlertState.success}`), value: AlertState.success },
Expand All @@ -403,7 +403,7 @@ function AlertList({
Header: t('Search'),
id: 'name',
input: 'search',
operator: FilterOperators.contains,
operator: FilterOperator.contains,
},
],
[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ import { createFetchRelated, createErrorHandler } from 'src/views/CRUD/utils';
import withToasts from 'src/messageToasts/enhancers/withToasts';
import SubMenu, { SubMenuProps } from 'src/components/Menu/SubMenu';
import ActionsBar, { ActionProps } from 'src/components/ListView/ActionsBar';
import ListView, { ListViewProps, Filters } from 'src/components/ListView';
import ListView, {
ListViewProps,
Filters,
FilterOperator,
} from 'src/components/ListView';
import Button from 'src/components/Button';
import DeleteModal from 'src/components/DeleteModal';
import ConfirmStatusChange from 'src/components/ConfirmStatusChange';
Expand Down Expand Up @@ -286,7 +290,7 @@ function AnnotationLayersList({
Header: t('Created by'),
id: 'created_by',
input: 'select',
operator: 'rel_o_m',
operator: FilterOperator.relationOneMany,
unfilteredLabel: 'All',
fetchSelects: createFetchRelated(
'annotation_layer',
Expand All @@ -305,7 +309,7 @@ function AnnotationLayersList({
Header: t('Search'),
id: 'name',
input: 'search',
operator: 'ct',
operator: FilterOperator.contains,
},
],
[],
Expand Down
14 changes: 7 additions & 7 deletions superset-frontend/src/views/CRUD/chart/ChartList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import ListView, {
ListViewProps,
Filters,
SelectOption,
FilterOperators,
FilterOperator,
} from 'src/components/ListView';
import { getFromLocalStorage } from 'src/utils/localStorageHelpers';
import withToasts from 'src/messageToasts/enhancers/withToasts';
Expand Down Expand Up @@ -385,7 +385,7 @@ function ChartList(props: ChartListProps) {
Header: t('Owner'),
id: 'owners',
input: 'select',
operator: FilterOperators.relationManyMany,
operator: FilterOperator.relationManyMany,
unfilteredLabel: t('All'),
fetchSelects: createFetchRelated(
'chart',
Expand All @@ -406,7 +406,7 @@ function ChartList(props: ChartListProps) {
Header: t('Created by'),
id: 'created_by',
input: 'select',
operator: FilterOperators.relationOneMany,
operator: FilterOperator.relationOneMany,
unfilteredLabel: t('All'),
fetchSelects: createFetchRelated(
'chart',
Expand All @@ -427,7 +427,7 @@ function ChartList(props: ChartListProps) {
Header: t('Viz type'),
id: 'viz_type',
input: 'select',
operator: FilterOperators.equals,
operator: FilterOperator.equals,
unfilteredLabel: t('All'),
selects: registry
.keys()
Expand All @@ -451,7 +451,7 @@ function ChartList(props: ChartListProps) {
Header: t('Dataset'),
id: 'datasource_id',
input: 'select',
operator: FilterOperators.equals,
operator: FilterOperator.equals,
unfilteredLabel: t('All'),
fetchSelects: createFetchDatasets(
createErrorHandler(errMsg =>
Expand All @@ -470,7 +470,7 @@ function ChartList(props: ChartListProps) {
id: 'id',
urlDisplay: 'favorite',
input: 'select',
operator: FilterOperators.chartIsFav,
operator: FilterOperator.chartIsFav,
unfilteredLabel: t('Any'),
selects: [
{ label: t('Yes'), value: true },
Expand All @@ -481,7 +481,7 @@ function ChartList(props: ChartListProps) {
Header: t('Search'),
id: 'slice_name',
input: 'search',
operator: FilterOperators.chartAllText,
operator: FilterOperator.chartAllText,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ import DeleteModal from 'src/components/DeleteModal';
import { Tooltip } from 'src/components/Tooltip';
import ConfirmStatusChange from 'src/components/ConfirmStatusChange';
import ActionsBar, { ActionProps } from 'src/components/ListView/ActionsBar';
import ListView, { ListViewProps, Filters } from 'src/components/ListView';
import ListView, {
ListViewProps,
Filters,
FilterOperator,
} from 'src/components/ListView';
import CssTemplateModal from './CssTemplateModal';
import { TemplateObject } from './types';

Expand Down Expand Up @@ -272,7 +276,7 @@ function CssTemplatesList({
Header: t('Created by'),
id: 'created_by',
input: 'select',
operator: 'rel_o_m',
operator: FilterOperator.relationOneMany,
unfilteredLabel: 'All',
fetchSelects: createFetchRelated(
'css_template',
Expand All @@ -291,7 +295,7 @@ function CssTemplatesList({
Header: t('Search'),
id: 'template_name',
input: 'search',
operator: 'ct',
operator: FilterOperator.contains,
},
],
[],
Expand Down
20 changes: 11 additions & 9 deletions superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import SubMenu, { SubMenuProps } from 'src/components/Menu/SubMenu';
import ListView, {
ListViewProps,
Filters,
FilterOperators,
FilterOperator,
} from 'src/components/ListView';
import { getFromLocalStorage } from 'src/utils/localStorageHelpers';
import Owner from 'src/types/Owner';
Expand All @@ -46,6 +46,7 @@ import ImportModelsModal from 'src/components/ImportModal/index';

import Dashboard from 'src/dashboard/containers/Dashboard';
import DashboardCard from './DashboardCard';
import { DashboardStatus } from './types';

const PAGE_SIZE = 25;
const PASSWORDS_NEEDED_MESSAGE = t(
Expand Down Expand Up @@ -230,9 +231,10 @@ function DashboardList(props: DashboardListProps) {
{
Cell: ({
row: {
original: { published },
original: { status },
},
}: any) => (published ? t('Published') : t('Draft')),
}: any) =>
status === DashboardStatus.PUBLISHED ? t('Published') : t('Draft'),
Header: t('Status'),
accessor: 'published',
size: 'xl',
Expand Down Expand Up @@ -362,7 +364,7 @@ function DashboardList(props: DashboardListProps) {
Header: t('Owner'),
id: 'owners',
input: 'select',
operator: FilterOperators.relationManyMany,
operator: FilterOperator.relationManyMany,
unfilteredLabel: t('All'),
fetchSelects: createFetchRelated(
'dashboard',
Expand All @@ -383,7 +385,7 @@ function DashboardList(props: DashboardListProps) {
Header: t('Created by'),
id: 'created_by',
input: 'select',
operator: FilterOperators.relationOneMany,
operator: FilterOperator.relationOneMany,
unfilteredLabel: t('All'),
fetchSelects: createFetchRelated(
'dashboard',
Expand All @@ -404,19 +406,19 @@ function DashboardList(props: DashboardListProps) {
Header: t('Status'),
id: 'published',
input: 'select',
operator: FilterOperators.equals,
operator: FilterOperator.equals,
unfilteredLabel: t('Any'),
selects: [
{ label: t('Published'), value: true },
{ label: t('Unpublished'), value: false },
{ label: t('Draft'), value: false },
],
},
{
Header: t('Favorite'),
id: 'id',
urlDisplay: 'favorite',
input: 'select',
operator: FilterOperators.dashboardIsFav,
operator: FilterOperator.dashboardIsFav,
unfilteredLabel: t('Any'),
selects: [
{ label: t('Yes'), value: true },
Expand All @@ -427,7 +429,7 @@ function DashboardList(props: DashboardListProps) {
Header: t('Search'),
id: 'dashboard_title',
input: 'search',
operator: FilterOperators.titleOrSlug,
operator: FilterOperator.titleOrSlug,
},
];

Expand Down
5 changes: 5 additions & 0 deletions superset-frontend/src/views/CRUD/dashboard/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ export type DashboardObject = {
position?: string;
metadata?: string;
};

export enum DashboardStatus {
PUBLISHED = 'published',
DRAFT = 'draft',
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import SubMenu, { SubMenuProps } from 'src/components/Menu/SubMenu';
import DeleteModal from 'src/components/DeleteModal';
import { Tooltip } from 'src/components/Tooltip';
import Icons from 'src/components/Icons';
import ListView, { Filters } from 'src/components/ListView';
import ListView, { FilterOperator, Filters } from 'src/components/ListView';
import { commonMenuData } from 'src/views/CRUD/data/common';
import ImportModelsModal from 'src/components/ImportModal/index';
import DatabaseModal from './DatabaseModal';
Expand Down Expand Up @@ -374,7 +374,7 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
Header: t('Expose in SQL Lab'),
id: 'expose_in_sqllab',
input: 'select',
operator: 'eq',
operator: FilterOperator.equals,
unfilteredLabel: 'All',
selects: [
{ label: 'Yes', value: true },
Expand All @@ -393,7 +393,7 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
),
id: 'allow_run_async',
input: 'select',
operator: 'eq',
operator: FilterOperator.equals,
unfilteredLabel: 'All',
selects: [
{ label: 'Yes', value: true },
Expand All @@ -404,7 +404,7 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
Header: t('Search'),
id: 'database_name',
input: 'search',
operator: 'ct',
operator: FilterOperator.contains,
},
],
[],
Expand Down
18 changes: 11 additions & 7 deletions superset-frontend/src/views/CRUD/data/dataset/DatasetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ import { useListViewResource } from 'src/views/CRUD/hooks';
import ConfirmStatusChange from 'src/components/ConfirmStatusChange';
import DatasourceModal from 'src/datasource/DatasourceModal';
import DeleteModal from 'src/components/DeleteModal';
import ListView, { ListViewProps, Filters } from 'src/components/ListView';
import ListView, {
ListViewProps,
Filters,
FilterOperator,
} from 'src/components/ListView';
import SubMenu, {
SubMenuProps,
ButtonProps,
Expand Down Expand Up @@ -308,7 +312,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
{
Cell: ({
row: {
original: { owners = [], table_name: tableName },
original: { owners = [] },
},
}: any) => <FacePile users={owners} />,
Header: t('Owners'),
Expand Down Expand Up @@ -397,7 +401,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
Header: t('Owner'),
id: 'owners',
input: 'select',
operator: 'rel_m_m',
operator: FilterOperator.relationManyMany,
unfilteredLabel: 'All',
fetchSelects: createFetchRelated(
'dataset',
Expand All @@ -416,7 +420,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
Header: t('Database'),
id: 'database',
input: 'select',
operator: 'rel_o_m',
operator: FilterOperator.relationManyMany,
unfilteredLabel: 'All',
fetchSelects: createFetchRelated(
'dataset',
Expand All @@ -431,7 +435,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
Header: t('Schema'),
id: 'schema',
input: 'select',
operator: 'eq',
operator: FilterOperator.equals,
unfilteredLabel: 'All',
fetchSelects: createFetchDistinct(
'dataset',
Expand All @@ -446,7 +450,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
Header: t('Type'),
id: 'sql',
input: 'select',
operator: 'dataset_is_null_or_empty',
operator: FilterOperator.datasetIsNullOrEmpty,
unfilteredLabel: 'All',
selects: [
{ label: 'Virtual', value: false },
Expand All @@ -457,7 +461,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({
Header: t('Search'),
id: 'table_name',
input: 'search',
operator: 'ct',
operator: FilterOperator.contains,
},
],
[],
Expand Down
Loading

0 comments on commit 2dd20df

Please sign in to comment.