File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ import { HiSearch } from 'react-icons/hi';
66
77import DebounceInput from '@/components/DebounceInput/DebounceInput' ;
88import { CustomDialog } from '@/components/Dialog/CustomDialog' ;
9+ import { treeListingCleanFullPaths } from '@/utils/constants/treeListing' ;
10+ import { hwListingCleanFullPaths } from '@/utils/constants/hardwareListing' ;
911
1012// Relates the type of listing to the corresponding search key
1113const forwardFields : Record < string , string > = {
@@ -26,11 +28,11 @@ export const SearchBoxNavigate = (): JSX.Element => {
2628 const lastMatch = matches [ matches . length - 1 ] ;
2729 const cleanFullPath = lastMatch ?. fullPath . replace ( / \/ / g, '' ) ?? '' ;
2830
29- if ( [ 'tree' , 'treev1' , 'treev2' ] . includes ( cleanFullPath ) ) {
31+ if ( treeListingCleanFullPaths . includes ( cleanFullPath ) ) {
3032 return 'tree' ;
3133 }
3234
33- if ( [ 'hardware' , 'hardwarev1' ] . includes ( cleanFullPath ) ) {
35+ if ( hwListingCleanFullPaths . includes ( cleanFullPath ) ) {
3436 return 'hardware' ;
3537 }
3638
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ import { Button } from '@/components/ui/button';
1818import MobileSideMenu from '@/components/SideMenu/MobileSideMenu' ;
1919
2020import { SearchBoxNavigate } from '@/components/SearchBoxNavigate' ;
21+ import { treeListingCleanFullPaths } from '@/utils/constants/treeListing' ;
22+ import { hwListingCleanFullPaths } from '@/utils/constants/hardwareListing' ;
2123
2224const OriginSelect = ( {
2325 isHardwarePath,
@@ -122,10 +124,10 @@ const TopBar = (): JSX.Element => {
122124 const lastMatch = matches [ matches . length - 1 ] ;
123125 const firstUrlLocation = lastMatch ?. pathname . split ( '/' ) [ 1 ] ?? '' ;
124126 const cleanFullPath = lastMatch ?. fullPath . replace ( / \/ / g, '' ) ?? '' ;
125- const isTreeListing = [ 'tree' , 'treev1' , 'treev2' ] . includes ( cleanFullPath ) ;
127+ const isTreeListing = treeListingCleanFullPaths . includes ( cleanFullPath ) ;
128+ const isHardwareListing = hwListingCleanFullPaths . includes ( cleanFullPath ) ;
126129 const isListingPage =
127- isTreeListing ||
128- [ 'hardware' , 'hardwarev1' , 'issues' ] . includes ( cleanFullPath ) ;
130+ isTreeListing || isHardwareListing || cleanFullPath . includes ( 'issues' ) ;
129131
130132 return {
131133 firstUrlLocation,
Original file line number Diff line number Diff line change @@ -13,3 +13,5 @@ export type HardwareListingRoutesMap = {
1313 search : ValidHardwareFroms < '/_main/hardware' | '/_main/hardware/v2' > ;
1414 } ;
1515} ;
16+
17+ export const hwListingCleanFullPaths = [ 'hardware' , 'hardwarev1' , 'hardwarev2' ] ;
Original file line number Diff line number Diff line change @@ -13,3 +13,5 @@ export type TreeListingRoutesMap = {
1313 search : ValidTreeFroms < '/_main/tree' | '/_main/tree/v2' > ;
1414 } ;
1515} ;
16+
17+ export const treeListingCleanFullPaths = [ 'tree' , 'treev1' , 'treev2' ] ;
You can’t perform that action at this time.
0 commit comments