Skip to content

Commit

Permalink
limit schema size (#588)
Browse files Browse the repository at this point in the history
* limit schema size

* change limit

* Update styling package (#589)

* update styling system

* update

* change font weight
  • Loading branch information
AnnaLysiuk committed Jan 12, 2024
1 parent 183c4ed commit a93f36c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 9 deletions.
17 changes: 14 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"@aexol-studio/hooks": "^0.1.28",
"@aexol-studio/styling-system": "^0.1.28",
"@aexol-studio/styling-system": "^0.2.6",
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
"color2k": "^1.2.4",
Expand Down Expand Up @@ -64,4 +64,4 @@
"@types/d3": "^7.4.0",
"@types/diff": "^5.0.2"
}
}
}
5 changes: 5 additions & 0 deletions packages/editor/src/Relation/PanZoom/ControlsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const ControlsBar: React.FC<{
labelPosition="start"
onChange={() => setCtrlToZoom(!ctrlToZoom)}
checked={ctrlToZoom}
wrapperCss={{ fontWeight: 300 }}
/>
<ZoomWrapper>
<IconWrapper
Expand All @@ -83,26 +84,30 @@ export const ControlsBar: React.FC<{
labelPosition="start"
onChange={() => setLibraryNodesOn(!libraryNodesOn)}
checked={libraryNodesOn}
wrapperCss={{ fontWeight: 300 }}
/>
)}
<Checkbox
label="fields"
labelPosition="start"
onChange={() => setFieldsOn(!fieldsOn)}
checked={fieldsOn}
wrapperCss={{ fontWeight: 300 }}
/>
<Checkbox
label="scalars"
disabled={!fieldsOn}
labelPosition="start"
onChange={() => setBaseTypesOn(!baseTypesOn)}
checked={fieldsOn ? baseTypesOn : false}
wrapperCss={{ fontWeight: 300 }}
/>
<Checkbox
label="inputs"
labelPosition="start"
onChange={() => setInputsOn(!inputsOn)}
checked={inputsOn}
wrapperCss={{ fontWeight: 300 }}
/>
<Tooltip title="Export to png" position="left-bottom">
<IconWrapper onClick={() => downloadPng()}>
Expand Down
16 changes: 15 additions & 1 deletion packages/editor/src/Relation/PanZoom/PanZoom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import {
} from "@/Relation/PanZoom/LinesDiagram/LinesDiagram";
import { nodeFilter } from "@/Relation/shared/nodeFilter";
import { useClickDetector } from "@/shared/hooks/useClickDetector";

const MAX_SCHEMA_SIZE = 20000 * 20000;

export const PanZoom: React.FC<{
nodes: ParserField[];
hide?: boolean;
Expand Down Expand Up @@ -74,7 +77,18 @@ export const PanZoom: React.FC<{
}, [nodes, baseTypesOn, inputsOn, libraryNodesOn]);

const downloadPng = useCallback(() => {
if (viewportParams?.height) {
if (viewportParams?.height && viewportParams?.width) {
if (viewportParams.height * viewportParams.width > MAX_SCHEMA_SIZE) {
createToast({
message:
"Schema is too big to be printed as a whole. Please focus some nodes or hide part of them before printing.",
variant: "error",
closeMethod: {
method: "closeManually",
},
});
return;
}
setLoading(true);
const ctx = getContext();
setParamsBeforeExport({
Expand Down
7 changes: 4 additions & 3 deletions packages/editor/src/shared/dialogs/ImportSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const ImportSchema: React.FC<{
try {
if (!url.startsWith("http://") && !url.startsWith("https://")) {
createToast({
message: `Please add https:// or http:// at the beggining of your URL we don't want to guess it.`,
message: `Please add https:// or http:// at the beginning of your URL we don't want to guess it.`,
variant: "error",
});
return false;
Expand Down Expand Up @@ -149,7 +149,7 @@ export const ImportSchema: React.FC<{
variant: "error",
})
: createToast({
message: "Unkown import error",
message: "Unknown import error",
variant: "error",
});
});
Expand Down Expand Up @@ -184,7 +184,7 @@ export const ImportSchema: React.FC<{
variant: "error",
})
: createToast({
message: "Unkown import error",
message: "Unknown import error",
variant: "error",
});
});
Expand All @@ -210,6 +210,7 @@ export const ImportSchema: React.FC<{
label="Proxy to avoid CORS"
checked={proxyImport}
onChange={() => setProxyImport(!proxyImport)}
wrapperCss={{ fontWeight: 300 }}
/>
<Typography variant="caption">Headers</Typography>
</Stack>
Expand Down

0 comments on commit a93f36c

Please sign in to comment.