Files
threshold-ui/ui/admin/app/templates/scopes/scope/auth-methods/index.hbs
T

221 lines
7.5 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}
<Rose::Layout::Page as |page|>
<page.header>
<Hds::PageHeader as |PH|>
<PH.Breadcrumb>
<Breadcrumbs::Container />
</PH.Breadcrumb>
<PH.Title>
{{t 'resources.auth-method.title_plural'}}
<DocLink @doc='auth-method' />
</PH.Title>
<PH.Description>
{{t 'resources.auth-method.description'}}
</PH.Description>
<PH.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}}
</PH.Actions>
</Hds::PageHeader>
</page.header>
<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'
@valign='middle'
@onSort={{this.onSort}}
@sortBy={{this.sortAttribute}}
@sortOrder={{this.sortDirection}}
>
<:head as |H|>
<H.Tr>
<H.ThSort
@onClickSort={{fn H.setSortBy 'name'}}
@sortOrder={{if (eq 'name' H.sortBy) H.sortOrder}}
>{{t 'form.name.label'}}</H.ThSort>
<H.ThSort
@onClickSort={{fn H.setSortBy 'type'}}
@sortOrder={{if (eq 'type' H.sortBy) H.sortOrder}}
>{{t 'form.type.label'}}</H.ThSort>
<H.ThSort
@onClickSort={{fn H.setSortBy 'id'}}
@sortOrder={{if (eq 'id' H.sortBy) H.sortOrder}}
>{{t 'form.id.label'}}</H.ThSort>
<H.Th>{{t 'resources.auth-method.titles.primary-method'}}</H.Th>
<H.Th>{{t 'titles.actions'}}</H.Th>
</H.Tr>
</:head>
<:body as |B|>
{{#each @model.authMethods as |data|}}
<B.Tr data-test-auth-methods-table-row={{data.id}}>
{{! Name }}
<B.Td>
{{#if (can 'read auth-method' data)}}
<LinkTo
@route='scopes.scope.auth-methods.auth-method'
@model={{data.id}}
>
{{data.displayName}}
</LinkTo>
{{else}}
{{data.displayName}}
{{/if}}
<Hds::Text::Body @tag='p'>
{{data.description}}
</Hds::Text::Body>
</B.Td>
{{! Type }}
<B.Td>
<Hds::Badge
@text={{t
(concat 'resources.auth-method.types.' data.type)
}}
/>
</B.Td>
{{! ID }}
<B.Td>
<Hds::Copy::Snippet
@textToCopy={{data.id}}
@color='secondary'
/>
</B.Td>
{{! isPrimary }}
<B.Td>
{{#if data.isPrimary}}
<Hds::Badge @text={{t 'states.primary'}} @color='success' />
{{/if}}
</B.Td>
{{! Actions }}
<B.Td>
{{#if (can 'makePrimary auth-method' data)}}
<Hds::Dropdown as |dd|>
<dd.ToggleIcon
@icon='more-horizontal'
@text={{t 'actions.manage'}}
@hasChevron={{false}}
/>
{{#unless data.isPrimary}}
<dd.Interactive
{{on 'click' (fn this.makePrimary data)}}
>
{{t 'resources.auth-method.actions.make-primary'}}
</dd.Interactive>
{{/unless}}
{{#if data.isPrimary}}
<dd.Interactive
{{on 'click' (fn this.removeAsPrimary data)}}
>
{{t
'resources.auth-method.actions.remove-as-primary'
}}
</dd.Interactive>
{{/if}}
</Hds::Dropdown>
{{/if}}
</B.Td>
</B.Tr>
{{/each}}
</: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>