web/admin: auto-select keypair in oauth provider creation when only 1 keypair exists

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-05-04 17:09:04 +02:00
parent 928c2bf0d6
commit e6431593f7

View file

@ -192,7 +192,11 @@ export class OAuth2ProviderFormPage extends Form<OAuth2Provider> {
hasKey: "true",
}).then(keys => {
return keys.results.map(key => {
return html`<option value=${ifDefined(key.pk)} ?selected=${this.provider?.rsaKey === key.pk}>${key.name}</option>`;
let selected = this.provider?.rsaKey === key.pk;
if (keys.results.length === 1) {
selected = true;
}
return html`<option value=${ifDefined(key.pk)} ?selected=${selected}>${key.name}</option>`;
});
}), html`<option>${t`Loading...`}</option>`)}
</select>