vault/ui/app/components/dashboard/quick-actions-card.hbs
2024-03-25 12:14:47 -07:00

103 lines
3.8 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
~}}
<Hds::Card::Container @hasBorder={{true}} class="has-padding-l" data-test-card="quick-actions">
<h3 class="title is-4">Quick actions</h3>
{{#if this.filteredSecretEngines}}
<div class="has-top-margin-m has-bottom-margin-m">
<h4 class="title is-marginless is-6" data-test-card-subtitle="secrets-engines">Secrets engines</h4>
<p class="is-size-8 has-top-margin-xxs has-bottom-margin-s has-text-grey">Supported engines include databases, KV
version 2, and PKI.</p>
<SearchSelect
@id="secrets-engines-select"
@options={{this.mountOptions}}
@selectLimit="1"
@disallowNewItems={{true}}
@fallbackComponent="input-search"
@onChange={{this.handleSearchEngineSelect}}
@placeholder="Type to select a mount"
@displayInherit={{true}}
@shouldRenderName={{true}}
@passObject={{true}}
@objectKeys={{array "type" "version"}}
class="is-marginless"
data-test-search-select="secrets-engines"
/>
</div>
{{#if this.selectedEngine}}
<h4 id="action-select-title" class="title is-6" data-test-card-subtitle="secrets-engines">Action</h4>
<Select
@name="action-select"
@options={{this.actionOptions}}
@isFullwidth={{true}}
@selectedValue={{this.selectedAction}}
@onChange={{this.setSelectedAction}}
@noDefault={{true}}
@ariaLabel="Action"
/>
{{#if this.searchSelectParams.model}}
{{! use special input to allow searching for KVv2 secrets inside a directory }}
{{#if (eq this.selectedEngine.type "kv")}}
<KvSuggestionInput
@label="Secret Path"
@value={{this.paramValue}}
@mountPath={{this.selectedEngine.id}}
@onChange={{fn (mut this.paramValue)}}
/>
{{else}}
<h4 class="title is-6" data-test-card-subtitle="param">{{this.searchSelectParams.title}}</h4>
<SearchSelect
class="is-flex-grow-1"
@selectLimit="1"
@models={{array this.searchSelectParams.model}}
@placeholder={{this.searchSelectParams.placeholder}}
@disallowNewItems={{true}}
@onChange={{this.handleActionSelect}}
@fallbackComponent="input-search"
@disabled={{not this.searchSelectParams.model}}
@nameKey={{this.searchSelectParams.nameKey}}
@queryObject={{this.searchSelectParams.queryObject}}
@objectKeys={{this.searchSelectParams.objectKeys}}
@passObject={{true}}
@shouldRenderName={{this.searchSelectParams.nameKey}}
data-test-search-select="params"
/>
{{/if}}
<div>
<Hds::Button
@text={{this.searchSelectParams.buttonText}}
class="has-top-margin-m"
disabled={{(not (and this.selectedAction this.selectedEngine this.paramValue))}}
{{on "click" this.navigateToPage}}
data-test-button={{this.searchSelectParams.buttonText}}
/>
</div>
{{/if}}
{{else}}
<EmptyState
@title="No mount selected"
@message="Select a mount above to get started."
data-test-empty-state="no-mount-selected"
/>
{{/if}}
{{else}}
<EmptyState
@title="Welcome to quick actions"
@message="Access secret engine actions easily. Enable a compatible secret engine (such as database, KV version 2, or PKI) to get started."
data-test-empty-state="quick-actions"
>
<Hds::Link::Standalone
@icon="chevron-right"
@iconPosition="trailing"
@text="Enable a secrets engine"
@route="vault.cluster.settings.mount-secret-backend"
/>
</EmptyState>
{{/if}}
</Hds::Card::Container>