Skip to content

Commit 98da2c4

Browse files
fix: searchBox on hardwareV2 (#1820)
Fixes the route matching in order to show the searchbox on the hardwareV2 listing page Closes #1794
1 parent 8fa0205 commit 98da2c4

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

dashboard/src/components/SearchBoxNavigate/SearchBoxNavigate.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { HiSearch } from 'react-icons/hi';
66

77
import DebounceInput from '@/components/DebounceInput/DebounceInput';
88
import { 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
1113
const 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

dashboard/src/components/TopBar/TopBar.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import { Button } from '@/components/ui/button';
1818
import MobileSideMenu from '@/components/SideMenu/MobileSideMenu';
1919

2020
import { SearchBoxNavigate } from '@/components/SearchBoxNavigate';
21+
import { treeListingCleanFullPaths } from '@/utils/constants/treeListing';
22+
import { hwListingCleanFullPaths } from '@/utils/constants/hardwareListing';
2123

2224
const 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,

dashboard/src/utils/constants/hardwareListing.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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'];

dashboard/src/utils/constants/treeListing.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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'];

0 commit comments

Comments
 (0)