Skip to content

Commit

Permalink
resolve control group not chaning on navigateToDashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
nreese committed Sep 20, 2024
1 parent 66bf269 commit bba739d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/plugins/dashboard/public/dashboard_api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
import {
HasAppContext,
HasType,
HasUniqueId,
PublishesDataViews,
PublishesPanelDescription,
PublishesPanelTitle,
Expand All @@ -40,7 +39,6 @@ export type DashboardApi = CanExpandPanels &
HasRuntimeChildState &
HasSerializedChildState &
HasType<'dashboard'> &
HasUniqueId &
PresentationContainer &
PublishesDataViews &
PublishesPanelDescription &
Expand Down Expand Up @@ -84,6 +82,8 @@ export type DashboardApi = CanExpandPanels &
setTimeRange: (timeRange?: TimeRange | undefined) => void;
setViewMode: (viewMode: ViewMode) => void;
useMargins$: PublishingSubject<boolean | undefined>;
// TODO replace with HasUniqueId once dashboard is refactored and navigateToDashboard is removed
uuid$: PublishingSubject<string>;

// TODO remove types below this line - from legacy embeddable system
untilEmbeddableLoaded: (id: string) => Promise<IEmbeddable | ErrorEmbeddable>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const DashboardViewportComponent = () => {
panels,
viewMode,
useMargins,
uuid,
] = useBatchedPublishingSubjects(
dashboardApi.controlGroupApi$,
dashboardApi.panelTitle,
Expand All @@ -61,7 +62,8 @@ export const DashboardViewportComponent = () => {
dashboardApi.focusedPanelId$,
dashboardApi.panels$,
dashboardApi.viewMode,
dashboardApi.useMargins$
dashboardApi.useMargins$,
dashboardApi.uuid$
);

const panelCount = useMemo(() => {
Expand Down Expand Up @@ -118,7 +120,7 @@ export const DashboardViewportComponent = () => {
ControlGroupRuntimeState,
ControlGroupApi
>
key={dashboardApi.uuid}
key={uuid}
hidePanelChrome={true}
panelProps={{ hideLoader: true }}
type={CONTROL_GROUP_TYPE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,11 @@ export class DashboardContainer
this.dispatch = reduxTools.dispatch;
this.select = reduxTools.select;

this.uuid = this.getInput().id;
this.uuid$ = embeddableInputToSubject<string>(
this.publishingSubscription,
this,
'id'
) as BehaviorSubject<string>;

this.savedObjectId = new BehaviorSubject(this.getDashboardSavedObjectId());
this.expandedPanelId = new BehaviorSubject(this.getExpandedPanelId());
Expand Down Expand Up @@ -586,7 +590,7 @@ export class DashboardContainer
public animatePanelTransforms$: BehaviorSubject<boolean | undefined>;
public panels$: BehaviorSubject<DashboardPanelMap>;
public embeddedExternally$: BehaviorSubject<boolean | undefined>;
public uuid: string;
public uuid$: BehaviorSubject<string>;

public async replacePanel(idToRemove: string, { panelType, initialState }: PanelPackage) {
const newId = await this.replaceEmbeddable(
Expand Down

0 comments on commit bba739d

Please sign in to comment.