From bba739d0e711627148550dee3ed705b554be9abe Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Fri, 20 Sep 2024 14:20:32 -0600 Subject: [PATCH] resolve control group not chaning on navigateToDashboard --- src/plugins/dashboard/public/dashboard_api/types.ts | 4 ++-- .../component/viewport/dashboard_viewport.tsx | 6 ++++-- .../embeddable/dashboard_container.tsx | 8 ++++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/dashboard/public/dashboard_api/types.ts b/src/plugins/dashboard/public/dashboard_api/types.ts index 55eedf60c2921..01d12c27ce443 100644 --- a/src/plugins/dashboard/public/dashboard_api/types.ts +++ b/src/plugins/dashboard/public/dashboard_api/types.ts @@ -18,7 +18,6 @@ import { import { HasAppContext, HasType, - HasUniqueId, PublishesDataViews, PublishesPanelDescription, PublishesPanelTitle, @@ -40,7 +39,6 @@ export type DashboardApi = CanExpandPanels & HasRuntimeChildState & HasSerializedChildState & HasType<'dashboard'> & - HasUniqueId & PresentationContainer & PublishesDataViews & PublishesPanelDescription & @@ -84,6 +82,8 @@ export type DashboardApi = CanExpandPanels & setTimeRange: (timeRange?: TimeRange | undefined) => void; setViewMode: (viewMode: ViewMode) => void; useMargins$: PublishingSubject; + // TODO replace with HasUniqueId once dashboard is refactored and navigateToDashboard is removed + uuid$: PublishingSubject; // TODO remove types below this line - from legacy embeddable system untilEmbeddableLoaded: (id: string) => Promise; diff --git a/src/plugins/dashboard/public/dashboard_container/component/viewport/dashboard_viewport.tsx b/src/plugins/dashboard/public/dashboard_container/component/viewport/dashboard_viewport.tsx index fe8609a3fa75e..1e4e0822f7ce8 100644 --- a/src/plugins/dashboard/public/dashboard_container/component/viewport/dashboard_viewport.tsx +++ b/src/plugins/dashboard/public/dashboard_container/component/viewport/dashboard_viewport.tsx @@ -53,6 +53,7 @@ export const DashboardViewportComponent = () => { panels, viewMode, useMargins, + uuid, ] = useBatchedPublishingSubjects( dashboardApi.controlGroupApi$, dashboardApi.panelTitle, @@ -61,7 +62,8 @@ export const DashboardViewportComponent = () => { dashboardApi.focusedPanelId$, dashboardApi.panels$, dashboardApi.viewMode, - dashboardApi.useMargins$ + dashboardApi.useMargins$, + dashboardApi.uuid$ ); const panelCount = useMemo(() => { @@ -118,7 +120,7 @@ export const DashboardViewportComponent = () => { ControlGroupRuntimeState, ControlGroupApi > - key={dashboardApi.uuid} + key={uuid} hidePanelChrome={true} panelProps={{ hideLoader: true }} type={CONTROL_GROUP_TYPE} diff --git a/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.tsx b/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.tsx index c3eb89e17b271..43f733895f1f5 100644 --- a/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.tsx +++ b/src/plugins/dashboard/public/dashboard_container/embeddable/dashboard_container.tsx @@ -293,7 +293,11 @@ export class DashboardContainer this.dispatch = reduxTools.dispatch; this.select = reduxTools.select; - this.uuid = this.getInput().id; + this.uuid$ = embeddableInputToSubject( + this.publishingSubscription, + this, + 'id' + ) as BehaviorSubject; this.savedObjectId = new BehaviorSubject(this.getDashboardSavedObjectId()); this.expandedPanelId = new BehaviorSubject(this.getExpandedPanelId()); @@ -586,7 +590,7 @@ export class DashboardContainer public animatePanelTransforms$: BehaviorSubject; public panels$: BehaviorSubject; public embeddedExternally$: BehaviorSubject; - public uuid: string; + public uuid$: BehaviorSubject; public async replacePanel(idToRemove: string, { panelType, initialState }: PanelPackage) { const newId = await this.replaceEmbeddable(