Skip to content

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

feat: update premium dialog

AykutSaracebc75dae1b5f
diff --git a/src/modules/GraphView/index.tsx b/src/modules/GraphView/index.tsx
index a13e9804..b3376059 100644
--- a/src/modules/GraphView/index.tsx
+++ b/src/modules/GraphView/index.tsx
@@ -1,4 +1,4 @@
-import React, { useEffect } from "react";
+import React from "react";
import { LoadingOverlay, Dialog, Group, Button, Text } from "@mantine/core";
import { useSessionStorage } from "@mantine/hooks";
import styled from "styled-components";
@@ -11,6 +11,7 @@ import useToggleHide from "src/hooks/useToggleHide";
import { CustomNode } from "src/modules/GraphView/CustomNode";
import useGraph from "src/modules/GraphView/stores/useGraph";
import useConfig from "src/store/useConfig";
+import useModal from "src/store/useModal";
import { CustomEdge } from "./CustomEdge";
import { NotSupported } from "./NotSupported";
@@ -138,25 +139,19 @@ const GraphCanvas = ({ isWidget }: GraphProps) => {
const SUPPORTED_LIMIT = 600;
export const GraphView = ({ isWidget = false }: GraphProps) => {
+ const setVisible = useModal(state => state.setVisible);
const setViewPort = useGraph(state => state.setViewPort);
const viewPort = useGraph(state => state.viewPort);
const aboveSupportedLimit = useGraph(state => state.nodes.length > SUPPORTED_LIMIT);
const loading = useGraph(state => state.loading);
const gesturesEnabled = useConfig(state => state.gesturesEnabled);
const rulersEnabled = useConfig(state => state.rulersEnabled);
- const nodeCount = useGraph(state => state.nodes.length);
- const [dialogVisible, setDialogVisible] = React.useState(false);
const [isDialogClosed, setDialogClosed] = useSessionStorage({
key: "graph-size-dialog",
defaultValue: false,
+ getInitialValueInEffect: false,
});
- useEffect(() => {
- if (nodeCount > 100 && !isDialogClosed) {
- setDialogVisible(true);
- }
- }, [isDialogClosed, nodeCount, setDialogVisible]);
-
const callback = React.useCallback(() => {
const canvas = document.querySelector(".jsoncrack-canvas") as HTMLDivElement | null;
canvas?.classList.add("dragging");
@@ -204,31 +199,31 @@ export const GraphView = ({ isWidget = false }: GraphProps) => {
<GraphCanvas isWidget={isWidget} />
</Space>
<Dialog
- opened={dialogVisible}
+ opened={!isDialogClosed}
size="lg"
radius="md"
- withCloseButton
- position={{ right: 5, bottom: 30 }}
- onClose={() => {
- setDialogVisible(false);
- setDialogClosed(true);
+ withBorder
+ position={{
+ right: 15,
+ bottom: 40,
}}
+ onClose={() => setDialogClosed(true)}
>
- <Text size="sm">
- You can reduce size of the graph by 50% with the premium version and make it simpler to
- understand.
+ <Text size="sm" fw={500}>
+ Try the powerful Premium editor for larger graphs and advanced features with money-back
+ guarantee.
</Text>
- <Group justify="right" mt="xs">
+ <Group justify="right" mt="sm">
+ <Button variant="default" onClick={() => setDialogClosed(true)}>
+ Close
+ </Button>
<Button
- variant="outline"
+ color="green"
onClick={() => {
- setDialogVisible(false);
+ setVisible("upgrade")(true);
setDialogClosed(true);
}}
>
- Close
- </Button>
- <Button component="a" color="brightBlue" href="/#pricing" target="_blank">
Explore
</Button>
</Group>