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

<Toolbar>
  <ToolbarActions>
    <ToolbarLink @route="vault.cluster.access.oidc.assignments.create" @type="add" data-test-oidc-assignment-create>
      Create assignment
    </ToolbarLink>
  </ToolbarActions>
</Toolbar>

{{#each this.model as |model|}}
  <LinkedBlock
    class="list-item-row {{if (eq model.name 'allow_all') 'is-disabled'}}"
    @params={{array "vault.cluster.access.oidc.assignments.assignment.details" model.name}}
    @disabled={{eq model.name "allow_all"}}
    data-test-oidc-assignment-linked-block={{model.name}}
  >
    <div class="level is-mobile">
      <div class="level-left">
        <div>
          <Icon @name="users" class="has-text-grey-light" />
          <span class="has-text-weight-semibold {{if (not-eq model.name 'allow_all') 'is-underline'}}">
            {{model.name}}
          </span>
          {{#if (eq model.name "allow_all")}}
            <div class="is-size-8">
              This is a built-in assignment that cannot be modified or deleted.
              <DocLink @path="/vault/docs/concepts/oidc-provider#assignments">
                Learn more
              </DocLink>
            </div>
          {{/if}}
        </div>
      </div>
      {{#if (not-eq model.name "allow_all")}}
        <div class="level-right is-flex is-paddingless is-marginless">
          <div class="level-item">
            <Hds::Dropdown @isInline={{true}} @listPosition="bottom-right" as |dd|>
              <dd.ToggleIcon
                @icon="more-horizontal"
                @text="Assignment nav options"
                @hasChevron={{false}}
                data-test-popup-menu-trigger
              />
              <dd.Interactive
                @route="vault.cluster.access.oidc.assignments.assignment.details"
                @model={{model.name}}
                @disabled={{eq model.canRead false}}
                data-test-oidc-assignment-menu-link="details"
              >Details</dd.Interactive>
              <dd.Interactive
                @route="vault.cluster.access.oidc.assignments.assignment.edit"
                @model={{model.name}}
                @disabled={{eq model.canEdit false}}
                data-test-oidc-assignment-menu-link="edit"
              >Edit</dd.Interactive>
            </Hds::Dropdown>
          </div>
        </div>
      {{/if}}
    </div>
  </LinkedBlock>
{{/each}}