Skip to content

Commit

Permalink
fix: Subthemes filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
bprusinowski committed Jun 27, 2024
1 parent c0ef2cc commit 84bc1c4
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions app/browser/dataset-browse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ const encodeFilter = (filter: BrowseFilter) => {
case "DataCubeOrganization":
return "organization";
case "DataCubeAbout":
throw new Error("Should not happen");
return "topic";
case "Termset":
return "termset";
default:
Expand Down Expand Up @@ -394,26 +394,26 @@ const NavItem = ({
{
includeDrafts,
search,
topic: level === 2 ? next.iri : undefined,
topic: level === 2 && !disableLink ? next.iri : undefined,
},
Boolean
)
);
const newFilters = [...filters].filter(
(f) =>
f.__typename !== "DataCubeAbout" &&
(disableLink ? true : f.__typename !== "DataCubeAbout") &&
(level === 1 ? f.__typename !== next.__typename : true)
);

if (level === 1) {
if (level === 1 || disableLink) {
newFilters.push(next);
}

return [
newFilters,
`/browse/${newFilters.map(encodeFilter).join("/")}?${extraURLParams}`,
] as const;
}, [includeDrafts, search, level, next, filters]);
}, [includeDrafts, search, level, next, filters, disableLink]);

const [newFiltersRemove, removeFilterPath] = useMemo(() => {
const extraURLParams = stringify(
Expand Down Expand Up @@ -446,10 +446,14 @@ const NavItem = ({
>
<ButtonBase
className={classes.removeFilterButton}
onClick={(ev) => {
ev.preventDefault();
setFilters(newFiltersRemove);
}}
onClick={
disableLink
? (e) => {
e.preventDefault();
setFilters(newFiltersRemove);
}
: undefined
}
>
<SvgIcClose width={24} height={24} />
</ButtonBase>
Expand Down Expand Up @@ -501,13 +505,17 @@ const NavItem = ({
>
<MUILink
className={classes.link}
href={path}
href={disableLink ? undefined : path}
underline="none"
variant="body2"
onClick={(ev) => {
ev.preventDefault();
setFilters(newFiltersAdd);
}}
onClick={
disableLink
? (e) => {
e.preventDefault();
setFilters(newFiltersAdd);
}
: undefined
}
>
{children}
</MUILink>
Expand Down

0 comments on commit 84bc1c4

Please sign in to comment.