Skip to content

Commit

Permalink
feat: make HardwareTest and HardwareUsed add filter on click
Browse files Browse the repository at this point in the history
Now when a HardwareTest or HardwareUsed item is clicked,
that item is added as a hardware filter

Close #622
  • Loading branch information
lfjnascimento committed Dec 2, 2024
1 parent da9e671 commit 2bd4e4d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 20 deletions.
43 changes: 28 additions & 15 deletions dashboard/src/components/Cards/HardwareTested.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,20 @@ import type { TTreeTestsData } from '@/types/tree/TreeDetails';

import { ScrollArea } from '@/components/ui/scroll-area';

import type { TFilter } from '@/types/general';

import FilterLink from '@/components/Tabs/FilterLink';

interface IHardwareTested
extends Pick<TTreeTestsData, 'environmentCompatible'> {
title: IBaseCard['title'];
diffFilter: TFilter;
}

const HardwareTested = ({
environmentCompatible,
title,
diffFilter,
}: IHardwareTested): JSX.Element => {
return (
<BaseCard
Expand All @@ -29,22 +35,29 @@ const HardwareTested = ({
environmentCompatible[hardwareTestedName];

return (
<ListingItem
hasBottomBorder
<FilterLink
key={hardwareTestedName}
text={hardwareTestedName}
leftIcon={
<GroupedTestStatus
done={DONE}
fail={FAIL}
error={ERROR}
miss={MISS}
pass={PASS}
skip={SKIP}
nullStatus={NULL}
/>
}
/>
filterValue={hardwareTestedName}
filterSection="hardware"
diffFilter={diffFilter}
>
<ListingItem
hasBottomBorder
key={hardwareTestedName}
text={hardwareTestedName}
leftIcon={
<GroupedTestStatus
done={DONE}
fail={FAIL}
error={ERROR}
miss={MISS}
pass={PASS}
skip={SKIP}
nullStatus={NULL}
/>
}
/>
</FilterLink>
);
})}
</DumbListingContent>
Expand Down
29 changes: 24 additions & 5 deletions dashboard/src/components/Cards/HardwareUsed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,41 @@ import type { IBaseCard } from '@/components/Cards/BaseCard';
import BaseCard from '@/components/Cards/BaseCard';

import { Badge } from '@/components/ui/badge';
import type { TFilter } from '@/types/general';

import FilterLink from '@/components/Tabs/FilterLink';

interface IHardwareUsed {
title: IBaseCard['title'];
hardwareUsed?: string[];
diffFilter: TFilter;
}

const HardwareUsed = ({ hardwareUsed, title }: IHardwareUsed): JSX.Element => {
const HardwareUsed = ({
hardwareUsed,
title,
diffFilter,
}: IHardwareUsed): JSX.Element => {
const hardwareSorted = useMemo(() => {
return hardwareUsed?.sort().map(hardware => {
return (
<Badge key={hardware} variant="outline" className="text-sm font-normal">
{hardware}
</Badge>
<FilterLink
key={hardware}
filterValue={hardware}
filterSection="hardware"
diffFilter={diffFilter}
>
<Badge
key={hardware}
variant="outline"
className="text-sm font-normal"
>
{hardware}
</Badge>
</FilterLink>
);
});
}, [hardwareUsed]);
}, [diffFilter, hardwareUsed]);

return (
<BaseCard
Expand Down
2 changes: 2 additions & 0 deletions dashboard/src/pages/TreeDetails/Tabs/Boots/BootsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const BootsTab = ({ reqFilter }: BootsTabProps): JSX.Element => {
<MemoizedHardwareTested
title={<FormattedMessage id="bootsTab.hardwareTested" />}
environmentCompatible={data.bootEnvironmentCompatible}
diffFilter={diffFilter}
/>
</div>
</DesktopGrid>
Expand Down Expand Up @@ -184,6 +185,7 @@ const BootsTab = ({ reqFilter }: BootsTabProps): JSX.Element => {
<MemoizedHardwareTested
title={<FormattedMessage id="bootsTab.hardwareTested" />}
environmentCompatible={data.bootEnvironmentCompatible}
diffFilter={diffFilter}
/>
</div>
</InnerMobileGrid>
Expand Down
2 changes: 2 additions & 0 deletions dashboard/src/pages/TreeDetails/Tabs/Tests/TestsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const TestsTab = ({ reqFilter }: TestsTabProps): JSX.Element => {
<MemoizedHardwareTested
title={<FormattedMessage id="testsTab.hardwareTested" />}
environmentCompatible={data.testEnvironmentCompatible}
diffFilter={diffFilter}
/>
</div>
</DesktopGrid>
Expand Down Expand Up @@ -187,6 +188,7 @@ const TestsTab = ({ reqFilter }: TestsTabProps): JSX.Element => {
<MemoizedHardwareTested
title={<FormattedMessage id="testsTab.hardwareTested" />}
environmentCompatible={data.testEnvironmentCompatible}
diffFilter={diffFilter}
/>
</div>
</InnerMobileGrid>
Expand Down
1 change: 1 addition & 0 deletions dashboard/src/pages/TreeDetails/TreeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ function TreeDetails(): JSX.Element {
<MemoizedHardwareUsed
title={<FormattedMessage id="treeDetails.hardwareUsed" />}
hardwareUsed={testsData?.hardwareUsed}
diffFilter={diffFilter}
/>
</div>
</QuerySwitcher>
Expand Down

0 comments on commit 2bd4e4d

Please sign in to comment.