mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
feat: Persist SQL Lab autocomplete setting across tabs and visits (#17708)
This commit is contained in:
parent
6edc183c5f
commit
5b0aa27f2b
@ -63,6 +63,11 @@ import {
|
||||
SQL_EDITOR_GUTTER_MARGIN,
|
||||
SQL_TOOLBAR_HEIGHT,
|
||||
} from 'src/SqlLab/constants';
|
||||
import {
|
||||
getItem,
|
||||
LocalStorageKeys,
|
||||
setItem,
|
||||
} from 'src/utils/localStorageHelpers';
|
||||
import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags';
|
||||
import TemplateParamsEditor from '../TemplateParamsEditor';
|
||||
import ConnectedSouthPane from '../SouthPane/state';
|
||||
@ -171,7 +176,10 @@ class SqlEditor extends React.PureComponent {
|
||||
northPercent: props.queryEditor.northPercent || INITIAL_NORTH_PERCENT,
|
||||
southPercent: props.queryEditor.southPercent || INITIAL_SOUTH_PERCENT,
|
||||
sql: props.queryEditor.sql,
|
||||
autocompleteEnabled: true,
|
||||
autocompleteEnabled: getItem(
|
||||
LocalStorageKeys.sqllab__is_autocomplete_enabled,
|
||||
true,
|
||||
),
|
||||
showCreateAsModal: false,
|
||||
createAs: '',
|
||||
};
|
||||
@ -365,9 +373,15 @@ class SqlEditor extends React.PureComponent {
|
||||
}
|
||||
|
||||
handleToggleAutocompleteEnabled = () => {
|
||||
this.setState(prevState => ({
|
||||
autocompleteEnabled: !prevState.autocompleteEnabled,
|
||||
}));
|
||||
this.setState(prevState => {
|
||||
setItem(
|
||||
LocalStorageKeys.sqllab__is_autocomplete_enabled,
|
||||
!prevState.autocompleteEnabled,
|
||||
);
|
||||
return {
|
||||
autocompleteEnabled: !prevState.autocompleteEnabled,
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
handleWindowResize() {
|
||||
|
@ -48,6 +48,7 @@ export enum LocalStorageKeys {
|
||||
* Example:
|
||||
* sqllab__is_autocomplete_enabled
|
||||
*/
|
||||
sqllab__is_autocomplete_enabled = 'sqllab__is_autocomplete_enabled',
|
||||
}
|
||||
|
||||
export type LocalStorageValues = {
|
||||
@ -60,6 +61,7 @@ export type LocalStorageValues = {
|
||||
homepage_dashboard_filter: TableTabTypes;
|
||||
homepage_collapse_state: string[];
|
||||
homepage_activity_filter: SetTabType | null;
|
||||
sqllab__is_autocomplete_enabled: boolean;
|
||||
};
|
||||
|
||||
export function getItem<K extends LocalStorageKeys>(
|
||||
|
Loading…
Reference in New Issue
Block a user