web: only load enterprise summary for user and admin interface (#8414)
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
		| @ -7,7 +7,7 @@ import { | |||||||
| import { configureSentry } from "@goauthentik/common/sentry"; | import { configureSentry } from "@goauthentik/common/sentry"; | ||||||
| import { me } from "@goauthentik/common/users"; | import { me } from "@goauthentik/common/users"; | ||||||
| import { WebsocketClient } from "@goauthentik/common/ws"; | import { WebsocketClient } from "@goauthentik/common/ws"; | ||||||
| import { Interface } from "@goauthentik/elements/Interface"; | import { EnterpriseAwareInterface } from "@goauthentik/elements/Interface"; | ||||||
| import "@goauthentik/elements/ak-locale-context"; | import "@goauthentik/elements/ak-locale-context"; | ||||||
| import "@goauthentik/elements/enterprise/EnterpriseStatusBanner"; | import "@goauthentik/elements/enterprise/EnterpriseStatusBanner"; | ||||||
| import "@goauthentik/elements/messages/MessageContainer"; | import "@goauthentik/elements/messages/MessageContainer"; | ||||||
| @ -33,7 +33,7 @@ import { AdminApi, SessionUser, UiThemeEnum, Version } from "@goauthentik/api"; | |||||||
| import "./AdminSidebar"; | import "./AdminSidebar"; | ||||||
|  |  | ||||||
| @customElement("ak-interface-admin") | @customElement("ak-interface-admin") | ||||||
| export class AdminInterface extends Interface { | export class AdminInterface extends EnterpriseAwareInterface { | ||||||
|     @property({ type: Boolean }) |     @property({ type: Boolean }) | ||||||
|     notificationDrawerOpen = getURLParam("notificationDrawerOpen", false); |     notificationDrawerOpen = getURLParam("notificationDrawerOpen", false); | ||||||
|  |  | ||||||
|  | |||||||
| @ -66,6 +66,29 @@ export class Interface extends AKElement implements AkInterface { | |||||||
|         return this._brand; |         return this._brand; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     constructor() { | ||||||
|  |         super(); | ||||||
|  |         document.adoptedStyleSheets = [...document.adoptedStyleSheets, ensureCSSStyleSheet(PFBase)]; | ||||||
|  |         brand().then((brand) => (this.brand = brand)); | ||||||
|  |         config().then((config) => (this.config = config)); | ||||||
|  |  | ||||||
|  |         this.dataset.akInterfaceRoot = "true"; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     _activateTheme(root: AdoptedStyleSheetsElement, theme: UiThemeEnum): void { | ||||||
|  |         super._activateTheme(root, theme); | ||||||
|  |         super._activateTheme(document, theme); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     async getTheme(): Promise<UiThemeEnum> { | ||||||
|  |         if (!this.uiConfig) { | ||||||
|  |             this.uiConfig = await uiConfig(); | ||||||
|  |         } | ||||||
|  |         return this.uiConfig.theme?.base || UiThemeEnum.Automatic; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | export class EnterpriseAwareInterface extends Interface { | ||||||
|     _licenseSummaryContext = new ContextProvider(this, { |     _licenseSummaryContext = new ContextProvider(this, { | ||||||
|         context: authentikEnterpriseContext, |         context: authentikEnterpriseContext, | ||||||
|         initialValue: undefined, |         initialValue: undefined, | ||||||
| @ -86,25 +109,8 @@ export class Interface extends AKElement implements AkInterface { | |||||||
|  |  | ||||||
|     constructor() { |     constructor() { | ||||||
|         super(); |         super(); | ||||||
|         document.adoptedStyleSheets = [...document.adoptedStyleSheets, ensureCSSStyleSheet(PFBase)]; |  | ||||||
|         brand().then((brand) => (this.brand = brand)); |  | ||||||
|         config().then((config) => (this.config = config)); |  | ||||||
|         new EnterpriseApi(DEFAULT_CONFIG).enterpriseLicenseSummaryRetrieve().then((enterprise) => { |         new EnterpriseApi(DEFAULT_CONFIG).enterpriseLicenseSummaryRetrieve().then((enterprise) => { | ||||||
|             this.licenseSummary = enterprise; |             this.licenseSummary = enterprise; | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|         this.dataset.akInterfaceRoot = "true"; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     _activateTheme(root: AdoptedStyleSheetsElement, theme: UiThemeEnum): void { |  | ||||||
|         super._activateTheme(root, theme); |  | ||||||
|         super._activateTheme(document, theme); |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     async getTheme(): Promise<UiThemeEnum> { |  | ||||||
|         if (!this.uiConfig) { |  | ||||||
|             this.uiConfig = await uiConfig(); |  | ||||||
|         } |  | ||||||
|         return this.uiConfig.theme?.base || UiThemeEnum.Automatic; |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import { Interface } from "./Interface"; | import { EnterpriseAwareInterface, Interface } from "./Interface"; | ||||||
|  |  | ||||||
| export { Interface }; | export { Interface, EnterpriseAwareInterface }; | ||||||
| export default Interface; | export default Interface; | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ import { UserDisplay } from "@goauthentik/common/ui/config"; | |||||||
| import { me } from "@goauthentik/common/users"; | import { me } from "@goauthentik/common/users"; | ||||||
| import { first } from "@goauthentik/common/utils"; | import { first } from "@goauthentik/common/utils"; | ||||||
| import { WebsocketClient } from "@goauthentik/common/ws"; | import { WebsocketClient } from "@goauthentik/common/ws"; | ||||||
| import { Interface } from "@goauthentik/elements/Interface"; | import { EnterpriseAwareInterface } from "@goauthentik/elements/Interface"; | ||||||
| import "@goauthentik/elements/ak-locale-context"; | import "@goauthentik/elements/ak-locale-context"; | ||||||
| import "@goauthentik/elements/buttons/ActionButton"; | import "@goauthentik/elements/buttons/ActionButton"; | ||||||
| import "@goauthentik/elements/enterprise/EnterpriseStatusBanner"; | import "@goauthentik/elements/enterprise/EnterpriseStatusBanner"; | ||||||
| @ -41,7 +41,7 @@ import PFDisplay from "@patternfly/patternfly/utilities/Display/display.css"; | |||||||
| import { CoreApi, EventsApi, SessionUser } from "@goauthentik/api"; | import { CoreApi, EventsApi, SessionUser } from "@goauthentik/api"; | ||||||
|  |  | ||||||
| @customElement("ak-interface-user") | @customElement("ak-interface-user") | ||||||
| export class UserInterface extends Interface { | export class UserInterface extends EnterpriseAwareInterface { | ||||||
|     @property({ type: Boolean }) |     @property({ type: Boolean }) | ||||||
|     notificationDrawerOpen = getURLParam("notificationDrawerOpen", false); |     notificationDrawerOpen = getURLParam("notificationDrawerOpen", false); | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jens L
					Jens L