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: have user go to explore after dataset creation #19965

Merged
merged 9 commits into from
Jul 12, 2022
13 changes: 13 additions & 0 deletions superset-frontend/src/addSlice/AddSliceContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
import React, { ReactNode } from 'react';
import rison from 'rison';
import querystring from 'query-string';
import { styled, t, SupersetClient, JsonResponse } from '@superset-ui/core';
import Button from 'src/components/Button';
import { Select, Steps } from 'src/components';
Expand All @@ -27,6 +28,7 @@ import { Tooltip } from 'src/components/Tooltip';
import VizTypeGallery, {
MAX_ADVISABLE_VIZ_GALLERY_WIDTH,
} from 'src/explore/components/controls/VizTypeControl/VizTypeGallery';
import _ from 'lodash';

type Dataset = {
id: number;
Expand All @@ -40,6 +42,7 @@ export type AddSliceContainerProps = {};
export type AddSliceContainerState = {
datasource?: { label: string; value: string };
visType: string | null;
datasetName?: string | string[] | null;
};

const ESTIMATED_NAV_HEIGHT = 56;
Expand Down Expand Up @@ -194,6 +197,16 @@ export default class AddSliceContainer extends React.PureComponent<
this.loadDatasources = this.loadDatasources.bind(this);
}

componentDidMount() {
const params = querystring.parse(window.location.search)?.dataset as string;
if (params) {
this.loadDatasources(params, 0, 1).then(r => {
const datasource = r.data[0];
this.setState({ datasource });
});
}
}

exploreUrl() {
const formData = encodeURIComponent(
JSON.stringify({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const DatasetModal: FunctionComponent<DatasetModalProps> = ({
onDatasetAdd({ id: response.id, ...response });
}
addSuccessToast(t('The dataset has been saved'));
window.location.href = `/chart/add?dataset=${currentTableName}`;
hide();
});
};
Expand All @@ -116,7 +117,7 @@ const DatasetModal: FunctionComponent<DatasetModalProps> = ({
disablePrimaryButton={disableSave}
onHandledPrimaryAction={onSave}
onHide={hide}
primaryButtonName={t('Add')}
primaryButtonName={t('Add Dataset and Create Chart')}
show={show}
title={t('Add dataset')}
>
Expand Down