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

216 lines
6.6 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.alias.title_plural'}}
<DocLink @doc='aliases' @iconSize='large' />
</h2>
<p>{{t 'resources.alias.description'}}</p>
</page.header>
<page.actions>
{{#if (can 'create model' this.scope collection='aliases')}}
{{#if @model}}
<Hds::Button
@route='scopes.scope.aliases.new'
@text={{t 'resources.alias.titles.new'}}
/>
{{/if}}
{{/if}}
</page.actions>
<page.body>
{{#if @model}}
<Hds::Table
@model={{@model}}
@columns={{array
(hash label=(t 'resources.alias.title'))
(hash label=(t 'resources.alias.titles.points_to'))
(hash label=(t 'resources.scope.title'))
(hash label=(t 'resources.alias.titles.resource_id'))
(hash label='')
}}
@valign='middle'
>
<:body as |B|>
<B.Tr>
<B.Td>
{{#if (can 'read model' B.data.alias)}}
<LinkTo
@route='scopes.scope.aliases.alias'
@model={{B.data.alias.id}}
>
{{B.data.alias.displayName}}
</LinkTo>
{{else}}
<Hds::Text::Body @tag='p'>
{{B.data.alias.displayName}}
</Hds::Text::Body>
{{/if}}
{{#if B.data.alias.description}}
<Hds::Text::Body @tag='p'>
{{B.data.alias.description}}
</Hds::Text::Body>
{{/if}}
</B.Td>
<B.Td>
{{#if B.data.target.displayName}}
<div class='aliases-list-cell-item'>
<span><FlightIcon @name='target' /></span>
<span> {{B.data.target.displayName}} </span>
</div>
{{else}}
<Hds::Text::Body
@tag='p'
@size='100'
@weight='medium'
@color='faint'
>
{{t 'titles.not-set'}}
</Hds::Text::Body>
{{/if}}
</B.Td>
<B.Td>
<Hds::Badge @text={{t 'titles.global'}} @icon='globe' />
</B.Td>
<B.Td>
{{#if B.data.alias.destination_id}}
<Hds::Copy::Snippet
@textToCopy={{B.data.alias.destination_id}}
@color='secondary'
/>
{{/if}}
</B.Td>
<B.Td>
{{#let
(hash
canRead=(can 'read model' B.data.alias)
canDelete=(can 'delete model' B.data.alias)
)
as |perms|
}}
{{#if (or perms.canRead perms.canDelete)}}
<Hds::Dropdown as |dd|>
<dd.ToggleIcon
@icon='more-horizontal'
@text={{t 'actions.manage'}}
@hasChevron={{false}}
@size='small'
/>
{{#if perms.canRead}}
<dd.Interactive
@route='scopes.scope.aliases.alias'
@model={{B.data.alias.id}}
@text={{t 'actions.edit'}}
/>
{{/if}}
{{#if (and perms.canRead perms.canDelete)}}
<dd.Separator />
{{/if}}
{{#if perms.canDelete}}
<dd.Interactive
@text={{t 'actions.delete'}}
@color='critical'
{{on 'click' (fn this.toggleModal B.data.alias)}}
/>
{{/if}}
</Hds::Dropdown>
{{/if}}
{{/let}}
</B.Td>
</B.Tr>
</:body>
</Hds::Table>
{{else}}
<Rose::Layout::Centered>
<Rose::Message
@title={{t 'resources.alias.messages.none.title'}}
as |message|
>
<message.description>
{{#if (can 'list model' this.scope collection='aliases')}}
{{t 'resources.alias.messages.none.description'}}
{{else if (can 'create model' this.scope collection='aliases')}}
{{t
'descriptions.create-but-not-list'
resource=(t 'resources.alias.title_plural')
}}
{{else}}
{{t
'descriptions.neither-list-nor-create'
resource=(t 'resources.alias.title_plural')
}}
{{/if}}
</message.description>
{{#if (can 'create model' this.scope collection='aliases')}}
<Hds::Link::Standalone
@icon='plus-circle'
@iconPosition='leading'
@route='scopes.scope.aliases.new'
@text={{t 'resources.alias.messages.none.link'}}
/>
{{/if}}
</Rose::Message>
</Rose::Layout::Centered>
{{/if}}
{{#if this.showModal}}
<Hds::Modal
class='alias-deletion-modal'
@color='warning'
@onClose={{this.toggleModal}}
as |M|
>
<M.Header @icon='alert-triangle'>
{{t 'questions.delete-confirm'}}
</M.Header>
<M.Body>
<p class='hds-typography-body-300 hds-foreground-primary'>
{{#if this.hasDestinationId}}
{{t 'resources.alias.messages.clear-or-delete'}}
{{else}}
{{t 'resources.alias.messages.delete'}}
{{/if}}
</p>
</M.Body>
<M.Footer>
<Hds::ButtonSet>
<Hds::Button
type='button'
@text={{t 'actions.delete'}}
{{on 'click' (fn this.deleteAlias this.selectedAlias)}}
/>
{{#if this.hasDestinationId}}
<Hds::Button
type='button'
@text={{t 'actions.clear'}}
@color='secondary'
{{on 'click' (fn this.clearAlias this.selectedAlias)}}
/>
{{/if}}
<Hds::Button
type='button'
@text={{t 'actions.cancel'}}
@color='secondary'
{{on 'click' this.toggleModal}}
/>
</Hds::ButtonSet>
</M.Footer>
</Hds::Modal>
{{/if}}
</page.body>
</Rose::Layout::Page>