Commit 70d98f9 1 parent c4f7b2f commit 70d98f9 Copy full SHA for 70d98f9
File tree 1 file changed +22
-0
lines changed
src/reactviews/pages/SchemaDesigner/toolbar
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 5
5
6
6
import { Button } from "@fluentui/react-components" ;
7
7
import * as FluentIcons from "@fluentui/react-icons" ;
8
+ import { useContext , useEffect , useRef } from "react" ;
9
+ import { SchemaDesignerContext } from "../schemaDesignerStateProvider" ;
8
10
9
11
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
+
10
27
return (
11
28
< Button
12
29
style = { {
13
30
minWidth : "100px" ,
14
31
} }
15
32
icon = { < FluentIcons . Add16Filled /> }
16
33
size = "small"
34
+ ref = { addTableButtonRef }
35
+ onClick = { ( ) => {
36
+ if ( context ?. schemaDesigner ) {
37
+ }
38
+ } }
17
39
>
18
40
Add Table
19
41
</ Button >
You can’t perform that action at this time.
0 commit comments