{{#if (has-feature "Namespaces")}}
  <PageHeader as |p|>
    <p.levelLeft>
      <h1 class="title is-3">
        Namespaces
      </h1>
    </p.levelLeft>
    <p.levelRight>
      {{#link-to 'vault.cluster.access.namespaces.create' class="button has-icon-right is-ghost is-compact"}}
        Create a namespace
        <ICon @glyph="chevron-right" @size=11 />
      {{/link-to}}
    </p.levelRight>
  </PageHeader>
  <ListView @items={{model}} @itemNoun="namespace" as |list|>
    <ListItem as |Item|>
      <Item.content>
        {{list.item.id}}
      </Item.content>
      <Item.menu>
        {{#with (concat currentNamespace (if currentNamespace "/") list.item.id) as |targetNamespace|}}
          {{#if (contains targetNamespace accessibleNamespaces)}}
            <li class="action">
              {{#link-to "vault.cluster.secrets" (query-params namespace=targetNamespace) class="is-block"}}
                Switch to namespace
              {{/link-to}}
            </li>
          {{/if}}
        {{/with}}
        <li class="action">
          <ConfirmAction
            @confirmButtonClasses="button is-primary"
            @confirmButtonText="Remove"
            @buttonClasses="link is-destroy"
            @onConfirmAction={{action
              (perform
                Item.callMethod
                "destroyRecord"
                list.item
                (concat "Successfully deleted namespace: " list.item.id)
                "There was an error deleting this namespace: "
                (action "refreshNamespaceList")
              )
            }}
            @confirmMessage={{concat "Are you sure you want to delete " list.item.id "?"}}
            @showConfirm={{get this (concat "shouldDelete-" list.item.id)}}
            @class={{if (get this (concat "shouldDelete-" list.item.id)) "message is-block is-warning is-outline"}}
            @containerClasses="message-body is-block"
            @messageClasses="is-block"
          >
            Delete
          </ConfirmAction>
        </li>
      </Item.menu>
    </ListItem>
  </ListView>
{{else}}
  <UpgradePage @title="Namespaces" @minimumEdition="Vault Enterprise Pro" />
{{/if}}
