From b4da45858a250c41b4c08ada334d844fafd83a06 Mon Sep 17 00:00:00 2001 From: ppisljar Date: Thu, 19 Mar 2020 03:39:46 -0700 Subject: [PATCH] fixes --- .../kibana/public/visualize/np_ready/editor/editor.js | 7 +++++++ .../visualize/np_ready/editor/lib/visualize_app_state.ts | 1 + .../kibana/public/visualize/np_ready/types.d.ts | 1 + .../np_ready/public/embeddable/visualize_embeddable.ts | 2 ++ 4 files changed, 11 insertions(+) diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js index 34c8fc1900302..aa7a77b8c421c 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/editor.js @@ -165,6 +165,12 @@ function VisualizeAppController( $scope.embeddableHandler = embeddableHandler; + const handleUiStateChange = () => { + stateContainer.transitions.updateUiState(visStateToEditorState().uiState); + }; + + $scope.vis.uiState.on('change', handleUiStateChange); + $scope.topNavMenu = [ ...(visualizeCapabilities.save ? [ @@ -576,6 +582,7 @@ function VisualizeAppController( savedVis.destroy(); subscriptions.unsubscribe(); $scope.eventEmitter.off('apply', _applyVis); + $scope.vis.uiState.off('change', handleUiStateChange); unsubscribePersisted(); unsubscribeStateUpdates(); diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/lib/visualize_app_state.ts b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/lib/visualize_app_state.ts index 86f39ea76dd3a..9939878e038e9 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/lib/visualize_app_state.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/editor/lib/visualize_app_state.ts @@ -82,6 +82,7 @@ export function useVisualizeAppState({ stateDefaults, kbnUrlStateStorage }: Argu linked: false, }), updateVisState: state => newVisState => ({ ...state, vis: toObject(newVisState) }), + updateUiState: state => newUiState => ({ ...state, uiState: newUiState }), updateFromSavedQuery: state => savedQuery => ({ ...state, savedQuery: savedQuery.id, diff --git a/src/legacy/core_plugins/kibana/public/visualize/np_ready/types.d.ts b/src/legacy/core_plugins/kibana/public/visualize/np_ready/types.d.ts index 8908079187c48..664b386f83524 100644 --- a/src/legacy/core_plugins/kibana/public/visualize/np_ready/types.d.ts +++ b/src/legacy/core_plugins/kibana/public/visualize/np_ready/types.d.ts @@ -56,6 +56,7 @@ export interface VisualizeAppStateTransitions { state: VisualizeAppState ) => ({ query, parentFilters }: { query?: Query; parentFilters?: Filter[] }) => VisualizeAppState; updateVisState: (state: VisualizeAppState) => (vis: PureVisState) => VisualizeAppState; + updateUiState: (state: VisualizeAppState) => (uiState: PersistedState) => VisualizeAppState; updateFromSavedQuery: (state: VisualizeAppState) => (savedQuery: SavedQuery) => VisualizeAppState; } diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/embeddable/visualize_embeddable.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/embeddable/visualize_embeddable.ts index f73a893075717..342824bade3dd 100644 --- a/src/legacy/core_plugins/visualizations/public/np_ready/public/embeddable/visualize_embeddable.ts +++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/embeddable/visualize_embeddable.ts @@ -162,6 +162,8 @@ export class VisualizeEmbeddable extends Embeddable