From 6a6017437127d3efef8477447f3a481bb38e1953 Mon Sep 17 00:00:00 2001 From: Ken Sternberg Date: Sun, 30 Jul 2023 06:44:40 -0700 Subject: [PATCH] Broke out the text input into a single renderer. Still works as required. --- web/src/admin/applications/ApplicationForm.ts | 197 ++++++++---------- web/src/admin/applications/renderers.ts | 35 ++++ 2 files changed, 117 insertions(+), 115 deletions(-) create mode 100644 web/src/admin/applications/renderers.ts diff --git a/web/src/admin/applications/ApplicationForm.ts b/web/src/admin/applications/ApplicationForm.ts index b9688590a..9a8f3e8ce 100644 --- a/web/src/admin/applications/ApplicationForm.ts +++ b/web/src/admin/applications/ApplicationForm.ts @@ -26,6 +26,8 @@ import { ProvidersApi, } from "@goauthentik/api"; +import { akText } from "./renderers"; + @customElement("ak-application-form") export class ApplicationForm extends ModelForm { async loadInstance(pk: string): Promise { @@ -90,70 +92,28 @@ export class ApplicationForm extends ModelForm { renderForm(): TemplateResult { return html`
- - -

${msg("Application's display Name.")}

-
- - -

- ${msg("Internal application name, used in URLs.")} -

-
- - -

- ${msg( - "Optionally enter a group name. Applications with identical groups are shown grouped together.", - )} -

-
- - => { - const args: ProvidersAllListRequest = { - ordering: "name", - }; - if (query !== undefined) { - args.search = query; - } - const items = await new ProvidersApi(DEFAULT_CONFIG).providersAllList(args); - return items.results; - }} - .renderElement=${(item: Provider): string => { - return item.name; - }} - .value=${(item: Provider | undefined): number | undefined => { - return item?.pk; - }} - .groupBy=${(items: Provider[]) => { - return groupBy(items, (item) => item.verboseName); - }} - .selected=${(item: Provider): boolean => { - return this.instance?.provider === item.pk; - }} - ?blankable=${true} - > - -

- ${msg("Select a provider that this application should use.")} -

-
- + ${akText({ + name: "name", + value: this.instance?.name, + label: msg("Name"), + required: true, + help: msg("Application's display Name."), + })} + ${akText({ + name: "slug", + value: this.instance?.slug, + label: msg("Slug"), + required: true, + help: msg("Internal application name, used in URLs."), + })} + ${akText({ + name: "group", + value: this.instance?.group, + label: msg("Group"), + help: msg( + "Optionally enter a group name. Applications with identical groups are shown grouped together." + ), + })} {

${msg( - "Select backchannel providers which augment the functionality of the main provider.", + "Select backchannel providers which augment the functionality of the main provider." )}

@@ -230,7 +190,7 @@ export class ApplicationForm extends ModelForm { />

${msg( - "If left empty, authentik will try to extract the launch URL based on the selected provider.", + "If left empty, authentik will try to extract the launch URL based on the selected provider." )}

@@ -250,61 +210,68 @@ export class ApplicationForm extends ModelForm {

${msg( - "If checked, the launch URL will open in a new browser tab or window from the user's application library.", + "If checked, the launch URL will open in a new browser tab or window from the user's application library." )}

- ${rootInterface()?.config?.capabilities.includes(CapabilitiesEnum.CanSaveMedia) - ? html` - + ${ + rootInterface()?.config?.capabilities.includes( + CapabilitiesEnum.CanSaveMedia + ) + ? html` + + ${this.instance?.metaIcon + ? html` +

+ ${msg("Currently set to:")} + ${this.instance?.metaIcon} +

+ ` + : html``} +
${this.instance?.metaIcon ? html` -

- ${msg("Currently set to:")} - ${this.instance?.metaIcon} -

- ` - : html``} -
- ${this.instance?.metaIcon - ? html` - - -

- ${msg("Delete currently set icon.")} -

-
- ` - : html``}` - : html` - -

${iconHelperText}

-
`} + + ${msg("Clear icon")} + + +

+ ${msg("Delete currently set icon.")} +

+ + ` + : html``}` + : html` + +

${iconHelperText}

+
` + } + +

${help}

+
`; +}