<PageHeader as |p|>
  <p.levelLeft>
    <h1 class="title is-3">
      Authentication Methods
    </h1>
  </p.levelLeft>
  <p.levelRight>
    {{#link-to 'vault.cluster.settings.auth.enable' class="button has-icon-right is-ghost is-compact"}}
      Enable new method
      {{i-con glyph="chevron-right" size=11}}
    {{/link-to}}
  </p.levelRight>
</PageHeader>

{{#each (sort-by "path" model) as |method|}}
  <div
    class="list-item-row"
    data-test-auth-backend-link={{method.id}}
    >
    <div class="level is-mobile">
      <div class="level-left">
        <div>
          {{i-con glyph="folder" size=14 class="has-text-grey-light"}}
          <span data-test-path data-test-id={{method.id}} class="has-text-weight-semibold has-text-grey">
            {{method.path}}
          </span>
          <br />
          <span class="tag">
            {{#if (eq method.methodType 'plugin')}}
              {{method.methodType}}: {{method.config.plugin_name}}
            {{else}}
              {{method.methodType}}
            {{/if}}
          </span>
          <code class="has-text-grey is-size-8">
            {{method.accessor}}
          </code>
        </div>
      </div>
      <div class="level-right is-flex is-paddingless is-marginless">
        <div class="level-item">
          {{#popup-menu name="auth-backend-nav" contentClass="is-wide"}}
            <nav class="menu">
              <ul class="menu-list">
                <li>
                  {{#link-to "vault.cluster.access.method.section" method.id "configuration"}}
                    View Configuration
                  {{/link-to}}
                </li>
                {{#if method.canEdit}}
                  <li>
                    {{#link-to "vault.cluster.settings.auth.configure" method.id}}
                      Edit Configuration
                    {{/link-to}}
                  </li>
                {{/if}}

                {{#if (and (not-eq method.methodType 'token') method.canDisable)}}
                  <li class="action">
                    {{#confirm-action
                      confirmButtonClasses="button is-primary"
                      buttonClasses="link is-destroy"
                      onConfirmAction=(perform disableMethod method)
                      confirmMessage=(concat "Are you sure you want to disable auth via " method.id "?")
                      showConfirm=(get this (concat "shouldDelete-" method.id))
                      class=(if (get this (concat "shouldDelete-" method.id)) "message is-block is-warning is-outline")
                      containerClasses="message-body is-block"
                      messageClasses="is-block"
                      confirmButtonText="Disable"
                    }}
                      Disable
                    {{/confirm-action}}
                  </li>
                {{/if}}
              </ul>
            </nav>
          {{/popup-menu}}
        </div>
      </div>
    </div>
  </div>
{{/each}}
