Merge pull request #245 from hashicorp/copyable-ids
feat: Make all IDs copyable
This commit is contained in:
33 files changed
+204
-37
No files matched your search
@@ -1,7 +1,6 @@
|
||||
{{#if this.isClipboardLibrarySupported}}
|
||||
<span
|
||||
id={{this.id}}
|
||||
aria-labelledby={{this.copyableButtonId}}
|
||||
class="copyable"
|
||||
{{did-insert this.register}}
|
||||
{{will-destroy this.destroy}}
|
||||
@@ -12,10 +11,12 @@
|
||||
|
||||
<Rose::Button
|
||||
id={{this.copyableButtonId}}
|
||||
aria-describedby={{this.id}}
|
||||
class="copyable-button"
|
||||
@style="ghost"
|
||||
@iconOnly={{this.icon}}
|
||||
>{{@text}}</Rose::Button>
|
||||
title={{this.copyableButtonText}}
|
||||
>{{this.copyableButtonText}}</Rose::Button>
|
||||
</span>
|
||||
{{else}}
|
||||
{{yield}}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Component from '@glimmer/component';
|
||||
import ClipboardJS from 'clipboard';
|
||||
import { action } from '@ember/object';
|
||||
import { tracked } from '@glimmer/tracking';
|
||||
import { generateComponentID } from 'rose/utilities/component-auto-id';
|
||||
import { task, timeout } from 'ember-concurrency';
|
||||
import { set } from '@ember/object';
|
||||
@@ -12,11 +11,9 @@ export default class CopyableComponent extends Component {
|
||||
// =attributes
|
||||
|
||||
id = generateComponentID();
|
||||
copyableButtonId = `copyable-button-${this.id}`;
|
||||
icon = 'copy-action';
|
||||
|
||||
@tracked text;
|
||||
@tracked clipboard;
|
||||
copyableButtonId = `copyable-button-${this.id}`;
|
||||
copyableButtonText = this.args.buttonText;
|
||||
|
||||
/**
|
||||
* A Ember Concurrency-based task that updates copy icon to a success state
|
||||
@@ -30,8 +27,10 @@ export default class CopyableComponent extends Component {
|
||||
*/
|
||||
@task(function * () {
|
||||
set(this, 'icon', 'copy-success');
|
||||
set(this, 'copyableButtonText', this.args.acknowledgeText);
|
||||
yield timeout(1000);
|
||||
set(this, 'icon', 'copy-action');
|
||||
set(this, 'copyableButtonText', this.args.buttonText);
|
||||
}).drop() successIconTimer;
|
||||
|
||||
// =methods
|
||||
|
||||
@@ -86,6 +86,9 @@
|
||||
|
||||
.copyable {
|
||||
.copyable-button {
|
||||
padding: 0;
|
||||
position: relative;
|
||||
top: -2px;
|
||||
padding: 0 sizing.rems(xxs);
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,9 @@
|
||||
<h2>{{t "resources.auth-method.title"}}</h2>
|
||||
<p>{{t "resources.auth-method.description"}}</p>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
+7
-1
@@ -1,2 +1,8 @@
|
||||
<h2>{{t "resources.account.title"}}</h2>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
+7
-1
@@ -1,3 +1,9 @@
|
||||
<h2>{{t "resources.account.title"}}</h2>
|
||||
<p>{{t 'resources.account.messages.set-password.description'}}</p>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
@@ -24,7 +24,13 @@
|
||||
{{account.username}}
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<code>{{account.id}}</code>
|
||||
<Copyable
|
||||
@text={{account.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{account.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
|
||||
@@ -46,7 +46,13 @@
|
||||
</Rose::Badge>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<code>{{authMethod.id}}</code>
|
||||
<Copyable
|
||||
@text={{authMethod.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{authMethod.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
<h2>{{t "resources.group.title"}}</h2>
|
||||
<p>{{t "resources.group.description"}}</p>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
@@ -17,7 +17,13 @@
|
||||
{{member.displayName}}
|
||||
</row.headerCell>
|
||||
<row.cell>
|
||||
<code>{{member.id}}</code>
|
||||
<Copyable
|
||||
@text={{member.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{member.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<Rose::Dropdown
|
||||
|
||||
@@ -39,7 +39,13 @@
|
||||
<p>{{group.description}}</p>
|
||||
</row.headerCell>
|
||||
<row.cell>
|
||||
<code>{{group.id}}</code>
|
||||
<Copyable
|
||||
@text={{group.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{group.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
|
||||
+7
-1
@@ -1,3 +1,9 @@
|
||||
<h2>{{t "resources.host-catalog.title"}}</h2>
|
||||
<p>{{t "resources.host-catalog.description"}}</p>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
+7
-1
@@ -1,3 +1,9 @@
|
||||
<h2>{{t "resources.host-set.title"}}</h2>
|
||||
<p>{{t "resources.host-set.description"}}</p>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
+7
-1
@@ -25,7 +25,13 @@
|
||||
<Rose::Badge>{{host.type}}</Rose::Badge>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<code>{{host.id}}</code>
|
||||
<Copyable
|
||||
@text={{host.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{host.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<Rose::Dropdown
|
||||
|
||||
+7
-1
@@ -26,7 +26,13 @@
|
||||
</Rose::Badge>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<code>{{hostSet.id}}</code>
|
||||
<Copyable
|
||||
@text={{hostSet.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{hostSet.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
|
||||
+7
-1
@@ -1,3 +1,9 @@
|
||||
<h2>{{t "resources.host.title"}}</h2>
|
||||
<p>{{t "resources.host.description"}}</p>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
+7
-1
@@ -27,7 +27,13 @@
|
||||
</Rose::Badge>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<code>{{host.id}}</code>
|
||||
<Copyable
|
||||
@text={{host.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{host.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<code>{{host.attributes.address}}</code>
|
||||
|
||||
@@ -47,7 +47,13 @@
|
||||
</Rose::Badge>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<code>{{hostCatalog.id}}</code>
|
||||
<Copyable
|
||||
@text={{hostCatalog.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{hostCatalog.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
|
||||
@@ -7,7 +7,13 @@
|
||||
<page.header>
|
||||
<h2>{{t "resources.project.title"}}</h2>
|
||||
<p>{{t "resources.project.description"}}</p>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
</page.header>
|
||||
|
||||
<page.navigation>
|
||||
|
||||
@@ -28,7 +28,13 @@
|
||||
{{#each @model as |sessionAggregate|}}
|
||||
<body.row as |row|>
|
||||
<row.headerCell>
|
||||
<code>{{sessionAggregate.session.id}}</code>
|
||||
<Copyable
|
||||
@text={{sessionAggregate.session.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{sessionAggregate.session.id}}</code>
|
||||
</Copyable>
|
||||
</row.headerCell>
|
||||
<row.cell>{{sessionAggregate.user.displayName}}</row.cell>
|
||||
<row.cell>{{sessionAggregate.target.displayName}}</row.cell>
|
||||
|
||||
@@ -51,7 +51,13 @@
|
||||
{{/if}}
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<code>{{target.id}}</code>
|
||||
<Copyable
|
||||
@text={{target.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{target.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
<h2>{{t "resources.target.title"}}</h2>
|
||||
<p>{{t "resources.target.description"}}</p>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
@@ -22,7 +22,13 @@
|
||||
<Rose::Badge>{{t (concat 'resources.host-set.types.' hostSet.model.type)}}</Rose::Badge>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<code>{{hostSet.model.id}}</code>
|
||||
<Copyable
|
||||
@text={{hostSet.model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{hostSet.model.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<Rose::Dropdown
|
||||
|
||||
@@ -41,7 +41,13 @@
|
||||
<p>{{role.description}}</p>
|
||||
</row.headerCell>
|
||||
<row.cell>
|
||||
<code>{{role.id}}</code>
|
||||
<Copyable
|
||||
@text={{role.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{role.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
<h2>{{t "resources.role.title"}}</h2>
|
||||
<p>{{t "resources.role.description"}}</p>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
@@ -1,3 +1,9 @@
|
||||
<h2>{{t "resources.role.title"}}</h2>
|
||||
<p>{{t "resources.role.grant.description"}}</p>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
@@ -21,7 +21,13 @@
|
||||
{{t (concat 'resources.role.principal.types.' principal.type)}}
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<code>{{principal.model.id}}</code>
|
||||
<Copyable
|
||||
@text={{principal.model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{principal.model.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
<row.cell>
|
||||
<Rose::Dropdown
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
<h2>{{t "resources.role.title"}}</h2>
|
||||
<p>{{t "resources.role.principal.description"}}</p>
|
||||
<p><code>{{@model.role.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
@@ -41,7 +41,13 @@
|
||||
<p>{{user.description}}</p>
|
||||
</row.headerCell>
|
||||
<row.cell>
|
||||
<code>{{user.id}}</code>
|
||||
<Copyable
|
||||
@text={{user.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{user.id}}</code>
|
||||
</Copyable>
|
||||
</row.cell>
|
||||
</body.row>
|
||||
{{/each}}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
<h2>{{t "resources.user.title"}}</h2>
|
||||
<p>{{t "resources.user.description"}}</p>
|
||||
<p><code>{{@model.id}}</code></p>
|
||||
<Copyable
|
||||
@text={{@model.id}}
|
||||
@buttonText={{t "actions.copy-to-clipboard"}}
|
||||
@acknowledgeText={{t "states.copied"}}
|
||||
>
|
||||
<code>{{@model.id}}</code>
|
||||
</Copyable>
|
||||
@@ -7,7 +7,7 @@ module('Integration | Component | copyable', function(hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test('it renders', async function(assert) {
|
||||
await render(hbs`<Copyable @text="Copy me">text</Copyable>`);
|
||||
await render(hbs`<Copyable @buttonText="Copy me">text</Copyable>`);
|
||||
assert.ok(find('.copyable'));
|
||||
assert.equal(find('.copyable-content').textContent.trim(), 'text');
|
||||
assert.equal(find('.copyable-button').textContent.trim(), 'Copy me');
|
||||
|
||||
@@ -7,6 +7,7 @@ save: Save
|
||||
manage: Manage
|
||||
help: Need help?
|
||||
back: Back
|
||||
copy-to-clipboard: Copy to Clipboard
|
||||
authenticate: Authenticate
|
||||
deauthenticate: Deauthenticate
|
||||
choose-org: Choose Scope
|
||||
@@ -27,4 +28,4 @@ add-members: Add Members
|
||||
add-hosts: Add Hosts
|
||||
set-password: Set Password
|
||||
change-password: Change Password
|
||||
edit-form: Edit Form
|
||||
edit-form: Edit Form
|
||||
@@ -2,3 +2,4 @@ info: Info
|
||||
success: Success
|
||||
warning: Warning
|
||||
error: Error
|
||||
copied: Copied
|
||||
Reference in new issue
Block a user