From 3c1bf93992539775719fb7570c3d9cb6b98b1892 Mon Sep 17 00:00:00 2001 From: sorodrigo Date: Tue, 21 May 2019 11:22:01 +0200 Subject: [PATCH 1/2] fix crash on undefined tooltips --- .../nav/filters-nav/recolor-by-selector/recolor-by-selector.js | 2 +- .../recolor-by-selector/recolor-by-selector.selectors.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/scripts/react-components/nav/filters-nav/recolor-by-selector/recolor-by-selector.js b/frontend/scripts/react-components/nav/filters-nav/recolor-by-selector/recolor-by-selector.js index 919a9e3596..87d5b690d5 100644 --- a/frontend/scripts/react-components/nav/filters-nav/recolor-by-selector/recolor-by-selector.js +++ b/frontend/scripts/react-components/nav/filters-nav/recolor-by-selector/recolor-by-selector.js @@ -11,7 +11,7 @@ const mapStateToProps = state => ({ recolorBys: getRecolorByOptions(state), recolorGroups: getToolRecolorByGroups(state), selectedRecolorBy: getSelectedRecolorByValue(state), - tooltip: state.app.tooltips.sankey.nav.colorBy.main + tooltip: state.app.tooltips?.sankey.nav.colorBy.main }); const mapDispatchToProps = dispatch => ({ diff --git a/frontend/scripts/react-components/nav/filters-nav/recolor-by-selector/recolor-by-selector.selectors.js b/frontend/scripts/react-components/nav/filters-nav/recolor-by-selector/recolor-by-selector.selectors.js index 5f9ce5b5de..709ed68844 100644 --- a/frontend/scripts/react-components/nav/filters-nav/recolor-by-selector/recolor-by-selector.selectors.js +++ b/frontend/scripts/react-components/nav/filters-nav/recolor-by-selector/recolor-by-selector.selectors.js @@ -17,7 +17,7 @@ const getSelectionRecolorBy = createSelector( groupNumber: -1, label: 'Selection', years: selectedYears, - description: tooltips.sankey.nav.colorBy.none + description: tooltips?.sankey.nav.colorBy.none }) ); From 6487042596359e176162b6c0b6da36967a0d519e Mon Sep 17 00:00:00 2001 From: sorodrigo Date: Tue, 21 May 2019 11:22:29 +0200 Subject: [PATCH 2/2] hide banner using feature flag --- frontend/.env.sample | 1 + frontend/.eslintrc.json | 1 + frontend/config/webpack.config.js | 1 + frontend/docs/index.mdx | 1 + .../shared/cookie-banner/cookie-banner.component.jsx | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/.env.sample b/frontend/.env.sample index 461ddf2df9..79ca80ff88 100644 --- a/frontend/.env.sample +++ b/frontend/.env.sample @@ -25,6 +25,7 @@ DATA_DOWNLOAD_ENABLED=true SHOW_WORLD_MAP_IN_EXPLORE=true ALWAYS_DISPLAY_DASHBOARD_INFO=true ENABLE_DASHBOARDS=true +ENABLE_COOKIE_BANNER=true ENABLE_LOGISTICS_MAP=true ENABLE_LEGACY_TOOL_SEARCH=false DISABLE_MULTIPLE_CONTEXT_PROFILES=false diff --git a/frontend/.eslintrc.json b/frontend/.eslintrc.json index cf8bdd01c1..5f7d6f98ae 100644 --- a/frontend/.eslintrc.json +++ b/frontend/.eslintrc.json @@ -56,6 +56,7 @@ "NODE_ENV_DEV": true, "API_V3_URL": true, "ENABLE_DASHBOARDS": true, + "ENABLE_COOKIE_BANNER": true, "ENABLE_LOGISTICS_MAP": true, "ENABLE_LEGACY_TOOL_SEARCH": true, "DISABLE_MULTIPLE_CONTEXT_PROFILES": true, diff --git a/frontend/config/webpack.config.js b/frontend/config/webpack.config.js index 3bcc689c56..37332444e9 100644 --- a/frontend/config/webpack.config.js +++ b/frontend/config/webpack.config.js @@ -47,6 +47,7 @@ module.exports = { SHOW_WORLD_MAP_IN_EXPLORE: process.env.SHOW_WORLD_MAP_IN_EXPLORE === 'true', ALWAYS_DISPLAY_DASHBOARD_INFO: process.env.ALWAYS_DISPLAY_DASHBOARD_INFO === 'true', ENABLE_DASHBOARDS: process.env.ENABLE_DASHBOARDS === 'true', + ENABLE_COOKIE_BANNER: process.env.ENABLE_COOKIE_BANNER === 'true', GFW_WIDGETS_BASE_URL: JSON.stringify(process.env.GFW_WIDGETS_BASE_URL), ENABLE_LOGISTICS_MAP: process.env.ENABLE_LOGISTICS_MAP === 'true', ENABLE_LEGACY_TOOL_SEARCH: process.env.ENABLE_LEGACY_TOOL_SEARCH === 'true', diff --git a/frontend/docs/index.mdx b/frontend/docs/index.mdx index 6e6d1fb858..aa909f1f4b 100644 --- a/frontend/docs/index.mdx +++ b/frontend/docs/index.mdx @@ -141,6 +141,7 @@ ENABLE_LOGISTICS_MAP: if set to true, the logistics map section will be visible GFW_WIDGETS_BASE_URL: URL to load GFW widgets from. You probably want to use `www.globalforestwatch.org` here. ENABLE_LEGACY_TOOL_SEARCH: if set to false the search algorithm in the tool will use `indexOf(query)` instead of fuzzy search. DISABLE_MULTIPLE_CONTEXT_PROFILES: if set to true, only Brazil-Soy will be available at the profiles page --> +ENABLE_COOKIE_BANNER: if true, the cookie banner will appear for first time users ``` If you are using the included development server, you can set those variables in the `.env` file (use the included `.env.sample` as an example) diff --git a/frontend/scripts/react-components/shared/cookie-banner/cookie-banner.component.jsx b/frontend/scripts/react-components/shared/cookie-banner/cookie-banner.component.jsx index cb65d9dd4e..053eecdd52 100644 --- a/frontend/scripts/react-components/shared/cookie-banner/cookie-banner.component.jsx +++ b/frontend/scripts/react-components/shared/cookie-banner/cookie-banner.component.jsx @@ -6,7 +6,7 @@ import Text from 'react-components/shared/text'; import 'react-components/shared/cookie-banner/cookie-banner.scss'; function CookieBanner({ setAccepted, accepted }) { - return accepted ? null : ( + return accepted || !ENABLE_COOKIE_BANNER ? null : (