{{!
  Copyright IBM Corp. 2016, 2025
  SPDX-License-Identifier: BUSL-1.1
}}

{{! template-lint-configure simple-unless "warn" }}
<Toolbar aria-label="manage secret">
  {{#unless (and (eq @mode "show") @isWriteWithoutRead)}}
    <ToolbarFilters aria-label="manage view">
      <Toggle
        @name="json"
        @disabled={{and (eq @mode "show") @secretDataIsAdvanced}}
        @checked={{@showAdvancedMode}}
        @onChange={{action @editActions.toggleAdvanced}}
      >
        <span class="has-text-grey">JSON</span>
      </Toggle>
    </ToolbarFilters>
  {{/unless}}
  <ToolbarActions aria-label="actions for {{@model.id}}">
    {{#if (and (eq @mode "show") @model.canDelete)}}
      <ConfirmAction
        @buttonText="Delete"
        class="toolbar-button"
        @buttonColor="secondary"
        @confirmTitle="Delete secret?"
        @confirmMessage="You will not be able to recover this secret data later."
        @onConfirmAction={{this.handleDelete}}
        data-test-secret-v1-delete
      />
      <div class="toolbar-separator"></div>
    {{/if}}
    {{#if (and (eq @mode "show") @canUpdateSecret)}}
      {{#unless (or @isWriteWithoutRead @modelForData.deleted)}}
        <CopySecretDropdown
          @clipboardText={{stringify @modelForData.secretData}}
          @onWrap={{perform this.wrapSecret}}
          @isWrapping={{this.wrapSecret.isRunning}}
          @wrappedData={{this.wrappedData}}
          @onClose={{this.clearWrappedData}}
        />
      {{/unless}}
    {{/if}}

    {{#if (and (eq @mode "show") @canUpdateSecret)}}
      {{#let (concat "vault.cluster.secrets.backend." (if (eq @mode "show") "edit" "show")) as |targetRoute|}}
        <ToolbarLink @route={{targetRoute}} @model={{@model.id}} @replace={{true}} data-test-secret-edit>
          Edit secret
        </ToolbarLink>
      {{/let}}
    {{/if}}
  </ToolbarActions>
</Toolbar>