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: Create dataset blank state #21058

Merged
merged 18 commits into from
Aug 22, 2022
Merged
Show file tree
Hide file tree
Changes from 11 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
38 changes: 38 additions & 0 deletions superset-frontend/src/assets/images/empty-dataset.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions superset-frontend/src/assets/images/empty-table.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,7 @@ export const ExploreChartHeader = ({
};

useEffect(() => {
if (dashboardId) {
fetchChartDashboardData();
}
if (dashboardId) fetchChartDashboardData();
}, []);

const openPropertiesModal = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* 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 { render, screen } from 'spec/helpers/testing-library';
import AddDataset from 'src/views/CRUD/data/dataset/AddDataset';

describe('AddDataset', () => {
it('renders a blank state AddDataset', () => {
render(<AddDataset />);

const blankeStateImgs = screen.getAllByRole('img', { name: /empty/i });

// Header
expect(screen.getByText(/header/i)).toBeVisible();
// Left panel
expect(blankeStateImgs[0]).toBeVisible();
expect(screen.getByText(/no database tables found/i)).toBeVisible();
// Database panel
expect(blankeStateImgs[1]).toBeVisible();
expect(screen.getByText(/select dataset source/i)).toBeVisible();
// Footer
expect(screen.getByText(/footer/i)).toBeVisible();

expect(blankeStateImgs.length).toBe(2);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* 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 { render, screen } from 'spec/helpers/testing-library';
import DatasetPanel from 'src/views/CRUD/data/dataset/AddDataset/DatasetPanel';

describe('DatasetPanel', () => {
it('renders a blank state DatasetPanel', () => {
render(<DatasetPanel />);

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,
);
const sqlLabLink = screen.getByRole('button', {
name: /create dataset from sql query/i,
});

expect(blankDatasetImg).toBeVisible();
expect(blankDatasetTitle).toBeVisible();
expect(blankDatasetDescription).toBeVisible();
expect(sqlLabLink).toBeVisible();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* 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 { t } from '@superset-ui/core';
import { EmptyStateBig } from 'src/components/EmptyState';

const renderDescription = () => (
<>
{t(
'Datasets can be created from database tables or SQL queries. Select a database table to the left or ',
)}
<span
role="button"
onClick={() => {
window.location.href = `/superset/sqllab`;
}}
tabIndex={0}
>
{t('create dataset from SQL query')}
</span>
{t(' to open SQL Lab. From there you can save the query as a dataset.')}
</>
);

export default function DatasetPanel() {
return (
<>
<EmptyStateBig
image="empty-dataset.svg"
title={t('Select dataset source')}
description={renderDescription()}
/>
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
* under the License.
*/
import React from 'react';
import { render, screen } from 'spec/helpers/testing-library';
import Footer from 'src/views/CRUD/data/dataset/AddDataset/Footer';

export default function DatasetPanel() {
return <div>Dataset Panel</div>;
}
describe('Footer', () => {
it('renders a blank state Footer', () => {
render(<Footer />);

expect(screen.getByText(/footer/i)).toBeVisible();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* 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 { render, screen } from 'spec/helpers/testing-library';
import Header from 'src/views/CRUD/data/dataset/AddDataset/Header';

describe('Header', () => {
it('renders a blank state Header', () => {
render(<Header />);

expect(screen.getByText(/header/i)).toBeVisible();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* 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 { render, screen } from 'spec/helpers/testing-library';
import LeftPanel from 'src/views/CRUD/data/dataset/AddDataset/LeftPanel';

describe('LeftPanel', () => {
it('renders a blank state LeftPanel', () => {
render(<LeftPanel />);

expect(screen.getByRole('img', { name: /empty/i })).toBeVisible();
expect(screen.getByText(/no database tables found/i)).toBeVisible();
expect(screen.getByText(/try selecting a different schema/i)).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@
* under the License.
*/
import React from 'react';
import { t } from '@superset-ui/core';
import { EmptyStateMedium } from 'src/components/EmptyState';

export default function LeftPanel() {
return <div>Left Panel</div>;
return (
<>
<EmptyStateMedium
image="empty-table.svg"
title={t('No database tables found')}
description={t('Try selecting a different schema')}
/>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* 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 { render, screen } from 'spec/helpers/testing-library';
import RightPanel from 'src/views/CRUD/data/dataset/AddDataset/RightPanel';

describe('RightPanel', () => {
it('renders a blank state RightPanel', () => {
render(<RightPanel />);

expect(screen.getByText(/right panel/i)).toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
* under the License.
*/
import React from 'react';
// import React, { useReducer, Reducer } from 'react';
import Header from './Header';
import DatasetPanel from './DatasetPanel';
import LeftPanel from './LeftPanel';
import RightPanel from './RightPanel';
import Footer from './Footer';
import { DatasetActionType, DatasetObject, DSReducerActionType } from './types';
import DatasetLayout from '../DatasetLayout';

export function datasetReducer(
state: Partial<DatasetObject> | null,
Expand Down Expand Up @@ -61,22 +60,19 @@ export function datasetReducer(
}
}

export default function DatasetPage() {
export default function AddDataset() {
// this is commented out for now, but can be commented in as the component
// is built up. Uncomment the useReducer in imports too
// const [dataset, setDataset] = useReducer<
// Reducer<Partial<DatasetObject> | null, DSReducerActionType>
// >(datasetReducer, null);

return (
<div>
<Header />
<LeftPanel />
<div css={{ display: 'flex' }}>
<DatasetPanel />
<Footer />
</div>
<RightPanel />
</div>
<DatasetLayout
header={Header()}
leftPanel={LeftPanel()}
datasetPanel={DatasetPanel()}
footer={Footer()}
/>
);
}
Loading