[embeddable rebuild] PublishesSettings interface (#179976)

Closes https://github.com/elastic/kibana/issues/179839

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Nathan Reese 2024-04-07 08:32:45 -06:00 committed by GitHub
parent eaef7753bf
commit 001f24c6b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 43 additions and 5 deletions

View file

@ -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>;

View file

@ -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');
};

View file

@ -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,
@ -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);
@ -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