Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: add message when copy fails #25479

Merged
merged 4 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog/25479.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: add error message when copy action fails
```
3 changes: 3 additions & 0 deletions ui/app/components/policy-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{@model.policy}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent"
data-test-copy-button
/>
Expand Down
7 changes: 6 additions & 1 deletion ui/app/components/sidebar/user-menu.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@
@isFullWidth={{true}}
@container="#container"
class="in-dropdown link is-flex-start"
{{on "click" (fn (set-flash-message "Token copied!"))}}
@onSuccess={{(fn (set-flash-message "Token copied!"))}}
@onError={{(fn
(set-flash-message
"Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger"
)
)}}
data-test-copy-button={{this.auth.currentToken}}
/>
</li>
Expand Down
3 changes: 3 additions & 0 deletions ui/app/templates/components/configure-ssh-secret.hbs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want to add onError to ConfirmAction here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
@buttonColor="secondary"
@confirmMessage="This will remove the CA certificate information."
@onConfirmAction={{this.delete}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
/>
</Hds::ButtonSet>
</div>
Expand Down
3 changes: 3 additions & 0 deletions ui/app/templates/components/console/log-json.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{stringify this.content}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent icon-grey-500 top-right-absolute"
/>
</div>
3 changes: 3 additions & 0 deletions ui/app/templates/components/console/log-list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{multi-line-join this.list}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent icon-grey-500 top-right-absolute"
/>
</div>
3 changes: 3 additions & 0 deletions ui/app/templates/components/console/log-object.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{this.columns}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent icon-grey-500 top-right-absolute"
/>
</div>
3 changes: 3 additions & 0 deletions ui/app/templates/components/console/log-text.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{@content}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent icon-grey-500 top-right-absolute"
/>
</div>
3 changes: 3 additions & 0 deletions ui/app/templates/components/control-group-success.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{stringify this.unwrapData}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent top-right-absolute"
/>
</div>
Expand Down
12 changes: 11 additions & 1 deletion ui/app/templates/components/control-group.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{this.model.id}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent top-right-absolute"
/>
<div class="message-body">
Expand Down Expand Up @@ -95,7 +98,14 @@
We’ve saved your request token, but you may want to copy it just in case:
</p>
<div>
<Hds::Copy::Snippet data-test-token-value @textToCopy={{this.controlGroupResponse.token}} @color="secondary" />
<Hds::Copy::Snippet
data-test-token-value
@textToCopy={{this.controlGroupResponse.token}}
@color="secondary"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
/>
</div>
</div>
{{/if}}
Expand Down
18 changes: 16 additions & 2 deletions ui/app/templates/components/generate-credentials.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,25 @@
</div>
<div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control">
<Hds::Copy::Button @text="Copy credentials" @textToCopy={{this.model.toCreds}} class="primary" />
<Hds::Copy::Button
@text="Copy credentials"
@textToCopy={{this.model.toCreds}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="primary"
/>
</div>
{{#if this.model.leaseId}}
<div class="control">
<Hds::Copy::Button @text="Copy Lease ID" @textToCopy={{this.model.leaseId}} class="secondary" />
<Hds::Copy::Button
@text="Copy Lease ID"
@textToCopy={{this.model.leaseId}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="secondary"
/>
</div>
{{/if}}
<div class="control">
Expand Down
9 changes: 8 additions & 1 deletion ui/app/templates/components/tool-hash.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@
</div>
<div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control">
<Hds::Copy::Button @text="Copy" @textToCopy={{@sum}} class="primary" />
<Hds::Copy::Button
@text="Copy"
@textToCopy={{@sum}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="primary"
/>
</div>
<div class="control">
<Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} data-test-tools-back={{true}} />
Expand Down
9 changes: 8 additions & 1 deletion ui/app/templates/components/tool-random.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
</div>
<div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control">
<Hds::Copy::Button @text="Copy" @textToCopy={{@random_bytes}} class="primary" />
<Hds::Copy::Button
@text="Copy"
@textToCopy={{@random_bytes}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="primary"
/>
</div>
<div class="control">
<Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} />
Expand Down
9 changes: 8 additions & 1 deletion ui/app/templates/components/tool-rewrap.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@
</div>
<div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control">
<Hds::Copy::Button @text="Copy" @textToCopy={{@rewrap_token}} class="primary" />
<Hds::Copy::Button
@text="Copy"
@textToCopy={{@rewrap_token}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="primary"
/>
</div>
<div class="control">
<Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} />
Expand Down
9 changes: 8 additions & 1 deletion ui/app/templates/components/tool-unwrap.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@
</T.Panel>
</Hds::Tabs>
<Hds::ButtonSet class="has-top-padding-m">
<Hds::Copy::Button @text="Copy unwrapped data" @textToCopy={{stringify @unwrap_data}} class="primary" />
<Hds::Copy::Button
@text="Copy unwrapped data"
@textToCopy={{stringify @unwrap_data}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="primary"
/>
<Hds::Button {{on "click" this.onClear}} @color="secondary" @text="Back" />
</Hds::ButtonSet>
{{else}}
Expand Down
9 changes: 8 additions & 1 deletion ui/app/templates/components/tool-wrap.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@
</div>
<div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control">
<Hds::Copy::Button @text="Copy" @textToCopy={{@token}} class="primary" />
<Hds::Copy::Button
@text="Copy"
@textToCopy={{@token}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="primary"
/>
</div>
<div class="control">
<Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} />
Expand Down
12 changes: 11 additions & 1 deletion ui/app/templates/components/transit-key-action/datakey.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,20 @@
@textToCopy={{@plaintext}}
@color="secondary"
@container="#transit-datakey-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
/>
{{/if}}
<h2 class="has-text-weight-semibold is-6">Ciphertext</h2>
<Hds::Copy::Snippet @textToCopy={{@ciphertext}} @color="secondary" @container="#transit-datakey-modal" />
<Hds::Copy::Snippet
@textToCopy={{@ciphertext}}
@color="secondary"
@container="#transit-datakey-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
/>
</M.Body>
<M.Footer as |F|>
<Hds::Button @text="Close" {{on "click" F.close}} />
Expand Down
3 changes: 3 additions & 0 deletions ui/app/templates/components/transit-key-action/decrypt.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
@textToCopy={{@plaintext}}
@color="secondary"
@container="#transit-decrypt-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
data-test-encrypted-value="plaintext"
/>
</M.Body>
Expand Down
3 changes: 3 additions & 0 deletions ui/app/templates/components/transit-key-action/encrypt.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
@textToCopy={{@ciphertext}}
@color="secondary"
@container="#transit-encrypt-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
data-test-encrypted-value="ciphertext"
/>
</M.Body>
Expand Down
6 changes: 6 additions & 0 deletions ui/app/templates/components/transit-key-action/export.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@
@textToCopy={{@wrappedToken}}
@color="secondary"
@container="#transit-export-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
data-test-encrypted-value="export"
/>
{{else}}
Expand All @@ -88,6 +91,9 @@
@isIconOnly={{true}}
@textToCopy={{stringify @keys}}
@container="#transit-export-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent top-right-absolute"
/>
</div>
Expand Down
3 changes: 3 additions & 0 deletions ui/app/templates/components/transit-key-action/hmac.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
@textToCopy={{@hmac}}
@color="secondary"
@container="#transit-hmac-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
data-test-encrypted-value="hmac"
/>
</M.Body>
Expand Down
9 changes: 8 additions & 1 deletion ui/app/templates/components/transit-key-action/rewrap.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@
</M.Header>
<M.Body>
<h2 class="title is-6">Ciphertext</h2>
<Hds::Copy::Snippet @textToCopy={{@ciphertext}} @color="secondary" @container="#transit-rewrap-modal" />
<Hds::Copy::Snippet
@textToCopy={{@ciphertext}}
@color="secondary"
@container="#transit-rewrap-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
/>
</M.Body>
<M.Footer as |F|>
<Hds::Button @text="Close" {{on "click" F.close}} />
Expand Down
3 changes: 3 additions & 0 deletions ui/app/templates/components/transit-key-action/sign.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
@textToCopy={{@signature}}
@color="secondary"
@container="#transit-sign-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
data-test-encrypted-value="signature"
/>
</M.Body>
Expand Down
18 changes: 16 additions & 2 deletions ui/app/templates/vault/cluster/secrets/backend/sign.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,25 @@
</div>
<div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control">
<Hds::Copy::Button @text="Copy key" @textToCopy={{this.model.signedKey}} class="primary" />
<Hds::Copy::Button
@text="Copy key"
@textToCopy={{this.model.signedKey}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="primary"
/>
</div>
{{#if this.model.leaseId}}
<div class="control">
<Hds::Copy::Button @text="Copy lease ID" @textToCopy={{this.model.leaseId}} class="secondary" />
<Hds::Copy::Button
@text="Copy lease ID"
@textToCopy={{this.model.leaseId}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="secondary"
/>
</div>
{{/if}}
<div class="control">
Expand Down
3 changes: 3 additions & 0 deletions ui/lib/core/addon/components/certificate-card.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{this.copyValue}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent"
data-test-copy-button={{or this.copyValue true}}
/>
Expand Down
3 changes: 3 additions & 0 deletions ui/lib/core/addon/components/choose-pgp-key-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
class="has-bottom-margin-s"
@textToCopy={{this.pgpKey}}
@color="secondary"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
data-test-pgp-key-copy
@container="#shamir-flow-modal"
/>
Expand Down
3 changes: 3 additions & 0 deletions ui/lib/core/addon/components/copy-secret-dropdown.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
@text="Copy JSON"
@textToCopy={{@clipboardText}}
@isFullWidth={{true}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="in-dropdown link is-flex-start"
{{on "click" (action (set-flash-message "JSON Copied!"))}}
data-test-copy-button={{@clipboardText}}
Expand Down
Loading
Loading