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

<Route
  @name={{routeName}}
as |route|>
  <DataLoader @src={{
    uri '/${partition}/${nspace}/${dc}/role/${id}'
      (hash
        partition=route.params.partition
        nspace=route.params.nspace
        dc=route.params.dc
        id=(or 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

  route.params.dc
  route.params.partition
  route.params.nspace

  loader.data
  loader.data.isNew
as |dc partition nspace item create|}}
  <AppView
    @login={{route.model.app.login.open}}
    >
      <BlockSlot @name="breadcrumbs">
          <ol>
              <li><a data-test-back href={{href-to 'dc.acls.roles'}}>All Roles</a></li>
          </ol>
      </BlockSlot>
      <BlockSlot @name="header">
          <h1>
    {{#if create }}
              <route.Title @title="New Role" />
    {{else}}
              <route.Title @title="Edit Role" />
    {{/if}}
          </h1>
      </BlockSlot>
      <BlockSlot @name="content">
  {{#if (not create) }}
        <div class="definition-table">
            <dl>
              <dt>Role ID</dt>
              <dd>
                <CopyableCode
                  @value={{item.ID}}
                  @name="Role ID"
                />
              </dd>
            </dl>
        </div>
  {{/if}}
        {{ partial 'dc/acls/roles/form'}}
      </BlockSlot>
  </AppView>
{{/let}}
    </BlockSlot>
  </DataLoader>
</Route>