vault/ui/app/components/secret-list/database-list-item.hbs
2025-08-01 10:04:25 -06:00

78 lines
3.1 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
}}
<LinkedBlock
@params={{array "vault.cluster.secrets.backend.show" (if this.keyTypeValue (concat "role/" @item.id) @item.id)}}
class="list-item-row"
data-test-secret-link={{@item.id}}
@encode={{true}}
@queryParams={{secret-query-params @backendType @item.type}}
>
<div class="columns is-mobile">
<div class="column is-10">
<LinkTo
@route={{concat "vault.cluster.secrets.backend.show"}}
@model={{if this.keyTypeValue (concat "role/" @item.id) @item.id}}
@query={{secret-query-params @backendType @item.type}}
class="has-text-black has-text-weight-semibold"
>
<Icon @name="user" class="has-text-grey-light is-pulled-left" />
<div class="role-item-details">
<span class="is-underline">{{if (eq @item.id " ") "(self)" (or @item.keyWithoutParent @item.id)}}</span>
{{#if this.keyTypeValue}}
<Hds::Badge @text={{this.keyTypeValue}} />
{{/if}}
</div>
</LinkTo>
</div>
<div class="column has-text-right">
<Hds::Dropdown @isInline={{true}} @listPosition="bottom-right" as |dd|>
<dd.ToggleIcon
@icon="more-horizontal"
@text="Manage database {{@item.id}}"
@hasChevron={{false}}
data-test-popup-menu-trigger
/>
{{#if @item.canEdit}}
<dd.Interactive @route="vault.cluster.secrets.backend.edit" @model={{@item.id}}>Edit connection</dd.Interactive>
{{/if}}
{{#if @item.canEditRole}}
<dd.Interactive @route="vault.cluster.secrets.backend.edit" @model={{concat "role/" @item.id}}>Edit Role</dd.Interactive>
{{/if}}
{{#if @item.canReset}}
<dd.Interactive
@icon={{if (eq this.actionRunning "reset") "loading"}}
{{on "click" (fn this.resetConnection @item.id)}}
>Reset connection</dd.Interactive>
{{/if}}
{{#if (and (eq @item.type "dynamic") @item.canGenerateCredentials)}}
<dd.Interactive
@route="vault.cluster.secrets.backend.credentials"
@model={{@item.id}}
@query={{hash roleType=this.keyTypeValue}}
>Generate credentials</dd.Interactive>
{{else if (and (eq @item.type "static") @item.canGetCredentials)}}
<dd.Interactive
@route="vault.cluster.secrets.backend.credentials"
@model={{@item.id}}
@query={{hash roleType=this.keyTypeValue}}
>Get credentials</dd.Interactive>
{{/if}}
{{#if (and @item.canRotateRoleCredentials (eq this.keyTypeValue "static"))}}
<dd.Interactive
@icon={{if (eq this.actionRunning "rotateRole") "loading"}}
{{on "click" (fn this.rotateRoleCred @item.id)}}
>Rotate credentials</dd.Interactive>
{{/if}}
{{#if @item.canRotateRoot}}
<dd.Interactive
@icon={{if (eq this.actionRunning "rotateRoot") "loading"}}
{{on "click" (fn this.rotateRootCred @item.id)}}
>Rotate root credentials</dd.Interactive>
{{/if}}
</Hds::Dropdown>
</div>
</div>
</LinkedBlock>