From d240ce9d50af8948b11ef4602cd595f1fc2eedf5 Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 27 May 2024 11:02:08 +0200 Subject: [PATCH 1/6] feat: update map --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 223e00200..01ae846b0 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@emotion/react": "11.11.4", "@emotion/styled": "11.11.5", "@graasp/chatbox": "3.1.0", - "@graasp/map": "1.12.1", + "@graasp/map": "1.13.1", "@graasp/query-client": "3.9.0", "@graasp/sdk": "4.12.0", "@graasp/translations": "1.28.0", diff --git a/yarn.lock b/yarn.lock index 72deefee2..de655f2dc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1540,9 +1540,9 @@ __metadata: languageName: node linkType: hard -"@graasp/map@npm:1.12.1": - version: 1.12.1 - resolution: "@graasp/map@npm:1.12.1" +"@graasp/map@npm:1.13.1": + version: 1.13.1 + resolution: "@graasp/map@npm:1.13.1" dependencies: "@emotion/react": "npm:11.11.4" "@emotion/styled": "npm:11.11.5" @@ -1577,7 +1577,7 @@ __metadata: react: "*" react-dom: "*" react-i18next: ^14.0.0 - checksum: 10/4274d83b66105867ddebcb9a515dd528d3aa18b8036461b3e35e90333180e21ea8046f49af15fc54da22b108d34f32be6f9d3e784583cb6be8c1b178357f6b1f + checksum: 10/f20768ffe8c8fe2080a4cb41c9ab6c5699c1357d37c556764df8cb488fb8e936c166a707ce7b80a30e7a42bb0c2f0c97b0a907f659cb2f5b7b18cc4616c80595 languageName: node linkType: hard @@ -7918,7 +7918,7 @@ __metadata: "@emotion/react": "npm:11.11.4" "@emotion/styled": "npm:11.11.5" "@graasp/chatbox": "npm:3.1.0" - "@graasp/map": "npm:1.12.1" + "@graasp/map": "npm:1.13.1" "@graasp/query-client": "npm:3.9.0" "@graasp/sdk": "npm:4.12.0" "@graasp/translations": "npm:1.28.0" From e37cb89e4655b856a30142681d4f1a2004c21056 Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 27 May 2024 11:41:09 +0200 Subject: [PATCH 2/6] refactor: add view item in map --- src/components/item/MapView.tsx | 3 +++ src/components/main/Items.tsx | 8 ++++++++ src/components/pages/MapItemsScreen.tsx | 16 +++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/components/item/MapView.tsx b/src/components/item/MapView.tsx index 571836d90..37363818b 100644 --- a/src/components/item/MapView.tsx +++ b/src/components/item/MapView.tsx @@ -16,6 +16,7 @@ type Props = { title?: string; height?: string; viewItem: (item: DiscriminatedItem) => void; + viewItemInBuilder: (item: DiscriminatedItem) => void; enableGeolocation?: boolean; }; @@ -83,6 +84,7 @@ const MapView = ({ title, height = '100vh', viewItem, + viewItemInBuilder, enableGeolocation = true, }: Props): JSX.Element => { const { data: currentMember } = hooks.useCurrentMember(); @@ -131,6 +133,7 @@ const MapView = ({ useSuggestionsForAddress={hooks.useSuggestionsForAddress} useItemsInMap={hooks.useItemsInMap} viewItem={viewItem} + viewItemInBuilder={viewItemInBuilder} currentMember={currentMember} item={parent} // use builder modal to add new item if the screen is big enough diff --git a/src/components/main/Items.tsx b/src/components/main/Items.tsx index 352ac69da..4a4b238d4 100644 --- a/src/components/main/Items.tsx +++ b/src/components/main/Items.tsx @@ -1,6 +1,9 @@ +import { useNavigate } from 'react-router'; + import { DiscriminatedItem, PackedItem, redirect } from '@graasp/sdk'; import { buildGraaspPlayerView } from '@/config/externalPaths'; +import { buildItemPath } from '@/config/paths'; import { buildPlayerTabName } from '@/config/selectors'; import { ShowOnlyMeChangeType } from '@/config/types'; @@ -63,6 +66,7 @@ const Items = ({ showDropzoneHelper = false, }: Props): JSX.Element | null => { const { mode } = useLayoutContext(); + const navigate = useNavigate(); const itemsStatuses = useItemsStatuses({ items, }); @@ -74,10 +78,14 @@ const Items = ({ openInNewTab: true, }); }; + const viewItemInBuilder = (item: DiscriminatedItem) => { + navigate(buildItemPath(item.id)); + }; return ( { const [urlSearchParams] = useSearchParams(); + const navigate = useNavigate(); const isMobileApp = urlSearchParams.get('isMobileApp') === 'true'; const enableGeolocation = urlSearchParams.get('enableGeolocation') @@ -30,9 +32,21 @@ const MapItemScreen = (): JSX.Element | null => { } }; + const viewItemInBuilder = (item: DiscriminatedItem) => { + if (isMobileApp) { + // todo: replace with universal/deep link? not sure it works inside iframe.. + window.parent.postMessage( + JSON.stringify({ item, action: 'open-builder' }), + ); + } else { + navigate(buildItemPath(item.id)); + } + }; + return ( From d221a3e53c467d19b334e4371a0d8d8533473a91 Mon Sep 17 00:00:00 2001 From: kim Date: Mon, 27 May 2024 11:43:12 +0200 Subject: [PATCH 3/6] fix: disable geolocation picker for inherited geoloc --- src/components/item/settings/GeolocationPicker.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/item/settings/GeolocationPicker.tsx b/src/components/item/settings/GeolocationPicker.tsx index 3edfe7c70..23e6683f4 100644 --- a/src/components/item/settings/GeolocationPicker.tsx +++ b/src/components/item/settings/GeolocationPicker.tsx @@ -64,12 +64,16 @@ const GeolocationPicker = ({ onChangeOption={onChangeOption} initialValue={geoloc?.addressLabel ?? undefined} useSuggestionsForAddress={hooks.useSuggestionsForAddress} + disabled={isDisabled} /> - - - - - + {/* show clear only if not disabled */} + {!isDisabled && ( + + + + + + )} {isDisabled && ( From 754fbf2668ca03145e53e07b5bf27ff76f05f94f Mon Sep 17 00:00:00 2001 From: kim Date: Tue, 28 May 2024 16:17:49 +0200 Subject: [PATCH 4/6] refactor: move to map in map --- src/components/main/Items.tsx | 10 ++++++++-- src/components/pages/MapItemsScreen.tsx | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/main/Items.tsx b/src/components/main/Items.tsx index 4a4b238d4..cbc02c488 100644 --- a/src/components/main/Items.tsx +++ b/src/components/main/Items.tsx @@ -1,4 +1,5 @@ import { useNavigate } from 'react-router'; +import { useSearchParams } from 'react-router-dom'; import { DiscriminatedItem, PackedItem, redirect } from '@graasp/sdk'; @@ -66,6 +67,7 @@ const Items = ({ showDropzoneHelper = false, }: Props): JSX.Element | null => { const { mode } = useLayoutContext(); + const [searchParams] = useSearchParams(); const navigate = useNavigate(); const itemsStatuses = useItemsStatuses({ items, @@ -75,11 +77,15 @@ const Items = ({ const viewItem = (item: DiscriminatedItem) => { redirect(window, buildGraaspPlayerView(item.id), { name: buildPlayerTabName(item.id), - openInNewTab: true, + openInNewTab: false, }); }; const viewItemInBuilder = (item: DiscriminatedItem) => { - navigate(buildItemPath(item.id)); + // navigate to item in map + navigate({ + pathname: buildItemPath(item.id), + search: searchParams.toString(), + }); }; return ( diff --git a/src/components/pages/MapItemsScreen.tsx b/src/components/pages/MapItemsScreen.tsx index cd346989c..4c24966b3 100644 --- a/src/components/pages/MapItemsScreen.tsx +++ b/src/components/pages/MapItemsScreen.tsx @@ -39,7 +39,11 @@ const MapItemScreen = (): JSX.Element | null => { JSON.stringify({ item, action: 'open-builder' }), ); } else { - navigate(buildItemPath(item.id)); + // navigate to item in map + navigate({ + pathname: buildItemPath(item.id), + search: urlSearchParams.toString(), + }); } }; From 29848e5664535030c3b9b2b65234bb4526038461 Mon Sep 17 00:00:00 2001 From: kim Date: Tue, 28 May 2024 16:20:11 +0200 Subject: [PATCH 5/6] refactor: show mode for all item types --- src/components/item/header/ItemHeaderActions.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/item/header/ItemHeaderActions.tsx b/src/components/item/header/ItemHeaderActions.tsx index 63d5b21a5..33261f5e9 100644 --- a/src/components/item/header/ItemHeaderActions.tsx +++ b/src/components/item/header/ItemHeaderActions.tsx @@ -2,7 +2,7 @@ import { useParams } from 'react-router-dom'; import { Stack } from '@mui/material'; -import { ItemType, PermissionLevel, PermissionLevelCompare } from '@graasp/sdk'; +import { PermissionLevel, PermissionLevelCompare } from '@graasp/sdk'; import { ChatboxButton } from '@graasp/ui'; import EditButton from '@/components/common/EditButton'; @@ -82,10 +82,7 @@ const ItemHeaderActions = (): JSX.Element => { return ( {renderItemActions()} - { - // show only for content with tables : root or folders - (item?.type === ItemType.FOLDER || !item?.id) && - } + ); }; From a48ce8dc04292cc7a6b14adeef36741ebaeaa86a Mon Sep 17 00:00:00 2001 From: kim Date: Wed, 29 May 2024 09:59:09 +0200 Subject: [PATCH 6/6] refactor: update map --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 01ae846b0..0773e0ecb 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@emotion/react": "11.11.4", "@emotion/styled": "11.11.5", "@graasp/chatbox": "3.1.0", - "@graasp/map": "1.13.1", + "@graasp/map": "1.14.0", "@graasp/query-client": "3.9.0", "@graasp/sdk": "4.12.0", "@graasp/translations": "1.28.0", diff --git a/yarn.lock b/yarn.lock index de655f2dc..3ddca2c54 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1540,9 +1540,9 @@ __metadata: languageName: node linkType: hard -"@graasp/map@npm:1.13.1": - version: 1.13.1 - resolution: "@graasp/map@npm:1.13.1" +"@graasp/map@npm:1.14.0": + version: 1.14.0 + resolution: "@graasp/map@npm:1.14.0" dependencies: "@emotion/react": "npm:11.11.4" "@emotion/styled": "npm:11.11.5" @@ -1577,7 +1577,7 @@ __metadata: react: "*" react-dom: "*" react-i18next: ^14.0.0 - checksum: 10/f20768ffe8c8fe2080a4cb41c9ab6c5699c1357d37c556764df8cb488fb8e936c166a707ce7b80a30e7a42bb0c2f0c97b0a907f659cb2f5b7b18cc4616c80595 + checksum: 10/ab968e938b7133fdd110406865c364c5f4bb053702bec7441e2c488402c0e98c75fb49aece3225970d9a0119b3390c5eb16248284d3ca45dfba0b66fbd729a8b languageName: node linkType: hard @@ -7918,7 +7918,7 @@ __metadata: "@emotion/react": "npm:11.11.4" "@emotion/styled": "npm:11.11.5" "@graasp/chatbox": "npm:3.1.0" - "@graasp/map": "npm:1.13.1" + "@graasp/map": "npm:1.14.0" "@graasp/query-client": "npm:3.9.0" "@graasp/sdk": "npm:4.12.0" "@graasp/translations": "npm:1.28.0"