From 40a61ac0602a4a2ee330c030f733cabdef15132f Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:05:34 +0300 Subject: [PATCH 1/8] Fix failing build Signed-off-by: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> --- .github/workflows/climatemappedafrica-deploy-dev.yml | 5 +++++ apps/climatemappedafrica/src/lib/data/common/index.js | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/climatemappedafrica-deploy-dev.yml b/.github/workflows/climatemappedafrica-deploy-dev.yml index 285b91405..7242154a9 100644 --- a/.github/workflows/climatemappedafrica-deploy-dev.yml +++ b/.github/workflows/climatemappedafrica-deploy-dev.yml @@ -33,6 +33,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -61,6 +65,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 target: climatemappedafrica-runner push: true tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}" diff --git a/apps/climatemappedafrica/src/lib/data/common/index.js b/apps/climatemappedafrica/src/lib/data/common/index.js index 33104d6b4..939d7a362 100644 --- a/apps/climatemappedafrica/src/lib/data/common/index.js +++ b/apps/climatemappedafrica/src/lib/data/common/index.js @@ -65,9 +65,12 @@ async function getNavBar(siteSettings, variant, { slug }, hurumapProfile) { export async function getPagePaths(api) { const hurumapSettings = await api.findGlobal("settings-hurumap"); const { docs: pages } = await api.getCollection("pages"); - const { - page: { value: explorePage }, - } = hurumapSettings; + let explorePage; + if (hurumapSettings.page) { + explorePage = hurumapSettings.page.value; + } else { + explorePage = null; + } const paths = pages.flatMap(({ slug }) => { // TODO(kilemensi): Handle parent > child page relation e.g. /insights/news if (slug !== explorePage?.slug) { From b7998296ac5fa9236845ed5612050cc451994ed4 Mon Sep 17 00:00:00 2001 From: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> Date: Tue, 5 Nov 2024 13:06:36 +0300 Subject: [PATCH 2/8] Update branch Signed-off-by: Kipruto <43873157+kelvinkipruto@users.noreply.github.com> --- .github/workflows/climatemappedafrica-deploy-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/climatemappedafrica-deploy-dev.yml b/.github/workflows/climatemappedafrica-deploy-dev.yml index 7242154a9..7aa2a9192 100644 --- a/.github/workflows/climatemappedafrica-deploy-dev.yml +++ b/.github/workflows/climatemappedafrica-deploy-dev.yml @@ -2,7 +2,7 @@ name: Climate Mapped Africa | Deploy | DEV on: push: - branches: [main] + branches: [ft/climatemapped-build-fix] paths: - "apps/climatemappedafrica/**" - "Dockerfile" From 66db738ba5e42eb14d8518b273ca8d8196a17e59 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Tue, 5 Nov 2024 13:35:08 +0300 Subject: [PATCH 3/8] Fixed disabled hurumap --- .../src/lib/data/blockify/hero.js | 5 ++--- .../src/lib/data/common/index.js | 13 +++---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/apps/climatemappedafrica/src/lib/data/blockify/hero.js b/apps/climatemappedafrica/src/lib/data/blockify/hero.js index 66b91a3e0..14909bac4 100644 --- a/apps/climatemappedafrica/src/lib/data/blockify/hero.js +++ b/apps/climatemappedafrica/src/lib/data/blockify/hero.js @@ -6,10 +6,9 @@ import { export default async function hero({ block, hurumap }) { const { rootGeography: { center, code, rootGeographyHasData: pinRootGeography }, - page: { - value: { slug: explorePageSlug }, - }, + page, } = hurumap; + const explorePageSlug = page?.value?.slug ?? null; const { geometries } = await fetchProfileGeography(code.toLowerCase()); const { level } = geometries.boundary?.properties ?? {}; const childLevelMaps = { diff --git a/apps/climatemappedafrica/src/lib/data/common/index.js b/apps/climatemappedafrica/src/lib/data/common/index.js index 939d7a362..cf3c2e0e1 100644 --- a/apps/climatemappedafrica/src/lib/data/common/index.js +++ b/apps/climatemappedafrica/src/lib/data/common/index.js @@ -65,12 +65,7 @@ async function getNavBar(siteSettings, variant, { slug }, hurumapProfile) { export async function getPagePaths(api) { const hurumapSettings = await api.findGlobal("settings-hurumap"); const { docs: pages } = await api.getCollection("pages"); - let explorePage; - if (hurumapSettings.page) { - explorePage = hurumapSettings.page.value; - } else { - explorePage = null; - } + const explorePage = hurumapSettings.page?.value || { slug: null }; const paths = pages.flatMap(({ slug }) => { // TODO(kilemensi): Handle parent > child page relation e.g. /insights/news if (slug !== explorePage?.slug) { @@ -112,9 +107,7 @@ export async function getPageProps(api, context) { } const hurumap = await api.findGlobal("settings-hurumap"); - const { - page: { value: explorePage }, - } = hurumap; + const explorePage = hurumap.page?.value || { slug: null }; const siteSettings = await api.findGlobal("settings-site"); const settings = { @@ -124,7 +117,7 @@ export async function getPageProps(api, context) { }; let blocks = await blockify(page.blocks, api, context, settings); - const variant = page.slug === explorePage.slug ? "explore" : "default"; + const variant = page.slug === explorePage?.slug ? "explore" : "default"; const footer = getFooter(siteSettings, variant); const menus = await getNavBar( From dcbe112015b258c36e7cf90680177738a004ee42 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Tue, 5 Nov 2024 13:44:20 +0300 Subject: [PATCH 4/8] Do not redirect on click if explore page is not defined --- apps/climatemappedafrica/src/components/Hero/Map.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/climatemappedafrica/src/components/Hero/Map.js b/apps/climatemappedafrica/src/components/Hero/Map.js index bd8f60512..e09f2833d 100644 --- a/apps/climatemappedafrica/src/components/Hero/Map.js +++ b/apps/climatemappedafrica/src/components/Hero/Map.js @@ -55,9 +55,11 @@ function Map({ }); }); layer.on("click", () => { - router.push( - `/${explorePageSlug}/${feature.properties.code.toLowerCase()}`, - ); + if (explorePageSlug) { + router.push( + `/${explorePageSlug}/${feature.properties.code.toLowerCase()}`, + ); + } }); } }; From 9c15a9008e2bdf1ea2b1e77f10f7959926cef761 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Tue, 5 Nov 2024 14:53:38 +0300 Subject: [PATCH 5/8] Fixed Hero rendering if hurumap is disabled --- apps/climatemappedafrica/src/components/Hero/Hero.js | 1 + apps/climatemappedafrica/src/components/Hero/Map.js | 10 ++++++---- apps/climatemappedafrica/src/lib/data/blockify/hero.js | 3 ++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/climatemappedafrica/src/components/Hero/Hero.js b/apps/climatemappedafrica/src/components/Hero/Hero.js index 6085bc944..abfd54da8 100644 --- a/apps/climatemappedafrica/src/components/Hero/Hero.js +++ b/apps/climatemappedafrica/src/components/Hero/Hero.js @@ -153,6 +153,7 @@ Hero.propTypes = { featuredLocations: PropTypes.arrayOf(PropTypes.shape({})), properties: PropTypes.shape({}), level: PropTypes.string, + explorePageSlug: PropTypes.string, }; export default Hero; diff --git a/apps/climatemappedafrica/src/components/Hero/Map.js b/apps/climatemappedafrica/src/components/Hero/Map.js index e09f2833d..5a828363f 100644 --- a/apps/climatemappedafrica/src/components/Hero/Map.js +++ b/apps/climatemappedafrica/src/components/Hero/Map.js @@ -42,10 +42,12 @@ function Map({ }); layer.on("mouseover", () => { onLayerMouseOver(feature.properties.name.toLowerCase()); - layer.setStyle({ - fillColor: theme.palette.primary.main, - fillOpacity: 0.5, - }); + if (explorePageSlug) { + layer.setStyle({ + fillColor: theme.palette.primary.main, + fillOpacity: 0.5, + }); + } }); layer.on("mouseout", () => { onLayerMouseOver(null); diff --git a/apps/climatemappedafrica/src/lib/data/blockify/hero.js b/apps/climatemappedafrica/src/lib/data/blockify/hero.js index 8d6b76ca3..ed18e6741 100644 --- a/apps/climatemappedafrica/src/lib/data/blockify/hero.js +++ b/apps/climatemappedafrica/src/lib/data/blockify/hero.js @@ -14,6 +14,7 @@ export default async function hero(block, _api, _context, { hurumap }) { const { profilePage, rootGeography: { center, code, hasData: pinRootGeography }, + enableHURUMap, } = hurumap; const { slug: explorePageSlug } = profilePage; const { geometries } = await fetchProfileGeography(code.toLowerCase()); @@ -37,7 +38,7 @@ export default async function hero(block, _api, _context, { hurumap }) { ...block, boundary, center, - explorePageSlug, + explorePageSlug: enableHURUMap ? explorePageSlug : null, featuredLocations, level, pinRootGeography, From 2ff029ee4ea008709bfe2cdaf9f866ea07911733 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Tue, 5 Nov 2024 16:54:24 +0300 Subject: [PATCH 6/8] Updated workflow brNCH --- .github/workflows/climatemappedafrica-deploy-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/climatemappedafrica-deploy-dev.yml b/.github/workflows/climatemappedafrica-deploy-dev.yml index 7aa2a9192..7242154a9 100644 --- a/.github/workflows/climatemappedafrica-deploy-dev.yml +++ b/.github/workflows/climatemappedafrica-deploy-dev.yml @@ -2,7 +2,7 @@ name: Climate Mapped Africa | Deploy | DEV on: push: - branches: [ft/climatemapped-build-fix] + branches: [main] paths: - "apps/climatemappedafrica/**" - "Dockerfile" From 4206a44e3d03d7a0ec7a41b88676e04102bd70d0 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Wed, 6 Nov 2024 09:55:31 +0300 Subject: [PATCH 7/8] Undo deploy to dev changes --- .github/workflows/climatemappedafrica-deploy-dev.yml | 5 ----- apps/climatemappedafrica/src/lib/data/blockify/hero.js | 6 +----- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/climatemappedafrica-deploy-dev.yml b/.github/workflows/climatemappedafrica-deploy-dev.yml index 7242154a9..285b91405 100644 --- a/.github/workflows/climatemappedafrica-deploy-dev.yml +++ b/.github/workflows/climatemappedafrica-deploy-dev.yml @@ -33,10 +33,6 @@ jobs: with: fetch-depth: 0 - # Add support for more platforms with QEMU (optional) - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -65,7 +61,6 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . - platforms: linux/arm64 target: climatemappedafrica-runner push: true tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}" diff --git a/apps/climatemappedafrica/src/lib/data/blockify/hero.js b/apps/climatemappedafrica/src/lib/data/blockify/hero.js index ed18e6741..f0b33fdf7 100644 --- a/apps/climatemappedafrica/src/lib/data/blockify/hero.js +++ b/apps/climatemappedafrica/src/lib/data/blockify/hero.js @@ -7,16 +7,12 @@ import { * This function will be called even when HURUmap is disabled. * @see @/climatemappedafrica/lib/data/common/index.js * - * TODO(koech): Handle the case when hurumap?.enabled is undefined/false - * Should we hide the map? */ export default async function hero(block, _api, _context, { hurumap }) { const { profilePage, rootGeography: { center, code, hasData: pinRootGeography }, - enableHURUMap, } = hurumap; - const { slug: explorePageSlug } = profilePage; const { geometries } = await fetchProfileGeography(code.toLowerCase()); const { level } = geometries.boundary?.properties ?? {}; const childLevelMaps = { @@ -38,7 +34,7 @@ export default async function hero(block, _api, _context, { hurumap }) { ...block, boundary, center, - explorePageSlug: enableHURUMap ? explorePageSlug : null, + explorePageSlug: profilePage?.slug || null, featuredLocations, level, pinRootGeography, From e03e84a1a38deed29ab67594106d3186546acc83 Mon Sep 17 00:00:00 2001 From: Kevin Koech Date: Wed, 6 Nov 2024 10:48:19 +0300 Subject: [PATCH 8/8] Ensure hurumap is not undefined --- apps/climatemappedafrica/src/lib/data/blockify/hero.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/climatemappedafrica/src/lib/data/blockify/hero.js b/apps/climatemappedafrica/src/lib/data/blockify/hero.js index f0b33fdf7..0f4cf6684 100644 --- a/apps/climatemappedafrica/src/lib/data/blockify/hero.js +++ b/apps/climatemappedafrica/src/lib/data/blockify/hero.js @@ -12,7 +12,7 @@ export default async function hero(block, _api, _context, { hurumap }) { const { profilePage, rootGeography: { center, code, hasData: pinRootGeography }, - } = hurumap; + } = hurumap ?? { rootGeography: {} }; const { geometries } = await fetchProfileGeography(code.toLowerCase()); const { level } = geometries.boundary?.properties ?? {}; const childLevelMaps = {