* feat: 🎸 create form for json credentials ✅ Closes: ICU-6682 * refactor: 💡 add new info field * refactor: 💡 add feature flag * refactor: 💡 add hds radio cards to json cred * Update ui/admin/tests/acceptance/credential-store/credentials/create-test.js * test: 💍 add test for json cred * chore: 🤖 Remove ember-data-model-fragments package * fix: 🐛 Update how json is added as a known credential type * refactor: 💡 update credentialTypes if statement to ternary * chore: 🤖 add ember-data back to addon/api project * chore: 🤖 remove ember-feature-flag from addon/api * refactor: 💡 remove if statement in cred form * refactor: 💡 update selectors for json cred. tests * refactor: 💡 Update Credential Form to use form.disabled * test: 💍 Fix test selectors for radio card credential tests * refactor: 💡 update credential types declaration to const * style: 💄 Fix style issue with SecretEditor in edit mode * refactor: 💡 remove disabled and readonly attributes in form * refactor: 💡 Create credential ability canRead override * test: 💍 add credential ability override tests * test: 💍 Fix brokered credential test with json support added * refactor: 💡 add attributes comment back to credential model Co-authored-by: Cameron Perera <cameron.perera@hashicorp.com>
112 lines
3.2 KiB
Handlebars
112 lines
3.2 KiB
Handlebars
<Rose::Form
|
|
@onSubmit={{@submit}}
|
|
@cancel={{@cancel}}
|
|
@disabled={{@model.isSaving}}
|
|
@showEditToggle={{if @model.isNew false true}}
|
|
as |form|
|
|
>
|
|
|
|
<form.input
|
|
@name='name'
|
|
@value={{@model.name}}
|
|
@label={{t 'form.name.label'}}
|
|
@error={{@model.errors.name}}
|
|
@helperText={{t 'form.name.help'}}
|
|
as |field|
|
|
>
|
|
{{#if @model.errors.name}}
|
|
<field.errors as |errors|>
|
|
{{#each @model.errors.name as |error|}}
|
|
<errors.message>{{error.message}}</errors.message>
|
|
{{/each}}
|
|
</field.errors>
|
|
{{/if}}
|
|
</form.input>
|
|
|
|
<form.textarea
|
|
@name='description'
|
|
@value={{@model.description}}
|
|
@label={{t 'form.description.label'}}
|
|
@error={{@model.errors.description}}
|
|
@helperText={{t 'form.description.help'}}
|
|
as |field|
|
|
>
|
|
{{#if @model.errors.description}}
|
|
<field.errors as |errors|>
|
|
{{#each @model.errors.description as |error|}}
|
|
<errors.message>{{error.message}}</errors.message>
|
|
{{/each}}
|
|
</field.errors>
|
|
{{/if}}
|
|
</form.textarea>
|
|
|
|
{{#if @model.isNew}}
|
|
<form.fieldset>
|
|
<:body>
|
|
<Hds::Form::RadioCard::Group as |G|>
|
|
<G.Legend>{{t 'form.type.label'}}</G.Legend>
|
|
{{#each @types as |credentialType|}}
|
|
<G.RadioCard
|
|
@name={{credentialType}}
|
|
@value={{credentialType}}
|
|
@checked={{eq credentialType @model.type}}
|
|
@maxWidth='20rem'
|
|
{{on 'input' (fn @changeType credentialType)}}
|
|
as |R|
|
|
>
|
|
<R.Label>{{t
|
|
(concat 'resources.credential.types.' credentialType)
|
|
}}</R.Label>
|
|
<R.Description>{{t
|
|
(concat 'resources.credential.help.' credentialType)
|
|
}}</R.Description>
|
|
</G.RadioCard>
|
|
{{/each}}
|
|
</Hds::Form::RadioCard::Group>
|
|
</:body>
|
|
</form.fieldset>
|
|
|
|
<form.fieldset>
|
|
<:title>{{t 'resources.credential.form.json.label'}}</:title>
|
|
<:description>{{t 'resources.credential.form.json.help'}}</:description>
|
|
<:body>
|
|
<Form::Field::JsonSecret
|
|
@value={{@model.json_object}}
|
|
@onInput={{fn (mut @model.json_object)}}
|
|
@showEditButton={{false}}
|
|
/>
|
|
</:body>
|
|
</form.fieldset>
|
|
{{else}}
|
|
<InfoField
|
|
@value={{t (concat 'resources.credential.help.' @model.type)}}
|
|
as |F|
|
|
>
|
|
<F.Label>{{t 'form.type.label'}}</F.Label>
|
|
<F.HelperText>{{t (concat 'resources.credential.types.' @model.type)}}
|
|
</F.HelperText>
|
|
</InfoField>
|
|
|
|
<form.fieldset>
|
|
<:title>{{t 'resources.credential.form.json.label'}}</:title>
|
|
<:description>{{t 'resources.credential.form.json.help'}}</:description>
|
|
<:body>
|
|
<Form::Field::JsonSecret
|
|
@disabled={{form.disabled}}
|
|
@value={{@model.json_object}}
|
|
@onInput={{fn (mut @model.json_object)}}
|
|
@showEditButton={{true}}
|
|
/>
|
|
</:body>
|
|
</form.fieldset>
|
|
{{/if}}
|
|
|
|
{{#if (can 'save model' @model)}}
|
|
<form.actions
|
|
@enableEditText={{t 'actions.edit-form'}}
|
|
@submitText={{t 'actions.save'}}
|
|
@cancelText={{t 'actions.cancel'}}
|
|
/>
|
|
{{/if}}
|
|
|
|
</Rose::Form> |