web: only load version context when authenticated (#12482)
* only add version context for authz interface Signed-off-by: Jens Langhammer <jens@goauthentik.io> * rename enterprise aware interface Signed-off-by: Jens Langhammer <jens@goauthentik.io> * dont log startup error Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -9,14 +9,14 @@ import type { ReactiveController } from "lit";
|
||||
import type { LicenseSummary } from "@goauthentik/api";
|
||||
import { EnterpriseApi } from "@goauthentik/api";
|
||||
|
||||
import type { AkEnterpriseInterface } from "./Interface";
|
||||
import type { AkAuthenticatedInterface } from "./Interface";
|
||||
|
||||
export class EnterpriseContextController implements ReactiveController {
|
||||
host!: ReactiveElementHost<AkEnterpriseInterface>;
|
||||
host!: ReactiveElementHost<AkAuthenticatedInterface>;
|
||||
|
||||
context!: ContextProvider<{ __context__: LicenseSummary | undefined }>;
|
||||
|
||||
constructor(host: ReactiveElementHost<AkEnterpriseInterface>) {
|
||||
constructor(host: ReactiveElementHost<AkAuthenticatedInterface>) {
|
||||
this.host = host;
|
||||
this.context = new ContextProvider(this.host, {
|
||||
context: authentikEnterpriseContext,
|
||||
|
||||
@ -20,7 +20,6 @@ export type AkInterface = HTMLElement & {
|
||||
brand?: CurrentBrand;
|
||||
uiConfig?: UIConfig;
|
||||
config?: Config;
|
||||
version?: Version;
|
||||
};
|
||||
|
||||
const brandContext = Symbol("brandContext");
|
||||
@ -29,16 +28,14 @@ const modalController = Symbol("modalController");
|
||||
const versionContext = Symbol("versionContext");
|
||||
|
||||
export class Interface extends AKElement implements AkInterface {
|
||||
@state()
|
||||
uiConfig?: UIConfig;
|
||||
|
||||
[brandContext]!: BrandContextController;
|
||||
|
||||
[configContext]!: ConfigContextController;
|
||||
|
||||
[modalController]!: ModalOrchestrationController;
|
||||
|
||||
[versionContext]!: VersionContextController;
|
||||
@state()
|
||||
uiConfig?: UIConfig;
|
||||
|
||||
@state()
|
||||
config?: Config;
|
||||
@ -57,7 +54,6 @@ export class Interface extends AKElement implements AkInterface {
|
||||
this[brandContext] = new BrandContextController(this);
|
||||
this[configContext] = new ConfigContextController(this);
|
||||
this[modalController] = new ModalOrchestrationController(this);
|
||||
this[versionContext] = new VersionContextController(this);
|
||||
}
|
||||
|
||||
_activateTheme(theme: UiThemeEnum, ...roots: DocumentOrShadowRoot[]): void {
|
||||
@ -83,20 +79,30 @@ export class Interface extends AKElement implements AkInterface {
|
||||
}
|
||||
}
|
||||
|
||||
export type AkEnterpriseInterface = AkInterface & {
|
||||
export type AkAuthenticatedInterface = AkInterface & {
|
||||
licenseSummary?: LicenseSummary;
|
||||
version?: Version;
|
||||
};
|
||||
|
||||
const enterpriseContext = Symbol("enterpriseContext");
|
||||
|
||||
export class EnterpriseAwareInterface extends Interface {
|
||||
export class AuthenticatedInterface extends Interface {
|
||||
[enterpriseContext]!: EnterpriseContextController;
|
||||
[versionContext]!: VersionContextController;
|
||||
|
||||
@state()
|
||||
licenseSummary?: LicenseSummary;
|
||||
|
||||
@state()
|
||||
version?: Version;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
_initContexts(): void {
|
||||
super._initContexts();
|
||||
this[enterpriseContext] = new EnterpriseContextController(this);
|
||||
this[versionContext] = new VersionContextController(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,14 +9,14 @@ import type { ReactiveController } from "lit";
|
||||
import type { Version } from "@goauthentik/api";
|
||||
import { AdminApi } from "@goauthentik/api";
|
||||
|
||||
import type { AkInterface } from "./Interface";
|
||||
import type { AkAuthenticatedInterface } from "./Interface";
|
||||
|
||||
export class VersionContextController implements ReactiveController {
|
||||
host!: ReactiveElementHost<AkInterface>;
|
||||
host!: ReactiveElementHost<AkAuthenticatedInterface>;
|
||||
|
||||
context!: ContextProvider<{ __context__: Version | undefined }>;
|
||||
|
||||
constructor(host: ReactiveElementHost<AkInterface>) {
|
||||
constructor(host: ReactiveElementHost<AkAuthenticatedInterface>) {
|
||||
this.host = host;
|
||||
this.context = new ContextProvider(this.host, {
|
||||
context: authentikVersionContext,
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { EnterpriseAwareInterface, Interface } from "./Interface";
|
||||
import { AuthenticatedInterface, Interface } from "./Interface";
|
||||
|
||||
export { Interface, EnterpriseAwareInterface };
|
||||
export { Interface, AuthenticatedInterface };
|
||||
export default Interface;
|
||||
|
||||
Reference in New Issue
Block a user