feat: 🎸 Allow prompts in oidc auth method form (#2007)
* feat: 🎸 Allow prompts in OIDC auth method form
This commit is contained in:
1 parent
02a89bd7ba
commit
3f2f2ba756
12 files changed
+115
-2
No files matched your search
@@ -528,6 +528,34 @@
|
||||
{{/if}}
|
||||
</form.input>
|
||||
|
||||
<Hds::Form::Checkbox::Group
|
||||
class='oidc-prompts'
|
||||
@isOptional={{true}}
|
||||
@name='prompts'
|
||||
disabled={{form.disabled}}
|
||||
as |G|
|
||||
>
|
||||
<G.Legend>{{t 'form.prompts.label'}}</G.Legend>
|
||||
<G.HelperText>{{t 'form.prompts.help'}}</G.HelperText>
|
||||
|
||||
{{#each this.prompts as |prompt|}}
|
||||
<G.Checkbox::Field
|
||||
@id={{prompt}}
|
||||
checked={{includes prompt this.selectedPrompts}}
|
||||
{{on 'change' (fn this.updatePrompt prompt)}}
|
||||
as |F|
|
||||
>
|
||||
<F.Label>
|
||||
{{t (concat 'resources.auth-method.form.' prompt '.label')}}
|
||||
</F.Label>
|
||||
<F.HelperText>
|
||||
{{t (concat 'resources.auth-method.form.' prompt '.help')}}
|
||||
</F.HelperText>
|
||||
</G.Checkbox::Field>
|
||||
{{/each}}
|
||||
|
||||
</Hds::Form::Checkbox::Group>
|
||||
|
||||
{{#unless @model.isNew}}
|
||||
<form.input
|
||||
@value={{@model.callback_url}}
|
||||
@@ -537,6 +565,7 @@
|
||||
@disabled={{true}}
|
||||
/>
|
||||
{{/unless}}
|
||||
|
||||
{{#if (can 'save model' @model)}}
|
||||
<form.actions
|
||||
@enableEditText={{t 'actions.edit-form'}}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
import Component from '@glimmer/component';
|
||||
import { options } from 'api/models/auth-method';
|
||||
import { action } from '@ember/object';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
|
||||
export default class FormAuthMethodOidcComponent extends Component {
|
||||
// =attributes
|
||||
@@ -27,4 +29,41 @@ export default class FormAuthMethodOidcComponent extends Component {
|
||||
* @type {string}
|
||||
*/
|
||||
newSigningAlgorithm = options.oidc.signing_algorithms[0];
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
prompts = options.oidc.prompts;
|
||||
|
||||
@tracked selectedPrompts = this.parsePromptsArray();
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
parsePromptsArray() {
|
||||
return this.args.model.prompts?.map((item) => item.value) ?? [];
|
||||
}
|
||||
|
||||
//actions
|
||||
|
||||
/**
|
||||
* @param {string} option
|
||||
* @param {object} event
|
||||
*/
|
||||
@action
|
||||
updatePrompt(value, event) {
|
||||
const currentSelection = { value };
|
||||
const previousSelection = this.args.model.prompts || [];
|
||||
|
||||
// Add the selected option to the model, only when the checkbox is in checked state
|
||||
if (event.target.checked) {
|
||||
this.args.model.prompts = [...previousSelection, currentSelection];
|
||||
} else {
|
||||
// When the checkbox is unchecked, remove the option form the exisiting list
|
||||
const removeSelection = previousSelection.filter(
|
||||
(prompt) => prompt.value !== value,
|
||||
);
|
||||
this.args.model.prompts = [...removeSelection];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user