Abstract types from editor

This commit is contained in:
1ilit
2024-03-13 01:27:42 +02:00
parent 1280219ac9
commit 24eecdc39b
8 changed files with 136 additions and 120 deletions

View File

@@ -43,11 +43,7 @@ import {
jsonToMariaDB,
jsonToSQLServer,
} from "../utils/toSQL";
import {
StateContext,
TabContext,
TypeContext,
} from "../pages/Editor";
import { StateContext, TabContext } from "../pages/Editor";
import { IconAddTable, IconAddArea, IconAddNote } from "./CustomIcons";
import { ObjectType, Action, Tab, State, Cardinality } from "../data/data";
import jsPDF from "jspdf";
@@ -71,6 +67,7 @@ import { ddbDiagramIsValid, jsonDiagramIsValid } from "../utils/validateSchema";
import { dataURItoBlob } from "../utils/utils";
import useAreas from "../hooks/useAreas";
import useNotes from "../hooks/useNotes";
import useTypes from "../hooks/useTypes";
export default function ControlPanel({
diagramId,
@@ -135,10 +132,8 @@ export default function ControlPanel({
addRelationship,
deleteRelationship,
} = useTables();
const { types, addType, deleteType, updateType, setTypes } =
useContext(TypeContext);
const { notes, setNotes, updateNote, addNote, deleteNote } =
useNotes();
const { types, addType, deleteType, updateType, setTypes } = useTypes();
const { notes, setNotes, updateNote, addNote, deleteNote } = useNotes();
const { areas, setAreas, updateArea, addArea, deleteArea } = useAreas();
const { undoStack, redoStack, setUndoStack, setRedoStack } = useUndoRedo();
const { selectedElement, setSelectedElement } = useSelect();

View File

@@ -1,14 +1,14 @@
import { useContext, useState, useEffect } from "react";
import { useState, useEffect } from "react";
import { Collapse, Badge } from "@douyinfe/semi-ui";
import { TypeContext } from "../pages/Editor";
import { arrayIsEqual } from "../utils/utils";
import { getIssues } from "../utils/issues";
import useSettings from "../hooks/useSettings";
import useTables from "../hooks/useTables";
import useTypes from "../hooks/useTypes";
export default function Issues() {
const { settings } = useSettings();
const { types } = useContext(TypeContext);
const { types } = useTypes();
const { tables, relationships } = useTables();
const [issues, setIssues] = useState([]);

View File

@@ -31,13 +31,14 @@ import {
SideSheet,
Toast,
} from "@douyinfe/semi-ui";
import { TabContext, TypeContext } from "../pages/Editor";
import { TabContext } from "../pages/Editor";
import { getSize, hasCheck, hasPrecision, isSized } from "../utils/toSQL";
import useLayout from "../hooks/useLayout";
import useSettings from "../hooks/useSettings";
import useUndoRedo from "../hooks/useUndoRedo";
import useTables from "../hooks/useTables";
import useSelect from "../hooks/useSelect";
import useTypes from "../hooks/useTypes";
export default function Table(props) {
const [isHovered, setIsHovered] = useState(false);
@@ -48,7 +49,7 @@ export default function Table(props) {
useTables();
const { tab, setTab } = useContext(TabContext);
const { settings } = useSettings();
const { types } = useContext(TypeContext);
const { types } = useTypes();
const { setUndoStack, setRedoStack } = useUndoRedo();
const { selectedElement, setSelectedElement } = useSelect();

View File

@@ -1,4 +1,4 @@
import { useContext, useState } from "react";
import { useState } from "react";
import {
Action,
ObjectType,
@@ -35,11 +35,11 @@ import {
IllustrationNoContent,
IllustrationNoContentDark,
} from "@douyinfe/semi-illustrations";
import { TypeContext } from "../pages/Editor";
import { getSize, hasCheck, hasPrecision, isSized } from "../utils/toSQL";
import useTables from "../hooks/useTables";
import useUndoRedo from "../hooks/useUndoRedo";
import useSelect from "../hooks/useSelect";
import useTypes from "../hooks/useTypes";
export default function TableOverview() {
const [indexActiveKey, setIndexActiveKey] = useState("");
@@ -52,7 +52,7 @@ export default function TableOverview() {
updateTable,
setRelationships,
} = useTables();
const { types } = useContext(TypeContext);
const { types } = useTypes();
const { setUndoStack, setRedoStack } = useUndoRedo();
const { selectedElement, setSelectedElement } = useSelect();
const [editField, setEditField] = useState({});

View File

@@ -1,4 +1,4 @@
import { useContext, useState } from "react";
import { useState } from "react";
import { Action, ObjectType, sqlDataTypes } from "../data/data";
import {
Collapse,
@@ -27,13 +27,13 @@ import {
IllustrationNoContent,
IllustrationNoContentDark,
} from "@douyinfe/semi-illustrations";
import { TypeContext } from "../pages/Editor";
import { isSized, hasPrecision, getSize } from "../utils/toSQL";
import useUndoRedo from "../hooks/useUndoRedo";
import useTypes from "../hooks/useTypes";
export default function TableOverview() {
const [value, setValue] = useState("");
const { types, addType, deleteType, updateType } = useContext(TypeContext);
const { types, addType, deleteType, updateType } = useTypes();
const { setUndoStack, setRedoStack } = useUndoRedo();
const [editField, setEditField] = useState({});
const [filteredResult, setFilteredResult] = useState(