Skip to content

Commit

Permalink
refactor(catalog): Remove onCardNavigate from Catalog, use new 'to' p…
Browse files Browse the repository at this point in the history
…roperty
  • Loading branch information
vgeorge committed Jan 14, 2025
1 parent 4b3105b commit bc20466
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
7 changes: 6 additions & 1 deletion app/scripts/components/common/catalog/catalog-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
getTaxonomy
} from '$utils/veda-data/taxonomies';
import { Pill } from '$styles/pill';
import { DATASETS_PATH } from '$utils/routes';

interface CatalogCardProps {
dataset: DatasetData;
Expand Down Expand Up @@ -115,14 +116,18 @@ export const CatalogCard = (props: CatalogCardProps) => {
}
};

const interactionProps = selectable
? { onClick: handleClick }
: { to: `${DATASETS_PATH}/${dataset.id}` };

return (
<CardSelectable
cardType='horizontal-info'
checked={selectable ? selected : undefined}
selectable={selectable}
tagLabels={allTaxonomyValues}
linkLabel='View dataset'
onClick={handleClick}
{...interactionProps}
title={
<TextHighlight value={searchTerm} disabled={searchTerm.length < 3}>
{title}
Expand Down
3 changes: 0 additions & 3 deletions app/scripts/components/common/catalog/catalog-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export interface CatalogContentProps {
search: string;
taxonomies: Record<string, string[]>;
onAction: (action: FilterActions, value?: any) => void;
onCardNavigate?: (path: string) => void;
}

const DEFAULT_SORT_OPTION = 'asc';
Expand Down Expand Up @@ -72,7 +71,6 @@ function CatalogContent({
search,
taxonomies,
onAction,
onCardNavigate
}: CatalogContentProps) {
const [exclusiveSourceSelected, setExclusiveSourceSelected] = useState<string | null>(null);
const isSelectable = selectedIds !== undefined;
Expand Down Expand Up @@ -278,7 +276,6 @@ function CatalogContent({
<CatalogCard
dataset={d}
searchTerm={search}
{...(onCardNavigate && {onDatasetClick: () => onCardNavigate(getDatasetPath(d, pathname))})}
/>
</li>
))}
Expand Down
3 changes: 0 additions & 3 deletions app/scripts/components/common/catalog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ export interface CatalogViewProps {
taxonomies: Record<string, string[]> | Record<string, never>,
onAction: () => void,
} | any;
onCardNavigate?: (path: string) => void;
}

function CatalogView({
datasets,
onFilterChanges,
onCardNavigate
}: CatalogViewProps) {

const { headerHeight } = useSlidingStickyHeaderProps();
Expand All @@ -70,7 +68,6 @@ function CatalogView({
search={search}
taxonomies={taxonomies}
onAction={onAction}
onCardNavigate={onCardNavigate}
/>
</CatalogWrapper>
);
Expand Down
6 changes: 0 additions & 6 deletions app/scripts/components/data-catalog/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ import { useFiltersWithQS } from '$components/common/catalog/controls/hooks/use-
export default function DataCatalogContainer() {
const allDatasets = getAllDatasetsProps(veda_faux_module_datasets);
const controlVars = useFiltersWithQS();
const navigate = useNavigate();

const handleCardNavigation = (path: string) => {
navigate(path);
};

return (
<PageMainContent>
Expand All @@ -40,7 +35,6 @@ export default function DataCatalogContainer() {
<CatalogView
datasets={allDatasets}
onFilterChanges={() => controlVars}
onCardNavigate={handleCardNavigation}
/>
</PageMainContent>
);
Expand Down

0 comments on commit bc20466

Please sign in to comment.