Skip to content

Commit fe5ef96

Browse files
Ciruit table hide non matching filtered circuits (#365)
* Removed the component of search bar and filter options * Fixed the changes of views with filter activated --------- Co-authored-by: Loris Olivier <53363974+loris-maru@users.noreply.github.com>
1 parent 843f933 commit fe5ef96

File tree

8 files changed

+318
-125
lines changed

8 files changed

+318
-125
lines changed

src/components/explore-section/Circuit/global/Columns.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { ColumnType } from 'antd/es/table';
33
import Link from 'next/link';
44
import { Key, SyntheticEvent } from 'react';
55
import { ResizeCallbackData } from 'react-resizable';
6-
import { CircuitSchemaProps } from '../type';
6+
import { CircuitSchemaProps, NumericFilterOptions } from '../type';
7+
import { circuitMatchFilter } from '../utils/circuits-match-filter';
78
import formatNumberWithComma from '../utils/format-number-with-comma';
89

910
import { ChevronRight, DownloadIcon } from '@/components/icons';
@@ -22,7 +23,11 @@ const columns = (
2223
handleExpandRow: (row: CircuitSchemaProps, index: number) => void,
2324
isCircuitDetailPage: boolean,
2425
handleOpenDownloadModal: (record: CircuitSchemaProps) => void,
25-
toggle: 'hierarchical' | 'flat'
26+
toggle: 'hierarchical' | 'flat',
27+
numericFilter: NumericFilterOptions | null,
28+
minValue: number | undefined,
29+
maxValue: number | undefined,
30+
searchQuery: string
2631
): ResizableColumnType[] => {
2732
return [
2833
{
@@ -50,17 +55,27 @@ const columns = (
5055
key: 'name',
5156
width: 150,
5257
render: (_value: any, record: CircuitSchemaProps, _index: number) => {
58+
const isFilterActive = numericFilter !== null || searchQuery.trim() !== '';
59+
const isMatching =
60+
isFilterActive &&
61+
circuitMatchFilter(record, numericFilter, minValue, maxValue, searchQuery);
5362
const href = isCircuitDetailPage ? `./${record.key}` : `./circuit/${record.key}`;
5463
return (
55-
<Link href={href} className="whitespace-nowrap">
64+
<Link
65+
href={href}
66+
className={classNames(
67+
'whitespace-nowrap',
68+
toggle === 'hierarchical' && isMatching ? 'font-bold' : ''
69+
)}
70+
>
5671
{record.name}
5772
</Link>
5873
);
5974
},
6075
},
6176
{
6277
title: 'Subcircuits',
63-
key: 'hasSubcircuits',
78+
key: 'subcircuits',
6479
width: 120,
6580
render: (_value: any, record: CircuitSchemaProps, index: number) => {
6681
const isExpanded = Array.isArray(expandedRowKeys) && expandedRowKeys.includes(record.key);

src/components/explore-section/Circuit/global/ViewToggle.tsx

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { Tooltip } from 'antd';
2+
13
import { FlatListViewIcon, HierarchicalViewIcon } from '@/components/icons';
24
import { classNames } from '@/util/utils';
35

@@ -17,12 +19,14 @@ export default function ViewToggle({
1719
<div className="relative flex flex-row items-center gap-x-4">
1820
<div className="text-base font-medium text-primary-9">View:</div>
1921
<div className="relative flex flex-row items-center gap-x-2">
20-
<div>
21-
<HierarchicalViewIcon
22-
iconColor={toggle === 'hierarchical' ? '#002766' : '#AAA'}
23-
className="h-4 w-4"
24-
/>
25-
</div>
22+
<Tooltip title="Hierarchical view">
23+
<div>
24+
<HierarchicalViewIcon
25+
iconColor={toggle === 'hierarchical' ? '#002766' : '#AAA'}
26+
className="h-4 w-4"
27+
/>
28+
</div>
29+
</Tooltip>
2630
<button
2731
type="button"
2832
className="relative h-6 w-12 rounded-xl border border-solid border-gray-200"
@@ -37,12 +41,14 @@ export default function ViewToggle({
3741
)}
3842
/>
3943
</button>
40-
<div>
41-
<FlatListViewIcon
42-
iconColor={toggle === 'flat' ? '#002766' : '#AAA'}
43-
className="h-4 w-4"
44-
/>
45-
</div>
44+
<Tooltip title="Flat list view">
45+
<div>
46+
<FlatListViewIcon
47+
iconColor={toggle === 'flat' ? '#002766' : '#AAA'}
48+
className="h-4 w-4"
49+
/>
50+
</div>
51+
</Tooltip>
4652
</div>
4753
</div>
4854
);

0 commit comments

Comments
 (0)