mirror of
https://github.com/drawdb-io/drawdb.git
synced 2026-02-12 02:00:40 +08:00
Abstract types from editor
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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([]);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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({});
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user