open-vault/ui/lib/pki/addon/components/pki-role-form.hbs
claire bontempo a4270c7701
UI: Pki engine (redesign) routing changes (#17997)
* reroute pki config routes

* issuers routes

* refactor role routes

* add issuer/generate- routes

* update key routes

* refactor cert routes;

* template cleanup, update routes

* update component names with pki-

* update components in test files
2022-11-17 16:50:58 -08:00

137 lines
4.6 KiB
Handlebars

<PageHeader as |p|>
<p.top>
<KeyValueHeader
@root={{hash label="role" text="role" path="vault.cluster.secrets.backend.pki.roles.index"}}
@isEngine={{true}}
>
<li>
<span class="sep">
/
</span>
<LinkTo @route="roles.index">
{{@model.backend}}
</LinkTo>
</li>
</KeyValueHeader>
</p.top>
<p.levelLeft>
<h1 class="title is-3">
{{#if @model.isNew}}
Create a PKI role
{{else}}
Edit a
{{@model.id}}
{{/if}}
</h1>
</p.levelLeft>
</PageHeader>
<form {{on "submit" (perform this.save)}}>
<div class="box is-sideless is-fullwidth is-marginless">
<MessageError @errorMessage={{this.errorBanner}} class="has-top-margin-s" />
{{! ARG TODO write a test for namespace reminder }}
<NamespaceReminder @mode={{if @model.isNew "create" "update"}} @noun="PKI role" />
{{#each @model.fieldGroups as |fieldGroup|}}
{{#each-in fieldGroup as |group fields|}}
{{! DEFAULT VIEW }}
{{#if (eq group "default")}}
{{#each fields as |attr|}}
<FormField
data-test-field={{true}}
@attr={{attr}}
@model={{@model}}
@modelValidations={{this.modelValidations}}
@showHelpText={{false}}
>
<RadioSelectTtlOrString @attr={{attr}} @model={{@model}} />
</FormField>
{{/each}}
{{else if (eq group "Key usage")}}
<PkiKeyUsage @model={{@model}} @group={{group}} />
{{else if (eq group "Key parameters")}}
<PkiKeyParameters @model={{@model}} @group={{group}} />
{{else}}
{{! Groups hidden behind Toggles }}
{{#let (camelize (concat "show" group)) as |prop|}}
<ToggleButton
@isOpen={{get @model prop}}
@openLabel={{concat "Hide " group}}
@closedLabel={{group}}
@onClick={{fn (mut (get @model prop))}}
class="is-block"
data-test-toggle-group={{group}}
/>
{{#if (get @model prop)}}
<div class="box is-marginless">
{{#let (get @model.fieldGroupsInfo group) as |groupInfo|}}
{{! Header }}
{{#if groupInfo.header}}
<div class="has-bottom-margin-s">
<FormFieldLabel
for={{groupInfo.header.name}}
@label={{groupInfo.header.label}}
@subText={{groupInfo.header.text}}
@docLink={{groupInfo.header.docLink}}
/>
</div>
{{/if}}
{{! Fields }}
{{#each fields as |attr|}}
<FormField
data-test-field={{true}}
@attr={{attr}}
@model={{@model}}
@modelValidations={{@modelValidations}}
@showHelpText={{false}}
>
{{yield attr}}
</FormField>
{{/each}}
{{! Footer }}
{{#if groupInfo.footer}}
<p class="sub-text">
<Icon @name="info" />
{{groupInfo.footer.text}}
{{#if groupInfo.footer.docLink}}
<DocLink @path={{groupInfo.footer.docLink}}>
{{groupInfo.footer.docText}}
</DocLink>
{{/if}}
</p>
{{/if}}
{{/let}}
</div>
{{/if}}
{{/let}}
{{/if}}
{{/each-in}}
{{/each}}
</div>
<div class="has-top-padding-s">
<button
type="submit"
class="button is-primary {{if this.save.isRunning 'is-loading'}}"
disabled={{this.save.isRunning}}
data-test-pki-role-save
>
{{if @model.isNew "Create" "Update"}}
</button>
<button
type="button"
class="button has-left-margin-s"
disabled={{this.save.isRunning}}
{{on "click" this.cancel}}
data-test-pki-role-cancel
>
Cancel
</button>
{{#if this.modelValidations.targets.errors}}
<AlertInline @type="danger" @message={{join ", " this.modelValidations.targets.errors}} @paddingTop={{true}} />
{{/if}}
{{#if this.invalidFormAlert}}
<div class="control">
<AlertInline @type="danger" @paddingTop={{true}} @message={{this.invalidFormAlert}} @mimicRefresh={{true}} />
</div>
{{/if}}
</div>
</form>