Skip to content

Commit

Permalink
web: only load enterprise summary for user and admin interface
Browse files Browse the repository at this point in the history
Signed-off-by: Jens Langhammer <jens@goauthentik.io>
  • Loading branch information
BeryJu committed Feb 5, 2024
1 parent 961d283 commit f44d811
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
4 changes: 2 additions & 2 deletions web/src/admin/AdminInterface/AdminInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { configureSentry } from "@goauthentik/common/sentry";
import { me } from "@goauthentik/common/users";
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/enterprise/EnterpriseStatusBanner";
import "@goauthentik/elements/messages/MessageContainer";
Expand All @@ -33,7 +33,7 @@ import { AdminApi, SessionUser, UiThemeEnum, Version } from "@goauthentik/api";
import "./AdminSidebar";

@customElement("ak-interface-admin")
export class AdminInterface extends Interface {
export class AdminInterface extends EnterpriseAwareInterface {
@property({ type: Boolean })
notificationDrawerOpen = getURLParam("notificationDrawerOpen", false);

Expand Down
40 changes: 23 additions & 17 deletions web/src/elements/Interface/Interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,29 @@ export class Interface extends AKElement implements AkInterface {
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, {
context: authentikEnterpriseContext,
initialValue: undefined,
Expand All @@ -86,25 +109,8 @@ export class Interface extends AKElement implements AkInterface {

constructor() {
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) => {
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;
}
}
4 changes: 2 additions & 2 deletions web/src/elements/Interface/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Interface } from "./Interface";
import { EnterpriseAwareInterface, Interface } from "./Interface";

export { Interface };
export { Interface, EnterpriseAwareInterface };
export default Interface;
4 changes: 2 additions & 2 deletions web/src/user/UserInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { UserDisplay } from "@goauthentik/common/ui/config";
import { me } from "@goauthentik/common/users";
import { first } from "@goauthentik/common/utils";
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/buttons/ActionButton";
import "@goauthentik/elements/enterprise/EnterpriseStatusBanner";
Expand Down Expand Up @@ -41,7 +41,7 @@ import PFDisplay from "@patternfly/patternfly/utilities/Display/display.css";
import { CoreApi, EventsApi, SessionUser } from "@goauthentik/api";

@customElement("ak-interface-user")
export class UserInterface extends Interface {
export class UserInterface extends EnterpriseAwareInterface {
@property({ type: Boolean })
notificationDrawerOpen = getURLParam("notificationDrawerOpen", false);

Expand Down

0 comments on commit f44d811

Please sign in to comment.