Skip to content

Commit

Permalink
Merge pull request #4688 from wri/develop
Browse files Browse the repository at this point in the history
PROD Deploy 2023-09-08 11:54am EST
  • Loading branch information
wri7tno authored Sep 8, 2023
2 parents e40606f + ac28af5 commit f10fca0
Show file tree
Hide file tree
Showing 13 changed files with 298 additions and 29 deletions.
5 changes: 4 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ NEXT_PUBLIC_PLANET_API_KEY=
NEXT_PUBLIC_GFW_API_KEY=

# Wordpress
NEXT_PUBLIC_WORDPRESS_URL=
NEXT_PUBLIC_WORDPRESS_URL=http://global-forest-watch-blog.lndo.site/wp-json

# this is only needed locally, to consume wp-json
NODE_TLS_REJECT_UNAUTHORIZED=0

# New Relic (used in lieu of newrelic.js)
NEW_RELIC_APP_NAME=
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ yarn-error.log*

# new relic agent
newrelic_agent.log

.yalc
4 changes: 3 additions & 1 deletion components/header/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import NavLink from 'components/nav-link';

import config from './config';

const Header = ({ setModalContactUsOpen, fullScreen, slim }) => {
const Header = ({ setModalContactUsOpen, fullScreen, slim, notifications }) => {
const { push, pushQuery, asPath, query } = useRouter();

return (
Expand All @@ -21,6 +21,7 @@ const Header = ({ setModalContactUsOpen, fullScreen, slim }) => {
<a className={className}>{headerChildren}</a>
</NavLink>
) : null}
notifications={notifications}
openContactUsModal={() => setModalContactUsOpen(true)}
setQueryToUrl={(search) => push(`/search/?query=${search}`)}
fullScreen={fullScreen}
Expand All @@ -39,6 +40,7 @@ Header.propTypes = {
fullScreen: PropTypes.bool,
href: PropTypes.string,
slim: PropTypes.bool,
notifications: PropTypes.array,
};

export default Header;
120 changes: 120 additions & 0 deletions fixtures/notifications/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
export const NOTIFICATIONS_RESPONSE = Object.freeze({
data: [
{
id: 16320,
date: '2023-09-05T22:44:03',
date_gmt: '2023-09-06T02:44:03',
guid: {
rendered:
'https://www.globalforestwatch.org/?post_type=notice&#038;p=16320',
},
modified: '2023-09-05T22:44:03',
modified_gmt: '2023-09-06T02:44:03',
slug: 'glad-l-alerts-outage-2',
status: 'publish',
type: 'notice',
link: 'https://www.globalforestwatch.org/notice/glad-l-alerts-outage-2',
title: {
rendered: 'GLAD-L Alerts Outage',
},
content: {
rendered:
'\n<p>Due to a a malfunction in the data processing pipeline for GLAD-L deforestation alerting system, new alerts will be unavailable until further notice.</p>\n',
protected: false,
},
template: '',
meta: [],
acf: {
notification_icon: 'warning',
notification_date: '2023-09-30',
},
_links: {
self: [
{
href: 'https://global-forest-watch-blog.lndo.site/wp-json/wp/v2/notice/16320',
},
],
collection: [
{
href: 'https://global-forest-watch-blog.lndo.site/wp-json/wp/v2/notice',
},
],
about: [
{
href: 'https://global-forest-watch-blog.lndo.site/wp-json/wp/v2/types/notice',
},
],
'wp:attachment': [
{
href: 'https://global-forest-watch-blog.lndo.site/wp-json/wp/v2/media?parent=16320',
},
],
curies: [
{
name: 'wp',
href: 'https://api.w.org/{rel}',
templated: true,
},
],
},
},
{
id: 16301,
date: '2023-09-05T10:48:52',
date_gmt: '2023-09-05T14:48:52',
guid: {
rendered:
'https://www.globalforestwatch.org/?post_type=notice&#038;p=16301',
},
modified: '2023-09-05T10:48:52',
modified_gmt: '2023-09-05T14:48:52',
slug: 'upcoming-webinar-net-change-in-tree-cover',
status: 'publish',
type: 'notice',
link: 'https://www.globalforestwatch.org/notice/upcoming-webinar-net-change-in-tree-cover',
title: {
rendered: 'Upcoming Webinar: Net Change in Tree Cover',
},
content: {
rendered:
'\n<p>Learn about the new net change in tree cover layer from WRI’s research team. After the presentation, participants will have the chance to ask questions. <a href="http://google.com">Sign up for the webinar here</a>.</p>\n',
protected: false,
},
template: '',
meta: [],
acf: {
notification_icon: 'layers',
notification_date: '2023-09-07',
},
_links: {
self: [
{
href: 'https://global-forest-watch-blog.lndo.site/wp-json/wp/v2/notice/16301',
},
],
collection: [
{
href: 'https://global-forest-watch-blog.lndo.site/wp-json/wp/v2/notice',
},
],
about: [
{
href: 'https://global-forest-watch-blog.lndo.site/wp-json/wp/v2/types/notice',
},
],
'wp:attachment': [
{
href: 'https://global-forest-watch-blog.lndo.site/wp-json/wp/v2/media?parent=16301',
},
],
curies: [
{
name: 'wp',
href: 'https://api.w.org/{rel}',
templated: true,
},
],
},
},
],
});
16 changes: 14 additions & 2 deletions pages/dashboards/[[...location]].js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { parseGadm36Id } from 'utils/gadm';
import { parseStringWithVars } from 'utils/strings';

import { getLocationData } from 'services/location';
import { getPublishedNotifications } from 'services/notifications';
import {
// getCountriesProvider,
getRegionsProvider,
Expand Down Expand Up @@ -107,6 +108,7 @@ export const getServerSideProps = async ({ params, query, req }) => {
}

let countryData = await getCategorisedCountries(true);
const notifications = await getPublishedNotifications();

if (!type || type === 'global') {
// get global data
Expand All @@ -126,6 +128,7 @@ export const getServerSideProps = async ({ params, query, req }) => {
geodescriber: JSON.stringify(data),
countryData: JSON.stringify(countryData),
description,
notifications: notifications || [],
},
};
}
Expand All @@ -136,7 +139,10 @@ export const getServerSideProps = async ({ params, query, req }) => {

if (!locationName) {
return {
props: notFoundProps,
props: {
...notFoundProps,
notifications: notifications || [],
},
};
}

Expand Down Expand Up @@ -219,6 +225,7 @@ export const getServerSideProps = async ({ params, query, req }) => {
geodescriber: JSON.stringify(data),
countryData: JSON.stringify(countryData),
noIndex,
notifications: notifications || [],
},
};
} catch (err) {
Expand All @@ -228,6 +235,7 @@ export const getServerSideProps = async ({ params, query, req }) => {
error: 504,
title: 'Network error | Global Forest Watch',
errorTitle: 'There was an error retrieving the data',
notifications: notifications || [],
},
};
}
Expand All @@ -238,12 +246,16 @@ export const getServerSideProps = async ({ params, query, req }) => {
error: 401,
title: 'Area is private | Global Forest Watch',
errorTitle: 'Area is private',
notifications: notifications || [],
},
};
}

return {
props: notFoundProps,
props: {
...notFoundProps,
notifications: notifications || [],
},
};
}
};
Expand Down
7 changes: 7 additions & 0 deletions pages/grants-and-fellowships/[section].js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getSGFPage } from 'services/grants-and-fellowships';
import { getSGFProjects, getSGFCountries } from 'services/projects';

import { getCountriesProvider } from 'services/country';
import { getPublishedNotifications } from 'services/notifications';

const SECTIONS = ['projects', 'about', 'apply'];

Expand All @@ -27,6 +28,8 @@ export const getServerSideProps = async ({ query }) => {
};
}

const notifications = await getPublishedNotifications();

if (query?.section === 'projects') {
const pageTexts = await getSGFPage();
const { sgfProjects, totalPages } = await getSGFProjects({
Expand Down Expand Up @@ -61,6 +64,7 @@ export const getServerSideProps = async ({ query }) => {
projectsTexts: pageTexts?.[0]?.acf,
header: pageTexts[0],
totalPages,
notifications: notifications || [],
},
};
}
Expand All @@ -73,6 +77,7 @@ export const getServerSideProps = async ({ query }) => {
section: query?.section,
about: pageTexts?.[0]?.acf?.about_section,
header: pageTexts[0],
notifications: notifications || [],
},
};
}
Expand All @@ -85,6 +90,7 @@ export const getServerSideProps = async ({ query }) => {
section: query?.section,
apply: pageTexts?.[0]?.acf?.apply_section,
header: pageTexts[0],
notifications: notifications || [],
},
};
}
Expand All @@ -95,6 +101,7 @@ export const getServerSideProps = async ({ query }) => {
query?.section
)} | Grants & Fellowships | Global Forest Watch`,
section: query?.section,
notifications: notifications || [],
},
};
};
Expand Down
10 changes: 10 additions & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import PageLayout from 'wrappers/page';
import SeoSearchBox from 'wrappers/seo/searchBox';

import PropTypes from 'prop-types';

import Home from 'layouts/home';

import { getNewsArticles } from 'services/news';
import { getPublishedNotifications } from 'services/notifications';

const HomePage = (props) => (
<PageLayout
title="Forest Monitoring, Land Use & Deforestation Trends | Global Forest Watch"
description="Global Forest Watch offers free, real-time data, technology and tools for monitoring the world’s forests, enabling better protection against illegal deforestation and unsustainable practices."
notifications={props.notifications}
>
<SeoSearchBox
title="Forest Monitoring, Land Use & Deforestation Trends | Global Forest Watch"
Expand All @@ -20,12 +24,18 @@ const HomePage = (props) => (

export const getStaticProps = async () => {
const newsArticles = await getNewsArticles();
const notifications = await getPublishedNotifications();

return {
props: {
news: newsArticles || [],
notifications: notifications || [],
},
};
};

HomePage.propTypes = {
notifications: PropTypes.array,
};

export default HomePage;
Loading

0 comments on commit f10fca0

Please sign in to comment.