-
-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* main: web: move context controllers into reactive controller plugins (#8996) web: maintenance: split tsconfig into “base” and “build” variants. (#9036) web: consistent style declarations internally (#9077)
- Loading branch information
Showing
13 changed files
with
309 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
### 2024-03-26T09:25:06-0700 | ||
|
||
Split the tsconfig file into a base and build variant. | ||
|
||
Lesson: This lesson is stored here and not in a comment in tsconfig.json because | ||
JSON doesn't like comments. Doug Crockford's purity requirement has doomed an | ||
entire generation to keeping its human-facing meta somewhere other than in the | ||
file where it belongs. | ||
|
||
Lesson: The `extend` command of tsconfig has an unexpected behavior. It is | ||
neither a merge or a replace, but some mixture of the two. The buildfile's | ||
`compilerOptions` is not a full replacement; instead, each of _its_ top-level | ||
fields is a replacement for what is found in the basefile. So while you don't | ||
need to include _everything_ in a `compilerOptions` field if you want to change | ||
one thing, if you want to modify _one_ path in `compilerOptions.path`, you must | ||
include the entire `compilerOptions.path` collection in your buildfile. | ||
g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { EVENT_REFRESH } from "@goauthentik/authentik/common/constants"; | ||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; | ||
import { authentikBrandContext } from "@goauthentik/elements/AuthentikContexts"; | ||
|
||
import { ContextProvider } from "@lit/context"; | ||
import { ReactiveController, ReactiveControllerHost } from "lit"; | ||
|
||
import type { CurrentBrand } from "@goauthentik/api"; | ||
import { CoreApi } from "@goauthentik/api"; | ||
|
||
import type { AkInterface } from "./Interface"; | ||
|
||
type ReactiveElementHost = Partial<ReactiveControllerHost> & AkInterface; | ||
|
||
export class BrandContextController implements ReactiveController { | ||
host!: ReactiveElementHost; | ||
|
||
context!: ContextProvider<{ __context__: CurrentBrand | undefined }>; | ||
|
||
constructor(host: ReactiveElementHost) { | ||
this.host = host; | ||
this.context = new ContextProvider(this.host, { | ||
context: authentikBrandContext, | ||
initialValue: undefined, | ||
}); | ||
this.fetch = this.fetch.bind(this); | ||
this.fetch(); | ||
} | ||
|
||
fetch() { | ||
new CoreApi(DEFAULT_CONFIG).coreBrandsCurrentRetrieve().then((brand) => { | ||
this.context.setValue(brand); | ||
this.host.brand = brand; | ||
}); | ||
} | ||
|
||
hostConnected() { | ||
window.addEventListener(EVENT_REFRESH, this.fetch); | ||
} | ||
|
||
hostDisconnected() { | ||
window.removeEventListener(EVENT_REFRESH, this.fetch); | ||
} | ||
|
||
hostUpdate() { | ||
// If the Interface changes its brand information for some reason, | ||
// we should notify all users of the context of that change. doesn't | ||
if (this.host.brand !== this.context.value) { | ||
this.context.setValue(this.host.brand); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { EVENT_REFRESH } from "@goauthentik/authentik/common/constants"; | ||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; | ||
import { authentikConfigContext } from "@goauthentik/elements/AuthentikContexts"; | ||
|
||
import { ContextProvider } from "@lit/context"; | ||
import { ReactiveController, ReactiveControllerHost } from "lit"; | ||
|
||
import type { Config } from "@goauthentik/api"; | ||
import { RootApi } from "@goauthentik/api"; | ||
|
||
import type { AkInterface } from "./Interface"; | ||
|
||
type ReactiveElementHost = Partial<ReactiveControllerHost> & AkInterface; | ||
|
||
export class ConfigContextController implements ReactiveController { | ||
host!: ReactiveElementHost; | ||
|
||
context!: ContextProvider<{ __context__: Config | undefined }>; | ||
|
||
constructor(host: ReactiveElementHost) { | ||
this.host = host; | ||
this.context = new ContextProvider(this.host, { | ||
context: authentikConfigContext, | ||
initialValue: undefined, | ||
}); | ||
this.fetch = this.fetch.bind(this); | ||
this.fetch(); | ||
} | ||
|
||
fetch() { | ||
new RootApi(DEFAULT_CONFIG).rootConfigRetrieve().then((config) => { | ||
this.context.setValue(config); | ||
this.host.config = config; | ||
}); | ||
} | ||
|
||
hostConnected() { | ||
window.addEventListener(EVENT_REFRESH, this.fetch); | ||
} | ||
|
||
hostDisconnected() { | ||
window.removeEventListener(EVENT_REFRESH, this.fetch); | ||
} | ||
|
||
hostUpdate() { | ||
// If the Interface changes its config information, we should notify all | ||
// users of the context of that change, without creating an infinite | ||
// loop of resets. | ||
if (this.host.config !== this.context.value) { | ||
this.context.setValue(this.host.config); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { EVENT_REFRESH_ENTERPRISE } from "@goauthentik/authentik/common/constants"; | ||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; | ||
import { authentikEnterpriseContext } from "@goauthentik/elements/AuthentikContexts"; | ||
|
||
import { ContextProvider } from "@lit/context"; | ||
import { ReactiveController, ReactiveControllerHost } from "lit"; | ||
|
||
import type { LicenseSummary } from "@goauthentik/api"; | ||
import { EnterpriseApi } from "@goauthentik/api"; | ||
|
||
import type { AkEnterpriseInterface } from "./Interface"; | ||
|
||
type ReactiveElementHost = Partial<ReactiveControllerHost> & AkEnterpriseInterface; | ||
|
||
export class EnterpriseContextController implements ReactiveController { | ||
host!: ReactiveElementHost; | ||
|
||
context!: ContextProvider<{ __context__: LicenseSummary | undefined }>; | ||
|
||
constructor(host: ReactiveElementHost) { | ||
this.host = host; | ||
this.context = new ContextProvider(this.host, { | ||
context: authentikEnterpriseContext, | ||
initialValue: undefined, | ||
}); | ||
this.fetch = this.fetch.bind(this); | ||
this.fetch(); | ||
} | ||
|
||
fetch() { | ||
new EnterpriseApi(DEFAULT_CONFIG).enterpriseLicenseSummaryRetrieve().then((enterprise) => { | ||
this.context.setValue(enterprise); | ||
this.host.licenseSummary = enterprise; | ||
}); | ||
} | ||
|
||
hostConnected() { | ||
window.addEventListener(EVENT_REFRESH_ENTERPRISE, this.fetch); | ||
} | ||
|
||
hostDisconnected() { | ||
window.removeEventListener(EVENT_REFRESH_ENTERPRISE, this.fetch); | ||
} | ||
|
||
hostUpdate() { | ||
// If the Interface changes its config information, we should notify all | ||
// users of the context of that change, without creating an infinite | ||
// loop of resets. | ||
if (this.host.licenseSummary !== this.context.value) { | ||
this.context.setValue(this.host.licenseSummary); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.