Skip to content

Commit

Permalink
disable import export (#593)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaLysiuk committed Feb 6, 2024
1 parent 1cd4169 commit 4534663
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
6 changes: 6 additions & 0 deletions packages/editor/src/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export interface EditorProps
// Editor custom fonts without whole theme needed to be passed
fontFamily?: string;
fontFamilySans?: string;
disableExport?: boolean;
disableImport?: boolean;
}

export interface ExternalEditorAPI {
Expand Down Expand Up @@ -120,6 +122,8 @@ export const Editor = React.forwardRef<ExternalEditorAPI, EditorProps>(
onNodeSelect,
onContentChange,
title,
disableExport,
disableImport,
onEditorMount,
},
ref
Expand Down Expand Up @@ -296,6 +300,8 @@ export const Editor = React.forwardRef<ExternalEditorAPI, EditorProps>(
const newState: typeof routes = { ...routes, pane: p };
set(newState, "internal");
}}
disableExport={disableExport}
disableImport={disableImport}
/>
{routes.pane !== "diff" && (
<DynamicResize
Expand Down
32 changes: 19 additions & 13 deletions packages/editor/src/editor/menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export interface MenuProps {
readOnly?: boolean;
setSchema: (props: PassedSchema, isInvalid?: boolean) => void;
path: string;
disableImport?: boolean;
disableExport?: boolean;
}

export const Menu = ({
Expand All @@ -112,6 +114,8 @@ export const Menu = ({
libraries,
readOnly,
excludePanes = [],
disableImport,
disableExport,
}: MenuProps) => {
const [importOpen, setImportOpen] = useState(false);
const { saveToFile } = useFileOperations();
Expand Down Expand Up @@ -201,19 +205,21 @@ export const Menu = ({
</Tooltip>
)}

<DropdownMenu
actionType="icon"
dropdownPosition="right-bottom"
menuItems={exportActions}
distanceX="10px"
>
<Tooltip title="Export schema" position="right-center">
<MenuItem {...dataIt("menuExport")} data-tour="export">
<ArrowNarrowUpMove />
</MenuItem>
</Tooltip>
</DropdownMenu>
{!readOnly && (
{!disableExport && (
<DropdownMenu
actionType="icon"
dropdownPosition="right-bottom"
menuItems={exportActions}
distanceX="10px"
>
<Tooltip title="Export schema" position="right-center">
<MenuItem {...dataIt("menuExport")} data-tour="export">
<ArrowNarrowUpMove />
</MenuItem>
</Tooltip>
</DropdownMenu>
)}
{!readOnly && !disableImport && (
<Tooltip title="Import schema" position="right-center">
<MenuItem
{...dataIt("menuImport")}
Expand Down
2 changes: 2 additions & 0 deletions packages/sandbox/apps/Pure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export const Pure = () => {
});
}}
schema={mySchema}
disableImport
disableExport
/>
</div>
);
Expand Down

0 comments on commit 4534663

Please sign in to comment.