{{!
  Copyright IBM Corp. 2016, 2025
  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 |cert|}}
      <LinkedBlock
        class="list-item-row"
        @params={{array "certificates.certificate.details" this.model.parentModel.id cert}}
        @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" aria-label="certificate serial number">
                {{cert}}
              </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 @route="certificates.certificate.details" @model={{cert}}>Details</dd.Interactive>
              </Hds::Dropdown>
            </div>
          </div>
        </div>
      </LinkedBlock>
    {{/each}}
  </:list>
  <:empty>
    <Hds::ApplicationState class="top-padding-32 is-marginless" as |A|>
      <A.Header @title="No certificates yet" @titleTag="h2" data-test-empty-state-title />
      <A.Body
        @text="When created, certificates will be listed here. Select a role to start generating certificates"
        data-test-empty-state-message
      />
    </Hds::ApplicationState>
  </:empty>
  <:configure>
    <Hds::ApplicationState class="top-padding-32 is-marginless" as |A|>
      <A.Header @title="PKI not configured" @titleTag="h2" data-test-empty-state-title />
      <A.Body @text={{this.notConfiguredMessage}} data-test-empty-state-message />
      <A.Footer data-test-empty-state-actions as |F|>
        <F.LinkStandalone
          @icon="chevron-right"
          @iconPosition="trailing"
          @text="Configure PKI"
          @route="configuration.create"
          @model={{this.model.parentModel.id}}
        />
      </A.Footer>
    </Hds::ApplicationState>
  </:configure>
</PkiPaginatedList>