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

<Toolbar>
  <ToolbarActions>
    {{#if @credentials.deletePath.canDelete}}
      <ConfirmAction
        @buttonText="Revoke credentials"
        class="toolbar-button"
        @buttonColor="secondary"
        @onConfirmAction={{@onRevokeCredentials}}
        @confirmTitle="Revoke this?"
        @confirmMessage="Any client using these credentials will no longer be able to."
      />
      <div class="toolbar-separator"></div>
    {{/if}}
    <Hds::Copy::Button
      @text="Copy certificate"
      @textToCopy={{@credentials.certificate}}
      @onError={{(fn (set-flash-message "Clipboard copy failed. The Clipboard API requires a secure context." "danger"))}}
      class="toolbar-button"
      data-test-copy-button
    />
    <div class="toolbar-separator"></div>
    <ToolbarLink
      @route="credentials.index"
      @models={{array @credentials.scope @credentials.role}}
      data-test-kmip-link-back-to-role
    >
      Back to role
    </ToolbarLink>
  </ToolbarActions>
</Toolbar>

<div class="box is-shadowless is-fullwidth is-sideless">
  <InfoTableRow @label="Serial number" @value={{@credentials.id}}>
    <MaskedInput @value={{@credentials.id}} @displayOnly={{true}} @allowCopy={{true}} />
  </InfoTableRow>
  {{#if @credentials.privateKey}}
    <InfoTableRow @label="Private key" @value={{@credentials.privateKey}}>
      <div class="is-block">
        <Hds::Alert data-test-warning @type="inline" @color="warning" @class="has-bottom-margin-s" as |A|>
          <A.Title>Warning</A.Title>
          <A.Description>You will not be able to access the private key later, so please copy the information below.</A.Description>
        </Hds::Alert>
        <MaskedInput @value={{@credentials.privateKey}} @name="Private key" @allowCopy={{true}} @displayOnly={{true}} />
      </div>
    </InfoTableRow>
  {{/if}}
  <InfoTableRow @label="Certificate" @value={{@credentials.certificate}}>
    <MaskedInput @value={{@credentials.certificate}} @displayOnly={{true}} @allowCopy={{true}} />
  </InfoTableRow>
  <InfoTableRow @label="CA Chain" @value={{@credentials.caChain}}>
    <div class="is-block">
      {{#each @credentials.caChain as |chain|}}
        <MaskedInput @value={{chain}} @displayOnly={{true}} @allowCopy={{true}} />
      {{/each}}
    </div>
  </InfoTableRow>
</div>