Skip to content

Commit 70d98f9

Browse files
committed
Implement drag-and-drop functionality for Add Table button in Schema Designer
1 parent c4f7b2f commit 70d98f9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/reactviews/pages/SchemaDesigner/toolbar/addTableButton.tsx

+22
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,37 @@
55

66
import { Button } from "@fluentui/react-components";
77
import * as FluentIcons from "@fluentui/react-icons";
8+
import { useContext, useEffect, useRef } from "react";
9+
import { SchemaDesignerContext } from "../schemaDesignerStateProvider";
810

911
export function AddTableButton() {
12+
const context = useContext(SchemaDesignerContext);
13+
if (!context) {
14+
return undefined;
15+
}
16+
17+
const addTableButtonRef = useRef<HTMLButtonElement | null>(null);
18+
19+
useEffect(() => {
20+
if (context?.schemaDesigner) {
21+
context.schemaDesigner.addTableDragAndDropListener(
22+
addTableButtonRef.current!,
23+
);
24+
}
25+
}, [context.schemaDesigner]);
26+
1027
return (
1128
<Button
1229
style={{
1330
minWidth: "100px",
1431
}}
1532
icon={<FluentIcons.Add16Filled />}
1633
size="small"
34+
ref={addTableButtonRef}
35+
onClick={() => {
36+
if (context?.schemaDesigner) {
37+
}
38+
}}
1739
>
1840
Add Table
1941
</Button>

0 commit comments

Comments
 (0)