<SecretListHeader
  @model={{this.model.parentModel}}
  @backendCrumb={{hash
    label=this.model.parentModel.id
    text=this.model.parentModel.id
    path="vault.cluster.secrets.backend.list-root"
    model=this.model.parentModel.id
  }}
  @isEngine={{true}}
/>

<PkiPaginatedList @listRoute="roles.index" @list={{this.model.roles}} @hasConfig={{this.model.hasConfig}}>
  <:actions>
    {{#if this.model.hasConfig}}
      <ToolbarLink @type="add" @route="roles.create" data-test-pki-role-create-link>
        Create role
      </ToolbarLink>
    {{/if}}
  </:actions>
  <:list as |roles|>
    {{#each roles as |pkiRole|}}
      <LinkedBlock class="list-item-row" @params={{array "roles.role.details" pkiRole.id}} @linkPrefix={{this.mountPoint}}>
        <div class="level is-mobile">
          <div class="level-left">
            <div>
              <Icon @name="user" class="has-text-grey-light" />
              <span class="has-text-weight-semibold is-underline">
                {{pkiRole.id}}
              </span>
            </div>
          </div>
          <div class="level-right is-flex is-paddingless is-marginless">
            <div class="level-item">
              <PopupMenu>
                <nav class="menu">
                  <ul class="menu-list">
                    <li>
                      <LinkTo @route="roles.role.details" @model={{pkiRole.id}}>
                        Details
                      </LinkTo>
                    </li>
                    <li>
                      <LinkTo @route="roles.role.edit" @model={{pkiRole.id}}>
                        Edit
                      </LinkTo>
                    </li>
                  </ul>
                </nav>
              </PopupMenu>
            </div>
          </div>
        </div>
      </LinkedBlock>
    {{/each}}
  </:list>
  <:empty>
    <EmptyState @title="No roles yet">
      <div>
        <p>When created, roles will be listed here. Create a role to start generating certificates.</p>
        <div class="has-top-margin-m">
          <LinkTo @route="roles.create">
            Create role
          </LinkTo>
        </div>
      </div>
    </EmptyState>
  </:empty>
  <:configure>
    <EmptyState @title="PKI not configured" @message={{this.notConfiguredMessage}}>
      <LinkTo @route="configuration.create">
        Configure PKI
      </LinkTo>
    </EmptyState>
  </:configure>
</PkiPaginatedList>