Files
threshold-ui/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs
T
Carlos Alcaide Corvo c4539b8e30 Refactor auth-methods list acceptance test selectors (#2654)
Refactor auth-methods list acceptance test selectors
2025-01-22 14:32:16 -08:00

198 lines
6.4 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}
<Rose::Layout::Page as |page|>
<page.header>
<h2>
{{t 'resources.auth-method.title_plural'}}
<DocLink @doc='auth-method' @iconSize='large' />
</h2>
<p>{{t 'resources.auth-method.description'}}</p>
</page.header>
<page.breadcrumbs>
<Breadcrumbs::Container />
</page.breadcrumbs>
<page.actions>
{{#if (can 'create model' this.scopeModel collection='auth-methods')}}
<Hds::Dropdown data-test-new-dropdown as |dd|>
<dd.ToggleButton @text={{t 'titles.new'}} @color='secondary' />
<dd.Interactive
@route='scopes.scope.auth-methods.new'
@query={{hash type='password'}}
>{{t 'resources.auth-method.types.password'}}</dd.Interactive>
<dd.Interactive
@route='scopes.scope.auth-methods.new'
@query={{hash type='oidc'}}
>{{t 'resources.auth-method.types.oidc'}}</dd.Interactive>
{{#if (feature-flag 'ldap-auth-methods')}}
<dd.Interactive
@route='scopes.scope.auth-methods.new'
@query={{hash type='ldap'}}
>
{{t 'resources.auth-method.types.ldap'}}
</dd.Interactive>
{{/if}}
</Hds::Dropdown>
{{/if}}
</page.actions>
<page.body class='search-filtering'>
{{#if @model.doAuthMethodsExist}}
{{#unless this.hasPrimaryAuthMethod}}
<Hds::Alert
class='auth-methods-list-alert'
@type='inline'
@color='warning'
as |A|
>
<A.Title>
{{t 'resources.auth-method.messages.no-primary-auth-method.title'}}
</A.Title>
<A.Description>
{{t
'resources.auth-method.messages.no-primary-auth-method.description'
}}
</A.Description>
</Hds::Alert>
{{/unless}}
<Hds::SegmentedGroup as |S|>
<S.TextInput
@value={{this.search}}
@type='search'
placeholder={{t 'actions.search'}}
aria-label={{t 'actions.search'}}
{{on 'input' this.handleSearchInput}}
/>
<S.Generic>
<Dropdown
name='type'
@toggleText={{t 'form.type.label'}}
@itemOptions={{this.authMethodTypeOptions}}
@checkedItems={{this.types}}
@applyFilter={{fn this.applyFilter 'types'}}
/>
</S.Generic>
<S.Generic>
<Dropdown
name='primary'
@toggleText={{t 'resources.auth-method.titles.primary'}}
@itemOptions={{this.primaryOptions}}
@checkedItems={{this.primary}}
@applyFilter={{fn this.applyFilter 'primary'}}
/>
</S.Generic>
</Hds::SegmentedGroup>
<FilterTags @filters={{this.filters}} />
{{#if @model.authMethods}}
<Hds::Table
class='auth-methods-list-table'
@model={{@model.authMethods}}
@columns={{array
(hash label=(t 'form.name.label'))
(hash label=(t 'form.type.label'))
(hash label=(t 'form.id.label'))
(hash
label=(t 'resources.auth-method.titles.primary')
isVisuallyHidden=true
)
(hash label=(t 'titles.actions'))
}}
@density='short'
@valign='middle'
>
<:body as |B|>
<B.Tr data-test-auth-methods-table-row={{B.data.id}}>
<B.Td>
{{#if (can 'read auth-method' B.data)}}
<LinkTo
@route='scopes.scope.auth-methods.auth-method'
@model={{B.data.id}}
>
{{B.data.displayName}}
</LinkTo>
{{else}}
{{B.data.displayName}}
{{/if}}
<p>{{B.data.description}}</p>
</B.Td>
<B.Td>
<Hds::Badge
@text={{t
(concat 'resources.auth-method.types.' B.data.type)
}}
/>
</B.Td>
<B.Td>
<Hds::Copy::Snippet
@textToCopy={{B.data.id}}
@color='secondary'
/>
</B.Td>
<B.Td>
{{#if B.data.isPrimary}}
<Hds::Badge @text={{t 'states.primary'}} @color='success' />
{{/if}}
</B.Td>
<B.Td>
{{#if (can 'makePrimary auth-method' B.data)}}
<Hds::Dropdown as |dd|>
<dd.ToggleIcon
@icon='more-horizontal'
@text={{t 'actions.manage'}}
@hasChevron={{false}}
/>
{{#unless B.data.isPrimary}}
<dd.Interactive
{{on 'click' (fn this.makePrimary B.data)}}
>
{{t 'resources.auth-method.actions.make-primary'}}
</dd.Interactive>
{{/unless}}
{{#if B.data.isPrimary}}
<dd.Interactive
{{on 'click' (fn this.removeAsPrimary B.data)}}
>
{{t 'resources.auth-method.actions.remove-as-primary'}}
</dd.Interactive>
{{/if}}
</Hds::Dropdown>
{{/if}}
</B.Td>
</B.Tr>
</:body>
</Hds::Table>
<Rose::Pagination
@totalItems={{@model.totalItems}}
@currentPage={{this.page}}
@currentPageSize={{this.pageSize}}
/>
{{else}}
<Hds::ApplicationState as |A|>
<A.Header @title={{t 'titles.no-results-found'}} />
<A.Body
@text={{t
(if
this.search
'descriptions.no-search-results'
'descriptions.no-filter-results'
)
query=this.search
resource=(t 'resources.auth-method.title_plural')
}}
/>
</Hds::ApplicationState>
{{/if}}
{{else}}
<Hds::ApplicationState as |A|>
<A.Header @title={{t 'resources.auth-method.messages.welcome.title'}} />
<A.Body @text={{this.messageDescription}} />
</Hds::ApplicationState>
{{/if}}
</page.body>
</Rose::Layout::Page>