fix: permalink save/overwrites in explore (#25112)

Co-authored-by: Elizabeth Thompson <eschutho@gmail.com>
This commit is contained in:
Hugh A. Miles II
2023-10-16 14:00:09 -04:00
committed by GitHub
parent 18a1c8d7d8
commit e58a3aba54
2 changed files with 48 additions and 10 deletions

View File

@@ -164,6 +164,17 @@ class SaveModal extends React.Component<SaveModalProps, SaveModalState> {
this.props.dispatch(setSaveChartModalVisibility(false));
}
handleRedirect = (windowLocationSearch: string, chart: any) => {
const searchParams = new URLSearchParams(windowLocationSearch);
searchParams.set('save_action', this.state.action);
if (this.state.action !== 'overwrite') {
searchParams.delete('form_data_key');
}
searchParams.set('slice_id', chart.id.toString());
return searchParams;
};
async saveOrOverwrite(gotodash: boolean) {
this.setState({ isLoading: true });
@@ -270,14 +281,7 @@ class SaveModal extends React.Component<SaveModalProps, SaveModalState> {
return;
}
const searchParams = new URLSearchParams(window.location.search);
searchParams.set('save_action', this.state.action);
if (this.state.action !== 'overwrite') {
searchParams.delete('form_data_key');
}
if (this.state.action === 'saveas') {
searchParams.set('slice_id', value.id.toString());
}
const searchParams = this.handleRedirect(window.location.search, value);
this.props.history.replace(`/explore/?${searchParams.toString()}`);
this.setState({ isLoading: false });
@@ -527,3 +531,6 @@ function mapStateToProps({
}
export default withRouter(connect(mapStateToProps)(SaveModal));
// User for testing purposes need to revisit once we convert this to functional component
export { SaveModal as PureSaveModal };