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

<SecretListHeader
  @isCertTab={{eq this.tab "cert"}}
  @model={{this.model}}
  @baseKey={{this.baseKey}}
  @backendCrumb={{this.backendCrumb}}
  @filter={{this.filter}}
/>

{{#if this.showEmptyState}}
  <div class="box is-fullwidth is-shadowless is-sideless is-paddingless is-marginless">
    <Toolbar />
    <EmptyState @title="Connect a database" @message={{this.emptyStateMessage}}>
      {{#if (or this.model.connectionCapabilities.canCreate this.model.connectionCapabilities.canUpdate)}}
        <Hds::Link::Standalone
          @icon="plus"
          @text="Connect a database"
          @query={{hash itemType="connection"}}
          @route="vault.cluster.secrets.backend.create-root"
          data-test-secret-create="connections"
        />
      {{/if}}
    </EmptyState>
  </div>
{{else}}
  <div class="box is-fullwidth is-shadowless has-tall-padding">
    <div class="selectable-card-container {{if (and (eq this.model.connections 403) (eq this.model.roles 403)) 'one-card'}}">
      {{#if this.model.connectionCapabilities.canList}}
        <OverviewCard
          @cardTitle="Connections"
          @subText="The total number of connections to external databases that you have access to."
        >
          <:action>
            <Hds::Link::Standalone
              @text="Configure new"
              @route="vault.cluster.secrets.backend.create-root"
              @query={{hash itemType="connection"}}
              @icon="plus"
              @iconPosition="trailing"
              data-test-action-text="Configure new"
            />
          </:action>
          <:content>
            <Hds::Text::Display class="has-top-padding-m" @tag="h2" @size="500">
              {{format-number (if (eq this.model.connections 404) 0 this.model.connections.length)}}
            </Hds::Text::Display>
          </:content>
        </OverviewCard>
      {{/if}}
      {{#if (or this.model.roleCapabilities.canList this.model.staticRoleCapabilities.canList)}}
        <OverviewCard @cardTitle="Roles" @subText="The total number of roles configured that you have permissions to list.">
          <:action>
            <Hds::Link::Standalone
              @text="Create new"
              @route="vault.cluster.secrets.backend.create-root"
              @query={{hash itemType="role"}}
              @icon="plus"
              @iconPosition="trailing"
              data-test-action-text="Create new"
            />
          </:action>
          <:content>
            <Hds::Text::Display class="has-top-padding-m" @tag="h2" @size="500">
              {{format-number (if (eq this.model.roles 404) 0 this.model.roles.length)}}
            </Hds::Text::Display>
          </:content>
        </OverviewCard>
      {{/if}}
      <GetCredentialsCard
        @title="Get Credentials"
        @searchLabel="Role to use"
        @backend={{this.model.backend}}
        @models={{array "database/role"}}
      />
    </div>
  </div>
{{/if}}