) => {
+ const tableName: string = e.currentTarget.value;
+ setEditTable({ ...editTable, tableName });
+ };
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+ {jsonError &&
{jsonError}
}
+
+
+
+
+
+ >
+ );
+};
diff --git a/src/pods/toolbar/components/import-button/import-button.component.tsx b/src/pods/toolbar/components/import-button/import-button.component.tsx
new file mode 100644
index 00000000..fd347db8
--- /dev/null
+++ b/src/pods/toolbar/components/import-button/import-button.component.tsx
@@ -0,0 +1,56 @@
+import { useModalDialogContext } from '@/core/providers/modal-dialog-provider';
+import { ToolbarButton } from '../toolbar-button/toolbarButton.component';
+import { useCanvasViewSettingsContext } from '@/core/providers';
+import classes from '@/pods/toolbar/toolbar.pod.module.css';
+import {
+ TableVm,
+ useCanvasSchemaContext,
+} from '@/core/providers/canvas-schema';
+import { IMPORT_COLLECTION_TITLE } from '@/common/components/modal-dialog';
+import { SHORTCUTS } from '../../shortcut/shortcut.const';
+import { ImportIcon } from '@/common/components/icons/import-icon.component';
+import { ImportPanel } from '@/pods/import-collection/import-panel.pod';
+
+const BORDER_MARGIN = 40;
+
+export const ImportButton = () => {
+ const { openModal, closeModal } = useModalDialogContext();
+ const { canvasSchema, addTable } = useCanvasSchemaContext();
+ const { canvasViewSettings, setLoadSample } = useCanvasViewSettingsContext();
+
+ const handleAddTable = (newTable: TableVm) => {
+ const updatedTable = {
+ ...newTable,
+ x: canvasViewSettings.scrollPosition.x + BORDER_MARGIN,
+ y: canvasViewSettings.scrollPosition.y + BORDER_MARGIN,
+ };
+
+ addTable(updatedTable);
+ closeModal();
+ };
+
+ const handleImportClick = () => {
+ setLoadSample(false);
+ openModal(
+ ,
+ IMPORT_COLLECTION_TITLE
+ );
+ };
+ const handleCloseModal = () => {
+ closeModal();
+ };
+
+ return (
+ }
+ label={'Import JSON'}
+ onClick={handleImportClick}
+ className={`${classes.button} hide-mobile`}
+ shortcutOptions={SHORTCUTS.import}
+ />
+ );
+};
diff --git a/src/pods/toolbar/components/import-button/index.ts b/src/pods/toolbar/components/import-button/index.ts
new file mode 100644
index 00000000..10615d9c
--- /dev/null
+++ b/src/pods/toolbar/components/import-button/index.ts
@@ -0,0 +1 @@
+export * from './import-button.component';
diff --git a/src/pods/toolbar/components/index.ts b/src/pods/toolbar/components/index.ts
index 2bef9a00..d4c20713 100644
--- a/src/pods/toolbar/components/index.ts
+++ b/src/pods/toolbar/components/index.ts
@@ -15,3 +15,4 @@ export * from './about-button';
export * from './duplicate-button';
export * from './copy-button';
export * from './paste-button';
+export * from './import-button';
diff --git a/src/pods/toolbar/shortcut/shortcut.const.ts b/src/pods/toolbar/shortcut/shortcut.const.ts
index a12f9eb9..3fee1730 100644
--- a/src/pods/toolbar/shortcut/shortcut.const.ts
+++ b/src/pods/toolbar/shortcut/shortcut.const.ts
@@ -1,98 +1,104 @@
import { ShortcutOptions } from './shortcut.model';
interface Shortcut {
- [key: string]: ShortcutOptions;
+ [key: string]: ShortcutOptions;
}
export const SHORTCUTS: Shortcut = {
- addCollection: {
- description: 'Add Collection',
- id: 'add-collection-button-shortcut',
- targetKey: ['c'],
- targetKeyLabel: 'C',
- },
- addRelation: {
- description: 'Add Relation',
- id: 'add-relation-button-shortcut',
- targetKey: ['r'],
- targetKeyLabel: 'R',
- },
- delete: {
- description: 'Delete',
- id: 'delete-button-shortcut',
- targetKey: ['backspace'],
- targetKeyLabel: 'Backspace',
- },
- export: {
- description: 'Export',
- id: 'export-button-shortcut',
- targetKey: ['e'],
- targetKeyLabel: 'E',
- },
- new: {
- description: 'New',
- id: 'new-button-shortcut',
- targetKey: ['n'],
- targetKeyLabel: 'N',
- },
- open: {
- description: 'Open',
- id: 'open-button-shortcut',
- targetKey: ['o'],
- targetKeyLabel: 'O',
- },
- redo: {
- description: 'Redo',
- id: 'redo-button-shortcut',
- targetKey: ['y'],
- targetKeyLabel: 'Y',
- },
- save: {
- description: 'Save',
- id: 'save-button-shortcut',
- targetKey: ['s'],
- targetKeyLabel: 'S',
- },
- settings: {
- description: 'Settings',
- id: 'settings-button-shortcut',
- targetKey: ['t'],
- targetKeyLabel: 'T',
- },
- undo: {
- description: 'Undo',
- id: 'undo-button-shortcut',
- targetKey: ['z'],
- targetKeyLabel: 'Z',
- },
- zoomIn: {
- description: 'Zoom In',
- id: 'zoom-in-button-shortcut',
- targetKey: ['=', '+'],
- targetKeyLabel: '"+"',
- },
- zoomOut: {
- description: 'Zoom Out',
- id: 'zoom-out-button-shortcut',
- targetKey: ['-', '-'],
- targetKeyLabel: '"-"',
- },
- duplicate: {
- description: 'Duplicate',
- id: 'duplicate-button-shortcut',
- targetKey: ['d'],
- targetKeyLabel: 'D',
- },
- copy: {
- description: 'Copy',
- id: 'copy-button-shortcut',
- targetKey: ['c'],
- targetKeyLabel: 'C',
- },
- paste: {
- description: 'Paste',
- id: 'paste-button-shortcut',
- targetKey: ['v'],
- targetKeyLabel: 'V',
- },
+ addCollection: {
+ description: 'Add Collection',
+ id: 'add-collection-button-shortcut',
+ targetKey: ['c'],
+ targetKeyLabel: 'C',
+ },
+ addRelation: {
+ description: 'Add Relation',
+ id: 'add-relation-button-shortcut',
+ targetKey: ['r'],
+ targetKeyLabel: 'R',
+ },
+ delete: {
+ description: 'Delete',
+ id: 'delete-button-shortcut',
+ targetKey: ['backspace'],
+ targetKeyLabel: 'Backspace',
+ },
+ export: {
+ description: 'Export',
+ id: 'export-button-shortcut',
+ targetKey: ['e'],
+ targetKeyLabel: 'E',
+ },
+ new: {
+ description: 'New',
+ id: 'new-button-shortcut',
+ targetKey: ['n'],
+ targetKeyLabel: 'N',
+ },
+ open: {
+ description: 'Open',
+ id: 'open-button-shortcut',
+ targetKey: ['o'],
+ targetKeyLabel: 'O',
+ },
+ redo: {
+ description: 'Redo',
+ id: 'redo-button-shortcut',
+ targetKey: ['y'],
+ targetKeyLabel: 'Y',
+ },
+ save: {
+ description: 'Save',
+ id: 'save-button-shortcut',
+ targetKey: ['s'],
+ targetKeyLabel: 'S',
+ },
+ settings: {
+ description: 'Settings',
+ id: 'settings-button-shortcut',
+ targetKey: ['t'],
+ targetKeyLabel: 'T',
+ },
+ undo: {
+ description: 'Undo',
+ id: 'undo-button-shortcut',
+ targetKey: ['z'],
+ targetKeyLabel: 'Z',
+ },
+ zoomIn: {
+ description: 'Zoom In',
+ id: 'zoom-in-button-shortcut',
+ targetKey: ['=', '+'],
+ targetKeyLabel: '"+"',
+ },
+ zoomOut: {
+ description: 'Zoom Out',
+ id: 'zoom-out-button-shortcut',
+ targetKey: ['-', '-'],
+ targetKeyLabel: '"-"',
+ },
+ duplicate: {
+ description: 'Duplicate',
+ id: 'duplicate-button-shortcut',
+ targetKey: ['d'],
+ targetKeyLabel: 'D',
+ },
+ copy: {
+ description: 'Copy',
+ id: 'copy-button-shortcut',
+ targetKey: ['c'],
+ targetKeyLabel: 'C',
+ },
+ paste: {
+ description: 'Paste',
+ id: 'paste-button-shortcut',
+ targetKey: ['v'],
+ targetKeyLabel: 'V',
+ },
+ import: {
+ description: 'Import',
+ id: 'import-button-shortcut',
+ targetKey: ['i'],
+ targetKeyLabel: 'I',
+ },
};
diff --git a/src/pods/toolbar/toolbar.pod.tsx b/src/pods/toolbar/toolbar.pod.tsx
index f5a15bc4..1db89408 100644
--- a/src/pods/toolbar/toolbar.pod.tsx
+++ b/src/pods/toolbar/toolbar.pod.tsx
@@ -17,6 +17,7 @@ import {
CanvasSettingButton,
CopyButton,
PasteButton,
+ ImportButton,
} from './components';
import classes from './toolbar.pod.module.css';
@@ -29,6 +30,7 @@ export const ToolbarPod: React.FC = () => {
+