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" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{@model.policy}} @textToCopy={{@model.policy}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent" class="transparent"
data-test-copy-button data-test-copy-button
/> />

View File

@@ -53,7 +53,12 @@
@isFullWidth={{true}} @isFullWidth={{true}}
@container="#container" @container="#container"
class="in-dropdown link is-flex-start" 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}} data-test-copy-button={{this.auth.currentToken}}
/> />
</li> </li>

View File

@@ -23,7 +23,14 @@
</div> </div>
<div class="field is-grouped-split box is-fullwidth is-bottomless"> <div class="field is-grouped-split box is-fullwidth is-bottomless">
<Hds::ButtonSet> <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 <ConfirmAction
@buttonText="Delete" @buttonText="Delete"
@buttonColor="secondary" @buttonColor="secondary"

View File

@@ -16,6 +16,9 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{stringify this.content}} @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" class="transparent icon-grey-500 top-right-absolute"
/> />
</div> </div>

View File

@@ -15,6 +15,9 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{multi-line-join this.list}} @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" class="transparent icon-grey-500 top-right-absolute"
/> />
</div> </div>

View File

@@ -9,6 +9,9 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{this.columns}} @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" class="transparent icon-grey-500 top-right-absolute"
/> />
</div> </div>

View File

@@ -9,6 +9,9 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{@content}} @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" class="transparent icon-grey-500 top-right-absolute"
/> />
</div> </div>

View File

@@ -29,6 +29,9 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{stringify this.unwrapData}} @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" class="transparent top-right-absolute"
/> />
</div> </div>

View File

@@ -53,6 +53,9 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{this.model.id}} @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" class="transparent top-right-absolute"
/> />
<div class="message-body"> <div class="message-body">
@@ -95,7 +98,14 @@
Weve saved your request token, but you may want to copy it just in case: Weve saved your request token, but you may want to copy it just in case:
</p> </p>
<div> <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>
</div> </div>
{{/if}} {{/if}}

View File

@@ -81,11 +81,25 @@
</div> </div>
<div class="field is-grouped box is-fullwidth is-bottomless"> <div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control"> <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> </div>
{{#if this.model.leaseId}} {{#if this.model.leaseId}}
<div class="control"> <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> </div>
{{/if}} {{/if}}
<div class="control"> <div class="control">

View File

@@ -22,7 +22,14 @@
</div> </div>
<div class="field is-grouped box is-fullwidth is-bottomless"> <div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control"> <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>
<div class="control"> <div class="control">
<Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} data-test-tools-back={{true}} /> <Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} data-test-tools-back={{true}} />

View File

@@ -18,7 +18,14 @@
</div> </div>
<div class="field is-grouped box is-fullwidth is-bottomless"> <div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control"> <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>
<div class="control"> <div class="control">
<Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} /> <Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} />

View File

@@ -29,7 +29,14 @@
</div> </div>
<div class="field is-grouped box is-fullwidth is-bottomless"> <div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control"> <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>
<div class="control"> <div class="control">
<Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} /> <Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} />

View File

@@ -43,7 +43,14 @@
</T.Panel> </T.Panel>
</Hds::Tabs> </Hds::Tabs>
<Hds::ButtonSet class="has-top-padding-m"> <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::Button {{on "click" this.onClear}} @color="secondary" @text="Back" />
</Hds::ButtonSet> </Hds::ButtonSet>
{{else}} {{else}}

View File

@@ -29,7 +29,14 @@
</div> </div>
<div class="field is-grouped box is-fullwidth is-bottomless"> <div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control"> <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>
<div class="control"> <div class="control">
<Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} /> <Hds::Button @text="Back" @color="secondary" {{on "click" this.onClear}} />

View File

@@ -86,10 +86,20 @@
@textToCopy={{@plaintext}} @textToCopy={{@plaintext}}
@color="secondary" @color="secondary"
@container="#transit-datakey-modal" @container="#transit-datakey-modal"
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
/> />
{{/if}} {{/if}}
<h2 class="has-text-weight-semibold is-6">Ciphertext</h2> <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.Body>
<M.Footer as |F|> <M.Footer as |F|>
<Hds::Button @text="Close" {{on "click" F.close}} /> <Hds::Button @text="Close" {{on "click" F.close}} />

View File

@@ -65,6 +65,9 @@
@textToCopy={{@plaintext}} @textToCopy={{@plaintext}}
@color="secondary" @color="secondary"
@container="#transit-decrypt-modal" @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" data-test-encrypted-value="plaintext"
/> />
</M.Body> </M.Body>

View File

@@ -78,6 +78,9 @@
@textToCopy={{@ciphertext}} @textToCopy={{@ciphertext}}
@color="secondary" @color="secondary"
@container="#transit-encrypt-modal" @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" data-test-encrypted-value="ciphertext"
/> />
</M.Body> </M.Body>

View File

@@ -76,6 +76,9 @@
@textToCopy={{@wrappedToken}} @textToCopy={{@wrappedToken}}
@color="secondary" @color="secondary"
@container="#transit-export-modal" @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" data-test-encrypted-value="export"
/> />
{{else}} {{else}}
@@ -88,6 +91,9 @@
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{stringify @keys}} @textToCopy={{stringify @keys}}
@container="#transit-export-modal" @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" class="transparent top-right-absolute"
/> />
</div> </div>

View File

@@ -60,6 +60,9 @@
@textToCopy={{@hmac}} @textToCopy={{@hmac}}
@color="secondary" @color="secondary"
@container="#transit-hmac-modal" @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" data-test-encrypted-value="hmac"
/> />
</M.Body> </M.Body>

View File

@@ -68,7 +68,14 @@
</M.Header> </M.Header>
<M.Body> <M.Body>
<h2 class="title is-6">Ciphertext</h2> <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.Body>
<M.Footer as |F|> <M.Footer as |F|>
<Hds::Button @text="Close" {{on "click" F.close}} /> <Hds::Button @text="Close" {{on "click" F.close}} />

View File

@@ -129,6 +129,9 @@
@textToCopy={{@signature}} @textToCopy={{@signature}}
@color="secondary" @color="secondary"
@container="#transit-sign-modal" @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" data-test-encrypted-value="signature"
/> />
</M.Body> </M.Body>

View File

@@ -47,11 +47,25 @@
</div> </div>
<div class="field is-grouped box is-fullwidth is-bottomless"> <div class="field is-grouped box is-fullwidth is-bottomless">
<div class="control"> <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> </div>
{{#if this.model.leaseId}} {{#if this.model.leaseId}}
<div class="control"> <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> </div>
{{/if}} {{/if}}
<div class="control"> <div class="control">

View File

@@ -25,6 +25,9 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{this.copyValue}} @textToCopy={{this.copyValue}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent" class="transparent"
data-test-copy-button={{or this.copyValue true}} data-test-copy-button={{or this.copyValue true}}
/> />

View File

@@ -26,6 +26,9 @@
class="has-bottom-margin-s" class="has-bottom-margin-s"
@textToCopy={{this.pgpKey}} @textToCopy={{this.pgpKey}}
@color="secondary" @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 data-test-pgp-key-copy
@container="#shamir-flow-modal" @container="#shamir-flow-modal"
/> />

View File

@@ -17,6 +17,9 @@
@text="Copy JSON" @text="Copy JSON"
@textToCopy={{@clipboardText}} @textToCopy={{@clipboardText}}
@isFullWidth={{true}} @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" class="in-dropdown link is-flex-start"
{{on "click" (action (set-flash-message "JSON Copied!"))}} {{on "click" (action (set-flash-message "JSON Copied!"))}}
data-test-copy-button={{@clipboardText}} data-test-copy-button={{@clipboardText}}

View File

@@ -40,6 +40,9 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{@value}} @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" class="transparent has-padding-xxs"
data-test-copy-button={{@value}} data-test-copy-button={{@value}}
/> />
@@ -94,6 +97,11 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{@tooltipText}} @textToCopy={{@tooltipText}}
@onError={{(fn
(set-flash-message
"Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger"
)
)}}
class="transparent white-icon" class="transparent white-icon"
data-test-tooltip-copy={{@tooltipText}} data-test-tooltip-copy={{@tooltipText}}
/> />

View File

@@ -39,6 +39,9 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{@value}} @textToCopy={{@value}}
@onError={{(fn
(set-flash-message "Clipboard copy failed. Please make sure the browser Clipboard API is allowed." "danger")
)}}
class="transparent" class="transparent"
data-test-copy-button={{@value}} data-test-copy-button={{@value}}
/> />

View File

@@ -40,6 +40,9 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{this.copyValue}} @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" class="transparent has-padding-xxs"
data-test-copy-button={{or this.copyValue true}} data-test-copy-button={{or this.copyValue true}}
/> />

View File

@@ -15,7 +15,14 @@
<p class="help has-text-grey has-bottom-margin-xs"> <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. This is a one-time token that will be used to generate the operation token. Please save it.
</p> </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> </div>
{{#if this.otp}} {{#if this.otp}}
<div class="has-bottom-margin-xl"> <div class="has-bottom-margin-xl">
@@ -25,7 +32,13 @@
<p class="help has-text-grey has-bottom-margin-xs"> <p class="help has-text-grey has-bottom-margin-xs">
This OTP will be used to decode the generated operation token. Please save it. This OTP will be used to decode the generated operation token. Please save it.
</p> </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> </div>
{{/if}} {{/if}}
<div class="has-bottom-margin-xl"> <div class="has-bottom-margin-xl">

View File

@@ -21,7 +21,15 @@
<h4 class="hds-alert__title hds-font-weight-semibold"> <h4 class="hds-alert__title hds-font-weight-semibold">
One Time Password (otp) One Time Password (otp)
</h4> </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> </A.Description>
</Hds::Alert> </Hds::Alert>
{{/if}} {{/if}}

View File

@@ -32,6 +32,9 @@
<Hds::Copy::Button <Hds::Copy::Button
@text="Copy certificate" @text="Copy certificate"
@textToCopy={{this.model.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" class="toolbar-link is-flex-center"
data-test-copy-button data-test-copy-button
/> />

View File

@@ -25,6 +25,9 @@
@text="Copy" @text="Copy"
@isIconOnly={{true}} @isIconOnly={{true}}
@textToCopy={{path.snippet}} @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}} data-test-copy-button={{path.snippet}}
class="transparent" class="transparent"
/> />

View File

@@ -89,6 +89,9 @@
@textToCopy={{this.token}} @textToCopy={{this.token}}
class="primary" class="primary"
@container=".hds-modal" @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")}} {{on "click" (action "onCopy")}}
/> />
<Hds::Button <Hds::Button