{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<KvPageHeader @breadcrumbs={{@breadcrumbs}} @pageTitle={{@path}}>
  <:tabLinks>
    <LinkTo @route="secret.details" data-test-secrets-tab="Secret">Secret</LinkTo>
    <LinkTo @route="secret.metadata.index" data-test-secrets-tab="Metadata">Metadata</LinkTo>
    <LinkTo @route="secret.paths" data-test-secrets-tab="Paths">Paths</LinkTo>
    {{#if @canReadMetadata}}
      <LinkTo @route="secret.metadata.versions" data-test-secrets-tab="Version History">Version History</LinkTo>
    {{/if}}
  </:tabLinks>
</KvPageHeader>

<h2 class="title is-5 has-top-margin-xl">
  Paths
</h2>

<div class="box is-fullwidth is-sideless is-paddingless is-marginless">
  {{#each this.paths as |path|}}
    <InfoTableRow @label={{path.label}} @labelWidth="is-one-third" @helperText={{path.text}} @truncateValue={{true}}>
      {{! replace with Hds::Copy::Snippet }}
      <CopyButton
        class="button is-compact is-transparent level-right"
        @clipboardText={{path.snippet}}
        @buttonType="button"
        @success={{fn (set-flash-message (concat path.label " copied!"))}}
      >
        <Icon @name="clipboard-copy" aria-label="Copy" />
      </CopyButton>
      <code class="is-flex-1 text-overflow-ellipsis has-left-margin-s">
        {{path.snippet}}
      </code>
    </InfoTableRow>
  {{/each}}
</div>

<h2 class="title is-5 has-top-margin-xl">
  Commands
</h2>

<div class="box is-fullwidth is-sideless">
  <h3 class="is-label">
    CLI
    <Hds::Badge @text="kv get" @color="neutral" />
  </h3>
  <p class="helper-text has-text-grey has-bottom-padding-s">
    This command retrieves the value from KV secrets engine at the given key name. For other CLI commands,
    <DocLink @path="/vault/docs/commands/kv">
      learn more.
    </DocLink>
  </p>
  <CodeSnippet data-test-commands="cli" @codeBlock={{this.commands.cli}} />

  <h3 class="has-top-margin-l is-label">
    API read secret version
  </h3>
  <p class="helper-text has-text-grey has-bottom-padding-s">
    This command obtains data and metadata for the latest version of this secret. In this example, Vault is located at
    https://127.0.0.1:8200. For other API commands,
    <DocLink @path="/vault/api-docs/secret/kv/kv-v2">
      learn more.
    </DocLink>
  </p>
  <CodeSnippet data-test-commands="api" @clipboardCode={{this.commands.apiCopy}} @codeBlock={{this.commands.apiDisplay}} />
</div>