mirror of
https://github.com/apache/superset.git
synced 2026-05-12 11:25:56 +00:00
feat: Save datapanel state in local storage (#12996)
* Save datapanel state in local storage * Export string to a constant * Move local storage helpers to separate file * Use helper functions in ExploreViewContainer
This commit is contained in:
committed by
GitHub
parent
69b0ed663d
commit
2ce79823df
@@ -30,6 +30,10 @@ import { Global } from '@emotion/core';
|
||||
import { Tooltip } from 'src/common/components/Tooltip';
|
||||
import { usePrevious } from 'src/common/hooks/usePrevious';
|
||||
import Icon from 'src/components/Icon';
|
||||
import {
|
||||
getFromLocalStorage,
|
||||
setInLocalStorage,
|
||||
} from 'src/utils/localStorageHelpers';
|
||||
import ExploreChartPanel from './ExploreChartPanel';
|
||||
import ConnectedControlPanelsContainer from './ControlPanelsContainer';
|
||||
import SaveModal from './SaveModal';
|
||||
@@ -379,20 +383,12 @@ function ExploreViewContainer(props) {
|
||||
}
|
||||
|
||||
function getSidebarWidths(key) {
|
||||
try {
|
||||
return localStorage.getItem(key) || defaultSidebarsWidth[key];
|
||||
} catch {
|
||||
return defaultSidebarsWidth[key];
|
||||
}
|
||||
return getFromLocalStorage(key, defaultSidebarsWidth[key]);
|
||||
}
|
||||
|
||||
function setSidebarWidths(key, dimension) {
|
||||
try {
|
||||
const newDimension = Number(getSidebarWidths(key)) + dimension.width;
|
||||
localStorage.setItem(key, newDimension);
|
||||
} catch {
|
||||
// Catch in case localStorage is unavailable
|
||||
}
|
||||
const newDimension = Number(getSidebarWidths(key)) + dimension.width;
|
||||
setInLocalStorage(key, newDimension);
|
||||
}
|
||||
|
||||
if (props.standalone) {
|
||||
|
||||
Reference in New Issue
Block a user