web/admin: replace more selects with search select

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-12-29 13:15:09 +01:00
parent 5fba08c911
commit 35678c18c5
No known key found for this signature in database
6 changed files with 206 additions and 216 deletions

View File

@ -1,5 +1,6 @@
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import { first } from "@goauthentik/common/utils"; import { first } from "@goauthentik/common/utils";
import "@goauthentik/elements/SearchSelect";
import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/FormGroup";
import "@goauthentik/elements/forms/HorizontalFormElement"; import "@goauthentik/elements/forms/HorizontalFormElement";
import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
@ -9,13 +10,14 @@ import { t } from "@lingui/macro";
import { TemplateResult, html } from "lit"; import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators.js"; import { customElement } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js"; import { ifDefined } from "lit/directives/if-defined.js";
import { until } from "lit/directives/until.js";
import { import {
AuthenticatorDuoStage, AuthenticatorDuoStage,
AuthenticatorDuoStageRequest, AuthenticatorDuoStageRequest,
Flow,
FlowsApi, FlowsApi,
FlowsInstancesListDesignationEnum, FlowsInstancesListDesignationEnum,
FlowsInstancesListRequest,
StagesApi, StagesApi,
} from "@goauthentik/api"; } from "@goauthentik/api";
@ -128,41 +130,36 @@ export class AuthenticatorDuoStageForm extends ModelForm<AuthenticatorDuoStage,
<span slot="header"> ${t`Stage-specific settings`} </span> <span slot="header"> ${t`Stage-specific settings`} </span>
<div slot="body" class="pf-c-form"> <div slot="body" class="pf-c-form">
<ak-form-element-horizontal label=${t`Configuration flow`} name="configureFlow"> <ak-form-element-horizontal label=${t`Configuration flow`} name="configureFlow">
<select class="pf-c-form-control"> <ak-search-select
<option .fetchObjects=${async (query?: string): Promise<Flow[]> => {
value="" const args: FlowsInstancesListRequest = {
?selected=${this.instance?.configureFlow === undefined} ordering: "slug",
> designation:
--------- FlowsInstancesListDesignationEnum.StageConfiguration,
</option> };
${until( if (query !== undefined) {
new FlowsApi(DEFAULT_CONFIG) args.search = query;
.flowsInstancesList({ }
ordering: "slug", const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList(
designation: args,
FlowsInstancesListDesignationEnum.StageConfiguration, );
}) return flows.results;
.then((flows) => { }}
return flows.results.map((flow) => { .renderElement=${(flow: Flow): string => {
let selected = this.instance?.configureFlow === flow.pk; return flow.name;
if ( }}
!this.instance?.pk && .renderDescription=${(flow: Flow): string => {
!this.instance?.configureFlow && return flow.slug;
flow.slug === "default-otp-time-configure" }}
) { .value=${(flow: Flow | undefined): string | undefined => {
selected = true; return flow?.pk;
} }}
return html`<option .selected=${(flow: Flow): boolean => {
value=${ifDefined(flow.pk)} return this.instance?.configureFlow === flow.pk;
?selected=${selected} }}
> ?blankable=${true}
${flow.name} (${flow.slug}) >
</option>`; </ak-search-select>
});
}),
html`<option>${t`Loading...`}</option>`,
)}
</select>
<p class="pf-c-form__helper-text"> <p class="pf-c-form__helper-text">
${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`} ${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`}
</p> </p>

View File

@ -1,5 +1,6 @@
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import { first } from "@goauthentik/common/utils"; import { first } from "@goauthentik/common/utils";
import "@goauthentik/elements/SearchSelect";
import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/FormGroup";
import "@goauthentik/elements/forms/HorizontalFormElement"; import "@goauthentik/elements/forms/HorizontalFormElement";
import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
@ -14,8 +15,10 @@ import { until } from "lit/directives/until.js";
import { import {
AuthTypeEnum, AuthTypeEnum,
AuthenticatorSMSStage, AuthenticatorSMSStage,
Flow,
FlowsApi, FlowsApi,
FlowsInstancesListDesignationEnum, FlowsInstancesListDesignationEnum,
FlowsInstancesListRequest,
PropertymappingsApi, PropertymappingsApi,
ProviderEnum, ProviderEnum,
StagesApi, StagesApi,
@ -258,41 +261,36 @@ export class AuthenticatorSMSStageForm extends ModelForm<AuthenticatorSMSStage,
</p> </p>
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal label=${t`Configuration flow`} name="configureFlow"> <ak-form-element-horizontal label=${t`Configuration flow`} name="configureFlow">
<select class="pf-c-form-control"> <ak-search-select
<option .fetchObjects=${async (query?: string): Promise<Flow[]> => {
value="" const args: FlowsInstancesListRequest = {
?selected=${this.instance?.configureFlow === undefined} ordering: "slug",
> designation:
--------- FlowsInstancesListDesignationEnum.StageConfiguration,
</option> };
${until( if (query !== undefined) {
new FlowsApi(DEFAULT_CONFIG) args.search = query;
.flowsInstancesList({ }
ordering: "slug", const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList(
designation: args,
FlowsInstancesListDesignationEnum.StageConfiguration, );
}) return flows.results;
.then((flows) => { }}
return flows.results.map((flow) => { .renderElement=${(flow: Flow): string => {
let selected = this.instance?.configureFlow === flow.pk; return flow.name;
if ( }}
!this.instance?.pk && .renderDescription=${(flow: Flow): string => {
!this.instance?.configureFlow && return flow.slug;
flow.slug === "default-otp-time-configure" }}
) { .value=${(flow: Flow | undefined): string | undefined => {
selected = true; return flow?.pk;
} }}
return html`<option .selected=${(flow: Flow): boolean => {
value=${ifDefined(flow.pk)} return this.instance?.configureFlow === flow.pk;
?selected=${selected} }}
> ?blankable=${true}
${flow.name} (${flow.slug}) >
</option>`; </ak-search-select>
});
}),
html`<option>${t`Loading...`}</option>`,
)}
</select>
<p class="pf-c-form__helper-text"> <p class="pf-c-form__helper-text">
${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`} ${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`}
</p> </p>

View File

@ -1,6 +1,6 @@
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import { first } from "@goauthentik/common/utils"; import { first } from "@goauthentik/common/utils";
import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/SearchSelect";
import "@goauthentik/elements/forms/HorizontalFormElement"; import "@goauthentik/elements/forms/HorizontalFormElement";
import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
@ -9,12 +9,13 @@ import { t } from "@lingui/macro";
import { TemplateResult, html } from "lit"; import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators.js"; import { customElement } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js"; import { ifDefined } from "lit/directives/if-defined.js";
import { until } from "lit/directives/until.js";
import { import {
AuthenticatorStaticStage, AuthenticatorStaticStage,
Flow,
FlowsApi, FlowsApi,
FlowsInstancesListDesignationEnum, FlowsInstancesListDesignationEnum,
FlowsInstancesListRequest,
StagesApi, StagesApi,
} from "@goauthentik/api"; } from "@goauthentik/api";
@ -76,41 +77,36 @@ export class AuthenticatorStaticStageForm extends ModelForm<AuthenticatorStaticS
/> />
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal label=${t`Configuration flow`} name="configureFlow"> <ak-form-element-horizontal label=${t`Configuration flow`} name="configureFlow">
<select class="pf-c-form-control"> <ak-search-select
<option .fetchObjects=${async (query?: string): Promise<Flow[]> => {
value="" const args: FlowsInstancesListRequest = {
?selected=${this.instance?.configureFlow === undefined} ordering: "slug",
> designation:
--------- FlowsInstancesListDesignationEnum.StageConfiguration,
</option> };
${until( if (query !== undefined) {
new FlowsApi(DEFAULT_CONFIG) args.search = query;
.flowsInstancesList({ }
ordering: "slug", const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList(
designation: args,
FlowsInstancesListDesignationEnum.StageConfiguration, );
}) return flows.results;
.then((flows) => { }}
return flows.results.map((flow) => { .renderElement=${(flow: Flow): string => {
let selected = this.instance?.configureFlow === flow.pk; return flow.name;
if ( }}
!this.instance?.pk && .renderDescription=${(flow: Flow): string => {
!this.instance?.configureFlow && return flow.slug;
flow.slug === "default-otp-time-configure" }}
) { .value=${(flow: Flow | undefined): string | undefined => {
selected = true; return flow?.pk;
} }}
return html`<option .selected=${(flow: Flow): boolean => {
value=${ifDefined(flow.pk)} return this.instance?.configureFlow === flow.pk;
?selected=${selected} }}
> ?blankable=${true}
${flow.name} (${flow.slug}) >
</option>`; </ak-search-select>
});
}),
html`<option>${t`Loading...`}</option>`,
)}
</select>
<p class="pf-c-form__helper-text"> <p class="pf-c-form__helper-text">
${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`} ${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`}
</p> </p>

View File

@ -1,4 +1,5 @@
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import "@goauthentik/elements/SearchSelect";
import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/FormGroup";
import "@goauthentik/elements/forms/HorizontalFormElement"; import "@goauthentik/elements/forms/HorizontalFormElement";
import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
@ -8,13 +9,14 @@ import { t } from "@lingui/macro";
import { TemplateResult, html } from "lit"; import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators.js"; import { customElement } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js"; import { ifDefined } from "lit/directives/if-defined.js";
import { until } from "lit/directives/until.js";
import { import {
AuthenticatorTOTPStage, AuthenticatorTOTPStage,
DigitsEnum, DigitsEnum,
Flow,
FlowsApi, FlowsApi,
FlowsInstancesListDesignationEnum, FlowsInstancesListDesignationEnum,
FlowsInstancesListRequest,
StagesApi, StagesApi,
} from "@goauthentik/api"; } from "@goauthentik/api";
@ -80,41 +82,36 @@ export class AuthenticatorTOTPStageForm extends ModelForm<AuthenticatorTOTPStage
</select> </select>
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal label=${t`Configuration flow`} name="configureFlow"> <ak-form-element-horizontal label=${t`Configuration flow`} name="configureFlow">
<select class="pf-c-form-control"> <ak-search-select
<option .fetchObjects=${async (query?: string): Promise<Flow[]> => {
value="" const args: FlowsInstancesListRequest = {
?selected=${this.instance?.configureFlow === undefined} ordering: "slug",
> designation:
--------- FlowsInstancesListDesignationEnum.StageConfiguration,
</option> };
${until( if (query !== undefined) {
new FlowsApi(DEFAULT_CONFIG) args.search = query;
.flowsInstancesList({ }
ordering: "slug", const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList(
designation: args,
FlowsInstancesListDesignationEnum.StageConfiguration, );
}) return flows.results;
.then((flows) => { }}
return flows.results.map((flow) => { .renderElement=${(flow: Flow): string => {
let selected = this.instance?.configureFlow === flow.pk; return flow.name;
if ( }}
!this.instance?.pk && .renderDescription=${(flow: Flow): string => {
!this.instance?.configureFlow && return flow.slug;
flow.slug === "default-otp-time-configure" }}
) { .value=${(flow: Flow | undefined): string | undefined => {
selected = true; return flow?.pk;
} }}
return html`<option .selected=${(flow: Flow): boolean => {
value=${ifDefined(flow.pk)} return this.instance?.configureFlow === flow.pk;
?selected=${selected} }}
> ?blankable=${true}
${flow.name} (${flow.slug}) >
</option>`; </ak-search-select>
});
}),
html`<option>${t`Loading...`}</option>`,
)}
</select>
<p class="pf-c-form__helper-text"> <p class="pf-c-form__helper-text">
${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`} ${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`}
</p> </p>

View File

@ -1,4 +1,5 @@
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import "@goauthentik/elements/SearchSelect";
import "@goauthentik/elements/forms/HorizontalFormElement"; import "@goauthentik/elements/forms/HorizontalFormElement";
import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
@ -7,13 +8,14 @@ import { t } from "@lingui/macro";
import { TemplateResult, html } from "lit"; import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators.js"; import { customElement } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js"; import { ifDefined } from "lit/directives/if-defined.js";
import { until } from "lit/directives/until.js";
import { import {
AuthenticateWebAuthnStage, AuthenticateWebAuthnStage,
AuthenticatorAttachmentEnum, AuthenticatorAttachmentEnum,
Flow,
FlowsApi, FlowsApi,
FlowsInstancesListDesignationEnum, FlowsInstancesListDesignationEnum,
FlowsInstancesListRequest,
ResidentKeyRequirementEnum, ResidentKeyRequirementEnum,
StagesApi, StagesApi,
UserVerificationEnum, UserVerificationEnum,
@ -154,41 +156,36 @@ export class AuthenticateWebAuthnStageForm extends ModelForm<AuthenticateWebAuth
</select> </select>
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal label=${t`Configuration flow`} name="configureFlow"> <ak-form-element-horizontal label=${t`Configuration flow`} name="configureFlow">
<select class="pf-c-form-control"> <ak-search-select
<option .fetchObjects=${async (query?: string): Promise<Flow[]> => {
value="" const args: FlowsInstancesListRequest = {
?selected=${this.instance?.configureFlow === undefined} ordering: "slug",
> designation:
--------- FlowsInstancesListDesignationEnum.StageConfiguration,
</option> };
${until( if (query !== undefined) {
new FlowsApi(DEFAULT_CONFIG) args.search = query;
.flowsInstancesList({ }
ordering: "slug", const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList(
designation: args,
FlowsInstancesListDesignationEnum.StageConfiguration, );
}) return flows.results;
.then((flows) => { }}
return flows.results.map((flow) => { .renderElement=${(flow: Flow): string => {
let selected = this.instance?.configureFlow === flow.pk; return flow.name;
if ( }}
!this.instance?.pk && .renderDescription=${(flow: Flow): string => {
!this.instance?.configureFlow && return flow.slug;
flow.slug === "default-otp-time-configure" }}
) { .value=${(flow: Flow | undefined): string | undefined => {
selected = true; return flow?.pk;
} }}
return html`<option .selected=${(flow: Flow): boolean => {
value=${ifDefined(flow.pk)} return this.instance?.configureFlow === flow.pk;
?selected=${selected} }}
> ?blankable=${true}
${flow.name} (${flow.slug}) >
</option>`; </ak-search-select>
});
}),
html`<option>${t`Loading...`}</option>`,
)}
</select>
<p class="pf-c-form__helper-text"> <p class="pf-c-form__helper-text">
${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`} ${t`Flow used by an authenticated user to configure this Stage. If empty, user will not be able to configure this stage.`}
</p> </p>

View File

@ -1,5 +1,6 @@
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
import { first } from "@goauthentik/common/utils"; import { first } from "@goauthentik/common/utils";
import "@goauthentik/elements/SearchSelect";
import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/FormGroup";
import "@goauthentik/elements/forms/HorizontalFormElement"; import "@goauthentik/elements/forms/HorizontalFormElement";
import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
@ -9,12 +10,13 @@ import { t } from "@lingui/macro";
import { TemplateResult, html } from "lit"; import { TemplateResult, html } from "lit";
import { customElement } from "lit/decorators.js"; import { customElement } from "lit/decorators.js";
import { ifDefined } from "lit/directives/if-defined.js"; import { ifDefined } from "lit/directives/if-defined.js";
import { until } from "lit/directives/until.js";
import { import {
BackendsEnum, BackendsEnum,
Flow,
FlowsApi, FlowsApi,
FlowsInstancesListDesignationEnum, FlowsInstancesListDesignationEnum,
FlowsInstancesListRequest,
PasswordStage, PasswordStage,
StagesApi, StagesApi,
} from "@goauthentik/api"; } from "@goauthentik/api";
@ -118,41 +120,44 @@ export class PasswordStageForm extends ModelForm<PasswordStage, string> {
?required=${true} ?required=${true}
name="configureFlow" name="configureFlow"
> >
<select class="pf-c-form-control"> <ak-search-select
<option .fetchObjects=${async (query?: string): Promise<Flow[]> => {
value="" const args: FlowsInstancesListRequest = {
?selected=${this.instance?.configureFlow === undefined} ordering: "slug",
> designation:
--------- FlowsInstancesListDesignationEnum.StageConfiguration,
</option> };
${until( if (query !== undefined) {
new FlowsApi(DEFAULT_CONFIG) args.search = query;
.flowsInstancesList({ }
ordering: "slug", const flows = await new FlowsApi(DEFAULT_CONFIG).flowsInstancesList(
designation: args,
FlowsInstancesListDesignationEnum.StageConfiguration, );
}) return flows.results;
.then((flows) => { }}
return flows.results.map((flow) => { .renderElement=${(flow: Flow): string => {
let selected = this.instance?.configureFlow === flow.pk; return flow.name;
if ( }}
!this.instance?.pk && .renderDescription=${(flow: Flow): string => {
!this.instance?.configureFlow && return flow.slug;
flow.slug === "default-password-change" }}
) { .value=${(flow: Flow | undefined): string | undefined => {
selected = true; return flow?.pk;
} }}
return html`<option .selected=${(flow: Flow): boolean => {
value=${ifDefined(flow.pk)} let selected = this.instance?.configureFlow === flow.pk;
?selected=${selected} if (
> !this.instance?.pk &&
${flow.name} (${flow.slug}) !this.instance?.configureFlow &&
</option>`; flow.slug === "default-password-change"
}); ) {
}), selected = true;
html`<option>${t`Loading...`}</option>`, }
)} return selected;
</select> }}
?blankable=${true}
>
</ak-search-select>
<p class="pf-c-form__helper-text"> <p class="pf-c-form__helper-text">
${t`Flow used by an authenticated user to configure their password. If empty, user will not be able to configure change their password.`} ${t`Flow used by an authenticated user to configure their password. If empty, user will not be able to configure change their password.`}
</p> </p>