From 714926e8928c61918d97d0e68948291d440cb73a Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Tue, 12 Dec 2023 15:16:26 +0530 Subject: [PATCH] fix: review changes --- packages/nc-gui/components/smartsheet/grid/Table.vue | 2 +- packages/nc-gui/composables/usePaste.ts | 10 +++++++++- packages/nc-gui/lang/en.json | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/grid/Table.vue b/packages/nc-gui/components/smartsheet/grid/Table.vue index 6fc56835d9..c9e8bca90b 100644 --- a/packages/nc-gui/components/smartsheet/grid/Table.vue +++ b/packages/nc-gui/components/smartsheet/grid/Table.vue @@ -169,7 +169,7 @@ const predictNextFormulas = async () => { await _predictNextFormulas(meta) } -const { paste } = usePaste() +const { paste } = usePaste(true) // #Refs diff --git a/packages/nc-gui/composables/usePaste.ts b/packages/nc-gui/composables/usePaste.ts index c9c35e19bd..0d70a447a7 100644 --- a/packages/nc-gui/composables/usePaste.ts +++ b/packages/nc-gui/composables/usePaste.ts @@ -1,4 +1,8 @@ -export const usePaste = () => { +import { useI18n, message } from '#imports' + +export const usePaste = (showDialogIfFailed = false) => { + const { t } = useI18n() + const paste = async (): Promise => { try { // Check if the Clipboard API is supported @@ -23,6 +27,10 @@ export const usePaste = () => { document.dispatchEvent(pasteEvent) return true } catch (e) { + if (!showDialogIfFailed) throw new Error(t('msg.error.pasteFromClipboardError')) + + message.error(t('msg.error.pasteFromClipboardError')) + return false } } diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json index b0e59194c8..95c7c7370e 100644 --- a/packages/nc-gui/lang/en.json +++ b/packages/nc-gui/lang/en.json @@ -1284,7 +1284,8 @@ "duplicateParameterKeysAreNotAllowed": "Duplicate parameter keys are not allowed", "fieldRequired": "{value} cannot be empty.", "projectNotAccessible": "Base not accessible", - "copyToClipboardError": "Failed to copy to clipboard" + "copyToClipboardError": "Failed to copy to clipboard", + "pasteFromClipboardError": "Failed to paste from clipboard" }, "toast": { "exportMetadata": "Base metadata exported successfully",