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: Integrate ant d table component into DatasetPanel #21948

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
0357202
ant design Table component work in progress
eric-briscoe Jul 30, 2022
c58edf1
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Aug 22, 2022
3409c07
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Aug 23, 2022
bdd1460
Work in progress, enabled resizeable columns in Table, added draft de…
eric-briscoe Aug 26, 2022
0d2ca7a
Update DesignSystem.stories.mdx
eric-briscoe Aug 26, 2022
bf9dd0a
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Aug 28, 2022
3a9d2ea
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Sep 12, 2022
668185f
Updates documentation, adds tests, separates resizable column and dra…
eric-briscoe Sep 19, 2022
367009c
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Sep 19, 2022
c99f556
Updates to markdown overview docs for table and additional Storybook …
eric-briscoe Sep 19, 2022
89f779e
Adds numeric cell renderer, updated buton cell renderer, adds documen…
eric-briscoe Sep 20, 2022
571a4b2
Cell renderer work in progress
eric-briscoe Sep 22, 2022
82674d6
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Oct 11, 2022
75b68f5
Fixes Lint and TS errors
eric-briscoe Oct 21, 2022
400e3d9
Improving folder structure, adding additional tests
eric-briscoe Oct 24, 2022
ee7521a
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Oct 24, 2022
7b54dbd
Integrates new Table component into the DatasetPanel to display Table…
eric-briscoe Oct 25, 2022
27fb88a
Removes leftover server side search that is no longer needed
eric-briscoe Oct 25, 2022
d80e5fc
Adds unit tests, story, decomposes more granular components, and impr…
eric-briscoe Oct 26, 2022
495d676
Adds missing license comments to new files
eric-briscoe Oct 26, 2022
f4b2017
Removes unnecessary code causing an import error
eric-briscoe Oct 28, 2022
a8e7f05
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
33f4c69
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
49d456d
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
d355c7d
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
3c5d543
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
d28af9a
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 7, 2022
0180d67
Update superset-frontend/src/components/Table/sorters.test.ts
eric-briscoe Nov 7, 2022
31d13bb
Update superset-frontend/src/components/Table/utils/utils.ts
eric-briscoe Nov 7, 2022
3306524
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
60c306b
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
8dab6ff
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 7, 2022
5dd4376
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 7, 2022
60c13f8
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 7, 2022
9d5ef1e
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 7, 2022
d86ebce
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 7, 2022
aabe653
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 7, 2022
62aba0a
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 7, 2022
200e582
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 7, 2022
8ca700e
Updates addressing PR comments for ACT Test errors, removal to type: …
eric-briscoe Nov 7, 2022
6170190
Merge branch 'ericbriscoe/sc-51384/create-table-component-based-on-an…
eric-briscoe Nov 7, 2022
487933f
Merge branch 'ericbriscoe/sc-51384/create-table-component-based-on-an…
eric-briscoe Nov 7, 2022
7417321
Remove addition to global style for action cell shadows
eric-briscoe Nov 7, 2022
aade1ab
Merge branch 'ericbriscoe/sc-51384/create-table-component-based-on-an…
eric-briscoe Nov 7, 2022
39daeb2
Address PR comment to shorten variable name
eric-briscoe Nov 7, 2022
f30422f
Merge branch 'master' into ericbriscoe/sc-51384/create-table-componen…
eric-briscoe Nov 7, 2022
6533536
Merge branch 'ericbriscoe/sc-51384/create-table-component-based-on-an…
eric-briscoe Nov 7, 2022
6dec34c
Removing storybook log file which should not have bend comitted
eric-briscoe Nov 7, 2022
bd16641
Update superset-frontend/src/components/DesignSystem.stories.mdx
eric-briscoe Nov 8, 2022
ca0a2d9
Update superset-frontend/src/components/DesignSystem.stories.mdx
eric-briscoe Nov 8, 2022
1fd223b
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 8, 2022
648c8fd
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 8, 2022
00c258b
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 8, 2022
2fd2589
Update superset-frontend/src/components/Table/index.tsx
eric-briscoe Nov 8, 2022
488e6ba
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 8, 2022
5aa6c9e
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 8, 2022
af08fb5
Update superset-frontend/src/components/Table/cell-renderers/NumericC…
eric-briscoe Nov 8, 2022
d81cfaa
Update superset-frontend/src/components/Table/cell-renderers/NumericC…
eric-briscoe Nov 8, 2022
83495e3
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 8, 2022
b7889be
Update superset-frontend/src/components/Table/Table.test.tsx
eric-briscoe Nov 8, 2022
0d9f650
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 8, 2022
cb12a4c
Update superset-frontend/src/components/Table/Table.overview.mdx
eric-briscoe Nov 8, 2022
34c5b02
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 8, 2022
4d63da8
Update superset-frontend/src/components/Table/cell-renderers/ActionCe…
eric-briscoe Nov 8, 2022
26af43d
Addresses PR comments
eric-briscoe Nov 8, 2022
68c8255
Merge branch 'ericbriscoe/sc-51384/create-table-component-based-on-an…
eric-briscoe Nov 8, 2022
11d230c
Apply suggestions from code review
eric-briscoe Nov 8, 2022
109feae
Consolidates initializeInteractiveTable function into the useEffect i…
eric-briscoe Nov 9, 2022
c4eb12f
Improve comments on why derivedColumns is excluded for effect depende…
eric-briscoe Nov 9, 2022
1a25f33
Adding comment in test file to clarify appendDataToMenu test purpose …
eric-briscoe Nov 9, 2022
cf7b6c4
Merge branch 'ericbriscoe/sc-51384/create-table-component-based-on-an…
eric-briscoe Nov 9, 2022
06a0425
Fix typ0 in story title
eric-briscoe Nov 9, 2022
662115f
Merge branch 'master' into ericbriscoe/sc-56078/create-dataset-add-an…
eric-briscoe Nov 9, 2022
ae8b35e
Apply suggestions from code review
eric-briscoe Nov 10, 2022
24206b8
Addresses PR comment for ACT errors
eric-briscoe Nov 10, 2022
d40bf1a
Fixes typescript error from github comment merge
eric-briscoe Nov 10, 2022
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
4 changes: 2 additions & 2 deletions superset-frontend/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ module.exports = {
builder: 'webpack5',
},
stories: [
'../src/@(components|common|filters|explore)/**/*.stories.@(tsx|jsx)',
'../src/@(components|common|filters|explore)/**/*.*.@(mdx)',
'../src/@(components|common|filters|explore|views)/**/*.stories.@(tsx|jsx)',
'../src/@(components|common|filters|explore|views)/**/*.*.@(mdx)',
],
addons: [
'@storybook/addon-essentials',
Expand Down
22 changes: 22 additions & 0 deletions superset-frontend/src/assets/images/no-columns.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions superset-frontend/src/components/EmptyState/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export enum EmptyStateSize {
export interface EmptyStateSmallProps {
title: ReactNode;
description?: ReactNode;
image: ReactNode;
image?: ReactNode;
eric-briscoe marked this conversation as resolved.
Show resolved Hide resolved
}

export interface EmptyStateProps extends EmptyStateSmallProps {
Expand Down Expand Up @@ -156,7 +156,7 @@ export const EmptyStateBig = ({
className,
}: EmptyStateProps) => (
<EmptyStateContainer className={className}>
<ImageContainer image={image} size={EmptyStateSize.Big} />
{image && <ImageContainer image={image} size={EmptyStateSize.Big} />}
<TextContainer
css={(theme: SupersetTheme) =>
css`
Expand Down Expand Up @@ -187,7 +187,7 @@ export const EmptyStateMedium = ({
buttonText,
}: EmptyStateProps) => (
<EmptyStateContainer>
<ImageContainer image={image} size={EmptyStateSize.Medium} />
{image && <ImageContainer image={image} size={EmptyStateSize.Medium} />}
<TextContainer
css={(theme: SupersetTheme) =>
css`
Expand Down Expand Up @@ -216,7 +216,7 @@ export const EmptyStateSmall = ({
description,
}: EmptyStateSmallProps) => (
<EmptyStateContainer>
<ImageContainer image={image} size={EmptyStateSize.Small} />
{image && <ImageContainer image={image} size={EmptyStateSize.Small} />}
<TextContainer
css={(theme: SupersetTheme) =>
css`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* 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 { ComponentStory, ComponentMeta } from '@storybook/react';
import { supersetTheme, ThemeProvider } from '@superset-ui/core';
import DatasetPanel from './DatasetPanel';
import { exampleColumns } from './fixtures';

export default {
title: 'Superset App/views/CRUD/data/dataset/DatasetPanel',
component: DatasetPanel,
} as ComponentMeta<typeof DatasetPanel>;

export const Basic: ComponentStory<typeof DatasetPanel> = args => (
<ThemeProvider theme={supersetTheme}>
<div style={{ height: '350px' }}>
<DatasetPanel {...args} />
</div>
</ThemeProvider>
);

Basic.args = {
tableName: 'example_table',
loading: false,
hasError: false,
columnList: exampleColumns,
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,124 @@
*/
import React from 'react';
import { render, screen } from 'spec/helpers/testing-library';
import DatasetPanel from 'src/views/CRUD/data/dataset/AddDataset/DatasetPanel';
import DatasetPanel, {
REFRESHING,
ALT_LOADING,
tableColumnDefinition,
COLUMN_TITLE,
} from './DatasetPanel';
import { exampleColumns } from './fixtures';
import {
SELECT_MESSAGE,
CREATE_MESSAGE,
VIEW_DATASET_MESSAGE,
SELECT_TABLE_TITLE,
NO_COLUMNS_TITLE,
NO_COLUMNS_DESCRIPTION,
ERROR_TITLE,
ERROR_DESCRIPTION,
} from './MessageContent';

jest.mock(
'src/components/Icons/Icon',
() =>
({ fileName }: { fileName: string }) =>
<span role="img" aria-label={fileName.replace('_', '-')} />,
);

describe('DatasetPanel', () => {
it('renders a blank state DatasetPanel', () => {
render(<DatasetPanel />);
render(<DatasetPanel hasError={false} columnList={[]} loading={false} />);

const blankDatasetImg = screen.getByRole('img', { name: /empty/i });
const blankDatasetTitle = screen.getByText(/select dataset source/i);
const blankDatasetDescription = screen.getByText(
/datasets can be created from database tables or sql queries\. select a database table to the left or to open sql lab\. from there you can save the query as a dataset\./i,
);
expect(blankDatasetImg).toBeVisible();
const blankDatasetTitle = screen.getByText(SELECT_TABLE_TITLE);
expect(blankDatasetTitle).toBeVisible();
const blankDatasetDescription1 = screen.getByText(SELECT_MESSAGE, {
exact: false,
});
expect(blankDatasetDescription1).toBeVisible();
const blankDatasetDescription2 = screen.getByText(VIEW_DATASET_MESSAGE, {
exact: false,
});
expect(blankDatasetDescription2).toBeVisible();
const sqlLabLink = screen.getByRole('button', {
name: /create dataset from sql query/i,
name: CREATE_MESSAGE,
});
expect(sqlLabLink).toBeVisible();
});

it('renders a no columns screen', () => {
render(
<DatasetPanel
tableName="Name"
hasError={false}
columnList={[]}
loading={false}
/>,
);

const blankDatasetImg = screen.getByRole('img', { name: /empty/i });
expect(blankDatasetImg).toBeVisible();
const noColumnsTitle = screen.getByText(NO_COLUMNS_TITLE);
expect(noColumnsTitle).toBeVisible();
const noColumnsDescription = screen.getByText(NO_COLUMNS_DESCRIPTION);
expect(noColumnsDescription).toBeVisible();
});

it('renders a loading screen', () => {
render(
<DatasetPanel
tableName="Name"
hasError={false}
columnList={[]}
loading
/>,
);

const blankDatasetImg = screen.getByAltText(ALT_LOADING);
expect(blankDatasetImg).toBeVisible();
const blankDatasetTitle = screen.getByText(REFRESHING);
expect(blankDatasetTitle).toBeVisible();
expect(blankDatasetDescription).toBeVisible();
expect(sqlLabLink).toBeVisible();
});

it('renders an error screen', () => {
render(
<DatasetPanel
tableName="Name"
hasError
columnList={[]}
loading={false}
/>,
);

const errorTitle = screen.getByText(ERROR_TITLE);
expect(errorTitle).toBeVisible();
const errorDescription = screen.getByText(ERROR_DESCRIPTION);
expect(errorDescription).toBeVisible();
});

it('renders a table with columns displayed', async () => {
const tableName = 'example_name';
render(
<DatasetPanel
tableName={tableName}
hasError={false}
columnList={exampleColumns}
loading={false}
/>,
);
expect(await screen.findByText(tableName)).toBeVisible();
expect(screen.getByText(COLUMN_TITLE)).toBeVisible();
expect(
screen.getByText(tableColumnDefinition[0].title as string),
).toBeInTheDocument();
expect(
screen.getByText(tableColumnDefinition[1].title as string),
).toBeInTheDocument();
exampleColumns.forEach(row => {
expect(screen.getByText(row.name)).toBeInTheDocument();
expect(screen.getByText(row.type)).toBeInTheDocument();
});
});
});
Loading