From bd2361d2a40a6329b8c024cef72068cbeac07078 Mon Sep 17 00:00:00 2001 From: Dima Arnautov Date: Thu, 4 Aug 2022 11:02:02 +0200 Subject: [PATCH] [ML] Fix the Dashboard saving indicator with Anomaly Swim Lane embeddable (#137989) --- .../anomaly_swimlane_embeddable.tsx | 4 +++ .../anomaly_swimlane_initializer.tsx | 30 +++++++++---------- .../anomaly_swimlane_setup_flyout.tsx | 7 ++--- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable.tsx b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable.tsx index bb239868aed77..639136b169471 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable.tsx +++ b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_embeddable.tsx @@ -53,6 +53,10 @@ export class AnomalySwimlaneEmbeddable extends Embeddable< ); } + public reportsEmbeddableLoad() { + return true; + } + public onLoading() { this.renderComplete.dispatchInProgress(); this.updateOutput({ loading: true, error: undefined }); diff --git a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx index 4fc43fc640b98..e5e2c2fd3b6be 100644 --- a/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx +++ b/x-pack/plugins/ml/public/embeddables/anomaly_swimlane/anomaly_swimlane_initializer.tsx @@ -25,17 +25,19 @@ import { i18n } from '@kbn/i18n'; import { SWIMLANE_TYPE, SwimlaneType } from '../../application/explorer/explorer_constants'; import { AnomalySwimlaneEmbeddableInput } from '..'; +interface ExplicitInput { + panelTitle: string; + swimlaneType: SwimlaneType; + viewBy?: string; +} + export interface AnomalySwimlaneInitializerProps { defaultTitle: string; influencers: string[]; initialInput?: Partial< Pick >; - onCreate: (swimlaneProps: { - panelTitle: string; - swimlaneType: SwimlaneType; - viewBy?: string; - }) => void; + onCreate: (swimlaneProps: ExplicitInput) => void; onCancel: () => void; } @@ -47,7 +49,7 @@ export const AnomalySwimlaneInitializer: FC = ( initialInput, }) => { const [panelTitle, setPanelTitle] = useState(defaultTitle); - const [swimlaneType, setSwimlaneType] = useState( + const [swimlaneType, setSwimlaneType] = useState( initialInput?.swimlaneType ?? SWIMLANE_TYPE.OVERALL ); const [viewBySwimlaneFieldName, setViewBySwimlaneFieldName] = useState(initialInput?.viewBy); @@ -81,6 +83,12 @@ export const AnomalySwimlaneInitializer: FC = ( (swimlaneType === SWIMLANE_TYPE.OVERALL || (swimlaneType === SWIMLANE_TYPE.VIEW_BY && !!viewBySwimlaneFieldName)); + const resultInput = { + panelTitle, + swimlaneType, + ...(viewBySwimlaneFieldName ? { viewBy: viewBySwimlaneFieldName } : {}), + }; + return ( @@ -162,15 +170,7 @@ export const AnomalySwimlaneInitializer: FC = ( /> - + { + onCreate={(explicitInput) => { modalSession.close(); resolve({ jobIds, - title: panelTitle, - swimlaneType, - viewBy, + title: explicitInput.panelTitle, + ...explicitInput, }); }} onCancel={() => {