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
This commit is contained in:
Chelsea Shaw
2024-02-16 11:29:29 -06:00
committed by GitHub
parent cbe09c76a2
commit 36c24e76f5
35 changed files with 211 additions and 17 deletions

3
changelog/25479.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:improvement
ui: add error message when copy action fails
```

View File

@@ -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
/>

View File

@@ -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>

View File

@@ -23,7 +23,14 @@
</div>
<div class="field is-grouped-split box is-fullwidth is-bottomless">
<Hds::ButtonSet>
<Hds::Copy::Button @text="Copy" @textToCopy={{@model.publicKey}} class="primary" />
<Hds::Copy::Button
@text="Copy"
@textToCopy={{@model.publicKey}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="primary"
/>
<ConfirmAction
@buttonText="Delete"
@buttonColor="secondary"

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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">
@@ -95,7 +98,14 @@
Weve 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}}

View File

@@ -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">

View File

@@ -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}} />

View File

@@ -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}} />

View File

@@ -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}} />

View File

@@ -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}}

View File

@@ -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}} />

View File

@@ -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}} />

View File

@@ -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>

View File

@@ -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>

View File

@@ -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"
/>
</div>

View File

@@ -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>

View File

@@ -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}} />

View File

@@ -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>

View File

@@ -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">

View File

@@ -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}}
/>

View File

@@ -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"
/>

View File

@@ -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}}

View File

@@ -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}}
/>

View File

@@ -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}}
/>

View File

@@ -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}}
/>

View File

@@ -15,7 +15,14 @@
<p class="help has-text-grey has-bottom-margin-xs">
This is a one-time token that will be used to generate the operation token. Please save it.
</p>
<Hds::Copy::Snippet @textToCopy={{this.encodedToken}} @container="#shamir-flow-modal" data-test-shamir-encoded-token />
<Hds::Copy::Snippet
@textToCopy={{this.encodedToken}}
@container="#shamir-flow-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
data-test-shamir-encoded-token
/>
</div>
{{#if this.otp}}
<div class="has-bottom-margin-xl">
@@ -25,7 +32,13 @@
<p class="help has-text-grey has-bottom-margin-xs">
This OTP will be used to decode the generated operation token. Please save it.
</p>
<Hds::Copy::Snippet @textToCopy={{this.otp}} @container="#shamir-flow-modal" />
<Hds::Copy::Snippet
@textToCopy={{this.otp}}
@container="#shamir-flow-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
/>
</div>
{{/if}}
<div class="has-bottom-margin-xl">

View File

@@ -21,7 +21,15 @@
<h4 class="hds-alert__title hds-font-weight-semibold">
One Time Password (otp)
</h4>
<Hds::Copy::Snippet data-test-otp @textToCopy={{@otp}} @color="secondary" @container="#shamir-flow-modal" />
<Hds::Copy::Snippet
data-test-otp
@textToCopy={{@otp}}
@color="secondary"
@container="#shamir-flow-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
/>
</A.Description>
</Hds::Alert>
{{/if}}

View File

@@ -32,6 +32,9 @@
<Hds::Copy::Button
@text="Copy certificate"
@textToCopy={{this.model.certificate}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="toolbar-link is-flex-center"
data-test-copy-button
/>

View File

@@ -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"
/>

View File

@@ -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")}}
/>
<Hds::Button