Files
vault/ui/lib/kv/addon/components/page/secret/details.hbs
claire bontempo f634808ed4 UI: Implement KV patch+subkey [enterprise] (#28212)
* UI: Implement overview page for KV v2 (#28162)

* build json editor patch form

* finish patch component and tests

* add tab to each route

* and path route

* add overview tab to tests

* update overview to use updated_time instead of created_time

* redirect relevant secret.details to secret.index

* compute secretState in component instead of pass as arg

* add capabilities service

* add error handling to fetchSubkeys adapter request

* add overview tabs to test

* add subtext to overview card

* remaining redirects in secret edit

* remove create new version from popup menu

* fix breadcrumbs for overview

* separate adding capabilities service

* add service to kv engine

* Revert "separate adding capabilities service"

This reverts commit bb70b12ab7dbcde0fbd2d4d81768e5c8b1c420cc.

* Revert "add service to kv engine"

This reverts commit bfa880535ef7d529d7610936b2c1aae55673d23f.

* update navigation test

* consistently navigate to secret.index route to be explicit

* finish overview navigation tests

* add copyright header

* update delete tests

* fix nav testrs

* cleanup secret edit redirects

* remove redundant async/awaits

* fix create test

* edge case tests

* secret acceptance tests

* final component tests

* rename kvSecretDetails external route to kvSecretOverview

* add comment

* UI: Add patch route and implement Page::Secret::Patch page component (sidebranch) (#28192)

* add tab to each route

* and path route

* add overview tab to tests

* update overview to use updated_time instead of created_time

* redirect relevant secret.details to secret.index

* compute secretState in component instead of pass as arg

* add capabilities service

* add error handling to fetchSubkeys adapter request

* add patch route and put in page component

* add patch secret action to subkeys card

* fix component name

* add patch capability

* alphabetize computed capabilities

* update links, cleanup selectors

* fix more merge conflict stuff

* add capabilities test

* add models to patch link

* add test for patch route

* rename external route

* add error templates

* make notes about enterprise tests, filter one

* remove errors, transition (redirect) instead

* redirect patch routes

* UI: Move fetching secret data to child route (#28198)

* remove @secret from metadata details

* use metadata model instead of secret in paths page

* put delete back into kv/data adapter

* grant access in control group test

* update metadata route and permissions

* remove secret from parent route, only fetch in details route

* change more permissions to route perms, add tests

* revert overview redirect from list view

* wrap model in conditional for perms

* remove redundant canReadCustomMetadata check

* rename adapter method

* handle overview 404

* remove comment

* add customMetadata as an arg

* update grantAccess in test

* make version param easier to follow

* VAULT-30494 handle 404 jira

* refactor capabilities to return an object

* update create tests

* add test for default truthy capabilities

* remove destroy-all-versions from kv/data adapter

* UI: Add enterprise checks (#28215)

* add enterprise check for subkey card

* add max height and scroll to subkey card

* only fetch subkeys if enterprise

* remove check in overview

* add test

* Update ui/tests/integration/components/kv/page/kv-page-overview-test.js

* fix test failures (#28222)

* add assertion

* add optional chaining

* create/delete versioned secret in each module

* wait for transition

* add another waitUntil

* UI: Add patch latest version to toolbar (#28223)

* add patch latest version action to toolbar

* make isPatchAllowed arg all encompassing

* no longer need model check

* use hash so both promises fire at the same time

* add subkeys to policy

* Update ui/lib/kv/addon/routes/secret.js

* add changelog

* small cleanup items! (#28229)

* add conditional for enterprise checking tabs

* cleanup fetchMultiplePaths method

* add test

* remove todo comment, ticket created and design wants to hold off

* keep transition, update comments

* cleanup tests, add index to breadcrumbs

* add some test coverage

* toggle so value is readable
2024-08-29 16:38:39 -07:00

183 lines
6.0 KiB
Handlebars

{{!
Copyright (c) HashiCorp, Inc.
SPDX-License-Identifier: BUSL-1.1
~}}
<KvPageHeader @breadcrumbs={{@breadcrumbs}} @pageTitle={{@path}}>
<:syncDetails>
{{#if this.syncStatus}}
<Hds::Alert data-test-sync-alert @type="inline" class="has-top-margin-s has-bottom-margin-m" @color="neutral" as |A|>
<A.Title>
This secret has been synced from Vault to
{{pluralize this.syncStatus.length "destination"}}. Updates to this secret will automatically sync to its
{{if (eq this.syncStatus.length 1) "destination" "destinations"}}.
</A.Title>
{{#each this.syncStatus as |status|}}
<A.Description data-test-sync-alert={{status.destinationName}}>
<SyncStatusBadge @status={{status.syncStatus}} />
<Hds::Link::Inline
@route="syncDestination"
@color="secondary"
@isRouteExternal={{true}}
@models={{array status.destinationType status.destinationName}}
>{{status.destinationName}}</Hds::Link::Inline>
- last updated
{{date-format status.updatedAt "MMMM do yyyy, h:mm:ss a"}}
</A.Description>
{{/each}}
<A.Button
@icon={{if this.fetchSyncStatus.isRunning "loading"}}
@text="Refresh"
@color="secondary"
{{on "click" (perform this.fetchSyncStatus)}}
/>
<A.LinkStandalone
@isHrefExternal={{true}}
@icon="docs-link"
@text="About sync statuses"
@href={{doc-link "/vault/docs/sync#sync-statuses"}}
/>
</Hds::Alert>
{{/if}}
</:syncDetails>
<:tabLinks>
<li>
<LinkTo
@route="secret.index"
@models={{array @secret.backend @path}}
data-test-secrets-tab="Overview"
>Overview</LinkTo>
</li>
<li>
<LinkTo @route="secret.details" @models={{array @secret.backend @path}} data-test-secrets-tab="Secret">Secret</LinkTo>
</li>
<li>
<LinkTo
@route="secret.metadata.index"
@models={{array @secret.backend @path}}
data-test-secrets-tab="Metadata"
>Metadata</LinkTo>
</li>
<li>
<LinkTo @route="secret.paths" @models={{array @secret.backend @path}} data-test-secrets-tab="Paths">Paths</LinkTo>
</li>
{{#if @secret.canReadMetadata}}
<li>
<LinkTo
@route="secret.metadata.versions"
@models={{array @secret.backend @path}}
data-test-secrets-tab="Version History"
>Version History</LinkTo>
</li>
{{/if}}
</:tabLinks>
<:toolbarFilters>
{{#unless this.emptyState}}
<Toggle @name="json" @checked={{this.showJsonView}} @onChange={{fn (mut this.showJsonView)}}>
<span class="has-text-grey">JSON</span>
</Toggle>
{{/unless}}
</:toolbarFilters>
<:toolbarActions>
{{#if this.showUndelete}}
<Hds::Button
@text="Undelete"
@color="secondary"
class="toolbar-button"
data-test-kv-delete="undelete"
{{on "click" this.undelete}}
/>
{{/if}}
{{#if this.showDelete}}
<KvDeleteModal
@mode="delete"
@secret={{@secret}}
@metadata={{@metadata}}
@onDelete={{this.handleDestruction}}
@version={{this.version}}
/>
{{/if}}
{{#if this.showDestroy}}
<KvDeleteModal @mode="destroy" @secret={{@secret}} @onDelete={{this.handleDestruction}} @version={{this.version}} />
{{/if}}
{{#if (or @secret.canReadData @secret.canReadMetadata @secret.canEditData)}}
<div class="toolbar-separator"></div>
{{/if}}
{{#if (and @secret.canReadData (eq @secret.state "created"))}}
<CopySecretDropdown
@clipboardText={{stringify @secret.secretData}}
@onWrap={{perform this.wrapSecret}}
@isWrapping={{this.wrapSecret.isRunning}}
@wrappedData={{this.wrappedData}}
@onClose={{this.clearWrappedData}}
/>
{{/if}}
{{#if @secret.canReadMetadata}}
<KvVersionDropdown @displayVersion={{this.version}} @metadata={{@metadata}} @onClose={{this.closeVersionMenu}} />
{{/if}}
{{! @isPatchAllowed is true if the version is enterprise AND a user has "patch" secret + "read" subkeys capabilities }}
{{#if @isPatchAllowed}}
<ToolbarLink data-test-patch-latest-version @route="secret.patch" @models={{array @secret.backend @path}} @type="add">
Patch latest version
</ToolbarLink>
{{/if}}
{{#if @secret.canEditData}}
<ToolbarLink
data-test-create-new-version
@route="secret.details.edit"
@models={{array @secret.backend @path}}
@type="add"
>
Create new version
</ToolbarLink>
{{/if}}
</:toolbarActions>
</KvPageHeader>
{{#if (or @secret.isSecretDeleted (not this.emptyState))}}
<div class="info-table-row-header">
<div class="info-table-row thead {{if this.showJsonView 'is-shadowless'}} ">
{{#unless this.hideHeaders}}
<div class="th column is-one-quarter">
Key
</div>
<div class="th column">
Value
</div>
{{/unless}}
<div class="th column justify-right">
{{#if (or @secret.isSecretDeleted @secret.createdTime)}}
<KvTooltipTimestamp
@text="Version {{if @secret.version @secret.version}} {{@secret.state}}"
@timestamp={{(if @secret.isSecretDeleted @secret.deletionTime @secret.createdTime)}}
/>
{{/if}}
</div>
</div>
</div>
{{/if}}
{{#if this.emptyState}}
<EmptyState @title={{this.emptyState.title}} @message={{this.emptyState.message}}>
{{#if this.emptyState.link}}
<Hds::Link::Standalone
@icon="docs-link"
@iconPosition="trailing"
@text="KV v2 API docs"
@href={{doc-link this.emptyState.link}}
@isHrefExternal={{true}}
/>
{{/if}}
</EmptyState>
{{else}}
<KvDataFields
@showJson={{this.showJsonView}}
@secret={{@secret}}
@modelValidations={{this.modelValidations}}
@type="details"
/>
{{/if}}