web: fix dual-select with dynamic selection (#11133)

* web: fix dual-select with dynamic selection

For dynamic selection, the property name is `.selector` to message that it's a function the
API layer uses to select the elements.

A few bits of lint picked.

* web: added comment to clarify what the fallback selector does
This commit is contained in:
Ken Sternberg
2024-08-30 09:53:14 -07:00
committed by GitHub
parent 1003c79d8c
commit 32d1488a56
2 changed files with 15 additions and 8 deletions

View File

@ -46,7 +46,8 @@ async function makeSourcesSelector(instanceSources: string[] | undefined) {
return localSources return localSources
? ([pk, _]: DualSelectPair) => localSources.has(pk) ? ([pk, _]: DualSelectPair) => localSources.has(pk)
: ([_0, _1, _2, source]: DualSelectPair<Source>) => : // Creating a new instance, auto-select built-in source only when no other sources exist
([_0, _1, _2, source]: DualSelectPair<Source>) =>
source !== undefined && source.component === ""; source !== undefined && source.component === "";
} }
@ -75,12 +76,12 @@ export class IdentificationStageForm extends BaseStageForm<IdentificationStage>
stageUuid: this.instance.pk || "", stageUuid: this.instance.pk || "",
identificationStageRequest: data, identificationStageRequest: data,
}); });
} else { }
return new StagesApi(DEFAULT_CONFIG).stagesIdentificationCreate({ return new StagesApi(DEFAULT_CONFIG).stagesIdentificationCreate({
identificationStageRequest: data, identificationStageRequest: data,
}); });
} }
}
isUserFieldSelected(field: UserFieldsEnum): boolean { isUserFieldSelected(field: UserFieldsEnum): boolean {
return ( return (
@ -232,12 +233,12 @@ export class IdentificationStageForm extends BaseStageForm<IdentificationStage>
?required=${true} ?required=${true}
name="sources" name="sources"
> >
<ak-dual-select-provider-dynamic-selected <ak-dual-select-dynamic-selected
.provider=${sourcesProvider} .provider=${sourcesProvider}
.selected=${makeSourcesSelector(this.instance?.sources)} .selector=${makeSourcesSelector(this.instance?.sources)}
available-label="${msg("Available Stages")}" available-label="${msg("Available Stages")}"
selected-label="${msg("Selected Stages")}" selected-label="${msg("Selected Stages")}"
></ak-dual-select-provider-dynamic-selected> ></ak-dual-select-dynamic-selected>
<p class="pf-c-form__helper-text"> <p class="pf-c-form__helper-text">
${msg( ${msg(
"Select sources should be shown for users to authenticate with. This only affects web-based sources, not LDAP.", "Select sources should be shown for users to authenticate with. This only affects web-based sources, not LDAP.",

View File

@ -50,3 +50,9 @@ export class AkDualSelectDynamic extends AkDualSelectProvider {
></ak-dual-select>`; ></ak-dual-select>`;
} }
} }
declare global {
interface HTMLElementTagNameMap {
"ak-dual-select-dynamic-selected": AkDualSelectDynamic;
}
}