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

<Toolbar>
  <ToolbarActions>
    {{#if @canDelete}}
      <ConfirmAction
        class="toolbar-button"
        @buttonColor="secondary"
        @onConfirmAction={{this.deleteKey}}
        @confirmTitle="Delete key?"
        @buttonText="Delete"
        data-test-pki-key-delete
      />
      <div class="toolbar-separator"></div>
    {{/if}}
    {{#if @key.privateKey}}
      <DownloadButton
        class="toolbar-button"
        @color="secondary"
        @filename="{{@key.backend}}-{{or @key.keyName 'private-key'}}"
        @data={{@key.privateKey}}
        @extension="pem"
        @text="Download private key"
      />
    {{/if}}
    {{#if @canEdit}}
      <ToolbarLink @route="keys.key.edit" @models={{array @key.backend @key.keyId}} data-test-pki-key-edit>
        Edit key
      </ToolbarLink>
    {{/if}}
  </ToolbarActions>
</Toolbar>

<div class="box is-fullwidth is-sideless is-paddingless is-marginless">
  {{#if @key.privateKey}}
    <div class="has-top-margin-m">
      <Hds::Alert data-test-pki-key-next-steps @type="inline" @color="highlight" class="has-bottom-margin-s" as |A|>
        <A.Title>Next steps</A.Title>
        <A.Description>This private key material will only be available once. Copy or download it now.</A.Description>
      </Hds::Alert>
    </div>
  {{/if}}
  {{#each @key.formFields as |attr|}}
    <InfoTableRow
      @label={{capitalize (or attr.options.detailsLabel attr.options.label (humanize (dasherize attr.name)))}}
      @value={{get @key attr.name}}
      @addCopyButton={{eq attr.name "keyId"}}
    />
  {{/each}}
  {{#if @key.privateKey}}
    <InfoTableRow @label="Private key">
      <CertificateCard @data={{@key.privateKey}} />
    </InfoTableRow>
  {{/if}}
</div>