Skip to content

Commit

Permalink
[embeddable rebuild] PublishesSettings interface (#179976)
Browse files Browse the repository at this point in the history
Closes #179839

---------

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
nreese and kibanamachine authored Apr 7, 2024
1 parent eaef775 commit 001f24c
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ import {
PublishingSubject,
} from '@kbn/presentation-publishing';
import { apiCanAddNewPanel, CanAddNewPanel } from './can_add_new_panel';
import { PublishesSettings } from './publishes_settings';

export interface PanelPackage {
panelType: string;
initialState?: object;
}

export interface PresentationContainer extends Partial<PublishesViewMode>, CanAddNewPanel {
addNewPanel: <ApiType extends unknown = unknown>(
panel: PanelPackage,
displaySuccessMessage?: boolean
) => Promise<ApiType | undefined>;
export interface PresentationContainer
extends Partial<PublishesViewMode & PublishesSettings>,
CanAddNewPanel {
removePanel: (panelId: string) => void;
canRemovePanels?: () => boolean;
replacePanel: (idToRemove: string, newPanel: PanelPackage) => Promise<string>;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { PublishingSubject } from '@kbn/presentation-publishing';

export interface PublishesSettings {
settings: Record<string, PublishingSubject<boolean | undefined>>;
}

export const apiPublishesSettings = (
unknownApi: null | unknown
): unknownApi is PublishesSettings => {
return Boolean(unknownApi && typeof (unknownApi as PublishesSettings)?.settings === 'object');
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Reference } from '@kbn/content-management-utils';
import type { ControlGroupContainer } from '@kbn/controls-plugin/public';
import type { KibanaExecutionContext, OverlayRef } from '@kbn/core/public';
import {
type PublishingSubject,
apiPublishesPanelTitle,
apiPublishesUnsavedChanges,
getPanelTitle,
Expand Down Expand Up @@ -136,6 +137,7 @@ export class DashboardContainer
public publishingSubscription: Subscription = new Subscription();
public diffingSubscription: Subscription = new Subscription();
public controlGroup?: ControlGroupContainer;
public settings: Record<string, PublishingSubject<boolean | undefined>>;

public searchSessionId?: string;
public searchSessionId$ = new BehaviorSubject<string | undefined>(undefined);
Expand Down Expand Up @@ -245,6 +247,24 @@ export class DashboardContainer
})
);
this.startAuditingReactEmbeddableChildren();

this.settings = {
syncColors$: embeddableInputToSubject<boolean | undefined, DashboardContainerInput>(
this.publishingSubscription,
this,
'syncColors'
),
syncCursor$: embeddableInputToSubject<boolean | undefined, DashboardContainerInput>(
this.publishingSubscription,
this,
'syncCursor'
),
syncTooltips$: embeddableInputToSubject<boolean | undefined, DashboardContainerInput>(
this.publishingSubscription,
this,
'syncTooltips'
),
};
this.timeslice$ = embeddableInputToSubject<
[number, number] | undefined,
DashboardContainerInput
Expand Down

0 comments on commit 001f24c

Please sign in to comment.