import { i18n } from '@osd/i18n' ; import { UiActionsStart } from 'src/plugins/ui_actions/public' ; import { CoreStart , ScopedHistory } from 'src/core/public' ; import { Start as InspectorStartContract } from 'src/plugins/inspector/public' ; import { EmbeddableFactory , EmbeddableStart } from '../../../../embeddable/public' ; import { ContainerOutput , EmbeddableFactoryDefinition , ErrorEmbeddable , Container , } from '../../embeddable_plugin' ; import { DashboardContainer , DashboardContainerInput } from './dashboard_container' ; import { DASHBOARD_CONTAINER_TYPE } from './dashboard_constants' ; interface StartServices { capabilities : CoreStart [ 'application' ] [ 'capabilities' ] ; application : CoreStart [ 'application' ] ; overlays : CoreStart [ 'overlays' ] ; notifications : CoreStart [ 'notifications' ] ; embeddable : EmbeddableStart ; inspector : InspectorStartContract ; SavedObjectFinder : React . ComponentType < any > ; ExitFullScreenButton : React . ComponentType < any > ; uiActions : UiActionsStart ; } export type DashboardContainerFactory = EmbeddableFactory < DashboardContainerInput , ContainerOutput , DashboardContainer > ; export class DashboardContainerFactoryDefinition implements EmbeddableFactoryDefinition < DashboardContainerInput , ContainerOutput , DashboardContainer > { public readonly isContainerType = true ; public readonly type = DASHBOARD_CONTAINER_TYPE ; constructor ( private readonly getStartServices , private getHistory ) { } public isEditable = async ( ) => { const { capabilities } = await this . getStartServices ( ) ; return ! ! capabilities . createNew && ! ! capabilities . showWriteControls ; } ; public readonly getDisplayName = ( ) => { return i18n . translate ( 'dashboard.factory.displayName' , { defaultMessage : 'dashboard' , } ) ; } ; public getDefaultInput ( ) { return { panels : { } , isEmbeddedExternally : false , isFullScreenMode : false , useMargins : true , } ; } public create = async ( initialInput , parent ? ) : Promise < DashboardContainer | ErrorEmbeddable > => { const services = await this . getStartServices ( ) ; const stateTransfer = services . embeddable . getStateTransfer ( this . getHistory ( ) ) ; return new DashboardContainer ( initialInput , services , stateTransfer , parent ) ; } ; }