fix: set link default value to random (#192)
* fix: set link default value to random * fix: add auto EOL and add conventional-changelog package * feat: Adding reverse shares' shares a clickable link (#178) * Add clickable link to reverse share's shares * Ran format * Apply suggestions from code review * fix: set link default value to random (#181) * fix: set link default value to random * fix: add auto EOL and add conventional-changelog package * Apply suggestions from code review --------- Co-authored-by: Elias Schneider <login@eliasschneider.com> * feat: Adding reverse share ability to copy the link (#179) --------- Co-authored-by: Elias Schneider <login@eliasschneider.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { Stack, TextInput } from "@mantine/core";
|
||||
import { ModalsContextProps } from "@mantine/modals/lib/context";
|
||||
|
||||
const showReverseShareLinkModal = (
|
||||
modals: ModalsContextProps,
|
||||
reverseShareToken: string,
|
||||
appUrl: string
|
||||
) => {
|
||||
const link = `${appUrl}/upload/${reverseShareToken}`;
|
||||
return modals.openModal({
|
||||
title: "Reverse share link",
|
||||
children: (
|
||||
<Stack align="stretch">
|
||||
<TextInput variant="filled" value={link} />
|
||||
</Stack>
|
||||
),
|
||||
});
|
||||
};
|
||||
|
||||
export default showReverseShareLinkModal;
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useRef, useState } from "react";
|
||||
import toast from "../../utils/toast.util";
|
||||
import { ActionIcon, TextInput } from "@mantine/core";
|
||||
import { TbCheck, TbCopy } from "react-icons/tb";
|
||||
import { useClipboard } from "@mantine/hooks";
|
||||
import { useRef, useState } from "react";
|
||||
import { TbCheck, TbCopy } from "react-icons/tb";
|
||||
import toast from "../../utils/toast.util";
|
||||
|
||||
function CopyTextField(props: { link: string }) {
|
||||
const clipboard = useClipboard({ timeout: 500 });
|
||||
@@ -14,7 +14,7 @@ function CopyTextField(props: { link: string }) {
|
||||
|
||||
const copyLink = () => {
|
||||
clipboard.copy(props.link);
|
||||
toast.success("Your link was copied to the keyboard.");
|
||||
toast.success("The link was copied to your clipboard.");
|
||||
if (timerRef.current) clearTimeout(timerRef.current);
|
||||
timerRef.current = setTimeout(() => {
|
||||
setCheckState(false);
|
||||
|
||||
@@ -62,6 +62,10 @@ const CreateUploadModalBody = ({
|
||||
}) => {
|
||||
const modals = useModals();
|
||||
|
||||
const generatedLink = Buffer.from(Math.random().toString(), "utf8")
|
||||
.toString("base64")
|
||||
.substr(10, 7);
|
||||
|
||||
const [showNotSignedInAlert, setShowNotSignedInAlert] = useState(true);
|
||||
|
||||
const validationSchema = yup.object().shape({
|
||||
@@ -78,7 +82,7 @@ const CreateUploadModalBody = ({
|
||||
});
|
||||
const form = useForm({
|
||||
initialValues: {
|
||||
link: "",
|
||||
link: generatedLink,
|
||||
recipients: [] as string[],
|
||||
password: undefined,
|
||||
maxViews: undefined,
|
||||
|
||||
Reference in New Issue
Block a user