* refactor: 💡 update query requests for resources in indexedDB ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-13359
217 lines
7.1 KiB
Handlebars
217 lines
7.1 KiB
Handlebars
{{!
|
|
Copyright (c) HashiCorp, Inc.
|
|
SPDX-License-Identifier: MPL-2.0
|
|
}}
|
|
|
|
<Rose::Layout::Page as |page|>
|
|
<page.breadcrumbs>
|
|
<Breadcrumbs::Container />
|
|
</page.breadcrumbs>
|
|
|
|
<page.header>
|
|
<h2>
|
|
{{t 'resources.target.title_plural'}}
|
|
<DocLink @doc='target' @iconSize='large' />
|
|
</h2>
|
|
{{#if @model.targetsExist}}
|
|
<p>{{t 'resources.target.description'}}</p>
|
|
{{/if}}
|
|
</page.header>
|
|
|
|
<page.actions>
|
|
{{#if (can 'create model' this.scope collection='targets')}}
|
|
{{#if @model.targetsExist}}
|
|
<Hds::Button
|
|
@route='scopes.scope.targets.new'
|
|
@text={{t 'resources.target.titles.new'}}
|
|
/>
|
|
{{/if}}
|
|
{{/if}}
|
|
</page.actions>
|
|
<page.body class='search-filtering'>
|
|
{{#if @model.targetsExist}}
|
|
<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='active-sessions'
|
|
@toggleText={{t 'resources.target.titles.active-sessions'}}
|
|
@itemOptions={{this.availableSessionOptions}}
|
|
@checkedItems={{this.availableSessions}}
|
|
@applyFilter={{fn this.applyFilter 'availableSessions'}}
|
|
/>
|
|
</S.Generic>
|
|
{{#if (feature-flag 'ssh-target')}}
|
|
<S.Generic>
|
|
<Dropdown
|
|
name='type'
|
|
@toggleText={{t 'form.type.label'}}
|
|
@itemOptions={{this.targetTypeOptions}}
|
|
@checkedItems={{this.types}}
|
|
@applyFilter={{fn this.applyFilter 'types'}}
|
|
/>
|
|
</S.Generic>
|
|
{{/if}}
|
|
</Hds::SegmentedGroup>
|
|
<FilterTags @filters={{this.filters}} />
|
|
|
|
{{#if @model.targets}}
|
|
<Hds::Table
|
|
@columns={{array
|
|
(hash label=(t 'form.name.label'))
|
|
(hash label=(t 'form.type.label'))
|
|
(hash label=(t 'resources.target.titles.active-sessions'))
|
|
(hash label=(t 'form.id.label'))
|
|
}}
|
|
@model={{@model.targets}}
|
|
@density='short'
|
|
@valign='middle'
|
|
>
|
|
<:body as |B|>
|
|
{{#if (feature-flag 'ssh-target')}}
|
|
<B.Tr data-test-targets-table-row={{B.data.id}}>
|
|
<B.Td>
|
|
{{#if (can 'read model' B.data)}}
|
|
<LinkTo
|
|
@route='scopes.scope.targets.target'
|
|
@model={{B.data.id}}
|
|
>
|
|
{{B.data.displayName}}
|
|
</LinkTo>
|
|
{{else}}
|
|
{{B.data.displayName}}
|
|
{{/if}}
|
|
<p>{{B.data.description}}</p>
|
|
</B.Td>
|
|
<B.Td>
|
|
{{#if B.data.type}}
|
|
<Hds::Badge
|
|
@text={{t (concat 'resources.target.types.' B.data.type)}}
|
|
/>
|
|
{{/if}}
|
|
</B.Td>
|
|
<B.Td>
|
|
{{#if B.data.isActive}}
|
|
<Hds::Link::Standalone
|
|
@text={{t 'actions.yes'}}
|
|
@route='scopes.scope.sessions.index'
|
|
@query={{hash targets=(array B.data.id)}}
|
|
@icon='info'
|
|
/>
|
|
{{/if}}
|
|
</B.Td>
|
|
<B.Td>
|
|
<Hds::Copy::Snippet
|
|
@textToCopy={{B.data.id}}
|
|
@color='secondary'
|
|
/>
|
|
</B.Td>
|
|
</B.Tr>
|
|
{{else}}
|
|
{{#if B.data.isTCP}}
|
|
<B.Tr data-test-targets-table-row={{B.data.id}}>
|
|
<B.Td>
|
|
{{#if (can 'read model' B.data)}}
|
|
<LinkTo
|
|
@route='scopes.scope.targets.target'
|
|
@model={{B.data.id}}
|
|
>
|
|
{{B.data.displayName}}
|
|
</LinkTo>
|
|
{{else}}
|
|
{{B.data.displayName}}
|
|
{{/if}}
|
|
<p>{{B.data.description}}</p>
|
|
</B.Td>
|
|
<B.Td>
|
|
{{#if B.data.type}}
|
|
<Hds::Badge
|
|
@text={{t
|
|
(concat 'resources.target.types.' B.data.type)
|
|
}}
|
|
/>
|
|
{{/if}}
|
|
</B.Td>
|
|
<B.Td>
|
|
{{#if B.data.isActive}}
|
|
<Hds::Link::Standalone
|
|
@text={{t 'actions.yes'}}
|
|
@route='scopes.scope.sessions.index'
|
|
@query={{hash targets=(array B.data.id)}}
|
|
@icon='info'
|
|
/>
|
|
{{/if}}
|
|
</B.Td>
|
|
<B.Td>
|
|
<Hds::Copy::Snippet
|
|
@textToCopy={{B.data.id}}
|
|
@color='secondary'
|
|
/>
|
|
</B.Td>
|
|
</B.Tr>
|
|
{{/if}}
|
|
{{/if}}
|
|
</:body>
|
|
</Hds::Table>
|
|
<Rose::Pagination
|
|
@totalItems={{@model.totalItems}}
|
|
@currentPage={{this.page}}
|
|
@currentPageSize={{this.pageSize}}
|
|
/>
|
|
{{else}}
|
|
<Hds::ApplicationState data-test-no-target-results 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.target.title_plural')
|
|
}}
|
|
/>
|
|
</Hds::ApplicationState>
|
|
{{/if}}
|
|
{{else}}
|
|
<Hds::ApplicationState as |A|>
|
|
<A.Header @title={{t 'resources.target.messages.welcome.title'}} />
|
|
<A.Body
|
|
{{! can list (at least): show default welcome message}}
|
|
{{! can create (only): show create-but-not-list welcome message}}
|
|
{{! can neither list nor create: show neither-list-nor-create welcome message}}
|
|
@text={{t
|
|
(if
|
|
(can 'list model' this.scope collection='targets')
|
|
'resources.target.description'
|
|
(if
|
|
(can 'create model' this.scope collection='targets')
|
|
'descriptions.create-but-not-list'
|
|
'descriptions.neither-list-nor-create'
|
|
)
|
|
)
|
|
resource=(t 'resources.target.title_plural')
|
|
}}
|
|
/>
|
|
{{#if (can 'create model' this.scope collection='targets')}}
|
|
<A.Footer as |F|>
|
|
<F.Link::Standalone
|
|
@icon='plus-circle'
|
|
@text={{t 'titles.new'}}
|
|
@route='scopes.scope.targets.new'
|
|
/>
|
|
|
|
</A.Footer>
|
|
{{/if}}
|
|
</Hds::ApplicationState>
|
|
{{/if}}
|
|
</page.body>
|
|
|
|
</Rose::Layout::Page> |