-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
chore(sqllab): Relocate user in SqlLab to root #25010
Changes from all commits
3eddfbe
03061e1
0bf21d6
93efcf2
3feffa4
424201c
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 |
---|---|---|
|
@@ -27,7 +27,7 @@ import { | |
isFeatureEnabled, | ||
} from '@superset-ui/core'; | ||
import { GlobalStyles } from 'src/GlobalStyles'; | ||
import { setupStore } from 'src/views/store'; | ||
import { setupStore, userReducer } from 'src/views/store'; | ||
import setupExtensions from 'src/setup/setupExtensions'; | ||
import getBootstrapData from 'src/utils/getBootstrapData'; | ||
import { tableApiUtil } from 'src/hooks/apiResources/tables'; | ||
|
@@ -78,12 +78,6 @@ const sqlLabPersistStateConfig = { | |
} | ||
}); | ||
|
||
if (subset.sqlLab?.user) { | ||
// Don't persist the user. | ||
// User should really not be stored under the "sqlLab" field. Oh well. | ||
delete subset.sqlLab.user; | ||
} | ||
|
||
const data = JSON.stringify(subset); | ||
// 2 digit precision | ||
const currentSize = | ||
|
@@ -105,17 +99,14 @@ const sqlLabPersistStateConfig = { | |
...initialState.sqlLab, | ||
}, | ||
}; | ||
// Filter out any user data that may have been persisted in an older version. | ||
// Get user from bootstrap data instead, every time | ||
result.sqlLab.user = initialState.sqlLab.user; | ||
return result; | ||
}, | ||
}, | ||
}; | ||
|
||
export const store = setupStore({ | ||
initialState, | ||
rootReducers: reducers, | ||
rootReducers: { ...reducers, user: userReducer }, | ||
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. Could you add the user reducer 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. First I intended to do so but |
||
...(!isFeatureEnabled(FeatureFlag.SQLLAB_BACKEND_PERSISTENCE) && { | ||
enhancers: [ | ||
persistState( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,6 @@ export default function getInitialState({ | |
tab_state_ids: tabStateIds = [], | ||
databases, | ||
queries: queries_, | ||
requested_query: requestedQuery, | ||
user, | ||
}) { | ||
/** | ||
|
@@ -200,11 +199,9 @@ export default function getInitialState({ | |
tabHistory: dedupeTabHistory(tabHistory), | ||
tables: Object.values(tables), | ||
queriesLastUpdate: Date.now(), | ||
user, | ||
unsavedQueryEditor, | ||
queryCostEstimates: {}, | ||
}, | ||
requestedQuery, | ||
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. Remove |
||
messageToasts: getToastsFromPyFlashMessages( | ||
(common || {}).flash_messages || [], | ||
), | ||
|
@@ -213,5 +210,6 @@ export default function getInitialState({ | |
flash_messages: common.flash_messages, | ||
conf: common.conf, | ||
}, | ||
user, | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ | |
import { JsonObject, QueryResponse } from '@superset-ui/core'; | ||
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes'; | ||
import { ToastType } from 'src/components/MessageToasts/types'; | ||
import { RootState } from 'src/dashboard/types'; | ||
import { DropdownButtonProps } from 'src/components/DropdownButton'; | ||
import { ButtonProps } from 'src/components/Button'; | ||
|
||
|
@@ -66,33 +65,20 @@ export type SqlLabRootState = { | |
tabHistory: string[]; // default is activeTab ? [activeTab.id.toString()] : [] | ||
tables: Record<string, any>[]; | ||
queriesLastUpdate: number; | ||
user: UserWithPermissionsAndRoles; | ||
errorMessage: string | null; | ||
unsavedQueryEditor: Partial<QueryEditor>; | ||
queryCostEstimates?: Record<string, QueryCostEstimate>; | ||
editorTabLastUpdatedAt?: number; | ||
}; | ||
localStorageUsageInKilobytes: number; | ||
messageToasts: toastState[]; | ||
user: UserWithPermissionsAndRoles; | ||
common: { | ||
flash_messages: string[]; | ||
conf: JsonObject; | ||
}; | ||
}; | ||
|
||
export type SqlLabExploreRootState = SqlLabRootState | RootState; | ||
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. @lyndsiWilliams I removed this user selector logic since it's under the same path. |
||
|
||
export const getInitialState = (state: SqlLabExploreRootState) => { | ||
if (state.hasOwnProperty('sqlLab')) { | ||
const { | ||
sqlLab: { user }, | ||
} = state as SqlLabRootState; | ||
return user; | ||
} | ||
|
||
const { user } = state as RootState; | ||
return user as UserWithPermissionsAndRoles; | ||
}; | ||
|
||
export enum DatasetRadioState { | ||
SAVE_NEW = 1, | ||
OVERWRITE_DATASET = 2, | ||
|
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.
Should we also remove?