From 36c24e76f5c3dc08a4a84df185bb950ac0791d62 Mon Sep 17 00:00:00 2001
From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com>
Date: Fri, 16 Feb 2024 11:29:29 -0600
Subject: [PATCH] UI: add message when copy fails (#25479)
* Add flash message when copy fails for copy button
* Add flash message when copy fails for copy snippet
* changelog
* Fix config-ssh onError
---
changelog/25479.txt | 3 +++
ui/app/components/policy-form.hbs | 3 +++
ui/app/components/sidebar/user-menu.hbs | 7 ++++++-
.../components/configure-ssh-secret.hbs | 9 ++++++++-
.../templates/components/console/log-json.hbs | 3 +++
.../templates/components/console/log-list.hbs | 3 +++
.../components/console/log-object.hbs | 3 +++
.../templates/components/console/log-text.hbs | 3 +++
.../components/control-group-success.hbs | 3 +++
ui/app/templates/components/control-group.hbs | 12 +++++++++++-
.../components/generate-credentials.hbs | 18 ++++++++++++++++--
ui/app/templates/components/tool-hash.hbs | 9 ++++++++-
ui/app/templates/components/tool-random.hbs | 9 ++++++++-
ui/app/templates/components/tool-rewrap.hbs | 9 ++++++++-
ui/app/templates/components/tool-unwrap.hbs | 9 ++++++++-
ui/app/templates/components/tool-wrap.hbs | 9 ++++++++-
.../components/transit-key-action/datakey.hbs | 12 +++++++++++-
.../components/transit-key-action/decrypt.hbs | 3 +++
.../components/transit-key-action/encrypt.hbs | 3 +++
.../components/transit-key-action/export.hbs | 6 ++++++
.../components/transit-key-action/hmac.hbs | 3 +++
.../components/transit-key-action/rewrap.hbs | 9 ++++++++-
.../components/transit-key-action/sign.hbs | 3 +++
.../vault/cluster/secrets/backend/sign.hbs | 18 ++++++++++++++++--
.../core/addon/components/certificate-card.hbs | 3 +++
.../addon/components/choose-pgp-key-form.hbs | 3 +++
.../addon/components/copy-secret-dropdown.hbs | 3 +++
.../core/addon/components/info-table-row.hbs | 8 ++++++++
ui/lib/core/addon/components/json-editor.hbs | 3 +++
ui/lib/core/addon/components/masked-input.hbs | 3 +++
.../addon/components/shamir/dr-token-flow.hbs | 17 +++++++++++++++--
ui/lib/core/addon/components/shamir/form.hbs | 10 +++++++++-
.../kmip/addon/templates/credentials/show.hbs | 3 +++
.../kv/addon/components/page/secret/paths.hbs | 3 +++
.../addon/templates/mode/secondaries/add.hbs | 3 +++
35 files changed, 211 insertions(+), 17 deletions(-)
create mode 100644 changelog/25479.txt
diff --git a/changelog/25479.txt b/changelog/25479.txt
new file mode 100644
index 0000000000..5c23d2bcb7
--- /dev/null
+++ b/changelog/25479.txt
@@ -0,0 +1,3 @@
+```release-note:improvement
+ui: add error message when copy action fails
+```
\ No newline at end of file
diff --git a/ui/app/components/policy-form.hbs b/ui/app/components/policy-form.hbs
index c4085e64f9..6545348de0 100644
--- a/ui/app/components/policy-form.hbs
+++ b/ui/app/components/policy-form.hbs
@@ -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
/>
diff --git a/ui/app/components/sidebar/user-menu.hbs b/ui/app/components/sidebar/user-menu.hbs
index b391b2d736..c881e952a2 100644
--- a/ui/app/components/sidebar/user-menu.hbs
+++ b/ui/app/components/sidebar/user-menu.hbs
@@ -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}}
/>
diff --git a/ui/app/templates/components/configure-ssh-secret.hbs b/ui/app/templates/components/configure-ssh-secret.hbs
index 25e8d19932..b7eb3e91fb 100644
--- a/ui/app/templates/components/configure-ssh-secret.hbs
+++ b/ui/app/templates/components/configure-ssh-secret.hbs
@@ -23,7 +23,14 @@
@@ -95,7 +98,14 @@
We’ve saved your request token, but you may want to copy it just in case:
-
+
{{/if}}
diff --git a/ui/app/templates/components/generate-credentials.hbs b/ui/app/templates/components/generate-credentials.hbs
index 3540bf1110..12b1939dec 100644
--- a/ui/app/templates/components/generate-credentials.hbs
+++ b/ui/app/templates/components/generate-credentials.hbs
@@ -81,11 +81,25 @@
-
+
{{#if this.model.leaseId}}
-
+
{{/if}}
diff --git a/ui/app/templates/components/tool-hash.hbs b/ui/app/templates/components/tool-hash.hbs
index db3e1521ff..b1b59ce368 100644
--- a/ui/app/templates/components/tool-hash.hbs
+++ b/ui/app/templates/components/tool-hash.hbs
@@ -22,7 +22,14 @@
-
+
diff --git a/ui/app/templates/components/tool-random.hbs b/ui/app/templates/components/tool-random.hbs
index e010c677df..83777b1ef0 100644
--- a/ui/app/templates/components/tool-random.hbs
+++ b/ui/app/templates/components/tool-random.hbs
@@ -18,7 +18,14 @@
-
+
diff --git a/ui/app/templates/components/tool-rewrap.hbs b/ui/app/templates/components/tool-rewrap.hbs
index 7a8679ab6c..96d9cc23a8 100644
--- a/ui/app/templates/components/tool-rewrap.hbs
+++ b/ui/app/templates/components/tool-rewrap.hbs
@@ -29,7 +29,14 @@
-
+
diff --git a/ui/app/templates/components/tool-unwrap.hbs b/ui/app/templates/components/tool-unwrap.hbs
index 91e1cdd633..0a96118930 100644
--- a/ui/app/templates/components/tool-unwrap.hbs
+++ b/ui/app/templates/components/tool-unwrap.hbs
@@ -43,7 +43,14 @@
-
+
{{else}}
diff --git a/ui/app/templates/components/tool-wrap.hbs b/ui/app/templates/components/tool-wrap.hbs
index b74cde52fa..981d5d1017 100644
--- a/ui/app/templates/components/tool-wrap.hbs
+++ b/ui/app/templates/components/tool-wrap.hbs
@@ -29,7 +29,14 @@
-
+
diff --git a/ui/app/templates/components/transit-key-action/datakey.hbs b/ui/app/templates/components/transit-key-action/datakey.hbs
index 4dd9a317ae..787c1ed2a1 100644
--- a/ui/app/templates/components/transit-key-action/datakey.hbs
+++ b/ui/app/templates/components/transit-key-action/datakey.hbs
@@ -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}}
Ciphertext
-
+
diff --git a/ui/app/templates/components/transit-key-action/decrypt.hbs b/ui/app/templates/components/transit-key-action/decrypt.hbs
index b0493679c1..8b45ceaaaf 100644
--- a/ui/app/templates/components/transit-key-action/decrypt.hbs
+++ b/ui/app/templates/components/transit-key-action/decrypt.hbs
@@ -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"
/>
diff --git a/ui/app/templates/components/transit-key-action/encrypt.hbs b/ui/app/templates/components/transit-key-action/encrypt.hbs
index 257ce66d9b..cd2a2dc62a 100644
--- a/ui/app/templates/components/transit-key-action/encrypt.hbs
+++ b/ui/app/templates/components/transit-key-action/encrypt.hbs
@@ -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"
/>
diff --git a/ui/app/templates/components/transit-key-action/export.hbs b/ui/app/templates/components/transit-key-action/export.hbs
index beb949099e..83e7c2bf2d 100644
--- a/ui/app/templates/components/transit-key-action/export.hbs
+++ b/ui/app/templates/components/transit-key-action/export.hbs
@@ -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}}
@@ -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"
/>
diff --git a/ui/app/templates/components/transit-key-action/hmac.hbs b/ui/app/templates/components/transit-key-action/hmac.hbs
index 3dedf52cdf..4e76fdba38 100644
--- a/ui/app/templates/components/transit-key-action/hmac.hbs
+++ b/ui/app/templates/components/transit-key-action/hmac.hbs
@@ -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"
/>
diff --git a/ui/app/templates/components/transit-key-action/rewrap.hbs b/ui/app/templates/components/transit-key-action/rewrap.hbs
index 5a173dbfb6..1bdf549a7a 100644
--- a/ui/app/templates/components/transit-key-action/rewrap.hbs
+++ b/ui/app/templates/components/transit-key-action/rewrap.hbs
@@ -68,7 +68,14 @@
Ciphertext
-
+
diff --git a/ui/app/templates/components/transit-key-action/sign.hbs b/ui/app/templates/components/transit-key-action/sign.hbs
index f89d3e4ee1..83ad590ef3 100644
--- a/ui/app/templates/components/transit-key-action/sign.hbs
+++ b/ui/app/templates/components/transit-key-action/sign.hbs
@@ -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"
/>
diff --git a/ui/app/templates/vault/cluster/secrets/backend/sign.hbs b/ui/app/templates/vault/cluster/secrets/backend/sign.hbs
index 23bcb1af17..96fd787dcc 100644
--- a/ui/app/templates/vault/cluster/secrets/backend/sign.hbs
+++ b/ui/app/templates/vault/cluster/secrets/backend/sign.hbs
@@ -47,11 +47,25 @@
-
+
{{#if this.model.leaseId}}
-
+
{{/if}}
diff --git a/ui/lib/core/addon/components/certificate-card.hbs b/ui/lib/core/addon/components/certificate-card.hbs
index d9ac86f556..65ac9cd04c 100644
--- a/ui/lib/core/addon/components/certificate-card.hbs
+++ b/ui/lib/core/addon/components/certificate-card.hbs
@@ -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}}
/>
diff --git a/ui/lib/core/addon/components/choose-pgp-key-form.hbs b/ui/lib/core/addon/components/choose-pgp-key-form.hbs
index 0e71073879..a799ca7360 100644
--- a/ui/lib/core/addon/components/choose-pgp-key-form.hbs
+++ b/ui/lib/core/addon/components/choose-pgp-key-form.hbs
@@ -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"
/>
diff --git a/ui/lib/core/addon/components/copy-secret-dropdown.hbs b/ui/lib/core/addon/components/copy-secret-dropdown.hbs
index 92119eb5d0..46fe99090a 100644
--- a/ui/lib/core/addon/components/copy-secret-dropdown.hbs
+++ b/ui/lib/core/addon/components/copy-secret-dropdown.hbs
@@ -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}}
diff --git a/ui/lib/core/addon/components/info-table-row.hbs b/ui/lib/core/addon/components/info-table-row.hbs
index a79b008216..7850fdf73e 100644
--- a/ui/lib/core/addon/components/info-table-row.hbs
+++ b/ui/lib/core/addon/components/info-table-row.hbs
@@ -40,6 +40,9 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{@value}}
+ @onError={{(fn
+ (set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
+ )}}
class="transparent has-padding-xxs"
data-test-copy-button={{@value}}
/>
@@ -94,6 +97,11 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{@tooltipText}}
+ @onError={{(fn
+ (set-flash-message
+ "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger"
+ )
+ )}}
class="transparent white-icon"
data-test-tooltip-copy={{@tooltipText}}
/>
diff --git a/ui/lib/core/addon/components/json-editor.hbs b/ui/lib/core/addon/components/json-editor.hbs
index ca427b194d..b357b9cd74 100644
--- a/ui/lib/core/addon/components/json-editor.hbs
+++ b/ui/lib/core/addon/components/json-editor.hbs
@@ -39,6 +39,9 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{@value}}
+ @onError={{(fn
+ (set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
+ )}}
class="transparent"
data-test-copy-button={{@value}}
/>
diff --git a/ui/lib/core/addon/components/masked-input.hbs b/ui/lib/core/addon/components/masked-input.hbs
index 07795d9d54..86af1df799 100644
--- a/ui/lib/core/addon/components/masked-input.hbs
+++ b/ui/lib/core/addon/components/masked-input.hbs
@@ -40,6 +40,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 has-padding-xxs"
data-test-copy-button={{or this.copyValue true}}
/>
diff --git a/ui/lib/core/addon/components/shamir/dr-token-flow.hbs b/ui/lib/core/addon/components/shamir/dr-token-flow.hbs
index 78445ec103..e9b4af6193 100644
--- a/ui/lib/core/addon/components/shamir/dr-token-flow.hbs
+++ b/ui/lib/core/addon/components/shamir/dr-token-flow.hbs
@@ -15,7 +15,14 @@
This is a one-time token that will be used to generate the operation token. Please save it.
-
+
{{#if this.otp}}
@@ -25,7 +32,13 @@
This OTP will be used to decode the generated operation token. Please save it.
-
+
{{/if}}
diff --git a/ui/lib/core/addon/components/shamir/form.hbs b/ui/lib/core/addon/components/shamir/form.hbs
index cc80a105cb..07a33cca6d 100644
--- a/ui/lib/core/addon/components/shamir/form.hbs
+++ b/ui/lib/core/addon/components/shamir/form.hbs
@@ -21,7 +21,15 @@
One Time Password (otp)
-
+
{{/if}}
diff --git a/ui/lib/kmip/addon/templates/credentials/show.hbs b/ui/lib/kmip/addon/templates/credentials/show.hbs
index 868cea644d..e81e0bc81d 100644
--- a/ui/lib/kmip/addon/templates/credentials/show.hbs
+++ b/ui/lib/kmip/addon/templates/credentials/show.hbs
@@ -32,6 +32,9 @@
diff --git a/ui/lib/kv/addon/components/page/secret/paths.hbs b/ui/lib/kv/addon/components/page/secret/paths.hbs
index 70e09cde05..2016674cc7 100644
--- a/ui/lib/kv/addon/components/page/secret/paths.hbs
+++ b/ui/lib/kv/addon/components/page/secret/paths.hbs
@@ -25,6 +25,9 @@
@text="Copy"
@isIconOnly={{true}}
@textToCopy={{path.snippet}}
+ @onError={{(fn
+ (set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
+ )}}
data-test-copy-button={{path.snippet}}
class="transparent"
/>
diff --git a/ui/lib/replication/addon/templates/mode/secondaries/add.hbs b/ui/lib/replication/addon/templates/mode/secondaries/add.hbs
index c6a6cbaabd..9fc54ccb78 100644
--- a/ui/lib/replication/addon/templates/mode/secondaries/add.hbs
+++ b/ui/lib/replication/addon/templates/mode/secondaries/add.hbs
@@ -89,6 +89,9 @@
@textToCopy={{this.token}}
class="primary"
@container=".hds-modal"
+ @onError={{(fn
+ (set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
+ )}}
{{on "click" (action "onCopy")}}
/>