-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 create dashboard_enhanced plugin
- Loading branch information
Showing
6 changed files
with
131 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# X-Pack part of `embeddable` plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"id": "embeddableEnhanced", | ||
"version": "kibana", | ||
"server": false, | ||
"ui": true, | ||
"requiredPlugins": ["uiActions", "embeddable"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { PluginInitializerContext } from 'src/core/public'; | ||
import { EmbeddableEnhancedPlugin } from './plugin'; | ||
|
||
export { | ||
SetupContract as EmbeddableEnhancedSetupContract, | ||
SetupDependencies as EmbeddableEnhancedSetupDependencies, | ||
StartContract as EmbeddableEnhancedStartContract, | ||
StartDependencies as EmbeddableEnhancedStartDependencies, | ||
} from './plugin'; | ||
|
||
export function plugin(context: PluginInitializerContext) { | ||
return new EmbeddableEnhancedPlugin(context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { EmbeddableEnhancedSetupContract, EmbeddableEnhancedStartContract } from '.'; | ||
|
||
export type Setup = jest.Mocked<EmbeddableEnhancedSetupContract>; | ||
export type Start = jest.Mocked<EmbeddableEnhancedStartContract>; | ||
|
||
const createSetupContract = (): Setup => { | ||
const setupContract: Setup = {}; | ||
|
||
return setupContract; | ||
}; | ||
|
||
const createStartContract = (): Start => { | ||
const startContract: Start = {}; | ||
|
||
return startContract; | ||
}; | ||
|
||
export const embeddableEnhancedPluginMock = { | ||
createSetupContract, | ||
createStartContract, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { CoreStart, CoreSetup, Plugin, PluginInitializerContext } from 'src/core/public'; | ||
import { SavedObjectAttributes } from 'kibana/public'; | ||
import { UiActionsSetup, UiActionsStart } from '../../../../src/plugins/ui_actions/public'; | ||
import { | ||
EmbeddableFactory, | ||
EmbeddableFactoryDefinition, | ||
EmbeddableInput, | ||
EmbeddableOutput, | ||
EmbeddableSetup, | ||
EmbeddableStart, | ||
IEmbeddable, | ||
defaultEmbeddableFactoryProvider, | ||
} from '../../../../src/plugins/embeddable/public'; | ||
|
||
export interface SetupDependencies { | ||
embeddable: EmbeddableSetup; | ||
uiActions: UiActionsSetup; | ||
} | ||
|
||
export interface StartDependencies { | ||
embeddable: EmbeddableStart; | ||
uiActions: UiActionsStart; | ||
} | ||
|
||
// eslint-disable-next-line | ||
export interface SetupContract {} | ||
|
||
// eslint-disable-next-line | ||
export interface StartContract {} | ||
|
||
export class EmbeddableEnhancedPlugin | ||
implements Plugin<SetupContract, StartContract, SetupDependencies, StartDependencies> { | ||
constructor(protected readonly context: PluginInitializerContext) {} | ||
|
||
public setup(core: CoreSetup<StartDependencies>, plugins: SetupDependencies): SetupContract { | ||
plugins.embeddable.setCustomEmbeddableFactoryProvider( | ||
< | ||
I extends EmbeddableInput = EmbeddableInput, | ||
O extends EmbeddableOutput = EmbeddableOutput, | ||
E extends IEmbeddable<I, O> = IEmbeddable<I, O>, | ||
T extends SavedObjectAttributes = SavedObjectAttributes | ||
>( | ||
def: EmbeddableFactoryDefinition<I, O, E, T> | ||
): EmbeddableFactory<I, O, E, T> => { | ||
const factory: EmbeddableFactory<I, O, E, T> = defaultEmbeddableFactoryProvider<I, O, E, T>( | ||
def | ||
); | ||
return { | ||
...factory, | ||
create: async (...args) => { | ||
const embeddable = await factory.create(...args); | ||
return embeddable; | ||
}, | ||
createFromSavedObject: async (...args) => { | ||
const embeddable = await factory.createFromSavedObject(...args); | ||
return embeddable; | ||
}, | ||
}; | ||
} | ||
); | ||
|
||
return {}; | ||
} | ||
|
||
public start(core: CoreStart, plugins: StartDependencies): StartContract { | ||
return {}; | ||
} | ||
|
||
public stop() {} | ||
} |