{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
}}

<Route
  @name={{this.routeName}}
as |route|>
  <DataLoader @src={{
    uri '/${partition}/${nspace}/${dc}/auth-method/${name}'
      (hash
        partition=route.params.partition
        nspace=route.params.nspace
        dc=route.params.dc
        name=route.params.id
      )
    }}
  as |loader|>

    <BlockSlot @name="error">
      {{#if (eq loader.error.status '401')}}
        <Consul::Acl::Disabled />
      {{else}}
        <AppError
          @error={{loader.error}}
          @login={{route.model.app.login.open}}
        />
      {{/if}}
    </BlockSlot>

    <BlockSlot @name="loaded">
{{#let
  loader.data
as |item|}}
  <AppView>
      <BlockSlot @name="breadcrumbs">
          <ol>
              <li><a data-test-back href={{href-to 'dc.acls.auth-methods'}}>All Auth Methods</a></li>
          </ol>
      </BlockSlot>
      <BlockSlot @name="header">
        <h1>
          <route.Title @title={{item.Name}} />
        </h1>
        <Consul::AuthMethod::Type @item={{item}} />
      </BlockSlot>
      <BlockSlot @name="nav">
        <TabNav @items={{
          compact
            (array
              (hash label="General info" href=(href-to "dc.acls.auth-methods.show.auth-method") selected=(is-href "dc.acls.auth-methods.show.auth-method"))
        (if (can "use nspaces")
              (hash label="Namespace rules" href=(href-to "dc.acls.auth-methods.show.nspace-rules") selected=(is-href "dc.acls.auth-methods.show.nspace-rules"))
        '')
              (hash label="Binding rules" href=(href-to "dc.acls.auth-methods.show.binding-rules") selected=(is-href "dc.acls.auth-methods.show.binding-rules"))
            )
          }}
        />
      </BlockSlot>
      <BlockSlot @name="content">
        <Outlet
          @name={{this.routeName}}
          @model={{hash
            item=item
          }}
        as |o|>
          {{outlet}}
        </Outlet>
      </BlockSlot>
  </AppView>
{{/let}}
    </BlockSlot>
  </DataLoader>
</Route>