UI/partials replace partials/role-ssh partials/role-aws partials/role-pki (#11702)

* role-pki

* role-ssh

* role-aws
This commit is contained in:
Angel Garbarino 2021-05-26 12:29:52 -06:00 committed by GitHub
parent 5ed63d4ce1
commit 7383c6a878
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 352 additions and 363 deletions

View File

@ -52,7 +52,58 @@
{{/if}}
{{#if (or (eq mode 'edit') (eq mode 'create'))}}
{{partial 'partials/role-aws/form'}}
<form onsubmit={{action "createOrUpdate" "create"}}>
<div class="box is-sideless is-fullwidth is-marginless">
<MessageError @model={{model}} />
<NamespaceReminder @mode={{mode}} @noun="AWS role" />
{{#if (gt model.credentialTypes.length 1)}}
<AlertBanner
@type="warning"
@message="This role has more than one credential_type, currently: {{join ', ' model.credentialTypes}}.
Multiple credential types is deprecated and you must choose one in order to save this role."
/>
{{/if}}
{{#each (if (eq mode 'edit') (drop 1 (or model.fields (array))) model.fields) as |attr|}}
{{form-field data-test-field attr=attr model=model}}
{{/each}}
</div>
<div class="field is-grouped-split box is-fullwidth is-bottomless">
<div class="control">
<button
type="submit"
disabled={{buttonDisabled}}
class="button is-primary"
data-test-role-aws-create=true
>
{{#if (eq mode 'create')}}
Create role
{{else if (eq mode 'edit')}}
Save
{{/if}}
</button>
<SecretLink @mode={{if (eq mode "create") "list" "show"}} @class="button" @secret={{model.id}}>
Cancel
</SecretLink>
</div>
</div>
</form>
{{else}}
{{partial 'partials/role-aws/show'}}
<div class="box is-fullwidth is-sideless is-paddingless is-marginless">
{{#if (gt model.credentialTypes.length 1)}}
<AlertBanner
@type="warning"
@message="This role has more than one credential_type, currently: {{join ', ' model.credentialTypes}}.
When you next edit this role, you will have to choose a single credential type."
/>
{{/if}}
{{#each model.fields as |attr|}}
{{#if (eq attr.name "policyDocument")}}
<InfoTableRow @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{model.policyDocument}}>
<pre><code class="is-paddingless">{{stringify (jsonify model.policyDocument)}}</code></pre>
</InfoTableRow>
{{else}}
<InfoTableRow @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{get model attr.name}} />
{{/if}}
{{/each}}
</div>
{{/if}}

View File

@ -63,9 +63,52 @@
</ToolbarActions>
</Toolbar>
{{/if}}
{{#if (or (eq mode 'edit') (eq mode 'create'))}}
{{partial 'partials/role-pki/form'}}
<form onsubmit={{action "createOrUpdate" "create"}}>
<div class="box is-sideless is-fullwidth is-marginless">
<MessageError @model={{model}} />
<NamespaceReminder @mode={{mode}} @noun="PKI role" />
{{partial "partials/form-field-groups-loop"}}
</div>
<div class="field is-grouped-split box is-fullwidth is-bottomless">
<div class="control">
<button
type="submit"
disabled={{buttonDisabled}}
class="button is-primary"
data-test-role-create=true
>
{{#if (eq mode 'create')}}
Create role
{{else if (eq mode 'edit')}}
Save
{{/if}}
</button>
<SecretLink @mode={{if (eq mode "create") "list" "show"}} @class="button" @secret={{model.id}}>
Cancel
</SecretLink>
</div>
</div>
</form>
{{else}}
{{partial 'partials/role-pki/show'}}
<div class="box is-sideless is-fullwidth is-marginless">
{{#each model.fieldGroups as |fieldGroup|}}
{{#each-in fieldGroup as |group fields|}}
{{#if (or (eq group "default") (eq group "Options"))}}
{{#each fields as |attr|}}
<InfoTableRow @alwaysRender={{true}} @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{get model attr.name}} />
{{/each}}
{{else}}
<div class="box is-sideless is-fullwidth is-marginless">
<h2 class="title is-5">
{{group}}
</h2>
{{#each fields as |attr|}}
<InfoTableRow @alwaysRender={{true}} @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{get model attr.name}} />
{{/each}}
</div>
{{/if}}
{{/each-in}}
{{/each}}
</div>
{{/if}}

View File

@ -63,7 +63,40 @@
{{/if}}
{{#if (or (eq mode 'edit') (eq mode 'create'))}}
{{partial 'partials/role-ssh/form'}}
<form onsubmit={{action "createOrUpdate" "create"}}>
<div class="box is-sideless is-fullwidth is-marginless">
<MessageError @model={{model}} />
<NamespaceReminder @mode={{mode}} @noun="SSH role" />
{{partial "partials/form-field-groups-loop"}}
</div>
<div class="field is-grouped-split box is-fullwidth is-bottomless">
<div class="control">
<button
type="submit"
disabled={{buttonDisabled}}
class="button is-primary"
data-test-role-ssh-create=true
>
{{#if (eq mode 'create')}}
Create role
{{else if (eq mode 'edit')}}
Save
{{/if}}
</button>
<SecretLink @mode={{if (eq mode "create") "list" "show"}} @class="button" @secret={{model.id}}>
Cancel
</SecretLink>
</div>
</div>
</form>
{{else}}
{{partial 'partials/role-ssh/show'}}
<div class="box is-fullwidth is-sideless is-paddingless is-marginless">
{{#each model.showFields as |attr|}}
{{#if (eq attr.type "object")}}
<InfoTableRow @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{stringify (get model attr.name)}} />
{{else}}
<InfoTableRow @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{get model attr.name}} />
{{/if}}
{{/each}}
</div>
{{/if}}

View File

@ -1,36 +0,0 @@
<form onsubmit={{action "createOrUpdate" "create"}}>
<div class="box is-sideless is-fullwidth is-marginless">
<MessageError @model={{model}} />
<NamespaceReminder @mode={{mode}} @noun="AWS role" />
{{#if (gt model.credentialTypes.length 1)}}
<AlertBanner
@type="warning"
@message="This role has more than one credential_type, currently: {{join ', ' model.credentialTypes}}.
Multiple credential types is deprecated and you must choose one in order to save this role."
/>
{{/if}}
{{#each (if (eq mode 'edit') (drop 1 (or model.fields (array))) model.fields) as |attr|}}
{{form-field data-test-field attr=attr model=model}}
{{/each}}
</div>
<div class="field is-grouped-split box is-fullwidth is-bottomless">
<div class="control">
<button
type="submit"
disabled={{buttonDisabled}}
class="button is-primary"
data-test-role-aws-create=true
>
{{#if (eq mode 'create')}}
Create role
{{else if (eq mode 'edit')}}
Save
{{/if}}
</button>
<SecretLink @mode={{if (eq mode "create") "list" "show"}} @class="button" @secret={{model.id}}>
Cancel
</SecretLink>
</div>
</div>
</form>

View File

@ -1,56 +0,0 @@
<PopupMenu @name="role-aws-nav" @contentClass="is-wide">
<Confirm as |c|>
<nav class="menu">
<ul class="menu-list">
{{#if item.generatePath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else if item.canGenerate}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.credentials" @model={{item.id}} data-test-role-aws-link="generate">
Generate credentials
</LinkTo>
</li>
{{/if}}
{{#if item.updatePath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else}}
{{#if item.canRead}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.show" @model={{item.id}} data-test-role-ssh-link="show">
Details
</LinkTo>
</li>
{{/if}}
{{#if item.canEdit}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.edit" @model={{item.id}} data-test-role-ssh-link="edit">
Edit
</LinkTo>
</li>
{{/if}}
{{#if item.canDelete}}
<li class="action">
<c.Message
@id={{item.id}}
@onConfirm={{action "delete" item}}
data-test-aws-role-delete={{item.id}}/>
</li>
{{/if}}
{{/if}}
</ul>
</nav>
</Confirm>
</PopupMenu>

View File

@ -1,18 +0,0 @@
<div class="box is-fullwidth is-sideless is-paddingless is-marginless">
{{#if (gt model.credentialTypes.length 1)}}
<AlertBanner
@type="warning"
@message="This role has more than one credential_type, currently: {{join ', ' model.credentialTypes}}.
When you next edit this role, you will have to choose a single credential type."
/>
{{/if}}
{{#each model.fields as |attr|}}
{{#if (eq attr.name "policyDocument")}}
<InfoTableRow @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{model.policyDocument}}>
<pre><code class="is-paddingless">{{stringify (jsonify model.policyDocument)}}</code></pre>
</InfoTableRow>
{{else}}
<InfoTableRow @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{get model attr.name}} />
{{/if}}
{{/each}}
</div>

View File

@ -1,26 +0,0 @@
<form onsubmit={{action "createOrUpdate" "create"}}>
<div class="box is-sideless is-fullwidth is-marginless">
<MessageError @model={{model}} />
<NamespaceReminder @mode={{mode}} @noun="PKI role" />
{{partial "partials/form-field-groups-loop"}}
</div>
<div class="field is-grouped-split box is-fullwidth is-bottomless">
<div class="control">
<button
type="submit"
disabled={{buttonDisabled}}
class="button is-primary"
data-test-role-create=true
>
{{#if (eq mode 'create')}}
Create role
{{else if (eq mode 'edit')}}
Save
{{/if}}
</button>
<SecretLink @mode={{if (eq mode "create") "list" "show"}} @class="button" @secret={{model.id}}>
Cancel
</SecretLink>
</div>
</div>
</form>

View File

@ -1,69 +0,0 @@
<PopupMenu @name="role-aws-nav">
<Confirm as |c|>
<nav class="menu">
{{#if (or item.generatePath.isPending item.signPath.isPending)}}
<ul class="menu-list">
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
</ul>
{{else if (or item.canGenerate item.canSign)}}
<ul class="menu-list">
{{#if item.canGenerate}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.credentials" @model={{item.id}} @query={{hash action="issue"}} data-test-role-pki-link="generate-certificate">
Generate certificate
</LinkTo>
</li>
{{/if}}
{{#if item.canSign}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.credentials" @model={{item.id}} @query={{hash action="sign"}} data-test-role-pki-link="sign-certificate">
Sign certificate
</LinkTo>
</li>
{{/if}}
</ul>
{{/if}}
<ul class="menu-list">
{{#if item.updatePath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else}}
{{#if item.canRead}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.show" @model={{item.id}} data-test-role-pki-link="show">
Details
</LinkTo>
</li>
{{/if}}
{{#if item.canEdit}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.edit" @model={{item.id}} data-test-role-pki-link="edit">
Edit
</LinkTo>
</li>
{{/if}}
{{#if item.canDelete}}
<li class="action">
<c.Message
@id={{item.id}}
@onConfirm={{action "delete" item}}
data-test-pki-role-delete={{item.id}}/>
</li>
{{/if}}
{{/if}}
</ul>
</nav>
</Confirm>
</PopupMenu>

View File

@ -1,20 +0,0 @@
<div class="box is-sideless is-fullwidth is-marginless">
{{#each model.fieldGroups as |fieldGroup|}}
{{#each-in fieldGroup as |group fields|}}
{{#if (or (eq group "default") (eq group "Options"))}}
{{#each fields as |attr|}}
<InfoTableRow @alwaysRender={{true}} @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{get model attr.name}} />
{{/each}}
{{else}}
<div class="box is-sideless is-fullwidth is-marginless">
<h2 class="title is-5">
{{group}}
</h2>
{{#each fields as |attr|}}
<InfoTableRow @alwaysRender={{true}} @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{get model attr.name}} />
{{/each}}
</div>
{{/if}}
{{/each-in}}
{{/each}}
</div>

View File

@ -1,26 +0,0 @@
<form onsubmit={{action "createOrUpdate" "create"}}>
<div class="box is-sideless is-fullwidth is-marginless">
<MessageError @model={{model}} />
<NamespaceReminder @mode={{mode}} @noun="SSH role" />
{{partial "partials/form-field-groups-loop"}}
</div>
<div class="field is-grouped-split box is-fullwidth is-bottomless">
<div class="control">
<button
type="submit"
disabled={{buttonDisabled}}
class="button is-primary"
data-test-role-ssh-create=true
>
{{#if (eq mode 'create')}}
Create role
{{else if (eq mode 'edit')}}
Save
{{/if}}
</button>
<SecretLink @mode={{if (eq mode "create") "list" "show"}} @class="button" @secret={{model.id}}>
Cancel
</SecretLink>
</div>
</div>
</form>

View File

@ -1,93 +0,0 @@
<PopupMenu @name="role-ssh-nav">
<Confirm as |c|>
<nav class="menu">
<ul class="menu-list">
{{#if (eq item.keyType 'otp')}}
{{#if item.generatePath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else if item.canGenerate}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.credentials" @model={{item.id}} data-test-role-ssh-link="generate">
Generate Credentials
</LinkTo>
</li>
{{/if}}
{{else if (eq item.keyType 'ca')}}
{{#if item.signPath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else if item.canGenerate}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.sign" @model={{item.id}} data-test-role-ssh-link="generate">
Sign Keys
</LinkTo>
</li>
{{/if}}
{{/if}}
{{#if item.canEditZeroAddress}}
{{#if item.zeroAddress}}
<li class="action">
<button type="button" disabled={{get this (concat "loading-" item.id)}} class="link button is-transparent
{{if (get this (concat "loading-" item.id)) 'is-loading'}} " {{action "toggleZeroAddress" item backendModel}}>
Disable Zero Address
</button>
</li>
{{else}}
<li class="action">
<button
type="button"
disabled={{get this (concat "loading-" item.id)}}
class="link button is-transparent {{if (get this (concat "loading-" item.id)) 'is-loading'}}"
{{action "toggleZeroAddress" item backendModel}}
>
Enable Zero Address
</button>
</li>
{{/if}}
{{/if}}
{{#if item.updatePath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else}}
{{#if item.canRead}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.show" @model={{item.id}} data-test-role-ssh-link="show">
Details
</LinkTo>
</li>
{{/if}}
{{#if item.canEdit}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.edit" @model={{item.id}} data-test-role-ssh-link="edit">
Edit
</LinkTo>
</li>
{{/if}}
{{#if item.canDelete}}
<li class="action">
<c.Message
@id={{item.id}}
@onConfirm={{action "delete" item}}
data-test-ssh-role-delete/>
</li>
{{/if}}
{{/if}}
</ul>
</nav>
</Confirm>
</PopupMenu>

View File

@ -1,9 +0,0 @@
<div class="box is-fullwidth is-sideless is-paddingless is-marginless">
{{#each model.showFields as |attr|}}
{{#if (eq attr.type "object")}}
<InfoTableRow @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{stringify (get model attr.name)}} />
{{else}}
<InfoTableRow @label={{capitalize (or attr.options.label (humanize (dasherize attr.name)))}} @value={{get model attr.name}} />
{{/if}}
{{/each}}
</div>

View File

@ -22,7 +22,62 @@
</LinkTo>
</div>
<div class="column has-text-right">
{{partial 'partials/role-aws/popup-menu'}}
<PopupMenu @name="role-aws-nav" @contentClass="is-wide">
<Confirm as |c|>
<nav class="menu">
<ul class="menu-list">
{{#if item.generatePath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else if item.canGenerate}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.credentials" @model={{item.id}} data-test-role-aws-link="generate">
Generate credentials
</LinkTo>
</li>
{{/if}}
{{#if item.updatePath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else}}
{{#if item.canRead}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.show" @model={{item.id}} data-test-role-ssh-link="show">
Details
</LinkTo>
</li>
{{/if}}
{{#if item.canEdit}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.edit" @model={{item.id}} data-test-role-ssh-link="edit">
Edit
</LinkTo>
</li>
{{/if}}
{{#if item.canDelete}}
<li class="action">
<c.Message
@id={{item.id}}
@onConfirm={{action "delete" item}}
data-test-aws-role-delete={{item.id}}/>
</li>
{{/if}}
{{/if}}
</ul>
</nav>
</Confirm>
</PopupMenu>
</div>
</div>
{{/linked-block}}

View File

@ -25,7 +25,75 @@
</LinkTo>
</div>
<div class="column has-text-right">
{{partial "partials/role-pki/popup-menu"}}
<PopupMenu @name="role-aws-nav">
<Confirm as |c|>
<nav class="menu">
{{#if (or item.generatePath.isPending item.signPath.isPending)}}
<ul class="menu-list">
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
</ul>
{{else if (or item.canGenerate item.canSign)}}
<ul class="menu-list">
{{#if item.canGenerate}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.credentials" @model={{item.id}} @query={{hash action="issue"}} data-test-role-pki-link="generate-certificate">
Generate certificate
</LinkTo>
</li>
{{/if}}
{{#if item.canSign}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.credentials" @model={{item.id}} @query={{hash action="sign"}} data-test-role-pki-link="sign-certificate">
Sign certificate
</LinkTo>
</li>
{{/if}}
</ul>
{{/if}}
<ul class="menu-list">
{{#if item.updatePath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else}}
{{#if item.canRead}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.show" @model={{item.id}} data-test-role-pki-link="show">
Details
</LinkTo>
</li>
{{/if}}
{{#if item.canEdit}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.edit" @model={{item.id}} data-test-role-pki-link="edit">
Edit
</LinkTo>
</li>
{{/if}}
{{#if item.canDelete}}
<li class="action">
<c.Message
@id={{item.id}}
@onConfirm={{action "delete" item}}
data-test-pki-role-delete={{item.id}}/>
</li>
{{/if}}
{{/if}}
</ul>
</nav>
</Confirm>
</PopupMenu>
</div>
</div>
{{/linked-block}}

View File

@ -28,7 +28,99 @@
</div>
<div class="column has-text-right">
{{#if (eq backendType 'ssh')}}
{{partial 'partials/role-ssh/popup-menu'}}
<PopupMenu @name="role-ssh-nav">
<Confirm as |c|>
<nav class="menu">
<ul class="menu-list">
{{#if (eq item.keyType 'otp')}}
{{#if item.generatePath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else if item.canGenerate}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.credentials" @model={{item.id}} data-test-role-ssh-link="generate">
Generate Credentials
</LinkTo>
</li>
{{/if}}
{{else if (eq item.keyType 'ca')}}
{{#if item.signPath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else if item.canGenerate}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.sign" @model={{item.id}} data-test-role-ssh-link="generate">
Sign Keys
</LinkTo>
</li>
{{/if}}
{{/if}}
{{#if item.canEditZeroAddress}}
{{#if item.zeroAddress}}
<li class="action">
<button type="button" disabled={{get this (concat "loading-" item.id)}} class="link button is-transparent
{{if (get this (concat "loading-" item.id)) 'is-loading'}} " {{action "toggleZeroAddress" item backendModel}}>
Disable Zero Address
</button>
</li>
{{else}}
<li class="action">
<button
type="button"
disabled={{get this (concat "loading-" item.id)}}
class="link button is-transparent {{if (get this (concat "loading-" item.id)) 'is-loading'}}"
{{action "toggleZeroAddress" item backendModel}}
>
Enable Zero Address
</button>
</li>
{{/if}}
{{/if}}
{{#if item.updatePath.isPending}}
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
<li class="action">
<button disabled type="button" class="link button is-loading is-transparent">
loading
</button>
</li>
{{else}}
{{#if item.canRead}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.show" @model={{item.id}} data-test-role-ssh-link="show">
Details
</LinkTo>
</li>
{{/if}}
{{#if item.canEdit}}
<li class="action">
<LinkTo @route="vault.cluster.secrets.backend.edit" @model={{item.id}} data-test-role-ssh-link="edit">
Edit
</LinkTo>
</li>
{{/if}}
{{#if item.canDelete}}
<li class="action">
<c.Message
@id={{item.id}}
@onConfirm={{action "delete" item}}
data-test-ssh-role-delete/>
</li>
{{/if}}
{{/if}}
</ul>
</nav>
</Confirm>
</PopupMenu>
{{/if}}
</div>
</div>