From bf364ad7f8697189aefe890a386f956c7a0b432b Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Fri, 4 Oct 2024 12:01:57 -0500 Subject: [PATCH 01/13] feat: (WIP) Auto save story map --- src/storyMap/components/StoryMap.js | 2 +- .../components/StoryMapForm/TopBar.js | 53 +++++++++++++++++-- src/storyMap/components/StoryMapForm/index.js | 36 +++++++++++-- src/storyMap/storyMapSlice.js | 23 +++----- 4 files changed, 89 insertions(+), 25 deletions(-) diff --git a/src/storyMap/components/StoryMap.js b/src/storyMap/components/StoryMap.js index bc5224375..f868b1af7 100644 --- a/src/storyMap/components/StoryMap.js +++ b/src/storyMap/components/StoryMap.js @@ -477,7 +477,7 @@ const Scroller = props => { filtered.forEach(setLayerOpacity); } }); - + scroller.disable(); setIsReady(true); window.addEventListener('resize', scroller.resize); diff --git a/src/storyMap/components/StoryMapForm/TopBar.js b/src/storyMap/components/StoryMapForm/TopBar.js index 02ffce873..64aab013c 100644 --- a/src/storyMap/components/StoryMapForm/TopBar.js +++ b/src/storyMap/components/StoryMapForm/TopBar.js @@ -18,7 +18,10 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; -import { Button, Divider, Grid, Typography } from '@mui/material'; +import CheckIcon from '@mui/icons-material/Check'; +import SyncIcon from '@mui/icons-material/Sync'; +import SyncProblemIcon from '@mui/icons-material/SyncProblem'; +import { Button, Divider, Grid, Stack, Typography } from '@mui/material'; import RouterLink from 'common/components/RouterLink'; @@ -26,10 +29,46 @@ import ShareDialog from './ShareDialog'; import { useStoryMapConfigContext } from './storyMapConfigContext'; import TopBarContainer from './TopBarContainer'; +const SAVE_STATUS = { + saving: { + message: 'Saving...', + Icon: SyncIcon, + }, + saved: { + message: 'Saved to Terraso', + Icon: CheckIcon, + }, + error: { + message: 'Trying to connect...', + Icon: SyncProblemIcon, + }, +}; + +const SaveStatus = props => { + const { requestStatus } = props; + const { saving, error } = requestStatus; + + const status = saving ? 'saving' : error ? 'error' : 'saved'; + const Icon = SAVE_STATUS[status].Icon; + const message = SAVE_STATUS[status].message; + + return ( + + + {message} + + ); +}; + const TopBar = props => { const { t } = useTranslation(); const { storyMap, config, setPreview } = useStoryMapConfigContext(); - const { onPublish, onSaveDraft } = props; + const { onPublish, onSaveDraft, isDirty, requestStatus } = props; const [openShareDialog, setOpenShareDialog] = React.useState(false); const isPublished = storyMap?.isPublished; @@ -69,8 +108,14 @@ const TopBar = props => { + {storyMap && ( <> {!isPublished && ( )} - + + {storyMap && ( + setOpenShareDialog(true)}> + {t('storyMap.form_share_button')} + + )} + setPreview(true)}> + {t('storyMap.form_preview_button')} + + + + ); +}; + +const TopBar = props => { + const { t } = useTranslation(); + const { storyMap, config } = useStoryMapConfigContext(); + const { onPublish, isDirty, requestStatus } = props; + + const isPublished = storyMap?.isPublished; + + return ( + + + - - - - {t('storyMap.form_back_button')} - - - - - - {config.title || t('storyMap.form_no_title_label')} + + + {t('storyMap.form_back_button')} - - + + + + {config.title || t('storyMap.form_no_title_label')} + + + + - {storyMap && ( - <> - - - - )} - - {!isPublished && ( - - )} + - - - + + + ); }; From a0913f3d5701acb1d6de258ff0146f32c186a21d Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Thu, 7 Nov 2024 12:02:20 -0500 Subject: [PATCH 05/13] feat: Use published version --- package.json | 2 +- src/storyMap/components/StoryMapNew.js | 6 ++-- src/storyMap/components/StoryMapUpdate.js | 6 ++-- src/storyMap/storyMapFragments.js | 7 +++++ src/storyMap/storyMapService.js | 34 +++++++++++++++++++++-- src/storyMap/storyMapSlice.js | 2 +- 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index e77874193..4d7e21b12 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "slate-hyperscript": "^0.100.0", "slate-react": "^0.111.0", "source-map-explorer": "^2.5.3", - "terraso-client-shared": "github:techmatters/terraso-client-shared#8cd860e", + "terraso-client-shared": "github:techmatters/terraso-client-shared#bec5d03dcaf0c47bc2e48661d35a4b73ed2b70fd", "use-debounce": "^10.0.4", "uuid": "^11.0.3", "web-vitals": "^4.2.4", diff --git a/src/storyMap/components/StoryMapNew.js b/src/storyMap/components/StoryMapNew.js index 319193189..87e966ddb 100644 --- a/src/storyMap/components/StoryMapNew.js +++ b/src/storyMap/components/StoryMapNew.js @@ -133,12 +133,12 @@ const StoryMapNew = () => { }, [dispatch, navigate, trackEvent, saved]); const save = useCallback( - (config, mediaFiles, published) => + (config, mediaFiles, publish) => dispatch( addStoryMap({ storyMap: { config, - published, + publish, }, files: mediaFiles, }) @@ -149,7 +149,7 @@ const StoryMapNew = () => { const storyMapId = _.get('payload.story_map_id', data); const id = _.get('payload.id', data); - setSaved({ id, slug, storyMapId, published }); + setSaved({ id, slug, storyMapId, published: publish }); return; } return Promise.reject(data); diff --git a/src/storyMap/components/StoryMapUpdate.js b/src/storyMap/components/StoryMapUpdate.js index 881ce8d06..47dd859f9 100644 --- a/src/storyMap/components/StoryMapUpdate.js +++ b/src/storyMap/components/StoryMapUpdate.js @@ -88,13 +88,13 @@ const StoryMapUpdate = props => { }, [storyMap, navigate, trackEvent, saved]); const save = useCallback( - (config, mediaFiles, published) => + (config, mediaFiles, publish) => dispatch( updateStoryMap({ storyMap: { id: storyMap?.id, config, - published, + publish, }, files: mediaFiles, }) @@ -111,7 +111,7 @@ const StoryMapUpdate = props => { title, slug, storyMapId, - published, + published: publish, }); return; } diff --git a/src/storyMap/storyMapFragments.js b/src/storyMap/storyMapFragments.js index eadee1d20..af6f6f92e 100644 --- a/src/storyMap/storyMapFragments.js +++ b/src/storyMap/storyMapFragments.js @@ -35,6 +35,13 @@ export const storyMapFields = /* GraphQL */ ` } `; +export const storyMapPublishedFields = /* GraphQL */ ` + fragment storyMapPublishedFields on StoryMapNode { + ...storyMapFields + publishedConfiguration + } +`; + export const storyMapMetadataFields = /* GraphQL */ ` fragment storyMapMetadataFields on StoryMapNode { id diff --git a/src/storyMap/storyMapService.js b/src/storyMap/storyMapService.js index 18143e180..ccdaf60d3 100644 --- a/src/storyMap/storyMapService.js +++ b/src/storyMap/storyMapService.js @@ -67,6 +67,36 @@ export const fetchSamples = (params, currentUser) => { export const fetchStoryMap = ({ slug, storyMapId }) => { const query = graphql(` query fetchStoryMap($slug: String!, $storyMapId: String!) { + storyMaps(slug: $slug, storyMapId: $storyMapId) { + edges { + node { + ...storyMapPublishedFields + membershipList { + ...collaborationMemberships + ...accountCollaborationMembership + } + } + } + } + } + `); + return terrasoApi + .requestGraphQL(query, { slug, storyMapId }) + .then(_.get('storyMaps.edges[0].node')) + .then(storyMap => storyMap || Promise.reject('not_found')) + .then(storyMap => ({ + ..._.omit(['membershipList', 'configuration'], storyMap), + config: storyMap.publishedConfiguration + ? JSON.parse(storyMap.publishedConfiguration) + : JSON.parse(storyMap.configuration), + memberships: extractMemberships(storyMap.membershipList), + accountMembership: extractAccountMembership(storyMap.membershipList), + })); +}; + +export const fetchStoryMapForm = ({ slug, storyMapId }) => { + const query = graphql(` + query fetchStoryMapForm($slug: String!, $storyMapId: String!) { storyMaps(slug: $slug, storyMapId: $storyMapId) { edges { node { @@ -98,7 +128,7 @@ export const addStoryMap = async ({ storyMap, files }) => { const storyMapForm = new FormData(); const title = _.get('config.title', storyMap); storyMapForm.append('title', _.isEmpty(title) ? 'Untitled' : title.trim()); // TODO translate - storyMapForm.append('is_published', storyMap.published); + storyMapForm.append('publish', storyMap.publish); storyMapForm.append('configuration', JSON.stringify(storyMap.config)); Object.keys(files).forEach((fileId, index) => { const file = files[fileId].file; @@ -119,7 +149,7 @@ export const updateStoryMap = async ({ storyMap, files }) => { const storyMapForm = new FormData(); storyMapForm.append('id', storyMap.id); storyMapForm.append('title', _.getOr('', 'config.title', storyMap).trim()); - storyMapForm.append('is_published', storyMap.published); + storyMapForm.append('publish', storyMap.publish); storyMapForm.append('configuration', JSON.stringify(storyMap.config)); Object.keys(files).forEach((fileId, index) => { const file = files[fileId].file; diff --git a/src/storyMap/storyMapSlice.js b/src/storyMap/storyMapSlice.js index 6656511e1..81c9be094 100644 --- a/src/storyMap/storyMapSlice.js +++ b/src/storyMap/storyMapSlice.js @@ -66,7 +66,7 @@ export const fetchStoryMap = createAsyncThunk( ); export const fetchStoryMapForm = createAsyncThunk( 'storyMap/fetchStoryMapForm', - storyMapService.fetchStoryMap + storyMapService.fetchStoryMapForm ); export const addStoryMap = createAsyncThunk( 'storyMap/addStoryMap', From f0cdb7fdf25b226c498a866e4e991df0cd9cd011 Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Fri, 8 Nov 2024 11:59:56 -0500 Subject: [PATCH 06/13] feat: Update url --- src/localization/locales/en-US.json | 7 +++-- .../components/StoryMapForm/TopBar.js | 30 +++++++++++++++---- src/storyMap/components/StoryMapUpdate.js | 14 +++++++-- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/src/localization/locales/en-US.json b/src/localization/locales/en-US.json index cdecddb7f..2b97ea3ad 100644 --- a/src/localization/locales/en-US.json +++ b/src/localization/locales/en-US.json @@ -887,12 +887,13 @@ "form_chapter_no_title_label": "Untitled", "form_back_button": "Story Maps", "form_byline": "By $t(user.full_name)", - "form_share_button": "Invite", + "form_share_button": "Invite editors", "form_actions_button": "Actions", - "form_preview_button": "Preview", + "form_preview_button": "Preview draft", + "form_view_published_button": "View published Story Map", "form_save_draft_button": "Save draft", "form_publish_button": "Publish", - "form_republish_button": "Save & Republish", + "form_republish_button": "Publish Changes", "form_preview_close": "Exit Preview", "form_preview_title": "You are previewing <1>{{title}}", "form_preview_title_blank": "You are previewing", diff --git a/src/storyMap/components/StoryMapForm/TopBar.js b/src/storyMap/components/StoryMapForm/TopBar.js index 90f0cd944..460f10381 100644 --- a/src/storyMap/components/StoryMapForm/TopBar.js +++ b/src/storyMap/components/StoryMapForm/TopBar.js @@ -22,9 +22,19 @@ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; import CheckIcon from '@mui/icons-material/Check'; import ErrorIcon from '@mui/icons-material/Error'; import SyncIcon from '@mui/icons-material/Sync'; -import { Button, Grid, Menu, MenuItem, Stack, Typography } from '@mui/material'; +import { + Button, + Divider, + Grid, + Link, + Menu, + MenuItem, + Stack, + Typography, +} from '@mui/material'; import RouterLink from 'common/components/RouterLink'; +import { generateStoryMapUrl } from 'storyMap/storyMapUtils'; import ShareDialog from './ShareDialog'; import { useStoryMapConfigContext } from './storyMapConfigContext'; @@ -113,14 +123,24 @@ const ActionsMenu = () => { open={open} onClose={handleClose} > + setPreview(true)}> + {t('storyMap.form_preview_button')} + + + + {t('storyMap.form_view_published_button')} + + {storyMap && ( - setOpenShareDialog(true)}> + setOpenShareDialog(true)}> {t('storyMap.form_share_button')} )} - setPreview(true)}> - {t('storyMap.form_preview_button')} - ); diff --git a/src/storyMap/components/StoryMapUpdate.js b/src/storyMap/components/StoryMapUpdate.js index 47dd859f9..52946b562 100644 --- a/src/storyMap/components/StoryMapUpdate.js +++ b/src/storyMap/components/StoryMapUpdate.js @@ -83,9 +83,19 @@ const StoryMapUpdate = props => { } if (title !== storyMap?.title) { - navigate(generateStoryMapEditUrl({ slug, storyMapId })); + // window.location.replace(generateStoryMapEditUrl({ slug, storyMapId })); + // navigate(generateStoryMapEditUrl({ slug, storyMapId })); + window.history.pushState( + null, + t('storyMap.edit_document_title', { + name: _.get('title', storyMap), + }), + generateStoryMapEditUrl({ slug, storyMapId }) + ); + // TODO data is not pudated after save + // dispatch(fetchStoryMapForm({ slug, storyMapId })); } - }, [storyMap, navigate, trackEvent, saved]); + }, [storyMap, navigate, trackEvent, saved, t, dispatch]); const save = useCallback( (config, mediaFiles, publish) => From 77571c1504afe146474f8751b3f7ace1f1e6bf36 Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Fri, 8 Nov 2024 17:18:12 -0500 Subject: [PATCH 07/13] fix: Use new slug for publish view --- src/storyMap/components/StoryMapForm/TopBar.js | 4 ++-- .../components/StoryMapForm/storyMapConfigContext.js | 4 ++++ src/storyMap/components/StoryMapUpdate.js | 12 ++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/storyMap/components/StoryMapForm/TopBar.js b/src/storyMap/components/StoryMapForm/TopBar.js index 460f10381..021350d7a 100644 --- a/src/storyMap/components/StoryMapForm/TopBar.js +++ b/src/storyMap/components/StoryMapForm/TopBar.js @@ -81,7 +81,7 @@ const SaveStatus = props => { const ActionsMenu = () => { const { t } = useTranslation(); - const { storyMap, setPreview } = useStoryMapConfigContext(); + const { storyMap, setPreview, slug } = useStoryMapConfigContext(); const [anchorEl, setAnchorEl] = useState(null); const [openShareDialog, setOpenShareDialog] = useState(false); @@ -130,7 +130,7 @@ const ActionsMenu = () => { {t('storyMap.form_view_published_button')} diff --git a/src/storyMap/components/StoryMapForm/storyMapConfigContext.js b/src/storyMap/components/StoryMapForm/storyMapConfigContext.js index e2656c524..893e6520d 100644 --- a/src/storyMap/components/StoryMapForm/storyMapConfigContext.js +++ b/src/storyMap/components/StoryMapForm/storyMapConfigContext.js @@ -34,6 +34,7 @@ export const StoryMapConfigContextProvider = props => { const [preview, setPreview] = useState(false); const [mediaFiles, setMediaFiles] = useState({}); const [isDirty, setIsDirty] = useState(false); + const [slug, setSlug] = useState(storyMap.slug); const init = useRef(false); const addMediaFile = useCallback((content, file) => { @@ -84,6 +85,8 @@ export const StoryMapConfigContextProvider = props => { init, saved, isDirty, + slug, + setSlug, }), [ storyMap, @@ -96,6 +99,7 @@ export const StoryMapConfigContextProvider = props => { setConfigWrapper, isDirty, saved, + slug, ] ); diff --git a/src/storyMap/components/StoryMapUpdate.js b/src/storyMap/components/StoryMapUpdate.js index 52946b562..530158f43 100644 --- a/src/storyMap/components/StoryMapUpdate.js +++ b/src/storyMap/components/StoryMapUpdate.js @@ -39,15 +39,18 @@ import { } from 'storyMap/storyMapUtils'; import StoryMapForm from './StoryMapForm'; -import { StoryMapConfigContextProvider } from './StoryMapForm/storyMapConfigContext'; +import { + StoryMapConfigContextProvider, + useStoryMapConfigContext, +} from './StoryMapForm/storyMapConfigContext'; const StoryMapUpdate = props => { const navigate = useNavigate(); const dispatch = useDispatch(); const { t } = useTranslation(); const { trackEvent } = useAnalytics(); - const { storyMap } = props; const [saved, setSaved] = useState(); + const { storyMap, setSlug } = useStoryMapConfigContext(); useDocumentTitle( t('storyMap.edit_document_title', { @@ -92,10 +95,11 @@ const StoryMapUpdate = props => { }), generateStoryMapEditUrl({ slug, storyMapId }) ); + setSlug(slug); // TODO data is not pudated after save // dispatch(fetchStoryMapForm({ slug, storyMapId })); } - }, [storyMap, navigate, trackEvent, saved, t, dispatch]); + }, [storyMap, navigate, trackEvent, saved, t, dispatch, setSlug]); const save = useCallback( (config, mediaFiles, publish) => @@ -174,7 +178,7 @@ const ContextWrapper = props => { baseConfig={storyMap.config} storyMap={storyMap} > - + ); }; From 286b6d535ba3a2714cf35ba3d84ce467666ec64b Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Wed, 13 Nov 2024 15:10:58 -0500 Subject: [PATCH 08/13] fix: Update all config on update --- src/storyMap/components/StoryMapForm/TopBar.js | 4 ++-- src/storyMap/components/StoryMapForm/index.js | 2 +- .../StoryMapForm/storyMapConfigContext.js | 14 ++++++++------ src/storyMap/components/StoryMapUpdate.js | 14 ++++++-------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/storyMap/components/StoryMapForm/TopBar.js b/src/storyMap/components/StoryMapForm/TopBar.js index 021350d7a..460f10381 100644 --- a/src/storyMap/components/StoryMapForm/TopBar.js +++ b/src/storyMap/components/StoryMapForm/TopBar.js @@ -81,7 +81,7 @@ const SaveStatus = props => { const ActionsMenu = () => { const { t } = useTranslation(); - const { storyMap, setPreview, slug } = useStoryMapConfigContext(); + const { storyMap, setPreview } = useStoryMapConfigContext(); const [anchorEl, setAnchorEl] = useState(null); const [openShareDialog, setOpenShareDialog] = useState(false); @@ -130,7 +130,7 @@ const ActionsMenu = () => { {t('storyMap.form_view_published_button')} diff --git a/src/storyMap/components/StoryMapForm/index.js b/src/storyMap/components/StoryMapForm/index.js index 7431e093d..5fbeba7bc 100644 --- a/src/storyMap/components/StoryMapForm/index.js +++ b/src/storyMap/components/StoryMapForm/index.js @@ -39,7 +39,7 @@ import TopBarPreview from './TopBarPreview'; import theme from 'theme'; -const AUTO_SAVE_DEBOUNCE = 1000; +const AUTO_SAVE_DEBOUNCE = 3000; const BASE_CHAPTER = { alignment: 'left', diff --git a/src/storyMap/components/StoryMapForm/storyMapConfigContext.js b/src/storyMap/components/StoryMapForm/storyMapConfigContext.js index 893e6520d..cf33b33cf 100644 --- a/src/storyMap/components/StoryMapForm/storyMapConfigContext.js +++ b/src/storyMap/components/StoryMapForm/storyMapConfigContext.js @@ -34,7 +34,6 @@ export const StoryMapConfigContextProvider = props => { const [preview, setPreview] = useState(false); const [mediaFiles, setMediaFiles] = useState({}); const [isDirty, setIsDirty] = useState(false); - const [slug, setSlug] = useState(storyMap.slug); const init = useRef(false); const addMediaFile = useCallback((content, file) => { @@ -43,12 +42,16 @@ export const StoryMapConfigContextProvider = props => { return id; }, []); + const clearMediaFiles = useCallback(() => { + setMediaFiles({}); + }, []); + const getMediaFile = useCallback(id => mediaFiles[id]?.content, [mediaFiles]); const saved = useCallback(() => setIsDirty(false), []); const setConfigWrapper = useCallback( - newConfigSetter => { + (newConfigSetter, dirty = true) => { setConfig(currentConfig => { const newConfig = typeof newConfigSetter === 'function' @@ -67,7 +70,7 @@ export const StoryMapConfigContextProvider = props => { dataLayers: _.pick(usedDataLayersIds, newConfig.dataLayers), }; }); - setIsDirty(true); + setIsDirty(dirty); }, [setConfig] ); @@ -82,11 +85,10 @@ export const StoryMapConfigContextProvider = props => { mediaFiles, addMediaFile, getMediaFile, + clearMediaFiles, init, saved, isDirty, - slug, - setSlug, }), [ storyMap, @@ -95,11 +97,11 @@ export const StoryMapConfigContextProvider = props => { mediaFiles, addMediaFile, getMediaFile, + clearMediaFiles, init, setConfigWrapper, isDirty, saved, - slug, ] ); diff --git a/src/storyMap/components/StoryMapUpdate.js b/src/storyMap/components/StoryMapUpdate.js index 530158f43..c1f661b7e 100644 --- a/src/storyMap/components/StoryMapUpdate.js +++ b/src/storyMap/components/StoryMapUpdate.js @@ -50,7 +50,7 @@ const StoryMapUpdate = props => { const { t } = useTranslation(); const { trackEvent } = useAnalytics(); const [saved, setSaved] = useState(); - const { storyMap, setSlug } = useStoryMapConfigContext(); + const { storyMap, setConfig, clearMediaFiles } = useStoryMapConfigContext(); useDocumentTitle( t('storyMap.edit_document_title', { @@ -86,8 +86,6 @@ const StoryMapUpdate = props => { } if (title !== storyMap?.title) { - // window.location.replace(generateStoryMapEditUrl({ slug, storyMapId })); - // navigate(generateStoryMapEditUrl({ slug, storyMapId })); window.history.pushState( null, t('storyMap.edit_document_title', { @@ -95,11 +93,8 @@ const StoryMapUpdate = props => { }), generateStoryMapEditUrl({ slug, storyMapId }) ); - setSlug(slug); - // TODO data is not pudated after save - // dispatch(fetchStoryMapForm({ slug, storyMapId })); } - }, [storyMap, navigate, trackEvent, saved, t, dispatch, setSlug]); + }, [storyMap, navigate, trackEvent, saved, t, dispatch]); const save = useCallback( (config, mediaFiles, publish) => @@ -119,6 +114,7 @@ const StoryMapUpdate = props => { const storyMapId = _.get('payload.story_map_id', data); const title = _.get('payload.title', data); const id = _.get('payload.id', data); + const config = _.get('payload.configuration', data); setSaved({ id, @@ -127,11 +123,13 @@ const StoryMapUpdate = props => { storyMapId, published: publish, }); + clearMediaFiles(); + setConfig(config, false); return; } return Promise.reject(data); }), - [storyMap?.id, dispatch] + [storyMap?.id, dispatch, clearMediaFiles, setConfig] ); const onPublish = useCallback( (config, mediaFiles) => save(config, mediaFiles, true), From 5e3389ad92f48971ba686a58223767fa653cee7c Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Wed, 13 Nov 2024 15:15:32 -0500 Subject: [PATCH 09/13] chore: package-lock update --- package-lock.json | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 767178048..4dfb8d21b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,7 @@ "slate-hyperscript": "^0.100.0", "slate-react": "^0.111.0", "source-map-explorer": "^2.5.3", - "terraso-client-shared": "github:techmatters/terraso-client-shared#8cd860e", + "terraso-client-shared": "github:techmatters/terraso-client-shared#bec5d03dcaf0c47bc2e48661d35a4b73ed2b70fd", "use-debounce": "^10.0.4", "uuid": "^11.0.3", "web-vitals": "^4.2.4", @@ -30257,19 +30257,20 @@ }, "node_modules/terraso-backend": { "version": "0.1.0", - "resolved": "git+ssh://git@github.com/techmatters/terraso-backend.git#b61c60caf963a400bffa8016cb6f894d5d9d72b4", - "integrity": "sha512-rM6ZXO+dX5GT3QuERDJ5PW03O1buJdD7DOkFiMnKbvQobAT+L71NypMKsZrcfxi4+6gT2dYo1j/5EmkFQxVoJQ==" + "resolved": "git+ssh://git@github.com/techmatters/terraso-backend.git#29d558f773853df94973499ab7c9f8c97fc74659", + "integrity": "sha512-Hvl31X7cLIl8V0EFhVRzyxRLEVv6MYFEIW0oEGDLc1p8p9PzVB9I889nl4pUCna4rJz16PZH6ywFj1Y3hnRLGg==" }, "node_modules/terraso-client-shared": { "version": "0.1.0", - "resolved": "git+ssh://git@github.com/techmatters/terraso-client-shared.git#8cd860ef31575487970a59a14cf6a700e1c156bf", + "resolved": "git+ssh://git@github.com/techmatters/terraso-client-shared.git#bec5d03dcaf0c47bc2e48661d35a4b73ed2b70fd", + "integrity": "sha512-CwEmZFMlLY0vq2wb1RR8EseEPj53gBGpLxHsHPlCfKUSogDKYCypdWXa9Sggn04C/Uufp5JjV6rUicuKRWglcQ==", "dependencies": { "@reduxjs/toolkit": "^1.9.7", "jwt-decode": "^4.0.0", "lodash": "^4.17.21", "react": "^18.3.1", "react-redux": "^8.1.3", - "terraso-backend": "github:techmatters/terraso-backend#0a4e249", + "terraso-backend": "github:techmatters/terraso-backend#29d558f773853df94973499ab7c9f8c97fc74659", "uuid": "^10.0.0" }, "engines": { From 17288cf483121e5f95bedad36dabfb877f05fbcd Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Wed, 13 Nov 2024 15:20:15 -0500 Subject: [PATCH 10/13] test: Enable scroller --- src/storyMap/components/StoryMap.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/storyMap/components/StoryMap.js b/src/storyMap/components/StoryMap.js index f868b1af7..ddb21d0c6 100644 --- a/src/storyMap/components/StoryMap.js +++ b/src/storyMap/components/StoryMap.js @@ -477,7 +477,9 @@ const Scroller = props => { filtered.forEach(setLayerOpacity); } }); - scroller.disable(); + // This is needed for development due to resize observer issue + // should not be here on production + // scroller.disable(); setIsReady(true); window.addEventListener('resize', scroller.resize); From 1d6cf6bbed64df9c00baca4776f104d5094116b8 Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Mon, 2 Dec 2024 12:27:42 -0500 Subject: [PATCH 11/13] fix: Remove see published when new story map --- .../components/StoryMapForm/TopBar.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/storyMap/components/StoryMapForm/TopBar.js b/src/storyMap/components/StoryMapForm/TopBar.js index 460f10381..f6651b704 100644 --- a/src/storyMap/components/StoryMapForm/TopBar.js +++ b/src/storyMap/components/StoryMapForm/TopBar.js @@ -127,15 +127,19 @@ const ActionsMenu = () => { {t('storyMap.form_preview_button')} - - {t('storyMap.form_view_published_button')} - - + {storyMap && ( + <> + + {t('storyMap.form_view_published_button')} + + + + )} {storyMap && ( setOpenShareDialog(true)}> {t('storyMap.form_share_button')} From bca089a6c9c8eab805723a25032a35f457c48662 Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Mon, 2 Dec 2024 13:22:11 -0500 Subject: [PATCH 12/13] fix: Avoid changing initial location after component mounts --- src/gis/components/Map.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gis/components/Map.js b/src/gis/components/Map.js index 0196a18b6..eb01767a2 100644 --- a/src/gis/components/Map.js +++ b/src/gis/components/Map.js @@ -305,7 +305,7 @@ const Map = React.forwardRef((props, ref) => { id, mapStyle, projection, - initialLocation, + initialLocation: propsInitialLocation, interactive = true, hash = false, attributionControl = true, @@ -325,6 +325,7 @@ const Map = React.forwardRef((props, ref) => { const { map, setMap } = useMap(); const mapContainer = useRef(null); const [bounds] = useState(initialBounds); + const [initialLocation] = useState(propsInitialLocation); useEffect(() => { const validBounds = isValidBounds(bounds); From 5129dd4fad40f8a2c44f0163a5b272d25aa60614 Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Mon, 2 Dec 2024 13:28:33 -0500 Subject: [PATCH 13/13] fix: Add menu items directly --- .../components/StoryMapForm/TopBar.js | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/storyMap/components/StoryMapForm/TopBar.js b/src/storyMap/components/StoryMapForm/TopBar.js index f6651b704..7e4c51e73 100644 --- a/src/storyMap/components/StoryMapForm/TopBar.js +++ b/src/storyMap/components/StoryMapForm/TopBar.js @@ -128,18 +128,16 @@ const ActionsMenu = () => { {storyMap && ( - <> - - {t('storyMap.form_view_published_button')} - - - + + {t('storyMap.form_view_published_button')} + )} + {storyMap && } {storyMap && ( setOpenShareDialog(true)}> {t('storyMap.form_share_button')}