diff --git a/src/containers/datasets/drawing-upload-tool/index.tsx b/src/containers/datasets/drawing-upload-tool/index.tsx index 9ab67bd3b..21730f34c 100644 --- a/src/containers/datasets/drawing-upload-tool/index.tsx +++ b/src/containers/datasets/drawing-upload-tool/index.tsx @@ -77,45 +77,43 @@ const WidgetDrawingUploadTool = () => { tooltipPosition={{ top: -100, left: -100 }} message="use this to upload an existing GIS file" > -
- {!uploadedGeojson && ( - - )} -
- {uploadedGeojson || isDrawingUploadToolEnabled ? ( - - ) : ( - + {(!customGeojson || !isDrawingToolEnabled) && ( +
+ - )} - -
-
+
+ +
+ +
+ )} + {(uploadedGeojson || isDrawingUploadToolEnabled) && ( +
+ +

Delete area

+
+
+ )} + // TO - DO - add when error gets defined // diff --git a/src/containers/map/delete-drawing-button/index.tsx b/src/containers/map/delete-drawing-button/index.tsx index 561ade3f3..e4db0b62d 100644 --- a/src/containers/map/delete-drawing-button/index.tsx +++ b/src/containers/map/delete-drawing-button/index.tsx @@ -1,4 +1,4 @@ -import { useCallback, useMemo } from 'react'; +import { useCallback, useMemo, ReactElement } from 'react'; import { useMap } from 'react-map-gl'; @@ -22,7 +22,13 @@ const SIZE = { sm: 'h-8 w-8', }; -export const DeleteDrawingButton = ({ size = 'md' }: { size?: 'sm' | 'md' }) => { +export const DeleteDrawingButton = ({ + size = 'md', + children = null, +}: { + size?: 'sm' | 'md'; + children?: ReactElement; +}) => { const resetAnalysisState = useResetRecoilState(analysisAtom); const locationTool = useRecoilValue(locationToolAtom); const resetDrawingState = useResetRecoilState(drawingToolAtom); @@ -66,16 +72,19 @@ export const DeleteDrawingButton = ({ size = 'md' }: { size?: 'sm' | 'md' }) => ]); return ( -
- +
+
+ +
+ {children && children}
); }; diff --git a/src/containers/map/legend/item/index.tsx b/src/containers/map/legend/item/index.tsx index 01b6075b2..5dd80b680 100644 --- a/src/containers/map/legend/item/index.tsx +++ b/src/containers/map/legend/item/index.tsx @@ -133,45 +133,45 @@ const LegendItem = ({ )} - - - - + + + + - - - - Layer statistics - - - - - - -
- + + - - -
- -
-
+
+ + + +
+ + + + + + + Layer statistics + + +
{!embedded && (
- - - - + + + + - - - - Info layer - - - - + + + +
+
+ {WidgetInfo && } +
+
+ +
+
+ + + + Layer info + + + - -
-
- {WidgetInfo && } -
-
- -
- diff --git a/src/containers/widgets/constants.ts b/src/containers/widgets/constants.ts index 27a0ce5bf..7a9c81a88 100644 --- a/src/containers/widgets/constants.ts +++ b/src/containers/widgets/constants.ts @@ -143,7 +143,7 @@ const widgets_prod = [ { name: 'Drivers of Change', slug: 'mangrove_drivers_change', - locationType: ['custom-area', 'wdpa', 'country'], + locationType: ['wdpa', 'country'], applicability: 'National', categoryIds: ['all_datasets', 'restoration_and_conservation'], layersIds: ['extent'], @@ -151,7 +151,7 @@ const widgets_prod = [ { name: 'Mangrove Fisheries', slug: 'mangrove_fisheries', - locationType: ['custom-area', 'wdpa', 'country'], + locationType: ['wdpa', 'country'], applicability: 'Global, National, and Sub-National', categoryIds: ['all_datasets', 'ecosystem_services'], layersIds: ['mangrove_fisheries'], @@ -159,7 +159,7 @@ const widgets_prod = [ { name: 'Coastal Protection', slug: 'mangrove_flood_protection', - locationType: ['custom-area', 'wdpa', 'country'], + locationType: ['wdpa', 'country'], applicability: 'National', categoryIds: ['all_datasets', 'ecosystem_services'], subLayersIds: [ @@ -181,35 +181,35 @@ const widgets_prod = [ { name: 'Protected Areas', slug: 'mangrove_protected_areas', - locationType: ['custom-area', 'wdpa', 'country', 'worldwide'], + locationType: ['wdpa', 'country', 'worldwide'], categoryIds: ['contextual_layers', 'all_datasets'], layersIds: ['mangrove_protected_areas'], }, { name: 'Allen Coral Atlas', slug: 'mangrove_allen_coral_reef', - locationType: ['custom-area', 'wdpa', 'country', 'worldwide'], + locationType: ['wdpa', 'country', 'worldwide'], categoryIds: ['contextual_layers', 'all_datasets'], layersIds: ['allen_coral_reef'], }, { name: 'Salt Marsh', slug: 'mangrove_salt_marsh', - locationType: ['custom-area', 'wdpa', 'country', 'worldwide'], + locationType: ['wdpa', 'country', 'worldwide'], categoryIds: ['contextual_layers', 'all_datasets'], layersIds: ['salt_marsh'], }, { name: 'Tidal Flats', slug: 'mangrove_tidal_flats', - locationType: ['custom-area', 'wdpa', 'country', 'worldwide'], + locationType: ['wdpa', 'country', 'worldwide'], categoryIds: ['contextual_layers', 'all_datasets'], layersIds: ['tidal_flats'], }, { name: 'Global Tidal Wetland Change', slug: 'mangrove_global_tidal_wetland_change', - locationType: ['custom-area', 'wdpa', 'country', 'worldwide'], + locationType: ['wdpa', 'country', 'worldwide'], categoryIds: ['contextual_layers', 'all_datasets'], layersIds: ['global_tidal_wetland_change'], }, diff --git a/src/containers/widgets/index.tsx b/src/containers/widgets/index.tsx index 6f4beeccb..d1d2fbda3 100644 --- a/src/containers/widgets/index.tsx +++ b/src/containers/widgets/index.tsx @@ -20,13 +20,14 @@ import { WIDGETS } from 'containers/datasets'; import Helper from 'containers/guide/helper'; import AppTools from 'containers/navigation'; import WidgetWrapper from 'containers/widget'; -import widgets from 'containers/widgets/constants'; +import { widgets, ANALYSIS_WIDGETS_SLUGS } from 'containers/widgets/constants'; import { useWidgetsIdsByCategory } from 'containers/widgets/hooks'; import { Dialog, DialogContent, DialogTrigger, DialogClose } from 'components/dialog'; import Icon from 'components/icon'; import { breakpoints } from 'styles/styles.config'; import { BUTTON_STYLES } from 'styles/widgets'; +import { WidgetTypes } from 'types/widget'; import ALERT_SVG from 'svgs/ui/alert.svg?sprite'; import SETTINGS_SVG from 'svgs/ui/settings.svg?sprite'; @@ -78,10 +79,13 @@ const WidgetsContainer: FC = () => { const [activeWidgets, setActiveWidgets] = useRecoilState(activeWidgetsAtom); const enabledWidgets = useWidgets(); const widgetsAvailable = useMemo(() => { + if (customGeojson || uploadedGeojson) { + return widgets.filter(({ slug }) => ANALYSIS_WIDGETS_SLUGS.includes(slug)); + } return enabledWidgets.filter( ({ slug }) => activeWidgets?.includes(slug) || slug === 'widgets_deck_tool' ); - }, [activeWidgets, enabledWidgets]); + }, [activeWidgets, enabledWidgets]) satisfies WidgetTypes[]; const setPrintingMode = useSetRecoilState(printModeState); const cat = useWidgetsIdsByCategory(activeWidgets); @@ -123,14 +127,14 @@ const WidgetsContainer: FC = () => { }, {}); const onClickDownload = useCallback(() => { - setWidgetsCollapsed(expandedWidgets); - setPrintingMode(true); + // setWidgetsCollapsed(expandedWidgets); + // setPrintingMode(true); setTimeout(() => { window.print(); }, 2000); - setTimeout(() => { - setPrintingMode(false); - }, 4000); + // setTimeout(() => { + // setPrintingMode(false); + // }, 4000); }, [expandedWidgets, setPrintingMode, setWidgetsCollapsed]); return ( @@ -235,10 +239,10 @@ const WidgetsContainer: FC = () => { {screenWidth > 0 && screenWidth < breakpoints.md && !!widgets.length && (
- {widgetsAvailable.map(({ slug, name, applicability }) => { + {widgetsAvailable.map(({ slug, name, ...props }) => { const Widget = WIDGETS[slug] satisfies () => JSX.Element; return ( - + {WIDGETS[slug] && } ); @@ -251,14 +255,14 @@ const WidgetsContainer: FC = () => { data-testid="widgets-wrapper" className="print:m-auto print:grid print:w-screen print:grid-cols-2 print:pr-24" > - {widgetsAvailable.map(({ slug, name, applicability }) => { + {widgetsAvailable.map(({ slug, name, ...props }) => { const Widget = WIDGETS[slug]; return (