+ <>
{t('Change order of columns.')}
{t('Available sorting modes:')}
- {t('By key: use column names as sorting key')}
- {t('By value: use metric values as sorting key')}
-
+ >
),
},
},
diff --git a/superset-frontend/src/dashboard/containers/DashboardPage.tsx b/superset-frontend/src/dashboard/containers/DashboardPage.tsx
index 20e98a598f71a..1f28ecad74e27 100644
--- a/superset-frontend/src/dashboard/containers/DashboardPage.tsx
+++ b/superset-frontend/src/dashboard/containers/DashboardPage.tsx
@@ -36,13 +36,13 @@ import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
import { addWarningToast } from 'src/components/MessageToasts/actions';
import {
- getFromLocalStorage,
- setInLocalStorage,
+ getItem,
+ setItem,
+ LocalStorageKeys,
} from 'src/utils/localStorageHelpers';
import {
FILTER_BOX_MIGRATION_STATES,
FILTER_BOX_TRANSITION_SNOOZE_DURATION,
- FILTER_BOX_TRANSITION_SNOOZED_AT,
} from 'src/explore/constants';
import { URL_PARAMS } from 'src/constants';
import { getUrlParam } from 'src/utils/urlUtils';
@@ -126,8 +126,10 @@ const DashboardPage: FC = () => {
}
// has cookie?
- const snoozeDash =
- getFromLocalStorage(FILTER_BOX_TRANSITION_SNOOZED_AT, 0) || {};
+ const snoozeDash = getItem(
+ LocalStorageKeys.filter_box_transition_snoozed_at,
+ {},
+ );
if (
Date.now() - (snoozeDash[id] || 0) <
FILTER_BOX_TRANSITION_SNOOZE_DURATION
@@ -210,9 +212,11 @@ const DashboardPage: FC = () => {
setFilterboxMigrationState(FILTER_BOX_MIGRATION_STATES.REVIEWING);
}}
onClickSnooze={() => {
- const snoozedDash =
- getFromLocalStorage(FILTER_BOX_TRANSITION_SNOOZED_AT, 0) || {};
- setInLocalStorage(FILTER_BOX_TRANSITION_SNOOZED_AT, {
+ const snoozedDash = getItem(
+ LocalStorageKeys.filter_box_transition_snoozed_at,
+ {},
+ );
+ setItem(LocalStorageKeys.filter_box_transition_snoozed_at, {
...snoozedDash,
[id]: Date.now(),
});
diff --git a/superset-frontend/src/explore/components/DataTablesPane/index.tsx b/superset-frontend/src/explore/components/DataTablesPane/index.tsx
index 55b11f9237d40..be0409ffeb925 100644
--- a/superset-frontend/src/explore/components/DataTablesPane/index.tsx
+++ b/superset-frontend/src/explore/components/DataTablesPane/index.tsx
@@ -25,8 +25,9 @@ import TableView, { EmptyWrapperType } from 'src/components/TableView';
import { getChartDataRequest } from 'src/chart/chartAction';
import { getClientErrorObject } from 'src/utils/getClientErrorObject';
import {
- getFromLocalStorage,
- setInLocalStorage,
+ getItem,
+ setItem,
+ LocalStorageKeys,
} from 'src/utils/localStorageHelpers';
import {
CopyToClipboardButton,
@@ -49,10 +50,6 @@ const NULLISH_RESULTS_STATE = {
const DATA_TABLE_PAGE_SIZE = 50;
-const STORAGE_KEYS = {
- isOpen: 'is_datapanel_open',
-};
-
const DATAPANEL_KEY = 'data';
const TableControlsWrapper = styled.div`
@@ -200,7 +197,7 @@ export const DataTablesPane = ({
[RESULT_TYPES.samples]?: boolean;
}>(NULLISH_RESULTS_STATE);
const [panelOpen, setPanelOpen] = useState(
- getFromLocalStorage(STORAGE_KEYS.isOpen, false),
+ getItem(LocalStorageKeys.is_datapanel_open, false),
);
const formattedData = useMemo(
@@ -283,7 +280,7 @@ export const DataTablesPane = ({
);
useEffect(() => {
- setInLocalStorage(STORAGE_KEYS.isOpen, panelOpen);
+ setItem(LocalStorageKeys.is_datapanel_open, panelOpen);
}, [panelOpen]);
useEffect(() => {
diff --git a/superset-frontend/src/explore/components/ExploreChartPanel.jsx b/superset-frontend/src/explore/components/ExploreChartPanel.jsx
index b331ae33e0cc6..7a930a7ff1c76 100644
--- a/superset-frontend/src/explore/components/ExploreChartPanel.jsx
+++ b/superset-frontend/src/explore/components/ExploreChartPanel.jsx
@@ -24,8 +24,9 @@ import { useResizeDetector } from 'react-resize-detector';
import { chartPropShape } from 'src/dashboard/util/propShapes';
import ChartContainer from 'src/chart/ChartContainer';
import {
- getFromLocalStorage,
- setInLocalStorage,
+ getItem,
+ setItem,
+ LocalStorageKeys,
} from 'src/utils/localStorageHelpers';
import ConnectedExploreChartHeader from './ExploreChartHeader';
import { DataTablesPane } from './DataTablesPane';
@@ -64,10 +65,6 @@ const CHART_PANEL_PADDING_HORIZ = 30;
const CHART_PANEL_PADDING_VERTICAL = 15;
const HEADER_PADDING = 15;
-const STORAGE_KEYS = {
- sizes: 'chart_split_sizes',
-};
-
const INITIAL_SIZES = [90, 10];
const MIN_SIZES = [300, 50];
const DEFAULT_SOUTH_PANE_HEIGHT_PERCENT = 40;
@@ -126,7 +123,7 @@ const ExploreChartPanel = props => {
refreshRate: 300,
});
const [splitSizes, setSplitSizes] = useState(
- getFromLocalStorage(STORAGE_KEYS.sizes, INITIAL_SIZES),
+ getItem(LocalStorageKeys.chart_split_sizes, INITIAL_SIZES),
);
const { slice } = props;
const updateQueryContext = useCallback(
@@ -192,7 +189,7 @@ const ExploreChartPanel = props => {
}, [recalcPanelSizes, splitSizes]);
useEffect(() => {
- setInLocalStorage(STORAGE_KEYS.sizes, splitSizes);
+ setItem(LocalStorageKeys.chart_split_sizes, splitSizes);
}, [splitSizes]);
const onDragEnd = sizes => {
diff --git a/superset-frontend/src/explore/components/ExploreViewContainer.jsx b/superset-frontend/src/explore/components/ExploreViewContainer.jsx
index e8b277319fd2a..b56f09a2ba2a0 100644
--- a/superset-frontend/src/explore/components/ExploreViewContainer.jsx
+++ b/superset-frontend/src/explore/components/ExploreViewContainer.jsx
@@ -32,8 +32,9 @@ import { usePrevious } from 'src/common/hooks/usePrevious';
import { useComponentDidMount } from 'src/common/hooks/useComponentDidMount';
import Icons from 'src/components/Icons';
import {
- getFromLocalStorage,
- setInLocalStorage,
+ getItem,
+ setItem,
+ LocalStorageKeys,
} from 'src/utils/localStorageHelpers';
import { URL_PARAMS } from 'src/constants';
import cx from 'classnames';
@@ -183,11 +184,6 @@ function ExploreViewContainer(props) {
? `${props.forcedHeight}px`
: `${windowSize.height - navHeight}px`;
- const storageKeys = {
- controlsWidth: 'controls_width',
- dataSourceWidth: 'datasource_width',
- };
-
const defaultSidebarsWidth = {
controls_width: 320,
datasource_width: 300,
@@ -455,12 +451,12 @@ function ExploreViewContainer(props) {
}
function getSidebarWidths(key) {
- return getFromLocalStorage(key, defaultSidebarsWidth[key]);
+ return getItem(key, defaultSidebarsWidth[key]);
}
function setSidebarWidths(key, dimension) {
const newDimension = Number(getSidebarWidths(key)) + dimension.width;
- setInLocalStorage(key, newDimension);
+ setItem(key, newDimension);
}
if (props.standalone) {
@@ -504,13 +500,13 @@ function ExploreViewContainer(props) {
)}