mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-29 01:28:59 -05:00
fix: show alternative to copy button if site is not using https
This commit is contained in:
parent
b1bfb09dfd
commit
7e877ce9f4
3 changed files with 37 additions and 14 deletions
16
frontend/src/components/account/showShareLinkModal.tsx
Normal file
16
frontend/src/components/account/showShareLinkModal.tsx
Normal file
|
@ -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: (
|
||||||
|
<Stack align="stretch">
|
||||||
|
<TextInput variant="filled" value={link} />
|
||||||
|
</Stack>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default showShareLinkModal;
|
|
@ -40,14 +40,16 @@ const Body = ({ share }: { share: Share }) => {
|
||||||
variant="filled"
|
variant="filled"
|
||||||
value={link}
|
value={link}
|
||||||
rightSection={
|
rightSection={
|
||||||
<ActionIcon
|
window.isSecureContext && (
|
||||||
onClick={() => {
|
<ActionIcon
|
||||||
clipboard.copy(link);
|
onClick={() => {
|
||||||
toast.success("Your link was copied to the keyboard.");
|
clipboard.copy(link);
|
||||||
}}
|
toast.success("Your link was copied to the keyboard.");
|
||||||
>
|
}}
|
||||||
<TbCopy />
|
>
|
||||||
</ActionIcon>
|
<TbCopy />
|
||||||
|
</ActionIcon>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Text
|
<Text
|
||||||
|
|
|
@ -17,6 +17,7 @@ import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { TbLink, TbTrash } from "react-icons/tb";
|
import { TbLink, TbTrash } from "react-icons/tb";
|
||||||
|
import showShareLinkModal from "../../components/account/showShareLinkModal";
|
||||||
import Meta from "../../components/Meta";
|
import Meta from "../../components/Meta";
|
||||||
import useUser from "../../hooks/user.hook";
|
import useUser from "../../hooks/user.hook";
|
||||||
import shareService from "../../services/share.service";
|
import shareService from "../../services/share.service";
|
||||||
|
@ -83,12 +84,16 @@ const MyShares = () => {
|
||||||
variant="light"
|
variant="light"
|
||||||
size={25}
|
size={25}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
clipboard.copy(
|
if (window.isSecureContext) {
|
||||||
`${window.location.origin}/share/${share.id}`
|
clipboard.copy(
|
||||||
);
|
`${window.location.origin}/share/${share.id}`
|
||||||
toast.success(
|
);
|
||||||
"Your link was copied to the keyboard."
|
toast.success(
|
||||||
);
|
"Your link was copied to the keyboard."
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
showShareLinkModal(modals, share.id);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TbLink />
|
<TbLink />
|
||||||
|
|
Loading…
Add table
Reference in a new issue