Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nav): Update Tabbed Nav on CRUD Pages #21213

Merged
merged 1 commit into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions superset-frontend/src/views/CRUD/data/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,8 @@
import { t } from '@superset-ui/core';

export const commonMenuData = {
name: t('Data'),
name: t('SQL'),
tabs: [
{
name: 'Databases',
label: t('Databases'),
url: '/databaseview/list/',
usesRouter: true,
},
{
name: 'Datasets',
label: t('Datasets'),
url: '/tablemodelview/list/',
usesRouter: true,
},
{
name: 'Saved queries',
label: t('Saved queries'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ describe('Admin DatabaseList', () => {
expect(wrapper.find(SubMenu)).toExist();
});

it('renders a SubMenu with no tabs', () => {
expect(wrapper.find(SubMenu).props().tabs).toBeUndefined();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is undefined correct here or null?

Copy link
Member Author

@Antonio-RiveroMartnez Antonio-RiveroMartnez Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined is correct since nothing should be passed to it, not even null.

});

it('renders a DatabaseModal', () => {
expect(wrapper.find(DatabaseModal)).toExist();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { Tooltip } from 'src/components/Tooltip';
import Icons from 'src/components/Icons';
import { isUserAdmin } from 'src/dashboard/util/permissionUtils';
import ListView, { FilterOperator, Filters } from 'src/components/ListView';
import { commonMenuData } from 'src/views/CRUD/data/common';
import handleResourceExport from 'src/utils/export';
import { ExtentionConfigs } from 'src/views/components/types';
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
Expand Down Expand Up @@ -247,7 +246,7 @@ function DatabaseList({ addDangerToast, addSuccessToast }: DatabaseListProps) {
const menuData: SubMenuProps = {
activeChild: 'Databases',
dropDownLinks: filteredDropDown,
...commonMenuData,
name: t('Databases'),
};

if (canCreate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import Button from 'src/components/Button';
import IndeterminateCheckbox from 'src/components/IndeterminateCheckbox';
import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
import { act } from 'react-dom/test-utils';
import SubMenu from 'src/views/components/SubMenu';

// store needed for withToasts(DatasetList)
const mockStore = configureStore([thunk]);
Expand Down Expand Up @@ -223,6 +224,14 @@ describe('DatasetList', () => {
});
expect(fetchMock.calls(/dataset\/duplicate/)).toHaveLength(1);
});

it('renders a SubMenu', () => {
expect(wrapper.find(SubMenu)).toExist();
});

it('renders a SubMenu with no tabs', () => {
expect(wrapper.find(SubMenu).props().tabs).toBeUndefined();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thought process here.

Copy link
Member Author

@Antonio-RiveroMartnez Antonio-RiveroMartnez Aug 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined is correct since nothing should be passed to it, not even null.

});
});

jest.mock('react-router-dom', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import SubMenu, {
SubMenuProps,
ButtonProps,
} from 'src/views/components/SubMenu';
import { commonMenuData } from 'src/views/CRUD/data/common';
import Owner from 'src/types/Owner';
import withToasts from 'src/components/MessageToasts/withToasts';
import { Tooltip } from 'src/components/Tooltip';
Expand Down Expand Up @@ -585,7 +584,7 @@ const DatasetList: FunctionComponent<DatasetListProps> = ({

const menuData: SubMenuProps = {
activeChild: 'Datasets',
...commonMenuData,
name: t('Datasets'),
};

const buttonArr: Array<ButtonProps> = [];
Expand Down
23 changes: 23 additions & 0 deletions superset-frontend/src/views/CRUD/data/query/QueryList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { QueryObject } from 'src/views/CRUD/types';
import ListView from 'src/components/ListView';
import Filters from 'src/components/ListView/Filters';
import SyntaxHighlighter from 'react-syntax-highlighter/dist/cjs/light';
import SubMenu from 'src/views/components/SubMenu';

// store needed for withToasts
const mockStore = configureStore([thunk]);
Expand Down Expand Up @@ -147,4 +148,26 @@ describe('QueryList', () => {
`"http://localhost/api/v1/query/?q=(filters:!((col:sql,opr:ct,value:fooo)),order_column:start_time,order_direction:desc,page:0,page_size:25)"`,
);
});

it('renders a SubMenu', () => {
expect(wrapper.find(SubMenu)).toExist();
});

it('renders a SubMenu with Saved queries and Query History links', () => {
expect(wrapper.find(SubMenu).props().tabs).toEqual(
expect.arrayContaining([
expect.objectContaining({ label: 'Saved queries' }),
expect.objectContaining({ label: 'Query history' }),
]),
);
});

it('renders a SubMenu without Databases and Datasets links', () => {
expect(wrapper.find(SubMenu).props().tabs).not.toEqual(
expect.arrayContaining([
expect.objectContaining({ label: 'Databases' }),
expect.objectContaining({ label: 'Datasets' }),
]),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,24 @@ describe('SavedQueryList', () => {
expect(wrapper.find(SubMenu)).toExist();
});

it('renders a SubMenu with Saved queries and Query History links', () => {
expect(wrapper.find(SubMenu).props().tabs).toEqual(
expect.arrayContaining([
expect.objectContaining({ label: 'Saved queries' }),
expect.objectContaining({ label: 'Query history' }),
]),
);
});

it('renders a SubMenu without Databases and Datasets links', () => {
expect(wrapper.find(SubMenu).props().tabs).not.toEqual(
expect.arrayContaining([
expect.objectContaining({ label: 'Databases' }),
expect.objectContaining({ label: 'Datasets' }),
]),
);
});

it('renders a ListView', () => {
expect(wrapper.find(ListView)).toExist();
});
Expand Down