1
- import { Box , Button , Icon , Menu , MenuButton , MenuItem , MenuList } from '@chakra-ui/react' ;
1
+ import { Box , Button , Icon , Menu , MenuButton , MenuGroup , MenuItem , MenuList } from '@chakra-ui/react' ;
2
2
import React from 'react' ;
3
3
import { FaChevronDown } from 'react-icons/fa' ;
4
4
import { useAppDispatch , useAppSelector } from '../../app/hooks' ;
@@ -8,12 +8,12 @@ import {
8
8
showBoundaryAnnotationForm ,
9
9
showCalledAfterAnnotationForm ,
10
10
showConstantAnnotationForm ,
11
+ showDescriptionAnnotationForm ,
11
12
showEnumAnnotationForm ,
12
13
showGroupAnnotationForm ,
13
14
showMoveAnnotationForm ,
14
15
showOptionalAnnotationForm ,
15
16
showRenameAnnotationForm ,
16
- showDescriptionAnnotationForm ,
17
17
showTodoAnnotationForm ,
18
18
} from '../ui/uiSlice' ;
19
19
@@ -71,60 +71,120 @@ export const AnnotationDropdown: React.FC<AnnotationDropdownProps> = function ({
71
71
Annotations
72
72
</ MenuButton >
73
73
< MenuList >
74
- { showAttribute && (
75
- < MenuItem onClick = { ( ) => dispatch ( showAttributeAnnotationForm ( target ) ) } > @attribute</ MenuItem >
76
- ) }
77
- { showBoundary && (
78
- < MenuItem onClick = { ( ) => dispatch ( showBoundaryAnnotationForm ( target ) ) } > @boundary</ MenuItem >
79
- ) }
80
- { showCalledAfter && (
81
- < MenuItem
82
- onClick = { ( ) =>
83
- dispatch (
84
- showCalledAfterAnnotationForm ( {
85
- target,
86
- calledAfterName : '' ,
87
- } ) ,
88
- )
89
- }
90
- >
91
- @calledAfter
92
- </ MenuItem >
93
- ) }
94
- { showConstant && (
95
- < MenuItem onClick = { ( ) => dispatch ( showConstantAnnotationForm ( target ) ) } > @constant</ MenuItem >
74
+ { ( showEnum || showBoundary ) && (
75
+ < MenuGroup title = "Type" >
76
+ { showBoundary && (
77
+ < MenuItem onClick = { ( ) => dispatch ( showBoundaryAnnotationForm ( target ) ) } paddingLeft = { 8 } >
78
+ @boundary
79
+ </ MenuItem >
80
+ ) }
81
+ { showEnum && (
82
+ < MenuItem onClick = { ( ) => dispatch ( showEnumAnnotationForm ( target ) ) } paddingLeft = { 8 } >
83
+ @enum
84
+ </ MenuItem >
85
+ ) }
86
+ </ MenuGroup >
96
87
) }
97
- { showDescription && (
98
- < MenuItem onClick = { ( ) => dispatch ( showDescriptionAnnotationForm ( target ) ) } >
99
- @description
100
- </ MenuItem >
101
- ) }
102
- { showEnum && < MenuItem onClick = { ( ) => dispatch ( showEnumAnnotationForm ( target ) ) } > @enum</ MenuItem > }
103
- { showGroup && (
104
- < MenuItem
105
- onClick = { ( ) =>
106
- dispatch (
107
- showGroupAnnotationForm ( {
108
- target,
109
- groupName : '' ,
110
- } ) ,
111
- )
112
- }
113
- >
114
- @group
115
- </ MenuItem >
116
- ) }
117
- { showMove && < MenuItem onClick = { ( ) => dispatch ( showMoveAnnotationForm ( target ) ) } > @move</ MenuItem > }
118
- { showOptional && (
119
- < MenuItem onClick = { ( ) => dispatch ( showOptionalAnnotationForm ( target ) ) } > @optional</ MenuItem >
88
+
89
+ { ( showAttribute || showConstant || showOptional || showRequired ) && (
90
+ < MenuGroup title = "Value" >
91
+ { showAttribute && (
92
+ < MenuItem onClick = { ( ) => dispatch ( showAttributeAnnotationForm ( target ) ) } paddingLeft = { 8 } >
93
+ @attribute
94
+ </ MenuItem >
95
+ ) }
96
+ { showConstant && (
97
+ < MenuItem onClick = { ( ) => dispatch ( showConstantAnnotationForm ( target ) ) } paddingLeft = { 8 } >
98
+ @constant
99
+ </ MenuItem >
100
+ ) }
101
+ { showOptional && (
102
+ < MenuItem onClick = { ( ) => dispatch ( showOptionalAnnotationForm ( target ) ) } paddingLeft = { 8 } >
103
+ @optional
104
+ </ MenuItem >
105
+ ) }
106
+ { showRequired && (
107
+ < MenuItem onClick = { ( ) => dispatch ( addRequired ( { target } ) ) } paddingLeft = { 8 } >
108
+ @required
109
+ </ MenuItem >
110
+ ) }
111
+ </ MenuGroup >
120
112
) }
121
- { showPure && < MenuItem onClick = { ( ) => dispatch ( addPure ( { target } ) ) } > @pure</ MenuItem > }
122
- { showRemove && < MenuItem onClick = { ( ) => dispatch ( addRemove ( { target } ) ) } > @remove</ MenuItem > }
123
- { showRename && (
124
- < MenuItem onClick = { ( ) => dispatch ( showRenameAnnotationForm ( target ) ) } > @rename</ MenuItem >
113
+
114
+ { ( showCalledAfter ||
115
+ showDescription ||
116
+ showGroup ||
117
+ showMove ||
118
+ showPure ||
119
+ showRemove ||
120
+ showRename ||
121
+ showTodo ) && (
122
+ < MenuGroup title = "Uncategorized" >
123
+ { showCalledAfter && (
124
+ < MenuItem
125
+ onClick = { ( ) =>
126
+ dispatch (
127
+ showCalledAfterAnnotationForm ( {
128
+ target,
129
+ calledAfterName : '' ,
130
+ } ) ,
131
+ )
132
+ }
133
+ paddingLeft = { 8 }
134
+ >
135
+ @calledAfter
136
+ </ MenuItem >
137
+ ) }
138
+ { showDescription && (
139
+ < MenuItem
140
+ onClick = { ( ) => dispatch ( showDescriptionAnnotationForm ( target ) ) }
141
+ paddingLeft = { 8 }
142
+ >
143
+ @description
144
+ </ MenuItem >
145
+ ) }
146
+ { showGroup && (
147
+ < MenuItem
148
+ onClick = { ( ) =>
149
+ dispatch (
150
+ showGroupAnnotationForm ( {
151
+ target,
152
+ groupName : '' ,
153
+ } ) ,
154
+ )
155
+ }
156
+ paddingLeft = { 8 }
157
+ >
158
+ @group
159
+ </ MenuItem >
160
+ ) }
161
+ { showMove && (
162
+ < MenuItem onClick = { ( ) => dispatch ( showMoveAnnotationForm ( target ) ) } paddingLeft = { 8 } >
163
+ @move
164
+ </ MenuItem >
165
+ ) }
166
+ { showPure && (
167
+ < MenuItem onClick = { ( ) => dispatch ( addPure ( { target } ) ) } paddingLeft = { 8 } >
168
+ @pure
169
+ </ MenuItem >
170
+ ) }
171
+ { showRemove && (
172
+ < MenuItem onClick = { ( ) => dispatch ( addRemove ( { target } ) ) } paddingLeft = { 8 } >
173
+ @remove
174
+ </ MenuItem >
175
+ ) }
176
+ { showRename && (
177
+ < MenuItem onClick = { ( ) => dispatch ( showRenameAnnotationForm ( target ) ) } paddingLeft = { 8 } >
178
+ @rename
179
+ </ MenuItem >
180
+ ) }
181
+ { showTodo && (
182
+ < MenuItem onClick = { ( ) => dispatch ( showTodoAnnotationForm ( target ) ) } paddingLeft = { 8 } >
183
+ @todo
184
+ </ MenuItem >
185
+ ) }
186
+ </ MenuGroup >
125
187
) }
126
- { showRequired && < MenuItem onClick = { ( ) => dispatch ( addRequired ( { target } ) ) } > @required</ MenuItem > }
127
- { showTodo && < MenuItem onClick = { ( ) => dispatch ( showTodoAnnotationForm ( target ) ) } > @todo</ MenuItem > }
128
188
</ MenuList >
129
189
</ Menu >
130
190
</ Box >
0 commit comments