This repository was archived by the owner on Jan 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed
api-editor/gui/src/features Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
12
12
MenuItemOption ,
13
13
MenuList ,
14
14
MenuOptionGroup ,
15
+ Spacer ,
15
16
useColorMode ,
16
17
} from '@chakra-ui/react' ;
17
18
import React from 'react' ;
@@ -57,6 +58,7 @@ import {
57
58
} from '../packageData/apiSlice' ;
58
59
import { selectUsages } from '../usages/usageSlice' ;
59
60
import { useLocation , useNavigate } from 'react-router-dom' ;
61
+ import { SelectionBreadcrumbs } from './SelectionBreadcrumbs' ;
60
62
61
63
interface MenuBarProps {
62
64
displayInferErrors : ( errors : string [ ] ) => void ;
@@ -424,6 +426,12 @@ export const MenuBar: React.FC<MenuBarProps> = function ({ displayInferErrors })
424
426
</ Menu >
425
427
</ Box >
426
428
</ HStack >
429
+
430
+ < Spacer />
431
+
432
+ < HStack >
433
+ < SelectionBreadcrumbs />
434
+ </ HStack >
427
435
</ Flex >
428
436
) ;
429
437
} ;
Original file line number Diff line number Diff line change
1
+ import { Breadcrumb , BreadcrumbItem } from '@chakra-ui/react' ;
2
+ import React from 'react' ;
3
+ import { Link as RouterLink , useLocation } from 'react-router-dom' ;
4
+ import { useAppSelector } from '../../app/hooks' ;
5
+ import { selectRawPythonPackage } from '../packageData/apiSlice' ;
6
+ import { PythonPackage } from '../packageData/model/PythonPackage' ;
7
+
8
+ export const SelectionBreadcrumbs = function ( ) {
9
+ const pythonPackage = useAppSelector ( selectRawPythonPackage ) ;
10
+ const selectedDeclaration = pythonPackage . getDeclarationById ( useLocation ( ) . pathname . split ( '/' ) . splice ( 1 ) . join ( '/' ) ) ;
11
+
12
+ if ( ! selectedDeclaration || selectedDeclaration instanceof PythonPackage ) {
13
+ return null ;
14
+ }
15
+
16
+ const declarations = [ ...selectedDeclaration . ancestorsOrSelf ( ) ] . reverse ( ) . splice ( 1 ) ;
17
+
18
+ return (
19
+ < Breadcrumb >
20
+ { declarations . map ( ( it ) => (
21
+ < BreadcrumbItem >
22
+ < RouterLink to = { it . id } > { it . name } </ RouterLink >
23
+ </ BreadcrumbItem >
24
+ ) ) }
25
+ </ Breadcrumb >
26
+ ) ;
27
+ } ;
Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ export abstract class PythonDeclaration {
15
15
return this . name ;
16
16
}
17
17
18
+ * ancestorsOrSelf ( ) : Generator < PythonDeclaration > {
19
+ let current : Optional < PythonDeclaration > = this ;
20
+ while ( current ) {
21
+ yield current ;
22
+ current = current . parent ( ) ;
23
+ }
24
+ }
25
+
18
26
* descendantsOrSelf ( ) : Generator < PythonDeclaration > {
19
27
yield this ;
20
28
for ( const child of this . children ( ) ) {
You can’t perform that action at this time.
0 commit comments