Skip to content

Commit

Permalink
use legacy helper in our own legacy TM obviously
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmorris committed Jan 8, 2020
1 parent a2cce60 commit 39b6857
Showing 1 changed file with 20 additions and 27 deletions.
47 changes: 20 additions & 27 deletions x-pack/legacy/plugins/task_manager/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import { Root } from 'joi';
import { Legacy } from 'kibana';
import mappings from './mappings.json';
import { migrations } from './migrations';
import { TaskManagerSetupContract } from '../../../../plugins/task_manager/server';

import { createLegacyApi } from './legacy';
import { createLegacyApi, getTaskManagerSetup } from './legacy';
export { LegacyTaskManagerApi, getTaskManagerSetup, getTaskManagerStart } from './legacy';

// Once all plugins are migrated to NP, this can be removed
Expand Down Expand Up @@ -43,35 +42,29 @@ export function taskManager(kibana: any) {
}).default();
},
init(server: Legacy.Server) {
const {
newPlatform: {
setup: {
plugins: { taskManager: taskManagerPluginApi },
},
},
} = server;

const legacyTaskManager = (taskManagerPluginApi as TaskManagerSetupContract)
.registerLegacyAPI({
savedObjectSchemas,
})
.then((taskManagerPlugin: TaskManager) => {
// we can't tell the Kibana Platform Task Manager plugin to
// to wait to `start` as that happens before legacy plugins
// instead we will start the internal Task Manager plugin when
// all legacy plugins have finished initializing
// Once all plugins are migrated to NP, this can be removed
this.kbnServer.afterPluginsInit(() => {
taskManagerPlugin.start();
});
return taskManagerPlugin;
});

/*
* We must expose the New Platform Task Manager Plugin via the legacy Api
* as removing it now would be a breaking change - we'll remove this in v8.0.0
*/
server.expose(createLegacyApi(legacyTaskManager));
server.expose(
createLegacyApi(
getTaskManagerSetup(server)!
.registerLegacyAPI({
savedObjectSchemas,
})
.then((taskManagerPlugin: TaskManager) => {
// we can't tell the Kibana Platform Task Manager plugin to
// to wait to `start` as that happens before legacy plugins
// instead we will start the internal Task Manager plugin when
// all legacy plugins have finished initializing
// Once all plugins are migrated to NP, this can be removed
this.kbnServer.afterPluginsInit(() => {
taskManagerPlugin.start();
});
return taskManagerPlugin;
})
)
);
},
uiExports: {
mappings,
Expand Down

0 comments on commit 39b6857

Please sign in to comment.