Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

add notice

AykutSarac96e3a3de698c
diff --git a/src/containers/Editor/BottomBar.tsx b/src/containers/Editor/BottomBar.tsx
index 1c86295a..4e18670a 100644
--- a/src/containers/Editor/BottomBar.tsx
+++ b/src/containers/Editor/BottomBar.tsx
@@ -1,23 +1,20 @@
import React from "react";
import Head from "next/head";
-import { useRouter } from "next/router";
import { Flex, Popover, Text } from "@mantine/core";
import styled from "styled-components";
-import toast from "react-hot-toast";
-import {
- AiOutlineCloudSync,
- AiOutlineCloudUpload,
- AiOutlineLink,
- AiOutlineLock,
- AiOutlineUnlock,
-} from "react-icons/ai";
+import { AiOutlineLink, AiOutlineLock, AiOutlineUnlock } from "react-icons/ai";
import { BiSolidDockLeft } from "react-icons/bi";
-import { MdOutlineCheckCircleOutline } from "react-icons/md";
-import { TbTransform } from "react-icons/tb";
-import { VscError, VscFeedback, VscSourceControl, VscSync, VscSyncIgnored } from "react-icons/vsc";
+import {
+ VscCheck,
+ VscError,
+ VscFeedback,
+ VscRunAll,
+ VscSourceControl,
+ VscSync,
+ VscSyncIgnored,
+} from "react-icons/vsc";
import { gaEvent } from "src/lib/utils/gaEvent";
import useGraph from "src/modules/GraphView/stores/useGraph";
-import { documentSvc } from "src/services/document.service";
import useConfig from "src/store/useConfig";
import useFile from "src/store/useFile";
import useModal from "src/store/useModal";
@@ -87,25 +84,20 @@ const StyledBottomBarItem = styled.button<{ $bg?: string }>`
`;
export const BottomBar = () => {
- const { query, replace } = useRouter();
const data = useFile(state => state.fileData);
const user = useUser(state => state.user);
const toggleLiveTransform = useConfig(state => state.toggleLiveTransform);
const liveTransformEnabled = useConfig(state => state.liveTransformEnabled);
- const hasChanges = useFile(state => state.hasChanges);
const error = useFile(state => state.error);
- const getContents = useFile(state => state.getContents);
const setContents = useFile(state => state.setContents);
const nodeCount = useGraph(state => state.nodes.length);
const fileName = useFile(state => state.fileData?.name);
const toggleFullscreen = useGraph(state => state.toggleFullscreen);
const fullscreen = useGraph(state => state.fullscreen);
+ const isAuthenticated = useUser(state => state.isAuthenticated);
const setVisible = useModal(state => state.setVisible);
- const setHasChanges = useFile(state => state.setHasChanges);
- const getFormat = useFile(state => state.getFormat);
const [isPrivate, setIsPrivate] = React.useState(false);
- const [isUpdating, setIsUpdating] = React.useState(false);
const toggleEditor = () => {
toggleFullscreen(!fullscreen);
@@ -116,69 +108,6 @@ export const BottomBar = () => {
setIsPrivate(data?.private ?? true);
}, [data]);
- const handleSaveJson = React.useCallback(async () => {
- if (!user) return setVisible("login")(true);
-
- if (
- hasChanges &&
- !error &&
- (typeof query.json === "string" || typeof query.json === "undefined")
- ) {
- try {
- setIsUpdating(true);
- toast.loading("Saving document...", { id: "fileSave" });
-
- const { data, error } = await documentSvc.upsert({
- id: query?.json,
- contents: getContents(),
- format: getFormat(),
- });
-
- if (error) throw error;
- if (data) replace({ query: { json: data } });
-
- toast.success("Document saved to cloud", { id: "fileSave" });
- setHasChanges(false);
- } catch (error: any) {
- toast.error(error.message, { id: "fileSave" });
- } finally {
- setIsUpdating(false);
- }
- }
- }, [
- error,
- getContents,
- getFormat,
- hasChanges,
- query.json,
- replace,
- setHasChanges,
- setVisible,
- user,
- ]);
-
- const setPrivate = async () => {
- try {
- if (!query.json) return handleSaveJson();
- setIsUpdating(true);
-
- const { data: updatedJsonData, error } = await documentSvc.update(query.json as string, {
- private: !isPrivate,
- });
-
- if (error) return toast.error(error.message);
-
- if (updatedJsonData[0]) {
- setIsPrivate(updatedJsonData[0].private);
- toast.success(`Document set to ${isPrivate ? "public" : "private"}.`);
- } else throw error;
- } catch (error) {
- console.error(error);
- } finally {
- setIsUpdating(false);
- }
- };
-
return (
<StyledBottomBar>
{data?.name && (
@@ -202,7 +131,7 @@ export const BottomBar = () => {
<Popover width="auto" shadow="md" position="top" withArrow>
<Popover.Target>
<Flex align="center" gap={2}>
- <VscError color="red" size={16} />
+ <VscError color="red" />
<Text c="red" fw={500} fz="xs">
Invalid
</Text>
@@ -214,55 +143,36 @@ export const BottomBar = () => {
</Popover>
) : (
<Flex align="center" gap={2}>
- <MdOutlineCheckCircleOutline />
+ <VscCheck />
<Text size="xs">Valid</Text>
</Flex>
)}
</StyledBottomBarItem>
- {(data?.owner_email === user?.email || (!data && user)) && (
- <StyledBottomBarItem onClick={handleSaveJson} disabled={isUpdating || error}>
- {hasChanges || !user ? <AiOutlineCloudUpload /> : <AiOutlineCloudSync />}
- {hasChanges || !user ? (query?.json ? "Unsaved Changes" : "Save to Cloud") : "Saved"}
- </StyledBottomBarItem>
- )}
- {data?.owner_email === user?.email && (
- <StyledBottomBarItem onClick={setPrivate} disabled={isUpdating}>
+ {isAuthenticated && data?.owner_email === user?.email && (
+ <StyledBottomBarItem onClick={() => setVisible("notice")(true)}>
{isPrivate ? <AiOutlineLock /> : <AiOutlineUnlock />}
{isPrivate ? "Private" : "Public"}
</StyledBottomBarItem>
)}
+ {isAuthenticated && (
+ <StyledBottomBarItem onClick={() => setVisible("notice")(true)}>
+ <AiOutlineLink />
+ Share
+ </StyledBottomBarItem>
+ )}
<StyledBottomBarItem
- onClick={() => setVisible("share")(true)}
- disabled={isPrivate || !data}
+ onClick={() => {
+ toggleLiveTransform(!liveTransformEnabled);
+ gaEvent("Bottom Bar", "toggle live transform", "manual");
+ }}
>
- <AiOutlineLink />
- Share
+ {liveTransformEnabled ? <VscSync /> : <VscSyncIgnored />}
+ <Text fz="xs">Live Transform</Text>
</StyledBottomBarItem>
- {liveTransformEnabled ? (
- <StyledBottomBarItem
- onClick={() => {
- toggleLiveTransform(false);
- gaEvent("Bottom Bar", "toggle live transform", "manual");
- }}
- >
- <VscSync />
- <Text fz="xs">Live Transform</Text>
- </StyledBottomBarItem>
- ) : (
- <StyledBottomBarItem
- onClick={() => {
- toggleLiveTransform(true);
- gaEvent("Bottom Bar", "toggle live transform", "live");
- }}
- >
- <VscSyncIgnored />
- <Text fz="xs">Manual Transform</Text>
- </StyledBottomBarItem>
- )}
{!liveTransformEnabled && (
- <StyledBottomBarItem onClick={() => setContents({})}>
- <TbTransform />
- Transform
+ <StyledBottomBarItem onClick={() => setContents({})} disabled={!!error}>
+ <VscRunAll />
+ Click to Transform
</StyledBottomBarItem>
)}
</StyledLeft>
diff --git a/src/containers/Modals/CloudModal/index.tsx b/src/containers/Modals/CloudModal/index.tsx
index 6f0d854d..d300404b 100644
--- a/src/containers/Modals/CloudModal/index.tsx
+++ b/src/containers/Modals/CloudModal/index.tsx
@@ -2,7 +2,6 @@ import React from "react";
import { useRouter } from "next/router";
import type { ModalProps, DefaultMantineColor } from "@mantine/core";
import {
- Modal,
Text,
ScrollArea,
Table,
@@ -11,28 +10,29 @@ import {
Paper,
Flex,
Button,
- Group,
- Stack,
RingProgress,
Drawer,
LoadingOverlay,
Menu,
TextInput,
+ Alert,
} from "@mantine/core";
import { useDebouncedValue } from "@mantine/hooks";
import { useQuery } from "@tanstack/react-query";
import dayjs from "dayjs";
import relativeTime from "dayjs/plugin/relativeTime";
import toast from "react-hot-toast";
-import { BiSearch, BiSolidFolderOpen, BiText } from "react-icons/bi";
+import { BiSearch } from "react-icons/bi";
import { FaTrash } from "react-icons/fa";
+import { LuDownload } from "react-icons/lu";
import { SlOptionsVertical } from "react-icons/sl";
-import { VscAdd } from "react-icons/vsc";
+import { VscAdd, VscWarning } from "react-icons/vsc";
import type { FileFormat } from "src/enums/file.enum";
import { gaEvent } from "src/lib/utils/gaEvent";
import { documentSvc } from "src/services/document.service";
import type { File } from "src/store/useFile";
import useFile from "src/store/useFile";
+import useModal from "src/store/useModal";
dayjs.extend(relativeTime);
@@ -44,62 +44,11 @@ const colorByFormat: Record<FileFormat, DefaultMantineColor> = {
csv: "grape",
};
-interface UpdateNameModalProps {
- file: File | null;
- onClose: () => void;
- refetch: () => void;
-}
-
-const UpdateNameModal = ({ file, onClose, refetch }: UpdateNameModalProps) => {
- const [name, setName] = React.useState("");
-
- React.useEffect(() => {
- if (file?.name) setName(file.name);
- }, [file?.name]);
-
- const onSubmit = async () => {
- try {
- if (!file) return;
-
- toast.loading("Updating document...", { id: "update-document" });
- await documentSvc.update(file.id, { name });
-
- refetch();
- setName("");
- toast.dismiss("update-document");
- } catch (error) {
- toast.error("An error occurred while updating the document!", { id: "update-document" });
- } finally {
- onClose();
- }
- };
-
- return (
- <Modal title="Update document name" opened={!!file} onClose={onClose} centered zIndex={202}>
- <Stack>
- <TextInput
- value={name}
- placeholder="File name"
- onChange={e => setName(e.currentTarget.value)}
- autoFocus
- data-autofocus
- />
- <Group justify="right">
- <Button variant="default" onClick={onClose}>
- Cancel
- </Button>
- <Button onClick={onSubmit}>Update</Button>
- </Group>
- </Stack>
- </Modal>
- );
-};
-
const TOTAL_QUOTA = 25;
export const CloudModal = ({ opened, onClose }: ModalProps) => {
+ const setVisible = useModal(state => state.setVisible);
const setFile = useFile(state => state.setFile);
- const [currentFile, setCurrentFile] = React.useState<File | null>(null);
const [searchValue, setSearchValue] = React.useState("");
const [debouncedSearchValue] = useDebouncedValue(searchValue, 1000);
const { isReady, replace } = useRouter();
@@ -137,6 +86,31 @@ export const CloudModal = ({ opened, onClose }: ModalProps) => {
[onClose, setFile]
);
+ const downloadFile = React.useCallback(async (id: string) => {
+ try {
+ // it will fetch the file first, then download it with corresponsing format
+ const { data, error } = await documentSvc.getById(id);
+ if (error) throw new Error(error.message);
+
+ const blob = new Blob([data[0].content], { type: "text/plain" });
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.href = url;
+ a.download = `${data[0].name}.${data[0].format}`;
+ a.click();
+ URL.revokeObjectURL(url);
+
+ gaEvent("Cloud Modal", "download file");
+
+ return true;
+ } catch (error) {
+ if (error instanceof Error) {
+ toast.error(error.message);
+ }
+ return false;
+ }
+ }, []);
+
const onDeleteClick = React.useCallback(
async (file: File) => {
try {
@@ -181,7 +155,7 @@ export const CloudModal = ({ opened, onClose }: ModalProps) => {
<Table.Td>{dayjs(element.updated_at).format("DD MMM YYYY")}</Table.Td>
<Table.Td onClick={e => e.stopPropagation()}>
<Flex gap="xs">
- <Menu width={150} position="bottom" withArrow shadow="md">
+ <Menu position="bottom" withArrow shadow="md">
<Menu.Target>
<ActionIcon variant="subtle" color="gray">
<SlOptionsVertical />
@@ -190,20 +164,14 @@ export const CloudModal = ({ opened, onClose }: ModalProps) => {
<Menu.Dropdown>
<Menu.Item
fz="xs"
- onClick={() => openFile(element.id)}
- leftSection={<BiSolidFolderOpen />}
- >
- Open
- </Menu.Item>
- <Menu.Item
- fz="xs"
- leftSection={<BiText />}
- onClick={() => setCurrentFile(element)}
+ onClick={() => downloadFile(element.id)}
+ leftSection={<LuDownload />}
>
- Rename File
+ Download
</Menu.Item>
<Menu.Divider />
<Menu.Item
+ c="red"
fz="xs"
onClick={() => onDeleteClick(element)}
leftSection={<FaTrash />}
@@ -216,7 +184,7 @@ export const CloudModal = ({ opened, onClose }: ModalProps) => {
</Table.Td>
</Table.Tr>
)),
- [data, onDeleteClick, openFile]
+ [data, downloadFile, onDeleteClick, openFile]
);
return (
@@ -229,7 +197,14 @@ export const CloudModal = ({ opened, onClose }: ModalProps) => {
pos="relative"
position="right"
>
- <Text fz="xs" pb="lg">
+ <Alert color="red" icon={<VscWarning />}>
+ Cloud storage will be terminated on <b>1 October 2024</b>. Please download your data before
+ the deadline.
+ <Button color="red" variant="light" mt="sm" onClick={() => setVisible("notice")(true)}>
+ Read More
+ </Button>
+ </Alert>
+ <Text fz="xs" py="lg">
The Cloud Save feature is primarily designed for convenient access and is not advisable for
storing sensitive data.
</Text>
@@ -242,7 +217,7 @@ export const CloudModal = ({ opened, onClose }: ModalProps) => {
placeholder="Search"
leftSection={<BiSearch />}
/>
- <ScrollArea h="calc(100vh - 220px)" offsetScrollbars>
+ <ScrollArea h="calc(100vh - 345px)" offsetScrollbars>
<LoadingOverlay visible={isLoading} />
<Table fz="xs" verticalSpacing="xs" highlightOnHover>
<Table.Thead>
@@ -285,7 +260,6 @@ export const CloudModal = ({ opened, onClose }: ModalProps) => {
</Flex>
)}
</Paper>
- <UpdateNameModal file={currentFile} onClose={() => setCurrentFile(null)} refetch={refetch} />
</Drawer>
);
};
diff --git a/src/containers/Modals/NodeModal/index.tsx b/src/containers/Modals/NodeModal/index.tsx
index 0c606c7c..6f26c822 100644
--- a/src/containers/Modals/NodeModal/index.tsx
+++ b/src/containers/Modals/NodeModal/index.tsx
@@ -26,7 +26,7 @@ export const NodeModal = ({ opened, onClose }: ModalProps) => {
<Modal title="Node Content" size="auto" opened={opened} onClose={onClose} centered>
<Stack py="sm" gap="sm">
<Stack gap="xs">
- <Text fz="sm" fw={700}>
+ <Text fz="xs" fw={500}>
Content
</Text>
<ScrollArea.Autosize mah={250} maw={600}>
@@ -42,7 +42,7 @@ export const NodeModal = ({ opened, onClose }: ModalProps) => {
>
Edit
</Button>
- <Text fz="sm" fw={700}>
+ <Text fz="xs" fw={500}>
JSON Path
</Text>
<ScrollArea.Autosize maw={600}>
diff --git a/src/containers/Modals/NoticeModal/index.tsx b/src/containers/Modals/NoticeModal/index.tsx
new file mode 100644
index 00000000..5e6f86a8
--- /dev/null
+++ b/src/containers/Modals/NoticeModal/index.tsx
@@ -0,0 +1,82 @@
+import React from "react";
+import type { ModalProps } from "@mantine/core";
+import { Button, Center, Divider, Group, Modal, Text } from "@mantine/core";
+import { useLocalStorage } from "@mantine/hooks";
+import useModal from "src/store/useModal";
+import useUser from "src/store/useUser";
+
+export const NoticeModal = (props: ModalProps) => {
+ const isAuthenticated = useUser(state => state.isAuthenticated);
+ const setVisible = useModal(state => state.setVisible);
+ const [seenModal, setSeenModal] = useLocalStorage({
+ key: "seenNoticeModal",
+ defaultValue: false,
+ getInitialValueInEffect: false,
+ });
+
+ const closeModal = () => {
+ setSeenModal(true);
+ props.onClose?.();
+ };
+
+ if (!isAuthenticated) return null;
+
+ return (
+ <Modal
+ title={
+ <Text c="red" fw={600} fz="lg">
+ Important Notice: Changes to Free Version
+ </Text>
+ }
+ opened={!seenModal || props.opened}
+ onClose={closeModal}
+ centered
+ zIndex={1000}
+ size="lg"
+ >
+ <Center></Center>
+ <Text>
+ Hello,
+ <br />
+ <br />
+ We want to inform you that starting from <b>1 October 2024</b>, the following features will
+ be removed from the free version of our service:
+ <br />
+ <br />
+ • Sign-in / Sign-up
+ <br />
+ • Cloud Storage
+ <br />
+ • Share
+ <br />
+ <br />
+ <Text fw={500}>
+ Any cloud-stored data that has not been accessed in the past 4 months will be
+ automatically deleted at 1 October 2024.
+ </Text>
+ <br />
+ To ensure you don&apos;t lose any important data, please download your data before the
+ deadline. If you wish to continue using these features, we recommend upgrading to our
+ premium plan, which will allow you to retain full access to these services and more.
+ <br />
+ <br />
+ Thank you for your understanding and continued support.
+ </Text>
+ <Divider my="xs" />
+ <Group justify="right">
+ <Button color="gray" variant="subtle" onClick={closeModal}>
+ Close
+ </Button>
+ <Button
+ variant="default"
+ onClick={() => {
+ setVisible("cloud")(true);
+ closeModal();
+ }}
+ >
+ Open Cloud
+ </Button>
+ </Group>
+ </Modal>
+ );
+};
diff --git a/src/containers/Modals/UpgradeModal/index.tsx b/src/containers/Modals/UpgradeModal/index.tsx
index 991786bb..9efbb1a4 100644
--- a/src/containers/Modals/UpgradeModal/index.tsx
+++ b/src/containers/Modals/UpgradeModal/index.tsx
@@ -61,7 +61,7 @@ export const UpgradeModal = ({ opened, onClose }: ModalProps) => {
size="md"
opened={opened}
onClose={onClose}
- zIndex={202}
+ zIndex={1001}
position="bottom"
radius="lg"
styles={{
diff --git a/src/containers/Modals/index.ts b/src/containers/Modals/index.ts
index 1b80a99c..5efa3d4b 100644
--- a/src/containers/Modals/index.ts
+++ b/src/containers/Modals/index.ts
@@ -13,6 +13,7 @@ export { ReviewModal } from "./ReviewModal";
export { JQModal } from "./JQModal";
export { TypeModal } from "./TypeModal";
export { JPathModal } from "./JPathModal";
+export { NoticeModal } from "./NoticeModal";
type Modal =
| "cloud"
@@ -28,6 +29,7 @@ type Modal =
| "review"
| "jq"
| "type"
- | "jpath";
+ | "jpath"
+ | "notice";
export type { Modal };
diff --git a/src/containers/Toolbar/index.tsx b/src/containers/Toolbar/index.tsx
index 0aad858a..1bf3b50e 100644
--- a/src/containers/Toolbar/index.tsx
+++ b/src/containers/Toolbar/index.tsx
@@ -1,9 +1,7 @@
import React from "react";
-import { Text, Flex, Group, Select, Indicator, ThemeIcon } from "@mantine/core";
-import { useLocalStorage } from "@mantine/hooks";
+import { Text, Flex, Group, Select } from "@mantine/core";
import toast from "react-hot-toast";
import { AiOutlineFullscreen } from "react-icons/ai";
-import { FaGift } from "react-icons/fa6";
import { FiDownload } from "react-icons/fi";
import { SearchInput } from "src/containers/Toolbar/SearchInput";
import { FileFormat } from "src/enums/file.enum";
@@ -11,6 +9,7 @@ import { JSONCrackLogo } from "src/layout/JsonCrackLogo";
import { gaEvent } from "src/lib/utils/gaEvent";
import useFile from "src/store/useFile";
import useModal from "src/store/useModal";
+import useUser from "src/store/useUser";
import { AccountMenu } from "./AccountMenu";
import { FileMenu } from "./FileMenu";
import { Logo } from "./Logo";
@@ -38,10 +37,7 @@ export const Toolbar = ({ isWidget = false }: ToolbarProps) => {
const setVisible = useModal(state => state.setVisible);
const setFormat = useFile(state => state.setFormat);
const format = useFile(state => state.format);
- const [seenPremium, setSeenPremium] = useLocalStorage({
- key: "seenPremium",
- defaultValue: false,
- });
+ const isAuthenticated = useUser(state => state.isAuthenticated);
return (
<Styles.StyledTools>
@@ -74,29 +70,25 @@ export const Toolbar = ({ isWidget = false }: ToolbarProps) => {
<FileMenu />
<ViewMenu />
<ToolsMenu />
- <Styles.StyledToolElement title="Cloud" onClick={() => setVisible("cloud")(true)}>
- Cloud
- </Styles.StyledToolElement>
+ {isAuthenticated && (
+ <Styles.StyledToolElement title="Cloud" onClick={() => setVisible("cloud")(true)}>
+ Cloud
+ </Styles.StyledToolElement>
+ )}
</Group>
)}
<Group gap="xs" justify="right" w="100%" style={{ flexWrap: "nowrap" }}>
{!isWidget && (
- <Indicator color="red" size="6" offset={6} processing disabled={seenPremium}>
- <Styles.StyledToolElement
- onClick={() => {
- setSeenPremium(true);
- setVisible("upgrade")(true);
- gaEvent("Toolbar", "click upgrade premium");
- }}
- >
- <ThemeIcon size="xs" variant="transparent" color="bright">
- <FaGift size="12" />
- </ThemeIcon>
- <Text c="bright" fw={600} fz="xs">
- Premium
- </Text>
- </Styles.StyledToolElement>
- </Indicator>
+ <Styles.StyledToolElement
+ onClick={() => {
+ setVisible("upgrade")(true);
+ gaEvent("Toolbar", "click upgrade premium");
+ }}
+ >
+ <Text c="bright" fw={600} fz="xs">
+ Upgrade Editor
+ </Text>
+ </Styles.StyledToolElement>
)}
<SearchInput />
diff --git a/src/layout/ModalController.tsx b/src/layout/ModalController.tsx
index d229040f..6cc8d2fa 100644
--- a/src/layout/ModalController.tsx
+++ b/src/layout/ModalController.tsx
@@ -21,6 +21,7 @@ const modalComponents: ModalComponent[] = [
{ key: "jq", component: Modals.JQModal },
{ key: "type", component: Modals.TypeModal },
{ key: "jpath", component: Modals.JPathModal },
+ { key: "notice", component: Modals.NoticeModal },
];
const ModalController = () => {