web: Detangling some circular dependencies in Admin and User (#6852)
* Web: Detangling some circular dependencies in Admin and User Admin, User, and Flow should not dependend upon each other, at least not in a circular way. If Admin and User depend on Flow, that's fine, but Flow should not correspondingly depend upon elements of either; if they have something in common, let's put them in `@goauthentik/common` or find some other smart place to store them. This commit refactors the intentToLabel and actionToLabel functions into `@goauthentik/common/labels` and converts them to static tables for maintenance purposes. * web: "Consistency is the hobgoblin of small minds" - Ralph Waldo Emerson * web: I found these confusing to look at, so I added comments. * web: remove admin-to-user component reference(s) (#6856) There was only one: AppIcon. This has been moved to `components`. Touching the LibraryApplications page triggered a cyclomatic complexity check. Extracting the expansion block and streamlining the class and style declarations with lit directives helped.
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import "@goauthentik/admin/tokens/TokenForm";
|
||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||
import { intentToLabel } from "@goauthentik/common/labels";
|
||||
import { uiConfig } from "@goauthentik/common/ui/config";
|
||||
import { PFColor } from "@goauthentik/elements/Label";
|
||||
import "@goauthentik/elements/buttons/Dropdown";
|
||||
@ -17,21 +18,6 @@ import { customElement, property } from "lit/decorators.js";
|
||||
|
||||
import { CoreApi, IntentEnum, Token } from "@goauthentik/api";
|
||||
|
||||
export function IntentToLabel(intent: IntentEnum): string {
|
||||
switch (intent) {
|
||||
case IntentEnum.Api:
|
||||
return msg("API Access");
|
||||
case IntentEnum.AppPassword:
|
||||
return msg("App password");
|
||||
case IntentEnum.Recovery:
|
||||
return msg("Recovery");
|
||||
case IntentEnum.Verification:
|
||||
return msg("Verification");
|
||||
case IntentEnum.UnknownDefaultOpenApi:
|
||||
return msg("Unknown intent");
|
||||
}
|
||||
}
|
||||
|
||||
@customElement("ak-token-list")
|
||||
export class TokenListPage extends TablePage<Token> {
|
||||
searchEnabled(): boolean {
|
||||
@ -121,7 +107,7 @@ export class TokenListPage extends TablePage<Token> {
|
||||
${item.expiring ? msg("Yes") : msg("No")}
|
||||
</ak-label>`,
|
||||
html`${item.expiring ? item.expires?.toLocaleString() : msg("-")}`,
|
||||
html`${IntentToLabel(item.intent || IntentEnum.Api)}`,
|
||||
html`${intentToLabel(item.intent ?? IntentEnum.Api)}`,
|
||||
html`
|
||||
${!item.managed
|
||||
? html`<ak-forms-modal>
|
||||
|
Reference in New Issue
Block a user