File tree Expand file tree Collapse file tree
extensions/ql-vscode/src/stories/model-editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as React from "react" ;
2+ import { useCallback , useEffect , useState } from "react" ;
23
34import { Meta , StoryFn } from "@storybook/react" ;
45
@@ -20,12 +21,33 @@ export default {
2021} as Meta < typeof MethodRowComponent > ;
2122
2223const Template : StoryFn < typeof MethodRowComponent > = ( args ) => {
24+ const [ modeledMethods , setModeledMethods ] = useState < ModeledMethod [ ] > (
25+ args . modeledMethods ,
26+ ) ;
27+
28+ useEffect ( ( ) => {
29+ setModeledMethods ( args . modeledMethods ) ;
30+ } , [ args . modeledMethods ] ) ;
31+
32+ const handleChange = useCallback (
33+ ( methodSignature : string , modeledMethods : ModeledMethod [ ] ) => {
34+ args . onChange ( methodSignature , modeledMethods ) ;
35+ setModeledMethods ( modeledMethods ) ;
36+ } ,
37+ [ args ] ,
38+ ) ;
39+
2340 const gridTemplateColumns = args . viewState ?. showMultipleModels
2441 ? MULTIPLE_MODELS_GRID_TEMPLATE_COLUMNS
2542 : SINGLE_MODEL_GRID_TEMPLATE_COLUMNS ;
43+
2644 return (
2745 < DataGrid gridTemplateColumns = { gridTemplateColumns } >
28- < MethodRowComponent { ...args } />
46+ < MethodRowComponent
47+ { ...args }
48+ modeledMethods = { modeledMethods }
49+ onChange = { handleChange }
50+ />
2951 </ DataGrid >
3052 ) ;
3153} ;
You can’t perform that action at this time.
0 commit comments