Skip to content

Commit 0c441ee

Browse files
authored
[ui] Read from localStorage to display a copyable access token and secret (#22105)
* Read from localStorage to display a copyable access token and secret * Error when loading handled
1 parent f360c5e commit 0c441ee

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

.changelog/22105.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:improvement
2+
ui: Adds a copyable token accessor/secret on the settings page when signed in
3+
```

ui/packages/consul-ui/app/templates/settings.hbs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,34 @@ as |item|}}
3535
<A.Title>Local Storage</A.Title>
3636
<A.Description>These settings are immediately saved to local storage and persisted through browser usage.</A.Description>
3737
</Hds::Alert>
38+
39+
<DataSource
40+
@src={{uri "settings://consul:token"}}
41+
@onchange={{action (mut token) value="data"}}
42+
@onerror={{action (mut error) value="error"}}
43+
/>
44+
{{#if error}}
45+
<Hds::Alert @type="inline" @color="highlight" class="mb-3 mt-2" @icon="token" as |A|>
46+
<A.Title>Error loading token</A.Title>
47+
<A.Description>
48+
{{error.message}}
49+
</A.Description>
50+
</Hds::Alert>
51+
{{/if}}
52+
{{#if token}}
53+
<Hds::Alert @type="inline" @color="highlight" class="mb-3 mt-2" @icon="token" as |A|>
54+
<A.Title>Your Access Token</A.Title>
55+
<A.Description>
56+
<Hds::Form::MaskedInput::Field readonly @isContentMasked={{false}} @hasCopyButton={{true}} @value={{token.AccessorID}} as |F|>
57+
<F.Label>Accessor ID</F.Label>
58+
</Hds::Form::MaskedInput::Field>
59+
<Hds::Form::MaskedInput::Field readonly @hasCopyButton={{true}} @value={{token.SecretID}} as |F|>
60+
<F.Label>Secret ID</F.Label>
61+
</Hds::Form::MaskedInput::Field>
62+
</A.Description>
63+
</Hds::Alert>
64+
{{/if}}
65+
3866
<form>
3967
{{#if (not (env 'CONSUL_UI_DISABLE_REALTIME'))}}
4068
<Disclosure as |disclosure|>

0 commit comments

Comments
 (0)