<form onsubmit={{action "createOrUpdateKey" "update"}} onchange={{action "handleChange"}}>
  <div class="box is-sideless is-fullwidth is-marginless">
    {{message-error model=key}}
    <NamespaceReminder @mode="edit" @noun="secret" />
    {{#unless showAdvancedMode}}
      <div class="table info-table-row-header">
        <div class="info-table-row thead">
          <div class="th column is-one-quarter">
            Key
          </div>
          <div class="th column">
            Value
          </div>
        </div>
      </div>
    {{/unless}}
  </div>
  {{#if capabilities.canUpdate}}
    {{partial "partials/secret-edit-display"}}
  {{else}}
    <div class="field is-horizontal box is-sideless is-marginless">
      <div class="content">
        <p>Your current token does not have capabilities to update this secret.</p>
        <p>
          {{#secret-link
            mode=(if key.isFolder "list" "show")
            secret=key.id
            class="button"
          }}
          Back to <code>{{key.id}}</code>
          {{/secret-link}}
        </p>
      </div>
    </div>
  {{/if}}

  <div class="field is-grouped is-grouped-split is-fullwidth box is-bottomless">
    <div class="field is-grouped">
      {{#unless key.isFolder}}
        {{#if capabilities.canUpdate}}
          <div class="control">
            <button
              type="submit"
              disabled={{buttonDisabled}}
              class="button is-primary"
            >
             Save
            </button>
          </div>
        {{/if}}
      {{/unless}}
      <div class="control">
        {{#secret-link
          mode=(if key.isFolder "list" "show")
          secret=key.id
          class="button"
        }}
          Cancel
        {{/secret-link}}
      </div>
    </div>
    {{#if capabilities.canDelete}}
      {{#confirm-action
        buttonClasses="button"
        onConfirmAction=(action "deleteKey")
        confirmMessage=(if key.isFolder
          (concat "Are you sure you want to delete " key.id " and all its contents?")
          (concat "Are you sure you want to delete " key.id "?")
        )
        cancelButtonText="Cancel"
        data-test-secret-delete="true"
      }}
        {{#if key.isFolder}}
          Delete folder
        {{else}}
          Delete secret
        {{/if}}
      {{/confirm-action}}
    {{/if}}
  </div>
</form>
