Skip to content

Commit

Permalink
Add compatibility layer for ApplicationService in legacy platform
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Oct 2, 2019
1 parent bc840e6 commit 7aa1a8b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/legacy/ui/public/new_platform/new_platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
import { IScope } from 'angular';

import { IUiActionsStart, IUiActionsSetup } from 'src/plugins/ui_actions/public';
import { Start as EmbeddableStart, Setup as EmbeddableSetup } from 'src/plugins/embeddable/public';
import { LegacyCoreSetup, LegacyCoreStart } from '../../../../core/public';
import { LegacyCoreSetup, LegacyCoreStart, App } from '../../../../core/public';
import { Plugin as DataPlugin } from '../../../../plugins/data/public';
import { Plugin as ExpressionsPlugin } from '../../../../plugins/expressions/public';
import {
Expand Down Expand Up @@ -68,6 +70,21 @@ export function __reset__() {
export function __setup__(coreSetup: LegacyCoreSetup, plugins: PluginsSetup) {
npSetup.core = coreSetup;
npSetup.plugins = plugins;

// Setup compatibility layer for AppService in legacy platform
npSetup.core.application.register = (app: App) => {
require('ui/chrome').setRootController(app.id, ($scope: IScope, $element: JQLite) => {
const element = $element[0];

// Root controller cannot return a Promise so use an internal async function and call it
(async () => {
const unmount = await app.mount({ core: npStart.core }, { element, appBasePath: '' });
$scope.$on('$destroy', () => {
unmount();
});
})();
});
};
}

export function __start__(coreStart: LegacyCoreStart, plugins: PluginsStart) {
Expand Down

0 comments on commit 7aa1a8b

Please sign in to comment.