Skip to content

Commit

Permalink
backport of commit 902d853 (#28638)
Browse files Browse the repository at this point in the history
Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
  • Loading branch information
1 parent aa327d5 commit 412e7c1
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 7 deletions.
3 changes: 3 additions & 0 deletions changelog/28629.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: Add button to copy secret path in kv v1 and v2 secrets engines
```
1 change: 1 addition & 0 deletions ui/app/templates/components/secret-edit.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Edit Secret
{{else}}
{{@key.id}}
<Hds::Copy::Button @isIconOnly={{true}} @text="Copy your secret path" @textToCopy={{@key.id}} />
{{/if}}
</h1>
</p.levelLeft>
Expand Down
5 changes: 4 additions & 1 deletion ui/lib/kv/addon/components/kv-page-header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<Icon @name="key-values" @size="24" class="has-text-grey-light" />
{{@mountName}}
<span class="tag">version 2</span>
{{else if @secretPath}}
{{@secretPath}}
<Hds::Copy::Button @isIconOnly={{true}} @text="Copy your secret path" @textToCopy={{@secretPath}} />
{{else}}
{{@pageTitle}}
{{/if}}
Expand All @@ -35,7 +38,7 @@
{{/if}}

{{#if (or (has-block "toolbarFilters") (has-block "toolbarActions"))}}
<Toolbar aria-label="menu items for managing {{or @mountName @pageTitle}}">
<Toolbar aria-label="menu items for managing {{or @mountName @secretPath @pageTitle}}">
<ToolbarFilters aria-label="filters for secrets list">
{{yield to="toolbarFilters"}}
</ToolbarFilters>
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kv/addon/components/page/secret/details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: BUSL-1.1
~}}

<KvPageHeader @breadcrumbs={{@breadcrumbs}} @pageTitle={{@path}}>
<KvPageHeader @breadcrumbs={{@breadcrumbs}} @secretPath={{@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|>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: BUSL-1.1
~}}

<KvPageHeader @breadcrumbs={{@breadcrumbs}} @pageTitle={{@path}}>
<KvPageHeader @breadcrumbs={{@breadcrumbs}} @secretPath={{@path}}>
<:tabLinks>
<li>
<LinkTo @route="secret.index" @models={{array @backend @path}} data-test-secrets-tab="Overview">Overview</LinkTo>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: BUSL-1.1
~}}

<KvPageHeader @breadcrumbs={{@breadcrumbs}} @pageTitle={{@path}}>
<KvPageHeader @breadcrumbs={{@breadcrumbs}} @secretPath={{@path}}>
<:tabLinks>
<li>
<LinkTo @route="secret.index" @models={{array @backend @path}} data-test-secrets-tab="Overview">Overview</LinkTo>
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kv/addon/components/page/secret/overview.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: BUSL-1.1
~}}

<KvPageHeader @breadcrumbs={{@breadcrumbs}} @pageTitle={{@path}}>
<KvPageHeader @breadcrumbs={{@breadcrumbs}} @secretPath={{@path}}>
<:tabLinks>
<li>
<LinkTo @route="secret.index" @models={{array @backend @path}} data-test-secrets-tab="Overview">Overview</LinkTo>
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/kv/addon/components/page/secret/paths.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
SPDX-License-Identifier: BUSL-1.1
~}}

<KvPageHeader @breadcrumbs={{@breadcrumbs}} @pageTitle={{@path}}>
<KvPageHeader @breadcrumbs={{@breadcrumbs}} @secretPath={{@path}}>
<:tabLinks>
<li>
<LinkTo @route="secret.index" @models={{array @backend @path}} data-test-secrets-tab="Overview">Overview</LinkTo>
Expand Down
11 changes: 10 additions & 1 deletion ui/tests/integration/components/kv/kv-page-header-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module('Integration | Component | kv | kv-page-header', function (hooks) {
.exists('final breadcrumb renders and it is not a link.');
});

test('it renders a custom title for a non engine view', async function (assert) {
test('it renders a custom title for @pageTitle', async function (assert) {
assert.expect(2);
await render(hbs`<KvPageHeader @breadcrumbs={{this.breadcrumbs}} @pageTitle="Create new version"/>`, {
owner: this.engine,
Expand All @@ -63,6 +63,15 @@ module('Integration | Component | kv | kv-page-header', function (hooks) {
assert.dom('[data-test-header-title] svg').doesNotExist('Does not show icon if not at engine level.');
});

test('it renders a title and copy button for @secretPath', async function (assert) {
await render(hbs`<KvPageHeader @breadcrumbs={{this.breadcrumbs}} @secretPath="my/secret/path"/>`, {
owner: this.engine,
});
assert.dom('[data-test-header-title]').hasText('my/secret/path', 'displays path');
assert.dom('[data-test-header-title] button').exists('renders copy button for path');
assert.dom('[data-test-icon="clipboard-copy"]').exists('renders copy icon');
});

test('it renders a title, icon and tag if engine view', async function (assert) {
assert.expect(2);
await render(hbs`<KvPageHeader @breadcrumbs={{this.breadcrumbs}} @mountName={{this.backend}} />`, {
Expand Down

0 comments on commit 412e7c1

Please sign in to comment.