diff --git a/apps/fishing-map/features/area-report/vessels/ReportVesselsTableFooter.tsx b/apps/fishing-map/features/area-report/vessels/ReportVesselsTableFooter.tsx
index 80745beab4..ff38745b0a 100644
--- a/apps/fishing-map/features/area-report/vessels/ReportVesselsTableFooter.tsx
+++ b/apps/fishing-map/features/area-report/vessels/ReportVesselsTableFooter.tsx
@@ -95,7 +95,7 @@ export default function ReportVesselsTableFooter({ reportName }: ReportVesselsTa
}
const onAddToVesselGroup = () => {
const dataviewIds = heatmapDataviews.map(({ id }) => id)
- dispatch(setVesselGroupConfirmationMode('saveAndNavigate'))
+ dispatch(setVesselGroupConfirmationMode('saveAndSeeInWorkspace'))
if (dataviewIds?.length) {
dispatch(setVesselGroupCurrentDataviewIds(dataviewIds))
}
diff --git a/apps/fishing-map/features/search/SearchActions.tsx b/apps/fishing-map/features/search/SearchActions.tsx
index ceb279cd33..81d163b105 100644
--- a/apps/fishing-map/features/search/SearchActions.tsx
+++ b/apps/fishing-map/features/search/SearchActions.tsx
@@ -75,7 +75,7 @@ function SearchActions() {
const onAddToVesselGroup = () => {
const dataviewIds = heatmapDataviews.map(({ id }) => id)
- dispatch(setVesselGroupConfirmationMode('saveAndNavigate'))
+ dispatch(setVesselGroupConfirmationMode('saveAndSeeInWorkspace'))
if (dataviewIds?.length) {
dispatch(setVesselGroupCurrentDataviewIds(dataviewIds))
}
diff --git a/apps/fishing-map/features/vessel-groups/VesselGroupAddButton.tsx b/apps/fishing-map/features/vessel-groups/VesselGroupAddButton.tsx
index 7fb417ee0d..52f131aa99 100644
--- a/apps/fishing-map/features/vessel-groups/VesselGroupAddButton.tsx
+++ b/apps/fishing-map/features/vessel-groups/VesselGroupAddButton.tsx
@@ -2,8 +2,10 @@ import { useCallback } from 'react'
import cx from 'classnames'
import { useTranslation } from 'react-i18next'
import React from 'react'
+import { useSelector } from 'react-redux'
import { Button, ButtonType, ButtonSize } from '@globalfishingwatch/ui-components'
import { MAX_VESSEL_GROUP_VESSELS } from 'features/vessel-groups/vessel-groups.slice'
+import { selectIsGuestUser } from 'features/user/selectors/user.selectors'
import styles from './VesselGroupListTooltip.module.css'
import VesselGroupListTooltip from './VesselGroupListTooltip'
import {
@@ -38,17 +40,21 @@ export function VesselGroupAddActionButton({
onToggleClick,
}: VesselGroupAddButtonToggleProps) {
const { t } = useTranslation()
+ const guestUser = useSelector(selectIsGuestUser)
const tooManyVessels = vessels && vessels?.length > MAX_VESSEL_GROUP_VESSELS
+ const disabled = guestUser || !vessels?.length || tooManyVessels
return (
-
+ {workspaceToNavigate && (
+
+ )}
))}
diff --git a/apps/fishing-map/features/vessel-groups/vessel-groups.selectors.ts b/apps/fishing-map/features/vessel-groups/vessel-groups.selectors.ts
index 76919948ca..63fb2bb433 100644
--- a/apps/fishing-map/features/vessel-groups/vessel-groups.selectors.ts
+++ b/apps/fishing-map/features/vessel-groups/vessel-groups.selectors.ts
@@ -1,14 +1,20 @@
import { createSelector } from '@reduxjs/toolkit'
import { isAdvancedSearchAllowed } from 'features/search/search.selectors'
-import { selectUrlDataviewInstances } from 'routes/routes.selectors'
+import { selectLocationQuery, selectUrlDataviewInstances } from 'routes/routes.selectors'
import {
MAX_VESSEL_GROUP_VESSELS,
selectNewVesselGroupSearchVessels,
selectVesselGroupSearchVessels,
} from 'features/vessel-groups/vessel-groups.slice'
-import { selectWorkspaceDataviewInstances } from 'features/workspace/workspace.selectors'
+import {
+ selectLastVisitedWorkspace,
+ selectWorkspace,
+ selectWorkspaceDataviewInstances,
+} from 'features/workspace/workspace.selectors'
import { selectHasUserGroupsPermissions } from 'features/user/selectors/user.permissions.selectors'
-import { selectDataviewInstancesResolvedVisible } from 'features/dataviews/selectors/dataviews.selectors'
+import { LastWorkspaceVisited } from 'features/workspace/workspace.slice'
+import { WORKSPACE } from 'routes/routes'
+import { DEFAULT_WORKSPACE_CATEGORY, DEFAULT_WORKSPACE_ID } from 'data/workspaces'
export const selectAllVesselGroupSearchVessels = createSelector(
[selectVesselGroupSearchVessels, selectNewVesselGroupSearchVessels],
@@ -47,6 +53,23 @@ export const selectWorkspaceVessselGroupsIds = createSelector(
}
)
+export const selectVesselGroupWorkspaceToNavigate = createSelector(
+ [selectLastVisitedWorkspace, selectWorkspace, selectLocationQuery],
+ (lastVisitedWorkspace, workspace, query): LastWorkspaceVisited => {
+ if (lastVisitedWorkspace) {
+ return lastVisitedWorkspace
+ }
+ return {
+ type: WORKSPACE,
+ payload: {
+ category: workspace?.category || DEFAULT_WORKSPACE_CATEGORY,
+ workspaceId: workspace?.id || DEFAULT_WORKSPACE_ID,
+ },
+ query: query,
+ }
+ }
+)
+
export const selectIsVessselGroupsFiltering = createSelector(
[selectWorkspaceVessselGroupsIds],
(workspaceVesselGroupIds = []) => {
diff --git a/apps/fishing-map/features/vessel-groups/vessel-groups.slice.ts b/apps/fishing-map/features/vessel-groups/vessel-groups.slice.ts
index b2466fa325..3c4023e107 100644
--- a/apps/fishing-map/features/vessel-groups/vessel-groups.slice.ts
+++ b/apps/fishing-map/features/vessel-groups/vessel-groups.slice.ts
@@ -34,7 +34,7 @@ export const MAX_VESSEL_GROUP_VESSELS = 1000
export const MAX_VESSEL_GROUP_SEARCH_VESSELS = 400
export type IdField = 'vesselId' | 'mmsi'
-export type VesselGroupConfirmationMode = 'save' | 'saveAndNavigate'
+export type VesselGroupConfirmationMode = 'save' | 'saveAndSeeInWorkspace'
interface VesselGroupsState extends AsyncReducer {
isModalOpen: boolean
diff --git a/apps/fishing-map/features/workspace/workspace.slice.ts b/apps/fishing-map/features/workspace/workspace.slice.ts
index 1e84606230..92ac83e729 100644
--- a/apps/fishing-map/features/workspace/workspace.slice.ts
+++ b/apps/fishing-map/features/workspace/workspace.slice.ts
@@ -59,7 +59,12 @@ import {
} from './workspace.selectors'
import { parseUpsertWorkspace } from './workspace.utils'
-type LastWorkspaceVisited = { type: ROUTE_TYPES; payload: any; query: any; replaceQuery?: boolean }
+export type LastWorkspaceVisited = {
+ type: ROUTE_TYPES
+ payload: any
+ query: any
+ replaceQuery?: boolean
+}
interface WorkspaceSliceState {
status: AsyncReducerStatus
diff --git a/apps/fishing-map/public/locales/source/translations.json b/apps/fishing-map/public/locales/source/translations.json
index c0a1282ff7..fd17772a55 100644
--- a/apps/fishing-map/public/locales/source/translations.json
+++ b/apps/fishing-map/public/locales/source/translations.json
@@ -1015,6 +1015,7 @@
"remove": "Remove vessel group",
"removeVessel": "Remove vessel from group",
"saveAndFilter": "Save and filter workspace",
+ "saveAndSeeInWorkspace": "Save and see in workspace",
"saveForLater": "Save for later",
"saveForLaterTooltip": "You'll find the group in the activity layers filters or your user panel button",
"searchLimit": "Search is limited up to {{limit}} vessels",