import { i18n } from '@kbn/i18n' ; import { SavedObjectsClientContract } from 'kibana/public' ; import { TodoSavedObjectAttributes } from 'examples/embeddable_examples/common' ; import { IContainer , EmbeddableStart , ErrorEmbeddable , EmbeddableFactoryDefinition , EmbeddableFactory , } from '../../../../src/plugins/embeddable/public' ; import { TodoRefEmbeddable , TODO_REF_EMBEDDABLE , TodoRefInput , TodoRefOutput , } from './todo_ref_embeddable' ; interface StartServices { getEmbeddableFactory : EmbeddableStart [ 'getEmbeddableFactory' ] ; savedObjectsClient : SavedObjectsClientContract ; } export type TodoRefEmbeddableFactory = EmbeddableFactory < TodoRefInput , TodoRefOutput , TodoRefEmbeddable , TodoSavedObjectAttributes > ; export class TodoRefEmbeddableFactoryDefinition implements EmbeddableFactoryDefinition < TodoRefInput , TodoRefOutput , TodoRefEmbeddable , TodoSavedObjectAttributes > { public readonly type = TODO_REF_EMBEDDABLE ; public readonly savedObjectMetaData = { name : 'Todo' , includeFields : [ 'task' , 'icon' , 'title' ] , type : 'todo' , getIconForSavedObject : ( ) => 'pencil' , } ; constructor ( private getStartServices ) { } public async isEditable ( ) { return true ; } public createFromSavedObject = ( savedObjectId , input , parent ? ) : Promise < TodoRefEmbeddable | ErrorEmbeddable > => { return this . create ( { ... input , savedObjectId } , parent ) ; } ; public async create ( input , parent ? ) { const { savedObjectsClient } = await this . getStartServices ( ) ; return new TodoRefEmbeddable ( input , { parent , savedObjectsClient , } ) ; } public getDisplayName ( ) { return i18n . translate ( 'embeddableExamples.todo.displayName' , { defaultMessage : 'Todo (by reference)' , } ) ; } }