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

<Hds::AppSideNav::Portal
  @ariaLabel="Access Navigation Links"
  tabindex="0"
  role="region"
  data-test-sidebar-nav-panel="Access control"
  as |Nav|
>
  <Nav.BackLink
    @route="vault.cluster"
    @current-when={{false}}
    @icon="arrow-left"
    @text="Back to main navigation"
    data-test-sidebar-nav-link="Back to main navigation"
  />

  {{! Policies }}
  {{#if (or (has-permission "policies") (has-permission "access"))}}
    <Nav.Title data-test-sidebar-nav-heading="Access control">Access control</Nav.Title>
  {{/if}}
  {{#if (has-permission "policies")}}
    {{#if (has-permission "policies" routeParams="acl")}}
      <Nav.Link
        @route="vault.cluster.policies"
        @model="acl"
        @current-when="vault.cluster.policies vault.cluster.policy"
        @text="ACL policies"
        data-test-sidebar-nav-link="ACL policies"
      />
    {{/if}}
    {{#if (and (has-feature "Sentinel") (has-permission "policies" routeParams="rgp"))}}
      <Nav.Link
        @route="vault.cluster.policies"
        @model="rgp"
        @current-when="vault.cluster.policies vault.cluster.policy"
        @text="Role governing policies"
        data-test-sidebar-nav-link="Role governing policies"
      />
    {{/if}}
    {{#if (and (has-feature "Sentinel") (has-permission "policies" routeParams="egp"))}}
      <Nav.Link
        @route="vault.cluster.policies"
        @model="egp"
        @current-when="vault.cluster.policies vault.cluster.policy"
        @text="Endpoint governing policies"
        data-test-sidebar-nav-link="Endpoint governing policies"
      />
    {{/if}}
  {{/if}}

  {{#if (has-permission "access")}}
    {{#if (and (has-feature "Control Groups") (has-permission "access" routeParams="control-groups"))}}
      <Nav.Link
        @route="vault.cluster.access.control-groups"
        @current-when="vault.cluster.access.control-groups vault.cluster.access.control-group-accessor vault.cluster.access.control-groups-configure"
        @text="Approval workflow"
        data-test-sidebar-nav-link="Approval workflow"
      />
    {{/if}}
    {{#if (has-permission "access" routeParams="leases")}}
      <Nav.Link @route="vault.cluster.access.leases" @text="Leases" data-test-sidebar-nav-link="Leases" />
    {{/if}}

    {{! Authentication }}
    {{#if (has-permission "access" routeParams=(array "methods" "mfa" "oidc"))}}
      <Nav.Title data-test-sidebar-nav-heading="Authentication">Authentication</Nav.Title>
    {{/if}}
    {{#if (has-permission "access" routeParams="methods")}}
      <Nav.Link
        @route="vault.cluster.access.methods"
        @current-when="vault.cluster.access.methods vault.cluster.access.method vault.cluster.settings.auth"
        @text="Authentication methods"
        data-test-sidebar-nav-link="Authentication methods"
      />
    {{/if}}
    {{#if (has-permission "access" routeParams="mfa")}}
      <Nav.Link
        @route="vault.cluster.access.mfa.methods"
        @current-when="vault.cluster.access.mfa.methods vault.cluster.access.mfa.enforcements vault.cluster.access.mfa.index"
        @text="Multi-factor authentication"
        data-test-sidebar-nav-link="Multi-factor authentication"
      />
    {{/if}}
    {{#if (has-permission "access" routeParams="oidc")}}
      <Nav.Link @route="vault.cluster.access.oidc" @text="OIDC provider" data-test-sidebar-nav-link="OIDC provider" />
    {{/if}}

    {{#if (has-permission "access" routeParams=(array "namespaces" "groups" "entities"))}}
      <Nav.Title data-test-sidebar-nav-heading="Organization">Organization</Nav.Title>
    {{/if}}
    {{#if (and (has-feature "Namespaces") (has-permission "access" routeParams="namespaces"))}}
      <Nav.Link @route="vault.cluster.access.namespaces" @text="Namespaces" data-test-sidebar-nav-link="Namespaces" />
    {{/if}}
    {{#if (has-permission "access" routeParams="groups")}}
      <Nav.Link @route="vault.cluster.access.identity" @model="groups" @text="Groups" data-test-sidebar-nav-link="Groups" />
    {{/if}}
    {{#if (has-permission "access" routeParams="entities")}}
      <Nav.Link
        @route="vault.cluster.access.identity"
        @model="entities"
        @text="Entities"
        data-test-sidebar-nav-link="Entities"
      />
    {{/if}}
  {{/if}}
</Hds::AppSideNav::Portal>