diff --git a/src/components/common/hover-tip/BasicMapHoverTip.tsx b/src/components/common/hover-tip/BasicMapHoverTip.tsx index d73ae372..1a46a42e 100644 --- a/src/components/common/hover-tip/BasicMapHoverTip.tsx +++ b/src/components/common/hover-tip/BasicMapHoverTip.tsx @@ -12,6 +12,7 @@ export interface BasicMapHoverTipProps { content?: string | undefined | null; sx?: SxProps; onDatasetSelected?: () => void; + tabNavigation?: (uuid: string, tab: string, section?: string) => void; } const BasicMapHoverTip: FC = ({ diff --git a/src/components/common/hover-tip/ComplexMapHoverTip.tsx b/src/components/common/hover-tip/ComplexMapHoverTip.tsx index e827401a..b3aed530 100644 --- a/src/components/common/hover-tip/ComplexMapHoverTip.tsx +++ b/src/components/common/hover-tip/ComplexMapHoverTip.tsx @@ -9,7 +9,6 @@ import { padding, } from "../../../styles/constants"; import ResultCardButtonGroup from "../../result/ResultCardButtonGroup"; -import useTabNavigation from "../../../hooks/useTabNavigation"; interface ComplexMapHoverTipProps extends BasicMapHoverTipProps { collection: OGCCollection; @@ -18,9 +17,13 @@ interface ComplexMapHoverTipProps extends BasicMapHoverTipProps { const ComplexMapHoverTip: FC = ({ collection, onDatasetSelected = () => {}, + tabNavigation = () => {}, sx, }) => { - const navigateToDetailPage = useTabNavigation(); + const onLinks = () => tabNavigation(collection.id, "links"); + const onDownload = () => + tabNavigation(collection.id, "abstract", "download-section"); + const onDetail = () => tabNavigation(collection.id, "abstract"); return ( @@ -63,12 +66,16 @@ const ComplexMapHoverTip: FC = ({ - + - navigateToDetailPage(collection.id, "abstract")} - > + {}}> ) => void; + tabNavigation?: (uuid: string, tab: string, section?: string) => void; } export interface MapPopupRef { forceRemovePopup: () => void; @@ -97,7 +98,7 @@ const handleDatasetSelect = ( }; const MapPopup: ForwardRefRenderFunction = ( - { layerId, onDatasetSelected, popupType = PopupType.Basic }, + { layerId, onDatasetSelected, tabNavigation, popupType = PopupType.Basic }, ref ) => { const dispatch = useAppDispatch(); @@ -165,6 +166,7 @@ const MapPopup: ForwardRefRenderFunction = ( onDatasetSelected={() => handleDatasetSelect(collection.id, onDatasetSelected) } + tabNavigation={tabNavigation} /> )} @@ -172,7 +174,7 @@ const MapPopup: ForwardRefRenderFunction = ( ); }, - [onDatasetSelected, popupHeight, popupType, popupWidth] + [onDatasetSelected, popupHeight, popupType, popupWidth, tabNavigation] ); const removePopup = useCallback(() => { diff --git a/src/components/map/mapbox/component/SpiderDiagram.tsx b/src/components/map/mapbox/component/SpiderDiagram.tsx index a98e6321..1d5adc2f 100644 --- a/src/components/map/mapbox/component/SpiderDiagram.tsx +++ b/src/components/map/mapbox/component/SpiderDiagram.tsx @@ -91,6 +91,7 @@ const SpiderDiagram: FC = ({ clusterSourceId, unclusterPointLayer, onDatasetSelected, + tabNavigation, showFullMap, }) => { const { map } = useContext(MapContext); @@ -502,6 +503,7 @@ const SpiderDiagram: FC = ({ layerId={getSpiderPinsLayerId(spiderifiedCluster.id)} onDatasetSelected={onDatasetSelected} popupType={showFullMap ? PopupType.Complex : PopupType.Basic} + tabNavigation={tabNavigation} /> )} {spiderifiedCluster && ( diff --git a/src/components/map/mapbox/layers/ClusterLayer.tsx b/src/components/map/mapbox/layers/ClusterLayer.tsx index d6213a72..ffc4e9ba 100644 --- a/src/components/map/mapbox/layers/ClusterLayer.tsx +++ b/src/components/map/mapbox/layers/ClusterLayer.tsx @@ -100,6 +100,7 @@ const ClusterLayer: FC = ({ collections, selectedUuids, onDatasetSelected, + tabNavigation, clusterLayerConfig, showFullMap, }: ClusterLayerProps) => { @@ -282,6 +283,7 @@ const ClusterLayer: FC = ({ layerId={unclusterPointLayer} popupType={showFullMap ? PopupType.Complex : PopupType.Basic} onDatasetSelected={onDatasetSelected} + tabNavigation={tabNavigation} /> = ({ unclusterPointLayer={unclusterPointLayer} onDatasetSelected={onDatasetSelected} showFullMap={showFullMap} + tabNavigation={tabNavigation} /> ); diff --git a/src/components/map/mapbox/layers/HeatmapLayer.tsx b/src/components/map/mapbox/layers/HeatmapLayer.tsx index 6cd3bd80..7c29f7db 100644 --- a/src/components/map/mapbox/layers/HeatmapLayer.tsx +++ b/src/components/map/mapbox/layers/HeatmapLayer.tsx @@ -110,6 +110,7 @@ const HeatmapLayer: FC = ({ selectedUuids, showFullMap, onDatasetSelected, + tabNavigation, heatmapLayerConfig, }: HeatmapLayerProps) => { const { map } = useContext(MapContext); @@ -337,6 +338,7 @@ const HeatmapLayer: FC = ({ layerId={unClusterPointLayer} popupType={showFullMap ? PopupType.Complex : PopupType.Basic} onDatasetSelected={onDatasetSelected} + tabNavigation={tabNavigation} /> = ({ unclusterPointLayer={unClusterPointLayer} onDatasetSelected={onDatasetSelected} showFullMap={showFullMap} + tabNavigation={tabNavigation} /> heatmapLayer} /> diff --git a/src/components/map/mapbox/layers/Layers.tsx b/src/components/map/mapbox/layers/Layers.tsx index f16df799..77eb21cc 100644 --- a/src/components/map/mapbox/layers/Layers.tsx +++ b/src/components/map/mapbox/layers/Layers.tsx @@ -14,6 +14,7 @@ export interface LayersProps { // dataset that user selected from result list or map selectedUuids?: string[]; showFullMap?: boolean; + tabNavigation?: (uuid: string, tab: string, section?: string) => void; } // Use to create static layer on map, you need to add menu item to select those layers, // refer to map section diff --git a/src/components/result/GridResultCard.tsx b/src/components/result/GridResultCard.tsx index a1c9bece..5e3bc4d5 100644 --- a/src/components/result/GridResultCard.tsx +++ b/src/components/result/GridResultCard.tsx @@ -21,8 +21,7 @@ import OrganizationLogo from "../logo/OrganizationLogo"; import ResultCardButtonGroup from "./ResultCardButtonGroup"; import MapSpatialExtents from "@/assets/icons/map-spatial-extents.png"; import { OGCCollection } from "../common/store/OGCCollectionDefinitions"; -import { useNavigate } from "react-router-dom"; -import { pageDefault } from "../common/constants"; +import useTabNavigation from "../../hooks/useTabNavigation"; interface GridResultCardProps { content?: OGCCollection; @@ -36,19 +35,15 @@ const GridResultCard: FC = ({ isSelectedDataset, }) => { const [showButtons, setShowButtons] = useState(false); - const navigate = useNavigate(); - const onDetail = useCallback( - (uuid: string) => { - const searchParams = new URLSearchParams(); - searchParams.append("uuid", uuid); - navigate(pageDefault.details + "?" + searchParams.toString()); - }, - [navigate] - ); + const goToDetailPage = useTabNavigation(); if (!content) return; const { id: uuid, title, findIcon, findThumbnail } = content; + const onLinks = () => goToDetailPage(uuid, "links"); + const onDownload = () => goToDetailPage(uuid, "abstract", "download-section"); + const onDetail = () => goToDetailPage(uuid, "abstract"); + return ( = ({ )} - onDetail(uuid)}> + onDetail}> = ({ paddingRight: padding.extraSmall, }} /> - + )} diff --git a/src/components/result/ListResultCard.tsx b/src/components/result/ListResultCard.tsx index 1d603e01..73622b34 100644 --- a/src/components/result/ListResultCard.tsx +++ b/src/components/result/ListResultCard.tsx @@ -42,6 +42,10 @@ const ListResultCard: FC = ({ if (!content) return; const { id: uuid, title, description, findIcon, findThumbnail } = content; + const onLinks = () => goToDetailPage(uuid, "links"); + const onDownload = () => goToDetailPage(uuid, "abstract", "download-section"); + const onDetail = () => goToDetailPage(uuid, "abstract"); + // TODO: buttons are changed, but the behaviors are fake / wrong return ( = ({ {(isSelectedDataset || showButtons) && ( - + )} diff --git a/src/components/result/ResultCardButtonGroup.tsx b/src/components/result/ResultCardButtonGroup.tsx index ea116066..ef5c9a50 100644 --- a/src/components/result/ResultCardButtonGroup.tsx +++ b/src/components/result/ResultCardButtonGroup.tsx @@ -9,12 +9,14 @@ import QuestionMarkIcon from "@mui/icons-material/QuestionMark"; import { OGCCollection } from "../common/store/OGCCollectionDefinitions"; import ResultCardButton from "../common/buttons/ResultCardButton"; import { color } from "../../styles/constants"; -import useTabNavigation from "../../hooks/useTabNavigation"; interface ResultCardButtonGroupProps { content: OGCCollection; isGridView?: boolean; shouldHideText?: boolean; + onLinks?: () => void; + onDownload?: () => void; + onDetail?: () => void; } interface ButtonContainerProps { @@ -74,9 +76,10 @@ const ResultCardButtonGroup: FC = ({ content, isGridView, shouldHideText = false, + onLinks = () => {}, + onDownload = () => {}, + onDetail = () => {}, }) => { - const goToDetailPanel = useTabNavigation(); - const ButtonContainer: FC = ({ children, sx }) => ( = ({ startIcon={LinkIcon} text={generateLinkText(links.length)} shouldHideText={shouldHideText} - onClick={() => goToDetailPanel(content.id, "links")} + onClick={onLinks} resultCardButtonConfig={{ color: links.length > 0 ? color.blue.dark : color.gray.light, }} @@ -117,9 +120,7 @@ const ResultCardButtonGroup: FC = ({ startIcon={DownloadIcon} text="Download" shouldHideText={shouldHideText} - onClick={() => - goToDetailPanel(content.id, "abstract", "download-section") - } + onClick={onDownload} /> @@ -127,7 +128,7 @@ const ResultCardButtonGroup: FC = ({ startIcon={InfoIcon} text="More details ..." shouldHideText={shouldHideText} - onClick={() => goToDetailPanel(content.id, "abstract")} + onClick={onDetail} /> diff --git a/src/pages/search-page/subpages/MapSection.tsx b/src/pages/search-page/subpages/MapSection.tsx index 7cb5977a..432b6a86 100644 --- a/src/pages/search-page/subpages/MapSection.tsx +++ b/src/pages/search-page/subpages/MapSection.tsx @@ -21,6 +21,7 @@ import { MapboxWorldLayersDef } from "../../../components/map/mapbox/layers/Mapb import SnackbarLoader from "../../../components/loading/SnackbarLoader"; import DisplayCoordinate from "../../../components/map/mapbox/controls/DisplayCoordinate"; import { capitalizeFirstLetter } from "../../../utils/StringUtils"; +import useTabNavigation from "../../../hooks/useTabNavigation"; const mapContainerId = "map-container-id"; @@ -58,6 +59,8 @@ const MapSection: React.FC = ({ ); const [staticLayer, setStaticLayer] = useState>([]); + const tabNavigation = useTabNavigation(); + const createPresentationLayers = useCallback( (id: string | null) => { switch (id) { @@ -68,6 +71,7 @@ const MapSection: React.FC = ({ selectedUuids={selectedUuids} showFullMap={showFullMap} onDatasetSelected={onDatasetSelected} + tabNavigation={tabNavigation} /> ); @@ -78,11 +82,12 @@ const MapSection: React.FC = ({ selectedUuids={selectedUuids} showFullMap={showFullMap} onDatasetSelected={onDatasetSelected} + tabNavigation={tabNavigation} /> ); } }, - [collections, onDatasetSelected, selectedUuids, showFullMap] + [collections, onDatasetSelected, selectedUuids, showFullMap, tabNavigation] ); return (