-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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: Use SPA navigation between AddSlice and Dataset list pages #21683
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
* under the License. | ||
*/ | ||
import React, { FunctionComponent, useState, useEffect } from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { styled, t } from '@superset-ui/core'; | ||
import { useSingleViewResource } from 'src/views/CRUD/hooks'; | ||
import Modal from 'src/components/Modal'; | ||
|
@@ -54,6 +55,7 @@ const DatasetModal: FunctionComponent<DatasetModalProps> = ({ | |
onHide, | ||
show, | ||
}) => { | ||
const history = useHistory(); | ||
const [currentDatabase, setCurrentDatabase] = useState< | ||
DatabaseObject | undefined | ||
>(); | ||
|
@@ -100,9 +102,13 @@ const DatasetModal: FunctionComponent<DatasetModalProps> = ({ | |
setDisableSave(true); | ||
}; | ||
|
||
const hide = () => { | ||
setItem(LocalStorageKeys.db, null); | ||
const cleanup = () => { | ||
clearModal(); | ||
setItem(LocalStorageKeys.db, null); | ||
}; | ||
|
||
const hide = () => { | ||
cleanup(); | ||
onHide(); | ||
}; | ||
|
||
|
@@ -122,8 +128,8 @@ const DatasetModal: FunctionComponent<DatasetModalProps> = ({ | |
if (onDatasetAdd) { | ||
onDatasetAdd({ id: response.id, ...response }); | ||
} | ||
window.location.href = `/chart/add?dataset=${currentTableName}`; | ||
hide(); | ||
history.push(`/chart/add?dataset=${currentTableName}`); | ||
cleanup(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The previous version had a call to
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, |
||
}); | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I separated the cleanup functions from
onHide()
, becauseonHide
doeshistory.replace
, which causes race condition withhistory.push
in line 131