Skip to content

Commit

Permalink
Fix: Migrate Panel edit uiState percentage strings to number (grafana…
Browse files Browse the repository at this point in the history
  • Loading branch information
peterholmberg authored Nov 26, 2020
1 parent bec3fbe commit 06e48cb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { OptionsPaneContent } from './OptionsPaneContent';
import { DashNavButton } from 'app/features/dashboard/components/DashNav/DashNavButton';
import { SubMenuItems } from 'app/features/dashboard/components/SubMenu/SubMenuItems';
import { BackButton } from 'app/core/components/BackButton/BackButton';
import { SplitPaneWrapper } from 'app/core/components/ThreePaneSplit/SplitPaneWrapper';
import { SplitPaneWrapper } from 'app/core/components/SplitPaneWrapper/SplitPaneWrapper';
import { SaveDashboardModalProxy } from '../SaveDashboard/SaveDashboardModalProxy';
import { DashboardPanel } from '../../dashgrid/DashboardPanel';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ export interface PanelEditorState {
}

export const initialState = (): PanelEditorState => {
const storedUiState = store.getObject(PANEL_EDITOR_UI_STATE_STORAGE_KEY, DEFAULT_PANEL_EDITOR_UI_STATE);

let migratedState = { ...storedUiState };

if (typeof storedUiState.rightPaneSize === 'string') {
migratedState = { ...storedUiState, rightPaneSize: parseFloat(storedUiState.rightPaneSize) / 100 };
}

return {
getPanel: () => new PanelModel({}),
getSourcePanel: () => new PanelModel({}),
Expand All @@ -50,7 +58,7 @@ export const initialState = (): PanelEditorState => {
isOpen: false,
ui: {
...DEFAULT_PANEL_EDITOR_UI_STATE,
...store.getObject(PANEL_EDITOR_UI_STATE_STORAGE_KEY, DEFAULT_PANEL_EDITOR_UI_STATE),
...migratedState,
},
};
};
Expand Down

0 comments on commit 06e48cb

Please sign in to comment.