Files
threshold-ui/ui/admin/app/templates/scopes/scope/workers/index.hbs
T
2024-12-17 16:03:56 -08:00

222 lines
6.9 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}
<Rose::Layout::Page as |page|>
<page.breadcrumbs>
<Breadcrumbs::Container />
</page.breadcrumbs>
<page.header>
<h2>
{{t 'titles.workers'}}
<DocLink @doc='worker' @iconSize='large' />
</h2>
</page.header>
<page.actions>
{{#if (can 'create worker led worker' this.scope collection='workers')}}
{{#if @model}}
<Hds::Button
@route='scopes.scope.workers.new'
@text={{t 'titles.new'}}
/>
{{/if}}
{{/if}}
</page.actions>
<page.body class='workers'>
{{#if @model}}
<Rose::Toolbar as |toolbar|>
<toolbar.primary>
<Rose::Form as |form|>
{{#let
(resource-filter 'scopes.scope.workers.index' 'tags')
as |filter|
}}
{{#if filter.allowedValues}}
<Rose::Dropdown
@text={{t (concat 'form.' filter.name '.label')}}
@count={{filter.selectedValue.length}}
@ignoreClickInside={{true}}
as |dropdown|
>
{{#each-in
(group-by 'key' filter.allowedValues)
as |key tags|
}}
<dropdown.section
@title={{key}}
@icon='flight-icons/svg/tag-16'
/>
<form.checkboxGroup
@name={{key}}
@items={{tags}}
@selectedItems={{filter.selectedValue}}
@onChange={{fn this.callFilterBy filter.name}}
@itemEqualityFunc={{this.isEqual}}
as |group|
>
<dropdown.item class='indent-label-1'>
<group.checkbox
@label={{group.item.value}}
value={{group.item}}
/>
</dropdown.item>
</form.checkboxGroup>
{{/each-in}}
</Rose::Dropdown>
{{/if}}
{{/let}}
{{#if
(has-resource-filter-selections
'scopes.scope.workers.index' 'tags'
)
}}
<Rose::Button
@style='inline-link-action'
@iconLeft='flight-icons/svg/x-16'
{{on 'click' this.callClearAllFilters}}
>{{t 'actions.clear-all-filters'}}
</Rose::Button>
{{/if}}
</Rose::Form>
</toolbar.primary>
<toolbar.secondary>
<ToolbarRefresher @onClick={{this.refresh}} />
</toolbar.secondary>
</Rose::Toolbar>
<Hds::Table
class='workers-list-table'
@model={{@model}}
@columns={{array
(hash label=(t 'resources.worker.title'))
(hash label=(t 'form.tags.label'))
(hash label=(t 'resources.session.title_plural'))
(hash label=(t 'resources.worker.table.release_version'))
(hash label=(t 'resources.worker.table.ip_address'))
(hash label=(t 'form.id.label'))
}}
@density='short'
@valign='middle'
>
<:body as |B|>
<B.Tr>
<B.Td>
{{#if (and (can 'read worker' B.data) B.data.isPki)}}
<LinkTo
@route='scopes.scope.workers.worker'
@model={{B.data.id}}
>
{{B.data.displayName}}
</LinkTo>
{{else}}
{{B.data.displayName}}
{{/if}}
{{#if B.data.description}}
<p>{{B.data.description}}</p>
{{/if}}
</B.Td>
<B.Td>
{{#if B.data.tagCount}}
<Hds::Button
data-test-worker-tags-flyout-button={{B.data.id}}
@icon='tag'
@text={{t
'resources.worker.table.tag_count'
tagCount=B.data.tagCount
}}
@color='tertiary'
@size='small'
{{on 'click' (fn this.selectWorker B.data)}}
/>
{{/if}}
</B.Td>
<B.Td>{{B.data.active_connection_count}}</B.Td>
<B.Td>{{B.data.release_version}}</B.Td>
<B.Td>{{B.data.address}} </B.Td>
<B.Td>
<Hds::Copy::Snippet
@textToCopy={{B.data.id}}
@color='secondary'
/>
</B.Td>
</B.Tr>
</:body>
</Hds::Table>
{{#if this.selectedWorker}}
<Hds::Flyout
data-test-worker-tags-flyout
@onClose={{fn this.selectWorker null}}
as |M|
>
<M.Header>
{{t
'resources.worker.flyout.title'
workerName=this.selectedWorker.displayName
}}
</M.Header>
<M.Body>
<Hds::Table
@model={{this.selectedWorkerTags}}
@columns={{array
(hash label=(t 'resources.worker.table.tag'))
(hash label=(t 'resources.worker.table.type'))
}}
@valign='middle'
>
<:body as |B|>
<B.Tr>
<B.Td>
<Hds::Text::Code class='tag-shortener'>
{{this.tagDisplayName B.data}}
</Hds::Text::Code>
</B.Td>
<B.Td>
<Hds::Badge @text={{B.data.type}} />
</B.Td>
</B.Tr>
</:body>
</Hds::Table>
{{#if (gt this.selectedWorker.allTags.length 10)}}
<div class='view-more-tags'>
<Hds::Link::Standalone
@icon='arrow-right'
@iconPosition='trailing'
@text={{t 'resources.worker.flyout.action.view_more'}}
@route='scopes.scope.workers.worker.tags'
@model={{this.selectedWorker}}
/>
</div>
{{/if}}
</M.Body>
</Hds::Flyout>
{{/if}}
{{else}}
<Rose::Layout::Centered>
<Hds::ApplicationState as |A|>
<A.Header @title={{t 'resources.worker.messages.welcome.title'}} />
<A.Body @text={{this.messageDescription}} />
{{#if
(can 'create worker led worker' this.scope collection='workers')
}}
<A.Footer as |F|>
<F.LinkStandalone
@icon='plus-circle'
@text={{t 'titles.new'}}
@route='scopes.scope.workers.new'
/>
</A.Footer>
{{/if}}
</Hds::ApplicationState>
</Rose::Layout::Centered>
{{/if}}
</page.body>
</Rose::Layout::Page>