ui: Add copy button for Secret ID in Tokens list page (#10735)

This commit is contained in:
Kenia 2021-07-30 13:52:37 -04:00 committed by GitHub
parent 475fec5670
commit ec27dfe706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 6 deletions

3
.changelog/10735.txt Normal file
View File

@ -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
```

View File

@ -1,6 +1,6 @@
%composite-row { %composite-row {
display: grid; display: grid;
grid-template-columns: auto 50px; grid-template-columns: 1fr auto;
grid-template-rows: 50% 50%; grid-template-rows: 50% 50%;
grid-template-areas: grid-template-areas:
@ -25,8 +25,7 @@
} }
%composite-row-actions { %composite-row-actions {
grid-area: actions; grid-area: actions;
justify-self: center; display: inline-flex;
align-self: center;
} }
%composite-row-header:nth-last-child(2) { %composite-row-header:nth-last-child(2) {

View File

@ -30,7 +30,14 @@ as |item|>
</dl> </dl>
</BlockSlot> </BlockSlot>
<BlockSlot @name="actions" as |Actions|> <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|> <Actions as |Action|>
<Action data-test-edit-action @href={{href-to 'dc.acls.tokens.edit' item.AccessorID}}> <Action data-test-edit-action @href={{href-to 'dc.acls.tokens.edit' item.AccessorID}}>
<BlockSlot @name="label"> <BlockSlot @name="label">

View File

@ -38,4 +38,9 @@ export default class Token extends Model {
get isGlobalManagement() { get isGlobalManagement() {
return (this.Policies || []).find(item => item.ID === MANAGEMENT_ID); return (this.Policies || []).find(item => item.ID === MANAGEMENT_ID);
} }
@computed('SecretID')
get hasSecretID() {
return this.SecretID !== '' && this.SecretID !== '<hidden>';
}
} }

View File

@ -15,6 +15,7 @@ ${ env('CONSUL_ACLS_LEGACY', false) ? `rpc error making call: rpc: can't find me
return ` return `
{ {
"AccessorID": "${i === 1 ? '00000000-0000-0000-0000-000000000002' : fake.random.uuid()}", "AccessorID": "${i === 1 ? '00000000-0000-0000-0000-000000000002' : fake.random.uuid()}",
"SecretID": "${fake.helpers.randomize([fake.random.uuid(), '<hidden>', ''])}",
"Name": "token-${i}", "Name": "token-${i}",
${typeof location.search.ns !== 'undefined' ? ` ${typeof location.search.ns !== 'undefined' ? `
"Namespace": "${location.search.ns}", "Namespace": "${location.search.ns}",
@ -22,7 +23,7 @@ ${typeof location.search.ns !== 'undefined' ? `
"IDPName": "${fake.hacker.noun()}", "IDPName": "${fake.hacker.noun()}",
"Policies": [ "Policies": [
${ ${
range(env('CONSUL_POLICY_COUNT', 10)).map( range(env('CONSUL_POLICY_COUNT', 3)).map(
function(item, j) { function(item, j) {
if(i == 1 && j == 0) { if(i == 1 && j == 0) {
return ` return `
@ -44,7 +45,7 @@ ${typeof location.search.ns !== 'undefined' ? `
], ],
"Roles": [ "Roles": [
${ ${
range(env('CONSUL_ROLE_COUNT', 10)).map( range(env('CONSUL_ROLE_COUNT', 3)).map(
function(item, j) { function(item, j) {
return ` return `
{ {

View File

@ -52,6 +52,7 @@ token:
global-management: Global Management global-management: Global Management
global: Global Scope global: Global Scope
local: Local Scope local: Local Scope
secretID: Secret ID
policy: policy:
search-bar: search-bar:
kind: kind: