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: Update query states to use spinner vs. progress bar #17804

Merged
merged 8 commits into from
Jan 5, 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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Provider } from 'react-redux';
import sinon from 'sinon';
import Alert from 'src/components/Alert';
import ProgressBar from 'src/components/ProgressBar';
import Loading from 'src/components/Loading';
import configureStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import fetchMock from 'fetch-mock';
Expand Down Expand Up @@ -63,6 +64,18 @@ const mockedProps = {
};
const stoppedQueryProps = { ...mockedProps, query: stoppedQuery };
const runningQueryProps = { ...mockedProps, query: runningQuery };
const fetchingQueryProps = {
...mockedProps,
query: {
dbId: 1,
cached: false,
ctas: false,
id: 'ryhHUZCGb',
progress: 100,
state: 'fetching',
startDttm: Date.now() - 500,
},
};
const cachedQueryProps = { ...mockedProps, query: cachedQuery };
const failedQueryWithErrorMessageProps = {
...mockedProps,
Expand Down Expand Up @@ -179,6 +192,11 @@ test('should render running/pending/fetching query', () => {
expect(wrapper.find(ProgressBar)).toExist();
});

test('should render fetching w/ 100 progress query', () => {
const wrapper = shallow(<ResultSet {...fetchingQueryProps} />);
expect(wrapper.find(Loading)).toExist();
});

test('should render a failed query with an error message', () => {
const wrapper = shallow(<ResultSet {...failedQueryWithErrorMessageProps} />);
expect(wrapper.find(ErrorMessageWithStackTrace)).toExist();
Expand Down
9 changes: 6 additions & 3 deletions superset-frontend/src/SqlLab/components/ResultSet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import React, { CSSProperties } from 'react';
import ButtonGroup from 'src/components/ButtonGroup';
import Alert from 'src/components/Alert';
import ProgressBar from 'src/components/ProgressBar';
import moment from 'moment';
import { RadioChangeEvent } from 'antd/lib/radio';
import Button from 'src/components/Button';
Expand All @@ -36,6 +35,7 @@ import { debounce } from 'lodash';
import ErrorMessageWithStackTrace from 'src/components/ErrorMessage/ErrorMessageWithStackTrace';
import { SaveDatasetModal } from 'src/SqlLab/components/SaveDatasetModal';
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
import ProgressBar from 'src/components/ProgressBar';
import Loading from 'src/components/Loading';
import FilterableTable from 'src/components/FilterableTable/FilterableTable';
import CopyToClipboard from 'src/components/CopyToClipboard';
Expand Down Expand Up @@ -801,8 +801,8 @@ export default class ResultSet extends React.PureComponent<
);
}
}
let progressBar;
let trackingUrl;
let progressBar;
if (query.progress > 0) {
progressBar = (
<ProgressBar
Expand All @@ -825,14 +825,17 @@ export default class ResultSet extends React.PureComponent<
query && query.extra && query.extra.progress
? query.extra.progress
: null;

return (
<div style={LOADING_STYLES}>
<div>{!progressBar && <Loading position="normal" />}</div>
{/* show loading bar whenever progress bar is completed but needs time to render */}
<div>{query.progress === 100 && <Loading position="normal" />}</div>
<QueryStateLabel query={query} />
<div>
{progressMsg && <Alert type="success" message={progressMsg} />}
</div>
<div>{progressBar}</div>
<div>{query.progress !== 100 && progressBar}</div>
<div>{trackingUrl}</div>
</div>
);
Expand Down