From 6067cca811ffe7a1a7f75ae7849284b97aa95df2 Mon Sep 17 00:00:00 2001 From: tischsoic Date: Thu, 19 Dec 2024 11:53:35 +0100 Subject: [PATCH 1/3] IBX-9313: Fix fetching ContentInfo on select --- .../services/universal.discovery.service.js | 18 ++++++++++++++++-- .../universal.discovery.module.js | 15 ++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/services/universal.discovery.service.js b/src/bundle/ui-dev/src/modules/universal-discovery/services/universal.discovery.service.js index 991943eb48..f2b021b1f8 100644 --- a/src/bundle/ui-dev/src/modules/universal-discovery/services/universal.discovery.service.js +++ b/src/bundle/ui-dev/src/modules/universal-discovery/services/universal.discovery.service.js @@ -424,7 +424,18 @@ export const createDraft = ({ token, siteaccess, accessToken, contentId, instanc }; export const loadContentInfo = ( - { token, siteaccess, accessToken, contentId, limit = QUERY_LIMIT, offset = 0, signal, instanceUrl = DEFAULT_INSTANCE_URL }, + { + token, + siteaccess, + accessToken, + contentId, + noLanguageCode = false, + useAlwaysAvailable = false, + limit = QUERY_LIMIT, + offset = 0, + signal, + instanceUrl = DEFAULT_INSTANCE_URL, + }, callback, ) => { const body = { @@ -438,10 +449,13 @@ export const loadContentInfo = ( limit, offset, }, + useAlwaysAvailable, }, }; - addLanguageCodeToCreateViewEndpoint(body); + if (!noLanguageCode) { + addLanguageCodeToCreateViewEndpoint(body); + } const request = new Request(`${instanceUrl}${ENDPOINT_CREATE_VIEW}`, { method: 'POST', diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js b/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js index cec9ce9c2b..9601a27c8c 100644 --- a/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js +++ b/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js @@ -244,7 +244,7 @@ const UniversalDiscoveryModule = (props) => { .join(','); if (!locationIds) { - return Promise.resolve([]); + return Promise.resolve(null); } return new Promise((resolve) => { @@ -265,7 +265,16 @@ const UniversalDiscoveryModule = (props) => { const contentId = locationsWithoutVersion.map((item) => item.location.ContentInfo.Content._id).join(','); return new Promise((resolve) => { - loadContentInfo({ ...restInfo, contentId, signal }, (response) => resolve(response)); + loadContentInfo( + { + ...restInfo, + noLanguageCode: true, + useAlwaysAvailable: true, + contentId, + signal, + }, + (response) => resolve(response), + ); }); }; const contentTypesMapGlobal = useMemo( @@ -362,7 +371,7 @@ const UniversalDiscoveryModule = (props) => { Promise.all([loadPermissions(), loadVersions(abortControllerRef.current.signal)]).then((response) => { const [locationsWithPermissions, locationsWithVersions] = response; - if (!locationsWithPermissions.length && !locationsWithVersions.length) { + if (!locationsWithPermissions?.LocationList.locations.length && !locationsWithVersions.length) { return; } From 4779908e3482186c0407ce6eac331609473a3ae1 Mon Sep 17 00:00:00 2001 From: tischsoic Date: Thu, 19 Dec 2024 12:02:41 +0100 Subject: [PATCH 2/3] contentIds --- .../modules/universal-discovery/universal.discovery.module.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js b/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js index 9601a27c8c..6f8a3fcbab 100644 --- a/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js +++ b/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js @@ -262,7 +262,7 @@ const UniversalDiscoveryModule = (props) => { return Promise.resolve([]); } - const contentId = locationsWithoutVersion.map((item) => item.location.ContentInfo.Content._id).join(','); + const contentIds = locationsWithoutVersion.map((item) => item.location.ContentInfo.Content._id).join(','); return new Promise((resolve) => { loadContentInfo( @@ -270,7 +270,7 @@ const UniversalDiscoveryModule = (props) => { ...restInfo, noLanguageCode: true, useAlwaysAvailable: true, - contentId, + contentId: contentIds, signal, }, (response) => resolve(response), From bd868373e0cda58df0f26601d9d3743d960f7e8b Mon Sep 17 00:00:00 2001 From: tischsoic Date: Thu, 19 Dec 2024 14:59:11 +0100 Subject: [PATCH 3/3] fix for props.selectedLocations --- .../services/universal.discovery.service.js | 27 ++++++++++++++++--- .../universal.discovery.module.js | 23 +++++++++++----- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/services/universal.discovery.service.js b/src/bundle/ui-dev/src/modules/universal-discovery/services/universal.discovery.service.js index f2b021b1f8..05dabc0018 100644 --- a/src/bundle/ui-dev/src/modules/universal-discovery/services/universal.discovery.service.js +++ b/src/bundle/ui-dev/src/modules/universal-discovery/services/universal.discovery.service.js @@ -257,7 +257,17 @@ export const findLocationsBySearchQuery = ( }; export const findLocationsById = ( - { token, siteaccess, accessToken, id, limit = QUERY_LIMIT, offset = 0, instanceUrl = DEFAULT_INSTANCE_URL }, + { + token, + siteaccess, + accessToken, + id, + noLanguageCode = false, + useAlwaysAvailable = undefined, + limit = QUERY_LIMIT, + offset = 0, + instanceUrl = DEFAULT_INSTANCE_URL, + }, callback, ) => { const body = { @@ -271,10 +281,17 @@ export const findLocationsById = ( limit, offset, }, + useAlwaysAvailable, }, }; - addLanguageCodeToCreateViewEndpoint(body); + if (useAlwaysAvailable !== undefined) { + body.ViewInput.useAlwaysAvailable = useAlwaysAvailable; + } + + if (!noLanguageCode) { + addLanguageCodeToCreateViewEndpoint(body); + } const request = new Request(`${instanceUrl}${ENDPOINT_CREATE_VIEW}`, { method: 'POST', @@ -430,7 +447,7 @@ export const loadContentInfo = ( accessToken, contentId, noLanguageCode = false, - useAlwaysAvailable = false, + useAlwaysAvailable = undefined, limit = QUERY_LIMIT, offset = 0, signal, @@ -453,6 +470,10 @@ export const loadContentInfo = ( }, }; + if (useAlwaysAvailable !== undefined) { + body.ViewInput.useAlwaysAvailable = useAlwaysAvailable; + } + if (!noLanguageCode) { addLanguageCodeToCreateViewEndpoint(body); } diff --git a/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js b/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js index 6f8a3fcbab..6c05404ac4 100644 --- a/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js +++ b/src/bundle/ui-dev/src/modules/universal-discovery/universal.discovery.module.js @@ -353,15 +353,24 @@ const UniversalDiscoveryModule = (props) => { return; } - findLocationsById({ ...restInfo, id: props.selectedLocations.join(','), limit: props.selectedLocations.length }, (locations) => { - const mappedLocation = props.selectedLocations.map((locationId) => { - const location = locations.find(({ id }) => id === parseInt(locationId, 10)); + findLocationsById( + { + ...restInfo, + noLanguageCode: true, + useAlwaysAvailable: true, + id: props.selectedLocations.join(','), + limit: props.selectedLocations.length, + }, + (locations) => { + const mappedLocation = props.selectedLocations.map((locationId) => { + const location = locations.find(({ id }) => id === parseInt(locationId, 10)); - return { location }; - }); + return { location }; + }); - dispatchSelectedLocationsAction({ type: 'REPLACE_SELECTED_LOCATIONS', locations: mappedLocation }); - }); + dispatchSelectedLocationsAction({ type: 'REPLACE_SELECTED_LOCATIONS', locations: mappedLocation }); + }, + ); }, [props.selectedLocations]); useEffect(() => {