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

<Page::Header @title={{this.model.id}}>
  <:breadcrumbs>
    <Page::Breadcrumbs
      @breadcrumbs={{array
        (hash label="Vault" route="vault.cluster.dashboard" icon="vault")
        (hash label=(concat (uppercase this.policyType) " policies") route="vault.cluster.policies" model=this.policyType)
        (hash label=this.model.id route="vault.cluster.policy.show" model=this.model.id)
        (hash label="Edit")
      }}
    />
  </:breadcrumbs>
  <:badges>
    {{#if this.model.enforcementLevel}}
      <Hds::Badge @text={{this.model.enforcementLevel}} aria-label="Enforcement level: {{this.model.enforcementLevel}}" />
    {{/if}}
  </:badges>
</Page::Header>

{{#if (and (not-eq this.model.id "root") (or this.model.canUpdate this.model.canDelete))}}
  <Toolbar>
    <ToolbarActions>
      {{#if (and (not-eq this.model.id "default") this.model.canDelete)}}
        <ConfirmAction
          @buttonText="Delete policy"
          class="toolbar-button"
          @buttonColor="secondary"
          @confirmMessage="Deleting this policy may affect access to Vault data."
          @onConfirmAction={{this.deletePolicy}}
        />
        <div class="toolbar-separator"></div>
      {{/if}}
      <ToolbarLink @route="vault.cluster.policy.show" @model={{this.model.id}} data-test-button="Back to policy">
        Back to policy
      </ToolbarLink>
    </ToolbarActions>
  </Toolbar>
{{/if}}

<PolicyForm
  @model={{this.model}}
  @onSave={{transition-to "vault.cluster.policy.show" this.model.policyType this.model.name}}
  @onCancel={{transition-to "vault.cluster.policy.show" this.model.policyType this.model.name}}
/>