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

<PkiPageHeader @backend={{this.model.parentModel}} />

<PkiPaginatedList
  @backend={{this.model.parentModel.id}}
  @listRoute="certificates.index"
  @list={{this.model.certificates}}
  @hasConfig={{this.model.hasConfig}}
>
  <:list as |certs|>
    {{#each certs as |pkiCertificate|}}
      <LinkedBlock
        class="list-item-row"
        @params={{array "certificates.certificate.details" this.model.parentModel.id pkiCertificate.id}}
        @linkPrefix={{this.mountPoint}}
      >
        <div class="level is-mobile">
          <div class="level-left">
            <div>
              <Icon @name="certificate" class="has-text-grey-light" />
              <span class="has-text-weight-semibold is-underline">
                {{pkiCertificate.id}}
              </span>
              <div class="is-flex-row has-left-margin-l has-top-margin-xs">
              </div>
            </div>
          </div>
          <div class="level-right is-flex is-paddingless is-marginless">
            <div class="level-item">
              <Hds::Dropdown @isInline={{true}} @listPosition="bottom-right" as |dd|>
                <dd.ToggleIcon
                  @icon="more-horizontal"
                  @text="Manage certificate"
                  @hasChevron={{false}}
                  data-test-popup-menu-trigger
                />
                <dd.Interactive @text="Details" @route="certificates.certificate.details" @model={{pkiCertificate.id}} />
              </Hds::Dropdown>
            </div>
          </div>
        </div>
      </LinkedBlock>
    {{/each}}
  </:list>
  <:empty>
    <EmptyState
      @title="No certificates yet"
      @message="When created, certificates will be listed here. Select a role to start generating certificates"
    />
  </:empty>
  <:configure>
    <EmptyState @title="PKI not configured" @message={{this.notConfiguredMessage}}>
      <Hds::Link::Standalone
        @icon="chevron-right"
        @iconPosition="trailing"
        @text="Configure PKI"
        @route="configuration.create"
        @model={{this.model.parentModel.id}}
      />
    </EmptyState>
  </:configure>
</PkiPaginatedList>