open-vault/ui/app/templates/components/secret-create-or-update.hbs
Jordan Reimer 5c2a08de6d
Ember Upgrade to 3.24 (#13443)
* Update browserslist

* Add browserslistrc

* ember-cli-update --to 3.26, fix conflicts

* Run codemodes that start with ember-*

* More codemods - before cp*

* More codemods (curly data-test-*)

* WIP ember-basic-dropdown template errors

* updates ember-basic-dropdown and related deps to fix build issues

* updates basic dropdown instances to new version API

* updates more deps -- ember-template-lint is working again

* runs no-implicit-this codemod

* creates and runs no-quoteless-attributes codemod

* runs angle brackets codemod

* updates lint:hbs globs to only touch hbs files

* removes yield only templates

* creates and runs deprecated args transform

* supresses lint error for invokeAction on LinkTo component

* resolves remaining ambiguous path lint errors

* resolves simple-unless lint errors

* adds warnings for deprecated tagName arg on LinkTo components

* adds warnings for remaining curly component invocation

* updates global template lint rules

* resolves remaining template lint errors

* disables some ember specfic lint rules that target pre octane patterns

* js lint fix run

* resolves remaining js lint errors

* fixes test run

* adds npm-run-all dep

* fixes test attribute issues

* fixes console acceptance tests

* fixes tests

* adds yield only wizard/tutorial-active template

* fixes more tests

* attempts to fix more flaky tests

* removes commented out settled in transit test

* updates deprecations workflow and adds initializer to filter by version

* updates flaky policies acl old test

* updates to flaky transit test

* bumps ember deps down to LTS version

* runs linters after main merge

* fixes client count tests after bad merge conflict fixes

* fixes client count history test

* more updates to lint config

* another round of hbs lint fixes after extending stylistic rule

* updates lint-staged commands

* removes indent eslint rule since it seems to break things

* fixes bad attribute in transform-edit-form template

* test fixes

* fixes enterprise tests

* adds changelog

* removes deprecated ember-concurrency-test-waiters dep and adds @ember/test-waiters

* flaky test fix

Co-authored-by: hashishaw <cshaw@hashicorp.com>
2021-12-16 20:44:29 -07:00

263 lines
9 KiB
Handlebars

{{#if (eq @mode "create")}}
<form class={{if @showAdvancedMode "advanced-edit" "simple-edit"}} onsubmit={{action "createOrUpdateKey" @mode}}>
<div class="field box is-fullwidth is-sideless is-marginless">
<NamespaceReminder @mode="create" @noun="secret" />
<MessageError @model={{@modelForData}} @errorMessage={{this.error}} />
<label class="is-label" for="kv-key">Path for this secret</label>
<p class="control is-expanded">
<Input
autocomplete="off"
spellcheck="false"
data-test-secret-path="true"
id="kv-key"
class="input {{if (get this.validationMessages "path") "has-error-border"}}"
@value={{get @modelForData @modelForData.pathAttr}}
{{on "keyup" (perform this.waitForKeyUp "path" value="target.value")}}
/>
</p>
{{#if (get this.validationMessages "path")}}
<AlertInline
@type="danger"
@message={{get this.validationMessages "path"}}
@paddingTop={{true}}
@isMarginless={{true}}
/>
{{/if}}
{{#if @modelForData.isFolder}}
<p class="help is-danger">
The secret path may not end in
<code>/</code>
</p>
{{/if}}
{{#if this.pathWhiteSpaceWarning}}
<div class="has-top-margin-m">
<AlertBanner
@type="warning"
@message="Your secret path contains whitespace. If this is desired, you'll need to encode it with %20 in API calls."
@marginTop={{true}}
data-test-whitespace-warning
/>
</div>
{{/if}}
</div>
{{#if @showAdvancedMode}}
<div class="form-section">
<JsonEditor
@title={{if @isV2 "Version Data" "Secret Data"}}
@value={{this.codemirrorString}}
@valueUpdated={{action "codemirrorUpdated"}}
@onFocusOut={{action "formatJSON"}}
/>
</div>
{{else}}
<div class="form-section">
<label class="title is-5">
Secret data
</label>
{{#each @secretData as |secret index|}}
<div class="info-table-row">
<div class="column is-one-quarter info-table-row-edit">
<Input
data-test-secret-key={{true}}
@value={{secret.name}}
placeholder="key"
{{on "change" (action "handleChange")}}
class="input"
autocomplete="off"
spellcheck="false"
/>
</div>
<div class="column info-table-row-edit">
<MaskedInput
@name={{secret.name}}
@onKeyDown={{action "handleKeyDown"}}
@onChange={{action "handleChange"}}
@value={{secret.value}}
data-test-secret-value="true"
/>
</div>
<div class="column is-narrow info-table-row-edit">
{{#if (eq @secretData.length (inc index))}}
<button
type="button"
{{action "addRow"}}
class="button is-outlined is-primary"
data-test-secret-add-row="true"
>
Add
</button>
{{else}}
<button
class="button has-text-grey is-expanded is-icon"
type="button"
{{on "click" (fn this.deleteRow secret.name)}}
aria-label="Delete row"
>
<Icon @name="trash" class="has-text-grey-light" />
</button>
{{/if}}
</div>
</div>
{{#if this.validationMessages.key}}
<AlertInline
@type="danger"
@message={{this.validationMessages.key}}
@paddingTop={{true}}
@isMarginless={{true}}
/>
{{/if}}
{{/each}}
</div>
{{/if}}
{{! must have UPDATE permissions to add secret metadata. Create only will not work }}
{{#if (and @isV2 @canUpdateSecretMetadata)}}
<ToggleButton
@class="is-block"
@toggleAttr={{"showMetadata"}}
@toggleTarget={{this}}
@openLabel="Hide secret metadata"
@closedLabel="Show secret metadata"
data-test-show-metadata-toggle
/>
{{#if this.showMetadata}}
<SecretEditMetadata
@model={{@model}}
@mode="create"
@updateValidationErrorCount={{action "updateValidationErrorCount"}}
/>
{{/if}}
{{/if}}
<div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control">
<button
type="submit"
disabled={{or @buttonDisabled this.validationErrorCount this.error}}
class="button is-primary"
data-test-secret-save={{true}}
>
Save
</button>
</div>
<div class="control">
<SecretLink @mode="list" @secret={{@model.parentKey}} @class="button">
Cancel
</SecretLink>
</div>
</div>
</form>
{{/if}}
{{#if (eq @mode "edit")}}
{{! no metadata option because metadata is version agnostic }}
<form onsubmit={{action "createOrUpdateKey" "edit"}}>
<div class="box is-sideless is-fullwidth is-marginless padding-top">
<MessageError @model={{@modelForData}} @errorMessage={{this.error}} />
{{#unless @canReadSecretData}}
<AlertBanner
@type="warning"
@message="You do not have read permissions. If a secret exists here creating a new secret will overwrite it."
data-test-warning-no-read-permissions
/>
{{/unless}}
<NamespaceReminder @mode="edit" @noun="secret" />
{{#if this.isCreateNewVersionFromOldVersion}}
<div class="form-section">
<AlertBanner
@type="warning"
@class="is-marginless"
@message="You are creating a new version based on data from Version {{@model.selectedVersion.version}}. The current version for {{@model.id}} is Version {{@model.currentVersion}}."
/>
</div>
{{/if}}
{{#if @showAdvancedMode}}
<div class="form-section">
<JsonEditor
@title={{if @isV2 "Version Data" "Secret Data"}}
@value={{this.codemirrorString}}
@valueUpdated={{action "codemirrorUpdated"}}
@onFocusOut={{action "formatJSON"}}
/>
</div>
{{else}}
<div class="form-section">
<label class="title is-5">
{{#if @isV2}}
Version data
{{else}}
Secret data
{{/if}}
</label>
{{#each @secretData as |secret index|}}
<div class="columns is-variable has-no-shadow">
<div class="column is-one-quarter">
<Input
data-test-secret-key={{true}}
@value={{secret.name}}
placeholder="key"
{{on "change" (action "handleChange")}}
class="input"
autocomplete="off"
spellcheck="false"
/>
</div>
<div class="column">
<MaskedInput
@name={{secret.name}}
@onKeyDown={{action "handleKeyDown"}}
@onChange={{action "handleChange"}}
@value={{secret.value}}
data-test-secret-value="true"
/>
</div>
<div class="column is-narrow">
{{#if (eq @secretData.length (inc index))}}
<button
type="button"
{{action "addRow"}}
class="button is-outlined is-primary"
data-test-secret-add-row="true"
>
Add
</button>
{{else}}
<button
class="button has-text-grey is-expanded is-icon"
type="button"
{{action "deleteRow" secret.name}}
aria-label="Delete row"
>
<Icon @name="trash" class="has-text-grey-light" />
</button>
{{/if}}
</div>
</div>
{{/each}}
</div>
{{/if}}
</div>
<div class="field is-grouped is-grouped-split is-fullwidth box is-bottomless">
<div class="field is-grouped">
<div class="control">
<button
data-test-secret-save
type="submit"
disabled={{or @buttonDisabled this.validationErrorCount}}
class="button is-primary"
>
Save
</button>
</div>
<div class="control">
<SecretLink
@mode="show"
@secret={{@model.id}}
@class="button"
@queryParams={{query-params version=@modelForData.version}}
>
Cancel
</SecretLink>
</div>
</div>
</div>
</form>
{{/if}}