Skip to content

Commit

Permalink
ui: Add copy button for Secret ID in Tokens list page (#10735)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaxcode authored Jul 30, 2021
1 parent 97fed47 commit 2ee501b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .changelog/10735.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
ui: Adds a copy button to each composite row in tokens list page, if Secret ID returns an actual ID
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
%composite-row {
display: grid;
grid-template-columns: auto 50px;
grid-template-columns: 1fr auto;
grid-template-rows: 50% 50%;

grid-template-areas:
Expand All @@ -25,8 +25,7 @@
}
%composite-row-actions {
grid-area: actions;
justify-self: center;
align-self: center;
display: inline-flex;
}

%composite-row-header:nth-last-child(2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ as |item|>
</dl>
</BlockSlot>
<BlockSlot @name="actions" as |Actions|>

{{#if item.hasSecretID}}
<CopyButton
@value={{item.SecretID}}
@name={{t "components.consul.token.secretID"}}
>
{{t "components.consul.token.secretID"}}
</CopyButton>
{{/if}}
<Actions as |Action|>
<Action data-test-edit-action @href={{href-to 'dc.acls.tokens.edit' item.AccessorID}}>
<BlockSlot @name="label">
Expand Down
5 changes: 5 additions & 0 deletions ui/packages/consul-ui/app/models/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ export default class Token extends Model {
get isGlobalManagement() {
return (this.Policies || []).find(item => item.ID === MANAGEMENT_ID);
}

@computed('SecretID')
get hasSecretID() {
return this.SecretID !== '' && this.SecretID !== '<hidden>';
}
}
5 changes: 3 additions & 2 deletions ui/packages/consul-ui/mock-api/v1/acl/tokens
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ ${ env('CONSUL_ACLS_LEGACY', false) ? `rpc error making call: rpc: can't find me
return `
{
"AccessorID": "${i === 1 ? '00000000-0000-0000-0000-000000000002' : fake.random.uuid()}",
"SecretID": "${fake.helpers.randomize([fake.random.uuid(), '<hidden>', ''])}",
"Name": "token-${i}",
${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}",
` : ``}
"IDPName": "${fake.hacker.noun()}",
"Policies": [
${
range(env('CONSUL_POLICY_COUNT', 10)).map(
range(env('CONSUL_POLICY_COUNT', 3)).map(
function(item, j) {
if(i == 1 && j == 0) {
return `
Expand All @@ -44,7 +45,7 @@ ${typeof location.search.ns !== 'undefined' ? `
],
"Roles": [
${
range(env('CONSUL_ROLE_COUNT', 10)).map(
range(env('CONSUL_ROLE_COUNT', 3)).map(
function(item, j) {
return `
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ token:
global-management: Global Management
global: Global Scope
local: Local Scope
secretID: Secret ID
policy:
search-bar:
kind:
Expand Down

0 comments on commit 2ee501b

Please sign in to comment.