web/admin: fix non-matching provider type being selected when creating an OAuth Source
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
67240fb9ad
commit
0021a93952
|
@ -86,6 +86,7 @@ class ProviderViewSet(
|
||||||
"name": _("SAML Provider from Metadata"),
|
"name": _("SAML Provider from Metadata"),
|
||||||
"description": _("Create a SAML Provider by importing its Metadata."),
|
"description": _("Create a SAML Provider by importing its Metadata."),
|
||||||
"component": "ak-provider-saml-import-form",
|
"component": "ak-provider-saml-import-form",
|
||||||
|
"model_name": "",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return Response(TypeCreateSerializer(data, many=True).data)
|
return Response(TypeCreateSerializer(data, many=True).data)
|
||||||
|
|
|
@ -128,6 +128,9 @@ export class SourceListPage extends TablePage<Source> {
|
||||||
</span>
|
</span>
|
||||||
<ak-proxy-form
|
<ak-proxy-form
|
||||||
slot="form"
|
slot="form"
|
||||||
|
.args=${{
|
||||||
|
"modelName": type.modelName
|
||||||
|
}}
|
||||||
type=${type.component}>
|
type=${type.component}>
|
||||||
</ak-proxy-form>
|
</ak-proxy-form>
|
||||||
<button slot="trigger" class="pf-c-dropdown__menu-item">
|
<button slot="trigger" class="pf-c-dropdown__menu-item">
|
||||||
|
|
|
@ -22,6 +22,9 @@ export class OAuthSourceForm extends Form<OAuthSource> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@property()
|
||||||
|
modelName?: string;
|
||||||
|
|
||||||
@property({attribute: false})
|
@property({attribute: false})
|
||||||
source?: OAuthSource;
|
source?: OAuthSource;
|
||||||
|
|
||||||
|
@ -148,7 +151,13 @@ export class OAuthSourceForm extends Form<OAuthSource> {
|
||||||
}}>
|
}}>
|
||||||
${until(new SourcesApi(DEFAULT_CONFIG).sourcesOauthSourceTypes().then(types => {
|
${until(new SourcesApi(DEFAULT_CONFIG).sourcesOauthSourceTypes().then(types => {
|
||||||
return types.map(type => {
|
return types.map(type => {
|
||||||
return html`<option ?data-urls-custom=${type.urlsCustomizable} value=${type.slug} ?selected=${this.source?.providerType === type.slug}>${type.name}</option>`;
|
let selected = this.source?.providerType === type.slug;
|
||||||
|
if (!this.source?.pk) {
|
||||||
|
if (this.modelName?.replace("oauthsource", "") === type.slug) {
|
||||||
|
selected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return html`<option ?data-urls-custom=${type.urlsCustomizable} value=${type.slug} ?selected=${selected}>${type.name}</option>`;
|
||||||
});
|
});
|
||||||
}), html`<option>${t`Loading...`}</option>`)}
|
}), html`<option>${t`Loading...`}</option>`)}
|
||||||
</select>
|
</select>
|
||||||
|
|
Reference in New Issue