Skip to content

Commit f542122

Browse files
committed
Settings::ApiTokens: Improve token value display
1 parent ab5f9fb commit f542122

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

app/components/settings/api-tokens.hbs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,21 @@
7373
</div>
7474

7575
{{#if token.token}}
76-
<div local-class="new-token" data-test-token>
76+
<div local-class="new-token">
7777
Please record this token somewhere, you cannot retrieve
7878
its value again. For use on the command line you can save it to <code>~/.cargo/credentials</code>
7979
with:
8080

81-
<pre class="terminal">cargo login {{token.token}}</pre>
81+
<div local-class="token-display">
82+
<span local-class="token-value" data-test-token>{{token.token}}</span>
83+
84+
{{#if (is-clipboard-supported)}}
85+
<CopyButton @copyText={{token.token}} local-class="copy-button">
86+
<span local-class="copy-button-label">Copy</span>
87+
{{svg-jar "copy" aria-hidden="true" local-class="copy-button-icon"}}
88+
</CopyButton>
89+
{{/if}}
90+
</div>
8291
</div>
8392
{{/if}}
8493

app/components/settings/api-tokens.module.css

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,44 @@
8383

8484
.new-token {
8585
margin: 24px 0;
86+
}
8687

87-
pre {
88-
border-radius: 4px;
89-
margin-bottom: 0;
90-
user-select: all;
88+
.token-display {
89+
display: grid;
90+
grid-template-columns: 1fr auto;
91+
align-items: center;
92+
background: var(--main-color);
93+
color: white;
94+
font-family: var(--font-monospace);
95+
border-radius: 4px;
96+
margin-top: 16px;
97+
}
98+
99+
.token-value {
100+
padding: 20px;
101+
user-select: all;
102+
}
103+
104+
.copy-button {
105+
composes: button-reset from '../../styles/shared/buttons.module.css';
106+
align-self: stretch;
107+
padding: 0 16px;
108+
cursor: pointer;
109+
110+
&:hover {
111+
color: #ddd8b2;
91112
}
92113
}
93114

115+
.copy-button-label {
116+
composes: sr-only from '../../styles/shared/a11y.module.css';
117+
}
118+
119+
.copy-button-icon {
120+
width: 24px;
121+
height: 24px;
122+
}
123+
94124
@media (min-width: 640px) {
95125
.new-token-form {
96126
display: grid;

tests/acceptance/api-token-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ module('Acceptance | api-tokens', function (hooks) {
126126
assert.dom('[data-test-api-token="3"] [data-test-revoke-token-button]').exists();
127127
assert.dom('[data-test-api-token="3"] [data-test-saving-spinner]').doesNotExist();
128128
assert.dom('[data-test-api-token="3"] [data-test-error]').doesNotExist();
129-
assert.dom('[data-test-token]').includesText(`cargo login ${token.token}`);
129+
assert.dom('[data-test-token]').hasText(token.token);
130130
});
131131

132132
test('navigating away while creating a token does not keep it in the list', async function (assert) {

0 commit comments

Comments
 (0)