From 35678c18c57da4023d6e4522116c5d44864495bd Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Thu, 29 Dec 2022 13:15:09 +0100 Subject: [PATCH] web/admin: replace more selects with search select Signed-off-by: Jens Langhammer --- .../AuthenticatorDuoStageForm.ts | 69 ++++++++--------- .../AuthenticatorSMSStageForm.ts | 68 ++++++++-------- .../AuthenticatorStaticStageForm.ts | 70 ++++++++--------- .../AuthenticatorTOTPStageForm.ts | 69 ++++++++--------- .../AuthenticateWebAuthnStageForm.ts | 69 ++++++++--------- .../stages/password/PasswordStageForm.ts | 77 ++++++++++--------- 6 files changed, 206 insertions(+), 216 deletions(-) diff --git a/web/src/admin/stages/authenticator_duo/AuthenticatorDuoStageForm.ts b/web/src/admin/stages/authenticator_duo/AuthenticatorDuoStageForm.ts index fd19b8451..9f2d76919 100644 --- a/web/src/admin/stages/authenticator_duo/AuthenticatorDuoStageForm.ts +++ b/web/src/admin/stages/authenticator_duo/AuthenticatorDuoStageForm.ts @@ -1,5 +1,6 @@ import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { first } from "@goauthentik/common/utils"; +import "@goauthentik/elements/SearchSelect"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; @@ -9,13 +10,14 @@ import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; -import { until } from "lit/directives/until.js"; import { AuthenticatorDuoStage, AuthenticatorDuoStageRequest, + Flow, FlowsApi, FlowsInstancesListDesignationEnum, + FlowsInstancesListRequest, StagesApi, } from "@goauthentik/api"; @@ -128,41 +130,36 @@ export class AuthenticatorDuoStageForm extends ModelForm ${t`Stage-specific settings`}
- + => { + const args: FlowsInstancesListRequest = { + ordering: "slug", + designation: + FlowsInstancesListDesignationEnum.StageConfiguration, + }; + if (query !== undefined) { + args.search = query; + } + const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList( + args, + ); + return flows.results; + }} + .renderElement=${(flow: Flow): string => { + return flow.name; + }} + .renderDescription=${(flow: Flow): string => { + return flow.slug; + }} + .value=${(flow: Flow | undefined): string | undefined => { + return flow?.pk; + }} + .selected=${(flow: Flow): boolean => { + return this.instance?.configureFlow === flow.pk; + }} + ?blankable=${true} + > +

${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`}

diff --git a/web/src/admin/stages/authenticator_sms/AuthenticatorSMSStageForm.ts b/web/src/admin/stages/authenticator_sms/AuthenticatorSMSStageForm.ts index 43399a5e6..7c2b86b80 100644 --- a/web/src/admin/stages/authenticator_sms/AuthenticatorSMSStageForm.ts +++ b/web/src/admin/stages/authenticator_sms/AuthenticatorSMSStageForm.ts @@ -1,5 +1,6 @@ import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { first } from "@goauthentik/common/utils"; +import "@goauthentik/elements/SearchSelect"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; @@ -14,8 +15,10 @@ import { until } from "lit/directives/until.js"; import { AuthTypeEnum, AuthenticatorSMSStage, + Flow, FlowsApi, FlowsInstancesListDesignationEnum, + FlowsInstancesListRequest, PropertymappingsApi, ProviderEnum, StagesApi, @@ -258,41 +261,36 @@ export class AuthenticatorSMSStageForm extends ModelForm
- + => { + const args: FlowsInstancesListRequest = { + ordering: "slug", + designation: + FlowsInstancesListDesignationEnum.StageConfiguration, + }; + if (query !== undefined) { + args.search = query; + } + const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList( + args, + ); + return flows.results; + }} + .renderElement=${(flow: Flow): string => { + return flow.name; + }} + .renderDescription=${(flow: Flow): string => { + return flow.slug; + }} + .value=${(flow: Flow | undefined): string | undefined => { + return flow?.pk; + }} + .selected=${(flow: Flow): boolean => { + return this.instance?.configureFlow === flow.pk; + }} + ?blankable=${true} + > +

${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`}

diff --git a/web/src/admin/stages/authenticator_static/AuthenticatorStaticStageForm.ts b/web/src/admin/stages/authenticator_static/AuthenticatorStaticStageForm.ts index 4b60e2783..b766f5362 100644 --- a/web/src/admin/stages/authenticator_static/AuthenticatorStaticStageForm.ts +++ b/web/src/admin/stages/authenticator_static/AuthenticatorStaticStageForm.ts @@ -1,6 +1,6 @@ import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { first } from "@goauthentik/common/utils"; -import "@goauthentik/elements/forms/FormGroup"; +import "@goauthentik/elements/SearchSelect"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; @@ -9,12 +9,13 @@ import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; -import { until } from "lit/directives/until.js"; import { AuthenticatorStaticStage, + Flow, FlowsApi, FlowsInstancesListDesignationEnum, + FlowsInstancesListRequest, StagesApi, } from "@goauthentik/api"; @@ -76,41 +77,36 @@ export class AuthenticatorStaticStageForm extends ModelForm
- + => { + const args: FlowsInstancesListRequest = { + ordering: "slug", + designation: + FlowsInstancesListDesignationEnum.StageConfiguration, + }; + if (query !== undefined) { + args.search = query; + } + const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList( + args, + ); + return flows.results; + }} + .renderElement=${(flow: Flow): string => { + return flow.name; + }} + .renderDescription=${(flow: Flow): string => { + return flow.slug; + }} + .value=${(flow: Flow | undefined): string | undefined => { + return flow?.pk; + }} + .selected=${(flow: Flow): boolean => { + return this.instance?.configureFlow === flow.pk; + }} + ?blankable=${true} + > +

${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`}

diff --git a/web/src/admin/stages/authenticator_totp/AuthenticatorTOTPStageForm.ts b/web/src/admin/stages/authenticator_totp/AuthenticatorTOTPStageForm.ts index 9f5e9a204..d5ea967fc 100644 --- a/web/src/admin/stages/authenticator_totp/AuthenticatorTOTPStageForm.ts +++ b/web/src/admin/stages/authenticator_totp/AuthenticatorTOTPStageForm.ts @@ -1,4 +1,5 @@ import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; +import "@goauthentik/elements/SearchSelect"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; @@ -8,13 +9,14 @@ import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; -import { until } from "lit/directives/until.js"; import { AuthenticatorTOTPStage, DigitsEnum, + Flow, FlowsApi, FlowsInstancesListDesignationEnum, + FlowsInstancesListRequest, StagesApi, } from "@goauthentik/api"; @@ -80,41 +82,36 @@ export class AuthenticatorTOTPStageForm extends ModelForm
- + => { + const args: FlowsInstancesListRequest = { + ordering: "slug", + designation: + FlowsInstancesListDesignationEnum.StageConfiguration, + }; + if (query !== undefined) { + args.search = query; + } + const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList( + args, + ); + return flows.results; + }} + .renderElement=${(flow: Flow): string => { + return flow.name; + }} + .renderDescription=${(flow: Flow): string => { + return flow.slug; + }} + .value=${(flow: Flow | undefined): string | undefined => { + return flow?.pk; + }} + .selected=${(flow: Flow): boolean => { + return this.instance?.configureFlow === flow.pk; + }} + ?blankable=${true} + > +

${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`}

diff --git a/web/src/admin/stages/authenticator_webauthn/AuthenticateWebAuthnStageForm.ts b/web/src/admin/stages/authenticator_webauthn/AuthenticateWebAuthnStageForm.ts index d90177cea..f07dbc849 100644 --- a/web/src/admin/stages/authenticator_webauthn/AuthenticateWebAuthnStageForm.ts +++ b/web/src/admin/stages/authenticator_webauthn/AuthenticateWebAuthnStageForm.ts @@ -1,4 +1,5 @@ import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; +import "@goauthentik/elements/SearchSelect"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; @@ -7,13 +8,14 @@ import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; -import { until } from "lit/directives/until.js"; import { AuthenticateWebAuthnStage, AuthenticatorAttachmentEnum, + Flow, FlowsApi, FlowsInstancesListDesignationEnum, + FlowsInstancesListRequest, ResidentKeyRequirementEnum, StagesApi, UserVerificationEnum, @@ -154,41 +156,36 @@ export class AuthenticateWebAuthnStageForm extends ModelForm
- + => { + const args: FlowsInstancesListRequest = { + ordering: "slug", + designation: + FlowsInstancesListDesignationEnum.StageConfiguration, + }; + if (query !== undefined) { + args.search = query; + } + const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList( + args, + ); + return flows.results; + }} + .renderElement=${(flow: Flow): string => { + return flow.name; + }} + .renderDescription=${(flow: Flow): string => { + return flow.slug; + }} + .value=${(flow: Flow | undefined): string | undefined => { + return flow?.pk; + }} + .selected=${(flow: Flow): boolean => { + return this.instance?.configureFlow === flow.pk; + }} + ?blankable=${true} + > +

${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`}

diff --git a/web/src/admin/stages/password/PasswordStageForm.ts b/web/src/admin/stages/password/PasswordStageForm.ts index e004a0175..d9a1f5917 100644 --- a/web/src/admin/stages/password/PasswordStageForm.ts +++ b/web/src/admin/stages/password/PasswordStageForm.ts @@ -1,5 +1,6 @@ import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { first } from "@goauthentik/common/utils"; +import "@goauthentik/elements/SearchSelect"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; @@ -9,12 +10,13 @@ import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; -import { until } from "lit/directives/until.js"; import { BackendsEnum, + Flow, FlowsApi, FlowsInstancesListDesignationEnum, + FlowsInstancesListRequest, PasswordStage, StagesApi, } from "@goauthentik/api"; @@ -118,41 +120,44 @@ export class PasswordStageForm extends ModelForm { ?required=${true} name="configureFlow" > - + => { + const args: FlowsInstancesListRequest = { + ordering: "slug", + designation: + FlowsInstancesListDesignationEnum.StageConfiguration, + }; + if (query !== undefined) { + args.search = query; + } + const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList( + args, + ); + return flows.results; + }} + .renderElement=${(flow: Flow): string => { + return flow.name; + }} + .renderDescription=${(flow: Flow): string => { + return flow.slug; + }} + .value=${(flow: Flow | undefined): string | undefined => { + return flow?.pk; + }} + .selected=${(flow: Flow): boolean => { + let selected = this.instance?.configureFlow === flow.pk; + if ( + !this.instance?.pk && + !this.instance?.configureFlow && + flow.slug === "default-password-change" + ) { + selected = true; + } + return selected; + }} + ?blankable=${true} + > +

${t`Flow used by an authenticated user to configure their password. If empty, user will not be able to configure change their password.`}