-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
fix: Address database options prepopulated with stale option, in dataset component #27797
base: master
Are you sure you want to change the base?
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ import { | |
DatasetObject, | ||
} from 'src/features/datasets/AddDataset/types'; | ||
import { Table } from 'src/hooks/apiResources'; | ||
import { useLocation } from 'react-router-dom'; | ||
|
||
interface LeftPanelProps { | ||
setDataset: Dispatch<SetStateAction<object>>; | ||
|
@@ -122,6 +123,9 @@ export default function LeftPanel({ | |
datasetNames, | ||
}: LeftPanelProps) { | ||
const { addDangerToast } = useToasts(); | ||
const location = useLocation(); | ||
|
||
const isAddingDataSet = location.pathname.includes('/dataset/add') ?? false; | ||
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. This is not the correct way of handling this case. This component receives the dataset as a parameter and it should be the responsibility of the caller to update the dataset accordingly, which will trigger a re-render of this component. If you check the call stack, you'll see the dataset is coming from a hook. We need to invalidate the cached results of that hook if the database changes. @justinpark 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. i see, i will check if i can patch a fix on the backend |
||
|
||
const setDatabase = useCallback( | ||
(db: Partial<DatabaseObject>) => { | ||
|
@@ -144,6 +148,7 @@ export default function LeftPanel({ | |
}); | ||
}; | ||
useEffect(() => { | ||
// TODO: storing and fetching the last selected database from local storage is potentially technical debt | ||
const currentUserSelectedDb = getItem( | ||
LocalStorageKeys.Database, | ||
null, | ||
|
@@ -174,7 +179,7 @@ export default function LeftPanel({ | |
return ( | ||
<LeftPanelStyle> | ||
<TableSelector | ||
database={dataset?.db} | ||
database={isAddingDataSet ? null : dataset?.db} | ||
handleError={addDangerToast} | ||
emptyState={emptyStateComponent(false)} | ||
onDbChange={setDatabase} | ||
|
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.