-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce UI PluginsService #32672
Introduce UI PluginsService #32672
Changes from 17 commits
a150c40
3377535
77aaedd
7595508
34b4660
eaa918f
8e4e696
63a8752
8a589da
39b82e4
ef41559
8af9f6a
92f9cc5
387c485
e31d95f
b43be68
7c623c3
a2bf27d
7536c1f
01903d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,9 @@ | |
|
||
import './core.css'; | ||
|
||
import { Subject } from 'rxjs'; | ||
|
||
import { CoreSetup } from '.'; | ||
import { BasePathService } from './base_path'; | ||
import { ChromeService } from './chrome'; | ||
import { FatalErrorsService } from './fatal_errors'; | ||
|
@@ -27,6 +30,7 @@ import { I18nService } from './i18n'; | |
import { InjectedMetadataParams, InjectedMetadataService } from './injected_metadata'; | ||
import { LegacyPlatformParams, LegacyPlatformService } from './legacy'; | ||
import { NotificationsService } from './notifications'; | ||
import { PluginsService } from './plugins'; | ||
import { UiSettingsService } from './ui_settings'; | ||
|
||
interface Params { | ||
|
@@ -37,6 +41,10 @@ interface Params { | |
useLegacyTestHarness?: LegacyPlatformParams['useLegacyTestHarness']; | ||
} | ||
|
||
/** @internal */ | ||
// tslint:disable-next-line no-empty-interface | ||
export interface CoreContext {} | ||
|
||
/** | ||
* The CoreSystem is the root of the new platform, and setups all parts | ||
* of Kibana in the UI, including the LegacyPlatform which is managed | ||
|
@@ -55,9 +63,10 @@ export class CoreSystem { | |
private readonly basePath: BasePathService; | ||
private readonly chrome: ChromeService; | ||
private readonly i18n: I18nService; | ||
private readonly plugins: PluginsService; | ||
|
||
private readonly rootDomElement: HTMLElement; | ||
private readonly notificationsTargetDomElement: HTMLDivElement; | ||
private readonly notificationsTargetDomElement$: Subject<HTMLDivElement>; | ||
private readonly legacyPlatformTargetDomElement: HTMLDivElement; | ||
|
||
constructor(params: Params) { | ||
|
@@ -85,15 +94,18 @@ export class CoreSystem { | |
}, | ||
}); | ||
|
||
this.notificationsTargetDomElement = document.createElement('div'); | ||
this.notificationsTargetDomElement$ = new Subject(); | ||
this.notifications = new NotificationsService({ | ||
targetDomElement: this.notificationsTargetDomElement, | ||
targetDomElement$: this.notificationsTargetDomElement$.asObservable(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why make this change in this PR? It seems unrelated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now that |
||
}); | ||
this.http = new HttpService(); | ||
this.basePath = new BasePathService(); | ||
this.uiSettings = new UiSettingsService(); | ||
this.chrome = new ChromeService({ browserSupportsCsp }); | ||
|
||
const core: CoreContext = {}; | ||
this.plugins = new PluginsService(core); | ||
|
||
this.legacyPlatformTargetDomElement = document.createElement('div'); | ||
this.legacyPlatform = new LegacyPlatformService({ | ||
targetDomElement: this.legacyPlatformTargetDomElement, | ||
|
@@ -102,14 +114,8 @@ export class CoreSystem { | |
}); | ||
} | ||
|
||
public setup() { | ||
public async setup() { | ||
try { | ||
// ensure the rootDomElement is empty | ||
this.rootDomElement.textContent = ''; | ||
this.rootDomElement.classList.add('coreSystemRootDomElement'); | ||
this.rootDomElement.appendChild(this.notificationsTargetDomElement); | ||
this.rootDomElement.appendChild(this.legacyPlatformTargetDomElement); | ||
|
||
const i18n = this.i18n.setup(); | ||
const notifications = this.notifications.setup({ i18n }); | ||
const injectedMetadata = this.injectedMetadata.setup(); | ||
|
@@ -127,16 +133,32 @@ export class CoreSystem { | |
notifications, | ||
}); | ||
|
||
this.legacyPlatform.setup({ | ||
const core: CoreSetup = { | ||
basePath, | ||
chrome, | ||
fatalErrors, | ||
http, | ||
i18n, | ||
injectedMetadata, | ||
fatalErrors, | ||
notifications, | ||
http, | ||
basePath, | ||
uiSettings, | ||
chrome, | ||
}); | ||
}; | ||
|
||
await this.plugins.setup(core); | ||
joshdover marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// ensure the rootDomElement is empty | ||
this.rootDomElement.textContent = ''; | ||
this.rootDomElement.classList.add('coreSystemRootDomElement'); | ||
|
||
const notificationsTargetDomElement = document.createElement('div'); | ||
this.rootDomElement.appendChild(notificationsTargetDomElement); | ||
this.rootDomElement.appendChild(this.legacyPlatformTargetDomElement); | ||
|
||
// Only provide the DOM element to notifications once it's attached to the page. | ||
// This prevents notifications from timing out before being displayed. | ||
this.notificationsTargetDomElement$.next(notificationsTargetDomElement); | ||
|
||
this.legacyPlatform.setup(core); | ||
|
||
return { fatalErrors }; | ||
} catch (error) { | ||
|
@@ -146,6 +168,7 @@ export class CoreSystem { | |
|
||
public stop() { | ||
this.legacyPlatform.stop(); | ||
this.plugins.stop(); | ||
this.notifications.stop(); | ||
this.http.stop(); | ||
this.uiSettings.stop(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: I’d remove this assertion, correctness of arguments is checked by TS compiler