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: show dialog on node count above 100

AykutSarac4c9119fccfcc
diff --git a/src/containers/Editor/LiveEditor/GraphView/index.tsx b/src/containers/Editor/LiveEditor/GraphView/index.tsx
index 451758cb..c904820e 100644
--- a/src/containers/Editor/LiveEditor/GraphView/index.tsx
+++ b/src/containers/Editor/LiveEditor/GraphView/index.tsx
@@ -1,5 +1,6 @@
-import React from "react";
-import { LoadingOverlay } from "@mantine/core";
+import React, { useEffect } from "react";
+import { LoadingOverlay, Dialog, Group, Button, Text } from "@mantine/core";
+import { useSessionStorage } from "@mantine/hooks";
import styled from "styled-components";
import debounce from "lodash.debounce";
import { Space } from "react-zoomable-ui";
@@ -143,6 +144,18 @@ export const Graph = ({ isWidget = false }: GraphProps) => {
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,
+ });
+
+ useEffect(() => {
+ if (nodeCount > 20 && !isDialogClosed) {
+ setDialogVisible(true);
+ }
+ }, [isDialogClosed, nodeCount, setDialogVisible]);
const callback = React.useCallback(() => {
const canvas = document.querySelector(".jsoncrack-canvas") as HTMLDivElement | null;
@@ -190,6 +203,36 @@ export const Graph = ({ isWidget = false }: GraphProps) => {
>
<GraphCanvas isWidget={isWidget} />
</Space>
+ <Dialog
+ opened={dialogVisible}
+ size="lg"
+ radius="md"
+ withCloseButton
+ position={{ right: 5, bottom: 30 }}
+ onClose={() => {
+ setDialogVisible(false);
+ 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>
+ <Group justify="right" mt="xs">
+ <Button
+ variant="outline"
+ onClick={() => {
+ setDialogVisible(false);
+ setDialogClosed(true);
+ }}
+ >
+ Close
+ </Button>
+ <Button component="a" variant="gradient" href="/#pricing" target="_blank">
+ Explore
+ </Button>
+ </Group>
+ </Dialog>
</StyledEditorWrapper>
</>
);