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

<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>
  <InfoTableRow @label="Mount's API path" @value={{or @cluster.path "None"}} />
  <InfoTableRow @label="AIA path" @value={{or @cluster.aia_path "None"}} />
{{/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>
  <InfoTableRow @label="ACME enabled" @value={{or @acme.enabled "None"}} />
  <InfoTableRow @label="Default directory policy" @value={{or @acme.default_directory_policy "None"}} />
  <InfoTableRow @label="Allowed roles" @value={{or @acme.allowed_roles "None"}} />
  <InfoTableRow @label="Allow role ExtKeyUsage" @value={{or @acme.allow_role_ext_key_usage "None"}} />
  <InfoTableRow @label="Allowed issuers" @value={{or @acme.allowed_issuers "None"}} />
  <InfoTableRow @label="EAB policy" @value={{or @acme.eab_policy "None"}} />
  <InfoTableRow @label="DNS resolver" @value={{or @acme.dns_resolver "None"}} />
  <InfoTableRow @label="Max TTL" @value={{or @acme.max_ttl "None"}} @formatTtl={{true}} />
{{/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.issuing_certificates "None"}} />
  <InfoTableRow @label="CRL distribution points" @value={{or @urls.crl_distribution_points "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.auto_rebuild "icon-true" "icon-false"}}
        @name={{if @crl.auto_rebuild "check-circle" "x-square"}}
      />
      {{if @crl.auto_rebuild "On" "Off"}}
    </InfoTableRow>
    {{#if @crl.auto_rebuild}}
      <InfoTableRow @label="Auto-rebuild grace period" @value={{@crl.auto_rebuild_grace_period}} />
    {{/if}}
    <InfoTableRow @label="Delta CRL building">
      <Icon
        class={{if @crl.enable_delta "icon-true" "icon-false"}}
        @name={{if @crl.enable_delta "check-circle" "x-square"}}
      />
      {{if @crl.enable_delta "On" "Off"}}
    </InfoTableRow>
    {{#if @crl.enable_delta}}
      <InfoTableRow @label="Delta rebuild interval" @value={{@crl.delta_rebuild_interval}} />
    {{/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.ocsp_disable "Disabled" "Enabled"}} />
  {{#unless @crl.ocsp_disable}}
    <InfoTableRow @label="Interval" @value={{@crl.ocsp_expiry}} />
  {{/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.cross_cluster_revocation}} />
    <InfoTableRow @label="Unified CRL" @value={{@crl.unified_crl}} />
    <InfoTableRow @label="Unified CRL on existing paths" @value={{@crl.unified_crl_on_existing_paths}} />
  {{/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}}