From 7e877ce9f4b82d61c9b238e17def9f4c29e7aeb8 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Sat, 10 Dec 2022 13:16:23 +0100 Subject: [PATCH] fix: show alternative to copy button if site is not using https --- .../components/account/showShareLinkModal.tsx | 16 ++++++++++++++++ .../upload/modals/showCompletedUploadModal.tsx | 18 ++++++++++-------- frontend/src/pages/account/shares.tsx | 17 +++++++++++------ 3 files changed, 37 insertions(+), 14 deletions(-) create mode 100644 frontend/src/components/account/showShareLinkModal.tsx diff --git a/frontend/src/components/account/showShareLinkModal.tsx b/frontend/src/components/account/showShareLinkModal.tsx new file mode 100644 index 000000000..e4dc94047 --- /dev/null +++ b/frontend/src/components/account/showShareLinkModal.tsx @@ -0,0 +1,16 @@ +import { Stack, TextInput } from "@mantine/core"; +import { ModalsContextProps } from "@mantine/modals/lib/context"; + +const showShareLinkModal = (modals: ModalsContextProps, shareId: string) => { + const link = `${window.location.origin}/share/${shareId}`; + return modals.openModal({ + title: "Share link", + children: ( + + + + ), + }); +}; + +export default showShareLinkModal; diff --git a/frontend/src/components/upload/modals/showCompletedUploadModal.tsx b/frontend/src/components/upload/modals/showCompletedUploadModal.tsx index b66bb0052..afbf2f32b 100644 --- a/frontend/src/components/upload/modals/showCompletedUploadModal.tsx +++ b/frontend/src/components/upload/modals/showCompletedUploadModal.tsx @@ -40,14 +40,16 @@ const Body = ({ share }: { share: Share }) => { variant="filled" value={link} rightSection={ - { - clipboard.copy(link); - toast.success("Your link was copied to the keyboard."); - }} - > - - + window.isSecureContext && ( + { + clipboard.copy(link); + toast.success("Your link was copied to the keyboard."); + }} + > + + + ) } /> { variant="light" size={25} onClick={() => { - clipboard.copy( - `${window.location.origin}/share/${share.id}` - ); - toast.success( - "Your link was copied to the keyboard." - ); + if (window.isSecureContext) { + clipboard.copy( + `${window.location.origin}/share/${share.id}` + ); + toast.success( + "Your link was copied to the keyboard." + ); + } else { + showShareLinkModal(modals, share.id); + } }} >