2021-08-31 15:41:41 +00:00
{{ # if ( eq @ mode "create" ) }}
2021-12-17 03:44:29 +00:00
<form class= {{ if @ showAdvancedMode "advanced-edit" "simple-edit" }} onsubmit= {{ action "createOrUpdateKey" @ mode }} >
2021-08-31 15:41:41 +00:00
<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">
2021-12-17 03:44:29 +00:00
<Input
autocomplete="off"
spellcheck="false"
2021-08-31 15:41:41 +00:00
data-test-secret-path="true"
2021-12-17 03:44:29 +00:00
id="kv-key"
class="input {{ if ( get this .validationMessages "path" ) "has-error-border" }} "
2021-08-31 15:41:41 +00:00
@value= {{ get @ modelForData @ modelForData .pathAttr }}
{{ on "keyup" ( perform this .waitForKeyUp "path" value = "target.value" ) }}
/>
</p>
2021-12-17 03:44:29 +00:00
{{ # if ( get this .validationMessages "path" ) }}
<AlertInline
@type="danger"
@message= {{ get this .validationMessages "path" }}
@paddingTop= {{ true }}
@isMarginless= {{ true }}
2021-08-31 15:41:41 +00:00
/>
{{ / if }}
{{ # if @ modelForData .isFolder }}
<p class="help is-danger">
2021-12-17 03:44:29 +00:00
The secret path may not end in
<code>/</code>
2021-08-31 15:41:41 +00:00
</p>
{{ / if }}
2021-10-28 16:50:33 +00:00
{{ # 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."
2021-12-17 03:44:29 +00:00
@marginTop= {{ true }}
2021-10-28 16:50:33 +00:00
data-test-whitespace-warning
/>
</div>
2021-12-17 03:44:29 +00:00
{{ / if }}
2021-08-31 15:41:41 +00:00
</div>
{{ # if @ showAdvancedMode }}
<div class="form-section">
<JsonEditor
@title= {{ if @ isV2 "Version Data" "Secret Data" }}
@value= {{ this .codemirrorString }}
@valueUpdated= {{ action "codemirrorUpdated" }}
2021-12-17 03:44:29 +00:00
@onFocusOut= {{ action "formatJSON" }}
/>
2021-08-31 15:41:41 +00:00
</div>
{{ else }}
<div class="form-section">
<label class="title is-5">
Secret data
</label>
2021-12-17 03:44:29 +00:00
{{ # each @ secretData as | secret in dex | }}
<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 ( in c in dex ) ) }}
<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>
2021-08-31 15:41:41 +00:00
</div>
2021-12-17 03:44:29 +00:00
{{ # if this .validationMessages .key }}
<AlertInline
@type="danger"
@message= {{ this .validationMessages .key }}
@paddingTop= {{ true }}
@isMarginless= {{ true }}
2021-08-31 15:41:41 +00:00
/>
2021-12-17 03:44:29 +00:00
{{ / if }}
{{ / each }}
2021-08-31 15:41:41 +00:00
</div>
{{ / if }}
2021-12-17 03:44:29 +00:00
{{! 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
/>
2021-08-31 15:41:41 +00:00
{{ # if this .showMetadata }}
<SecretEditMetadata
@model= {{ @ model }}
@mode="create"
@updateValidationErrorCount= {{ action "updateValidationErrorCount" }}
/>
{{ / if }}
2021-12-17 03:44:29 +00:00
{{ / if }}
2021-08-31 15:41:41 +00:00
<div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control">
<button
2021-12-17 03:44:29 +00:00
type="submit"
disabled= {{ or @ buttonDisabled this .validationErrorCount this .error }}
class="button is-primary"
data-test-secret-save= {{ true }}
2021-08-31 15:41:41 +00:00
>
Save
</button>
</div>
<div class="control">
<SecretLink @mode="list" @secret= {{ @ model .parentKey }} @class="button">
Cancel
</SecretLink>
</div>
</div>
</form>
{{ / if }}
{{ # if ( eq @ mode "edit" ) }}
2021-12-17 03:44:29 +00:00
{{! no metadata option because metadata is version agnostic }}
2021-08-31 15:41:41 +00:00
<form onsubmit= {{ action "createOrUpdateKey" "edit" }} >
2021-09-03 17:08:26 +00:00
<div class="box is-sideless is-fullwidth is-marginless padding-top">
2021-10-12 19:42:04 +00:00
<MessageError @model= {{ @ modelForData }} @errorMessage= {{ this .error }} />
{{ # unless @ canReadSecretData }}
2021-09-03 17:08:26 +00:00
<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
/>
2021-10-12 19:42:04 +00:00
{{ / unless }}
2021-08-31 15:41:41 +00:00
<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" }}
2021-12-17 03:44:29 +00:00
@onFocusOut= {{ action "formatJSON" }}
/>
2021-08-31 15:41:41 +00:00
</div>
{{ else }}
<div class="form-section">
<label class="title is-5">
{{ # if @ isV2 }}
Version data
{{ else }}
Secret data
{{ / if }}
</label>
2021-12-17 03:44:29 +00:00
{{ # each @ secretData as | secret in dex | }}
<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 ( in c in dex ) ) }}
<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>
2021-08-31 15:41:41 +00:00
</div>
2021-12-17 03:44:29 +00:00
{{ / each }}
2021-08-31 15:41:41 +00:00
</div>
{{ / if }}
2021-12-17 03:44:29 +00:00
</div>
2021-08-31 15:41:41 +00:00
<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">
2021-12-17 03:44:29 +00:00
<SecretLink
@mode="show"
@secret= {{ @ model .id }}
@class="button"
@queryParams= {{ query-params version = @ modelForData .version }}
>
2021-08-31 15:41:41 +00:00
Cancel
</SecretLink>
</div>
</div>
</div>
</form>
2021-12-17 03:44:29 +00:00
{{ / if }}