#1448, add notification toast for copy success & failure
This commit is contained in:
parent
877d108c2c
commit
bfe1851969
|
@ -1,4 +1,6 @@
|
||||||
import { Controller } from "@hotwired/stimulus";
|
import { Controller } from "@hotwired/stimulus";
|
||||||
|
import I18n from 'retrospring/i18n';
|
||||||
|
import { showErrorNotification, showNotification } from "retrospring/utilities/notifications";
|
||||||
|
|
||||||
export default class extends Controller {
|
export default class extends Controller {
|
||||||
|
|
||||||
|
@ -9,6 +11,12 @@ export default class extends Controller {
|
||||||
declare readonly copyValue: string;
|
declare readonly copyValue: string;
|
||||||
|
|
||||||
async copy(){
|
async copy(){
|
||||||
|
try {
|
||||||
await navigator.clipboard.writeText(this.copyValue);
|
await navigator.clipboard.writeText(this.copyValue);
|
||||||
|
showNotification(I18n.translate("frontend.clipboard_copy.success"));
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
showErrorNotification(I18n.translate("frontend.clipboard_copy.error"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,3 +62,6 @@ en:
|
||||||
title: "Are you sure you want to report this %{type}?"
|
title: "Are you sure you want to report this %{type}?"
|
||||||
text: "A moderator will review your report and decide what happens.\nYou can optionally specify a reason."
|
text: "A moderator will review your report and decide what happens.\nYou can optionally specify a reason."
|
||||||
input: "Specify a reason…"
|
input: "Specify a reason…"
|
||||||
|
clipboard_copy:
|
||||||
|
success: "Content copied to clipboard."
|
||||||
|
error: "Failed to copy content to clipboard."
|
||||||
|
|
Loading…
Reference in New Issue