@@ -30,6 +30,8 @@ import {
30
30
import {
31
31
BatchMode ,
32
32
HeatMapMode ,
33
+ NoUserAction ,
34
+ selectCurrentUserAction ,
33
35
selectExpandDocumentationByDefault ,
34
36
selectFilter ,
35
37
selectHeatMapMode ,
@@ -87,6 +89,7 @@ export const MenuBar: React.FC<MenuBarProps> = function ({ displayInferErrors })
87
89
const annotations = useAppSelector ( selectAnnotationStore ) ;
88
90
const usages = useAppSelector ( selectUsages ) ;
89
91
const declaration = rawPythonPackage . getDeclarationById ( useLocation ( ) . pathname . split ( '/' ) . splice ( 1 ) . join ( '/' ) ) ;
92
+ const currentUserAction = useAppSelector ( selectCurrentUserAction ) ;
90
93
91
94
const exportAnnotations = ( ) => {
92
95
const a = document . createElement ( 'a' ) ;
@@ -118,11 +121,11 @@ export const MenuBar: React.FC<MenuBarProps> = function ({ displayInferErrors })
118
121
dispatch ( toggleComplete ( declaration . id ) ) ;
119
122
} ;
120
123
const goToPreviousMatch = ( ) => {
121
- if ( ! declaration ) {
124
+ if ( ! declaration || currentUserAction !== NoUserAction ) {
122
125
return ;
123
126
}
124
127
125
- let { id : navStr , wrappedAround } = getPreviousElementPath (
128
+ const { id : navStr , wrappedAround } = getPreviousElementPath (
126
129
allDeclarations ,
127
130
declaration ,
128
131
pythonFilter ,
@@ -149,11 +152,11 @@ export const MenuBar: React.FC<MenuBarProps> = function ({ displayInferErrors })
149
152
}
150
153
} ;
151
154
const goToNextMatch = ( ) => {
152
- if ( ! declaration ) {
155
+ if ( ! declaration || currentUserAction !== NoUserAction ) {
153
156
return ;
154
157
}
155
158
156
- let { id : navStr , wrappedAround } = getNextElementPath (
159
+ const { id : navStr , wrappedAround } = getNextElementPath (
157
160
allDeclarations ,
158
161
declaration ,
159
162
pythonFilter ,
@@ -180,24 +183,32 @@ export const MenuBar: React.FC<MenuBarProps> = function ({ displayInferErrors })
180
183
}
181
184
} ;
182
185
const goToParent = ( ) => {
186
+ if ( ! declaration || currentUserAction !== NoUserAction ) {
187
+ return ;
188
+ }
189
+
183
190
const parent = declaration ?. parent ( ) ;
184
191
if ( parent && ! ( parent instanceof PythonPackage ) ) {
185
192
navigate ( `/${ parent . id } ` ) ;
186
193
}
187
194
} ;
188
195
const expandAll = ( ) => {
189
- dispatch ( setAllExpandedInTreeView ( getDescendantsOrSelf ( pythonPackage ) ) ) ;
196
+ if ( currentUserAction === NoUserAction ) {
197
+ dispatch ( setAllExpandedInTreeView ( getDescendantsOrSelf ( pythonPackage ) ) ) ;
198
+ }
190
199
} ;
191
200
const collapseAll = ( ) => {
192
- dispatch ( setAllCollapsedInTreeView ( getDescendantsOrSelf ( pythonPackage ) ) ) ;
201
+ if ( currentUserAction === NoUserAction ) {
202
+ dispatch ( setAllCollapsedInTreeView ( getDescendantsOrSelf ( pythonPackage ) ) ) ;
203
+ }
193
204
} ;
194
205
const expandSelected = ( ) => {
195
- if ( declaration ) {
206
+ if ( declaration && currentUserAction === NoUserAction ) {
196
207
dispatch ( setAllExpandedInTreeView ( getDescendantsOrSelf ( declaration ) ) ) ;
197
208
}
198
209
} ;
199
210
const collapseSelected = ( ) => {
200
- if ( declaration ) {
211
+ if ( declaration && currentUserAction === NoUserAction ) {
201
212
dispatch ( setAllCollapsedInTreeView ( getDescendantsOrSelf ( declaration ) ) ) ;
202
213
}
203
214
} ;
@@ -331,7 +342,11 @@ export const MenuBar: React.FC<MenuBarProps> = function ({ displayInferErrors })
331
342
332
343
< Box >
333
344
< Menu >
334
- < MenuButton as = { Button } rightIcon = { < Icon as = { FaChevronDown } /> } >
345
+ < MenuButton
346
+ as = { Button }
347
+ rightIcon = { < Icon as = { FaChevronDown } /> }
348
+ disabled = { currentUserAction !== NoUserAction }
349
+ >
335
350
Navigate
336
351
</ MenuButton >
337
352
< MenuList >
0 commit comments