{{!
  Copyright IBM Corp. 2016, 2025
  SPDX-License-Identifier: BUSL-1.1
}}

{{#if @hasConfig}}
  <Toolbar aria-label="PKI configuration">
    <ToolbarActions aria-label="actions for PKI configuration">
      {{#if @canDeleteAllIssuers}}
        <Hds::Button
          @text="Delete all issuers"
          @color="secondary"
          class="toolbar-button"
          {{on "click" (fn (mut this.showDeleteAllIssuers) true)}}
          data-test-delete-all-issuers-link
        />
        <div class="toolbar-separator"></div>
      {{/if}}
      <ToolbarLink @route="configuration.edit" @model={{@backend}}>
        Edit configuration
      </ToolbarLink>
    </ToolbarActions>
  </Toolbar>

  {{#if (not-eq @cluster 403)}}
    <h2 class="title is-4 has-bottom-margin-xs has-top-margin-xl has-border-bottom-light has-bottom-padding-s">
      Cluster Config
    </h2>
    {{#each @cluster.allFields as |attr|}}
      <InfoTableRow
        @label={{or attr.options.label (humanize (dasherize attr.name))}}
        @value={{or (get @cluster attr.name) "None"}}
      />
    {{/each}}
  {{/if}}

  {{#if (not-eq @acme 403)}}
    <h2 class="title is-4 has-bottom-margin-xs has-top-margin-xl has-border-bottom-light has-bottom-padding-s">
      ACME Config
    </h2>
    {{#each @acme.allFields as |attr|}}
      <InfoTableRow
        @label={{or attr.options.label (humanize (dasherize attr.name))}}
        @value={{or (get @acme attr.name) "None"}}
        @formatTtl={{eq attr.options.editType "ttl"}}
      />
    {{/each}}
  {{/if}}

  {{#if (not-eq @urls 403)}}
    <h2 class="title is-4 has-bottom-margin-xs has-top-margin-xl has-border-bottom-light has-bottom-padding-s">
      Global URLs
    </h2>
    <InfoTableRow @label="Issuing certificates" @value={{or @urls.issuingCertificates "None"}} />
    <InfoTableRow
      @label="CRL distribution points"
      @value={{if @urls.crlDistributionPoints @urls.crlDistributionPoints "None"}}
    />
  {{/if}}

  {{#if (not-eq @crl 403)}}
    <h2 class="title is-4 has-bottom-margin-xs has-top-margin-xl has-border-bottom-light has-bottom-padding-s">
      Certificate Revocation List (CRL)
    </h2>
    <InfoTableRow @label="CRL building" @value={{if @crl.disable "Disabled" "Enabled"}} />
    {{#unless @crl.disable}}
      <InfoTableRow @label="Expiry" @value={{@crl.expiry}} />
      <InfoTableRow @label="Auto-rebuild">
        <Icon
          class={{if @crl.autoRebuild "icon-true" "icon-false"}}
          @name={{if @crl.autoRebuild "check-circle" "x-square"}}
        />
        {{if @crl.autoRebuild "On" "Off"}}
      </InfoTableRow>
      {{#if @crl.autoRebuild}}
        <InfoTableRow @label="Auto-rebuild grace period" @value={{@crl.autoRebuildGracePeriod}} />
      {{/if}}
      <InfoTableRow @label="Delta CRL building">
        <Icon
          class={{if @crl.enableDelta "icon-true" "icon-false"}}
          @name={{if @crl.enableDelta "check-circle" "x-square"}}
        />
        {{if @crl.enableDelta "On" "Off"}}
      </InfoTableRow>
      {{#if @crl.enableDelta}}
        <InfoTableRow @label="Delta rebuild interval" @value={{@crl.deltaRebuildInterval}} />
      {{/if}}
    {{/unless}}
    <h2 class="title is-4 has-bottom-margin-xs has-top-margin-xl has-border-bottom-light has-bottom-padding-s">
      Online Certificate Status Protocol (OCSP)
    </h2>
    <InfoTableRow @label="Responder APIs" @value={{if @crl.ocspDisable "Disabled" "Enabled"}} />
    {{#unless @crl.ocspDisable}}
      <InfoTableRow @label="Interval" @value={{@crl.ocspExpiry}} />
    {{/unless}}

    {{#if this.isEnterprise}}
      <h2 class="title is-4 has-bottom-margin-xs has-top-margin-xl has-border-bottom-light has-bottom-padding-s">
        Unified Revocation
      </h2>
      <InfoTableRow @label="Cross-cluster revocation" @value={{@crl.crossClusterRevocation}} />
      <InfoTableRow @label="Unified CRL" @value={{@crl.unifiedCrl}} />
      <InfoTableRow @label="Unified CRL on existing paths" @value={{@crl.unifiedCrlOnExistingPaths}} />
    {{/if}}
  {{/if}}
{{/if}}

<div class="has-top-margin-m"></div>

{{#if this.showDeleteAllIssuers}}
  <ConfirmationModal
    @title="Delete all issuers?"
    @toConfirmMsg="deleting all issuers and keys."
    @confirmText="delete-all"
    @isActive={{this.showDeleteAllIssuers}}
    @onClose={{action (mut this.showDeleteAllIssuers) false}}
    @onConfirm={{this.deleteAllIssuers}}
  >
    <p>
      This endpoint deletes
      <strong>all</strong>
      issuers and keys within the mount. It is highly recommended to use the individual delete operations instead. This mount
      will be unusable until new issuers and keys are provisioned.
    </p>
  </ConfirmationModal>
{{/if}}