Fix: Migrate Panel edit uiState percentage strings to number (#29412) (#29723)

(cherry picked from commit 06e48cb869)
This commit is contained in:
Peter Holmberg
2020-12-09 15:49:30 +01:00
committed by GitHub
parent 751f32c752
commit f5d8063da2
@@ -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({}),
@@ -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,
},
};
};