From 0b39c4a8430522fb0c0b58e5886e616b4bd1d71a Mon Sep 17 00:00:00 2001 From: Alexey Zinoviev Date: Fri, 20 Sep 2024 19:08:22 +0400 Subject: [PATCH] eqzms-1175: improve copy UX when clipboard is not available (#6657) Signed-off-by: Alexey Zinoviev --- models/tracker/src/actions.ts | 3 +++ models/view/src/plugin.ts | 1 + .../src/components/InviteLink.svelte | 16 +++++++++++++--- plugins/view-resources/src/index.ts | 4 +++- plugins/view-resources/src/visibilityTester.ts | 4 ++++ 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/models/tracker/src/actions.ts b/models/tracker/src/actions.ts index 783895f8c5..e42af938fa 100644 --- a/models/tracker/src/actions.ts +++ b/models/tracker/src/actions.ts @@ -562,6 +562,7 @@ export function createActions (builder: Builder, issuesId: string, componentsId: input: 'focus', category: tracker.category.Tracker, target: tracker.class.Issue, + visibilityTester: view.function.IsClipboardAvailable, context: { mode: ['context', 'browser'], application: tracker.app.Tracker, @@ -582,6 +583,7 @@ export function createActions (builder: Builder, issuesId: string, componentsId: input: 'focus', category: tracker.category.Tracker, target: tracker.class.Issue, + visibilityTester: view.function.IsClipboardAvailable, context: { mode: ['context', 'browser'], application: tracker.app.Tracker, @@ -602,6 +604,7 @@ export function createActions (builder: Builder, issuesId: string, componentsId: input: 'focus', category: tracker.category.Tracker, target: tracker.class.Issue, + visibilityTester: view.function.IsClipboardAvailable, context: { mode: ['context', 'browser'], application: tracker.app.Tracker, diff --git a/models/view/src/plugin.ts b/models/view/src/plugin.ts index c45bfc0e37..aeb975a63d 100644 --- a/models/view/src/plugin.ts +++ b/models/view/src/plugin.ts @@ -140,6 +140,7 @@ export default mergeIds(viewId, view, { CanDeleteSpace: '' as Resource<(doc?: Doc | Doc[]) => Promise>, CanJoinSpace: '' as Resource<(doc?: Doc | Doc[]) => Promise>, CanLeaveSpace: '' as Resource<(doc?: Doc | Doc[]) => Promise>, + IsClipboardAvailable: '' as Resource<(doc?: Doc | Doc[]) => Promise>, BlobImageMetadata: '' as Resource<(file: FileOrBlob, blob: Ref) => Promise>, BlobVideoMetadata: '' as Resource<(file: FileOrBlob, blob: Ref) => Promise> }, diff --git a/plugins/login-resources/src/components/InviteLink.svelte b/plugins/login-resources/src/components/InviteLink.svelte index 2f8e18dcdb..5d42a5d75f 100644 --- a/plugins/login-resources/src/components/InviteLink.svelte +++ b/plugins/login-resources/src/components/InviteLink.svelte @@ -40,6 +40,7 @@ const dispatch = createEventDispatcher() const query = createQuery() + const isSecureContext = window.isSecureContext interface InviteParams { expirationTime: number @@ -87,6 +88,7 @@ } } function copy (): void { + if (!isSecureContext) return if (link === undefined) return copyTextToClipboard(link) copied = true @@ -109,7 +111,7 @@ let loading = false -