initialize controllers only when it makes sense

This commit is contained in:
Jacob Overgaard
2024-04-04 16:02:35 +02:00
parent 2fe52cd500
commit 184e498bc2
2 changed files with 10 additions and 9 deletions

View File

@@ -20,6 +20,13 @@ import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registr
@customElement('umb-app')
export class UmbAppElement extends UmbLitElement {
/**
* Backoffice extension registry.
* This enables to register and unregister extensions via DevTools, or just via querying this element via the DOM.
* @type {UmbExtensionsRegistry}
*/
public extensionRegistry = umbExtensionsRegistry;
/**
* The base URL of the configured Umbraco server.
*
@@ -69,7 +76,7 @@ export class UmbAppElement extends UmbLitElement {
#umbIconRegistry = new UmbIconRegistry();
#uuiIconRegistry = new UUIIconRegistryEssential();
#serverConnection?: UmbServerConnection;
#authController = new UmbAppAuthController(this);
#authController?: UmbAppAuthController;
constructor() {
super();
@@ -91,6 +98,7 @@ export class UmbAppElement extends UmbLitElement {
}
async #setup() {
this.#authController = new UmbAppAuthController(this);
this.#serverConnection = await new UmbServerConnection(this.serverUrl).connect();
this.#authContext = new UmbAuthContext(this, this.serverUrl, this.backofficePath, this.bypassAuth);
@@ -191,7 +199,7 @@ export class UmbAppElement extends UmbLitElement {
}
#isAuthorizedGuard(): Guard {
return () => this.#authController.isAuthorized();
return () => this.#authController?.isAuthorized() ?? false;
}
#errorPage(errorMsg: string, error?: unknown) {

View File

@@ -38,13 +38,6 @@ const CORE_PACKAGES = [
@customElement('umb-backoffice')
export class UmbBackofficeElement extends UmbLitElement {
/**
* Backoffice extension registry.
* This enables to register and unregister extensions via DevTools, or just via querying this element via the DOM.
* @type {UmbExtensionsRegistry}
*/
public extensionRegistry = umbExtensionsRegistry;
constructor() {
super();