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

{{#let (options-for-backend @model.engineType) as |options|}}
  <PageHeader as |p|>
    <p.top>
      <Hds::Breadcrumb>
        <Hds::Breadcrumb::Item @text="Secrets" @route="vault.cluster.secrets" />
        <Hds::Breadcrumb::Item
          @text={{@model.id}}
          @current={{not @isConfigure}}
          @route="vault.cluster.secrets.backend.list-root"
          @model={{@model.id}}
        />
        {{#if @isConfigure}}
          <Hds::Breadcrumb::Item @text="Configure" @current={{true}} />
        {{/if}}
      </Hds::Breadcrumb>
    </p.top>
    <p.levelLeft>
      <h1 class="title is-3">
        <Icon @name={{@model.icon}} @size="24" class="has-text-grey-light" />
        {{@model.id}}
        {{#if this.isKV}}
          <span class="tag" data-test-kv-version-badge>
            version
            {{or @model.version "1"}}
          </span>
        {{/if}}
      </h1>

    </p.levelLeft>
  </PageHeader>
  {{#if options.tabs}}
    <div class="tabs-container box is-bottomless is-marginless is-fullwidth is-paddingless">
      <nav class="tabs" aria-label="secret tabs">
        <ul>
          {{#if options.hasOverview}}
            <li>
              <LinkTo @route="vault.cluster.secrets.backend.overview" @model={{@model.id}} data-test-tab="overview">
                Overview
              </LinkTo>
            </li>
          {{/if}}
          {{#each options.tabs as |oTab|}}
            <li>
              <SecretListHeaderTab
                @displayName={{options.displayName}}
                @id={{@model.id}}
                @path={{oTab.checkCapabilitiesPath}}
                @label={{oTab.label}}
                @tab={{or oTab.tab ""}}
              />
            </li>
          {{/each}}
          <li>
            <LinkTo
              @route="vault.cluster.secrets.backend.configuration"
              @model={{@model.id}}
              data-test-configuration-tab={{true}}
            >
              Configuration
            </LinkTo>
          </li>
        </ul>
      </nav>
    </div>
  {{else}}
    {{! if there are no tabs in the options, we'll hardcode them here }}
    <div class="tabs-container box is-bottomless is-marginless is-fullwidth is-paddingless">
      <nav class="tabs" aria-label="tabs">
        <ul>
          {{#if (includes @model.engineType (supported-secret-backends))}}
            <li>
              <LinkTo
                @route="vault.cluster.secrets.backend.list-root"
                @model={{@model.id}}
                @current-when="vault.cluster.secrets.backend.list-root vault.cluster.secrets.backend.list"
                data-test-tab={{@model.id}}
              >
                {{capitalize (pluralize options.item)}}
              </LinkTo>
            </li>
          {{/if}}
          <li>
            <LinkTo
              @route="vault.cluster.secrets.backend.configuration"
              @model={{@model.id}}
              data-test-configuration-tab={{true}}
            >
              Configuration
            </LinkTo>
          </li>
        </ul>
      </nav>
    </div>
  {{/if}}
{{/let}}