@@ -31,7 +31,8 @@ import {
3131 EditableDragOperationType ,
3232 GraphElementProps ,
3333 isEdge ,
34- Model
34+ Model ,
35+ ContextSubMenuItem
3536} from '@patternfly/react-topology' ;
3637import CustomPathNode from '../../components/CustomPathNode' ;
3738import CustomPolygonNode from '../../components/CustomPolygonNode' ;
@@ -99,8 +100,16 @@ const contextMenuItem = (label: string, i: number): React.ReactElement => {
99100 if ( label === '-' ) {
100101 return < ContextMenuSeparator component = "li" key = { `separator:${ i . toString ( ) } ` } /> ;
101102 }
103+ if ( label === 'Second' ) {
104+ return (
105+ < ContextSubMenuItem label = { label } key = { label } >
106+ < ContextMenuItem onClick = { ( ) => alert ( `Selected: ${ label } 1` ) } > { `${ label } subitem number 1` } </ ContextMenuItem >
107+ < ContextMenuItem onClick = { ( ) => alert ( `Selected: ${ label } 2` ) } > { `${ label } subitem number 2` } </ ContextMenuItem >
108+ < ContextMenuItem onClick = { ( ) => alert ( `Selected: ${ label } 3` ) } > { `${ label } subitem number 3` } </ ContextMenuItem >
109+ </ ContextSubMenuItem >
110+ ) ;
111+ }
102112 return (
103- // eslint-disable-next-line no-alert
104113 < ContextMenuItem key = { label } onClick = { ( ) => alert ( `Selected: ${ label } ` ) } >
105114 { label }
106115 </ ContextMenuItem >
@@ -117,7 +126,7 @@ const demoComponentFactory: ComponentFactory = (
117126) : React . ComponentType < { element : GraphElement } > | undefined => {
118127 if ( kind === ModelKind . graph ) {
119128 return withDndDrop ( graphDropTargetSpec ( [ NODE_DRAG_TYPE ] ) ) (
120- withPanZoom ( ) ( withAreaSelection ( [ 'ctrlKey' , 'shiftKey' ] ) ( GraphComponent ) )
129+ withPanZoom ( ) ( withAreaSelection ( [ 'ctrlKey' , 'shiftKey' ] ) ( withContextMenu ( ( ) => defaultMenu ) ( GraphComponent ) ) )
121130 ) ;
122131 }
123132 switch ( type ) {
0 commit comments