Skip to content

Commit

Permalink
Remove REACT_APP_FEATURE_AOI_CHANGES and legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
Bluesmile82 committed Apr 26, 2023
1 parent 4b71366 commit 8eadf9b
Show file tree
Hide file tree
Showing 21 changed files with 209 additions and 1,444 deletions.
1 change: 0 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ GENERATE_SOURCEMAP=

REACT_APP_FEATURE_SPECIFIC_REGIONS_AOI=
REACT_APP_FEATURE_ALLOWED_LANGUAGES=en,es,pt,fr
REACT_APP_FEATURE_AOI_CHANGES=
59 changes: 0 additions & 59 deletions src/components/charts/species-bar-legacy/component.jsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/charts/species-bar-legacy/index.js

This file was deleted.

62 changes: 0 additions & 62 deletions src/components/charts/species-bar-legacy/styles.module.scss

This file was deleted.

54 changes: 14 additions & 40 deletions src/constants/analyze-areas-constants.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,14 @@ import React from 'react';
import { t } from '@transifex/native';
import { T } from '@transifex/react';

import {
getTotalPressures,
getMainPressure,
roundUpPercentage,
} from 'utils/analyze-areas-utils';
import { roundUpPercentage } from 'utils/analyze-areas-utils';
import { percentageFormat } from 'utils/data-formatting-utils';

import {
BIRDS,
AMPHIBIANS,
MAMMALS,
REPTILES,
getLandPressuresTranslatedLabels,
} from 'constants/geo-processing-services';
import {
ADMIN_AREAS_FEATURE_LAYER,
Expand Down Expand Up @@ -72,8 +67,6 @@ export const {

export const DEFAULT_SOURCE = ADMINISTRATIVE_BOUNDARIES;

const { REACT_APP_FEATURE_AOI_CHANGES } = process.env;

export const getPrecalculatedAOIOptions = () => [
{
title: ADMINISTRATIVE_BOUNDARIES,
Expand Down Expand Up @@ -190,9 +183,7 @@ export const getSidebarCardsConfig = (locale) => ({
),
},
[PROTECTION_SLUG]: {
title: REACT_APP_FEATURE_AOI_CHANGES
? t('What is already protected in this area?')
: t('Current protection status'),
title: t('What is already protected in this area?'),
description: ({ protectionPercentage, percentage, DESIG }) => {
const isProtectedArea = !!DESIG;
if (isProtectedArea) return null;
Expand All @@ -219,44 +210,27 @@ export const getSidebarCardsConfig = (locale) => ({
warning: null,
},
[LAND_HUMAN_PRESSURES_SLUG]: {
title: REACT_APP_FEATURE_AOI_CHANGES
? t('How much do humans affect this area?')
: t('Human impact'),
title: t('How much do humans affect this area?'),
description: ({ pressures }) => {
if (
REACT_APP_FEATURE_AOI_CHANGES &&
(!pressures ||
Object.values(pressures).every(
(p) => !p || p.length === 0 || p.every((v) => v.value === 0)
))
!pressures ||
Object.values(pressures).every(
(p) => !p || p.length === 0 || p.every((v) => v.value === 0)
)
) {
// em = *{highHumanPressure}* is used here for the tooltip
return `${t('The current area is not facing {highHumanPressures}', {
highHumanPressures: `*${t('high human pressures')}*`,
})}`;
}

if (REACT_APP_FEATURE_AOI_CHANGES) {
// em = *{highHumanPressure}* is used here for the tooltip
return `${t(
'The current area is facing {highHumanPressure} from the following pressures. The percentage figures refer to the latest year of the time series (2017).',
{
highHumanPressure: `*${t('high human pressure')}*`,
}
)}`;
}

if (pressures && !REACT_APP_FEATURE_AOI_CHANGES) {
return `${t('Of the current area, ')}__${roundUpPercentage(
getTotalPressures(pressures)
)}${t('% is currently experiencing human pressures__')}, ${t(
'the majority of which are pressures from '
)}${
getLandPressuresTranslatedLabels(t)[getMainPressure(pressures)] ||
getMainPressure(pressures)
}.`;
}
return '';
// em = *{highHumanPressure}* is used here for the tooltip
return `${t(
'The current area is facing {highHumanPressure} from the following pressures. The percentage figures refer to the latest year of the time series (2017).',
{
highHumanPressure: `*${t('high human pressure')}*`,
}
)}`;
},
warning: null,
},
Expand Down
117 changes: 39 additions & 78 deletions src/constants/geo-processing-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
AMPHIBIAN_LOOKUP,
} from 'constants/layers-slugs';

const { REACT_APP_FEATURE_AOI_CHANGES } = process.env;

export const CRF_NAMES = {
BIRDS: 'birds_equal_area_20211003',
REPTILES: 'reptiles_equal_area_20211003',
Expand Down Expand Up @@ -70,66 +68,36 @@ export const LOOKUP_TABLES = {
[AMPHIBIANS]: AMPHIBIAN_LOOKUP,
};

const LAND_PRESSURES_LABELS = REACT_APP_FEATURE_AOI_CHANGES
? {
extraction: 'extraction',
transportation: 'transportation',
builtup: 'builtup',
agriculture: 'agriculture',
intrusion: 'intrusion',
}
: {
irrigated: 'irrigated agriculture',
rainfed: 'rainfed agriculture',
rangelands: 'rangelands',
urban: 'urban activities',
};

export const getLandPressuresTranslatedLabels = (t) =>
REACT_APP_FEATURE_AOI_CHANGES
? {
energy: t('energy and extractive resources'),
transportation: t('transportation'),
builtup: t('urban and built up'),
agriculture: t('agriculture pressures'),
intrusion: t('human intrusion'),
}
: {
irrigated: t('irrigated agriculture'),
rainfed: t('rainfed agriculture'),
rangelands: t('rangelands'),
urban: t('urban activities'),
};
const LAND_PRESSURES_LABELS = {
extraction: 'extraction',
transportation: 'transportation',
builtup: 'builtup',
agriculture: 'agriculture',
intrusion: 'intrusion',
};
export const getLandPressuresTranslatedLabels = (t) => ({
energy: t('energy and extractive resources'),
transportation: t('transportation'),
builtup: t('urban and built up'),
agriculture: t('agriculture pressures'),
intrusion: t('human intrusion'),
});

export const LAND_PRESSURES_LABELS_SLUGS = REACT_APP_FEATURE_AOI_CHANGES
? {
[LAND_PRESSURES_LABELS.extraction]: 'extraction',
[LAND_PRESSURES_LABELS.intrusion]: 'intrusion',
[LAND_PRESSURES_LABELS.transportation]: 'transportation',
[LAND_PRESSURES_LABELS.builtup]: 'builtup',
[LAND_PRESSURES_LABELS.agriculture]: 'agriculture',
}
: {
[LAND_PRESSURES_LABELS.irrigated]: 'percent_irrigated',
[LAND_PRESSURES_LABELS.rainfed]: 'percent_rainfed',
[LAND_PRESSURES_LABELS.rangelands]: 'percent_rangeland',
[LAND_PRESSURES_LABELS.urban]: 'percent_urban',
};
export const LAND_PRESSURES_LABELS_SLUGS = {
[LAND_PRESSURES_LABELS.extraction]: 'extraction',
[LAND_PRESSURES_LABELS.intrusion]: 'intrusion',
[LAND_PRESSURES_LABELS.transportation]: 'transportation',
[LAND_PRESSURES_LABELS.builtup]: 'builtup',
[LAND_PRESSURES_LABELS.agriculture]: 'agriculture',
};

export const LAND_PRESSURES_LOOKUP = REACT_APP_FEATURE_AOI_CHANGES
? [
LAND_PRESSURES_LABELS.extraction,
LAND_PRESSURES_LABELS.intrusion,
LAND_PRESSURES_LABELS.transportation,
LAND_PRESSURES_LABELS.builtup,
LAND_PRESSURES_LABELS.agriculture,
]
: [
LAND_PRESSURES_LABELS.irrigated,
LAND_PRESSURES_LABELS.rainfed,
LAND_PRESSURES_LABELS.rangelands,
LAND_PRESSURES_LABELS.urban,
];
export const LAND_PRESSURES_LOOKUP = [
LAND_PRESSURES_LABELS.extraction,
LAND_PRESSURES_LABELS.intrusion,
LAND_PRESSURES_LABELS.transportation,
LAND_PRESSURES_LABELS.builtup,
LAND_PRESSURES_LABELS.agriculture,
];

export const CRFS_CONFIG = {
inputRasterKey: 'crf_name',
Expand All @@ -144,9 +112,7 @@ export const CONTEXTUAL_DATA_SERVICE_CONFIG = {
inputRasterKeyPairs: {
crf_name_population: `${CRFS_CONFIG.basePath}/${POPULATION}.crf`,
crf_name_elu: `${CRFS_CONFIG.basePath}/${ECOLOGICAL_LAND_UNITS}.crf`,
[REACT_APP_FEATURE_AOI_CHANGES
? 'crf_name_wdpa'
: 'crf_name_wdpa_percentage']: `${CRFS_CONFIG.basePath}/${PROTECTED_AREA_PERCENTAGE}.crf`,
crf_name_wdpa: `${CRFS_CONFIG.basePath}/${PROTECTED_AREA_PERCENTAGE}.crf`,
crf_name_extraction: `${CRFS_CONFIG.basePath}/${EXTRACTION}.crf`,
crf_name_agriculture: `${CRFS_CONFIG.basePath}/${AGRICULTURE}.crf`,
crf_name_transportation: `${CRFS_CONFIG.basePath}/${TRANSPORTATION}.crf`,
Expand All @@ -172,19 +138,14 @@ export const BIODIVERSITY_CRFS_CONFIG = {
};

export const GEOPROCESSING_SERVICES_URLS = {
[BIRDS]: REACT_APP_FEATURE_AOI_CHANGES
? 'https://heportal.esri.com/server/rest/services/BirdsProd_SPS/GPServer/BirdsProd_SPS'
: 'https://heportal.esri.com/server/rest/services/SampleBirdsProd20220131/GPServer/SampleBirdsProdRange',
[REPTILES]: REACT_APP_FEATURE_AOI_CHANGES
? 'https://heportal.esri.com/server/rest/services/ReptilesProd_SPS/GPServer/ReptilesProd_SPS'
: 'https://heportal.esri.com/server/rest/services/SampleReptProd20220131/GPServer/SampleReptProdRange',
[MAMMALS]: REACT_APP_FEATURE_AOI_CHANGES
? 'https://heportal.esri.com/server/rest/services/MammalsProd_SPS/GPServer/MammalsProd_SPS'
: 'https://heportal.esri.com/server/rest/services/SampleMamProd20220131/GPServer/SampleMamProdRange',
[AMPHIBIANS]: REACT_APP_FEATURE_AOI_CHANGES
? 'https://heportal.esri.com/server/rest/services/AmphibiansProd_SPS/GPServer/AmphibiansProd_SPS'
: 'https://heportal.esri.com/server/rest/services/SampleAmphProd20220131/GPServer/SampleAmphProdRange',
[CONTEXTUAL_DATA]: REACT_APP_FEATURE_AOI_CHANGES
? 'https://heportal.esri.com/server/rest/services/Contextual_Prod3/GPServer/Contextual_Prod3'
: 'https://heportal.esri.com/server/rest/services/ContextualLayersProd20220131/GPServer/ContextualLayersProd',
[BIRDS]:
'https://heportal.esri.com/server/rest/services/BirdsProd_SPS/GPServer/BirdsProd_SPS',
[REPTILES]:
'https://heportal.esri.com/server/rest/services/ReptilesProd_SPS/GPServer/ReptilesProd_SPS',
[MAMMALS]:
'https://heportal.esri.com/server/rest/services/MammalsProd_SPS/GPServer/MammalsProd_SPS',
[AMPHIBIANS]:
'https://heportal.esri.com/server/rest/services/AmphibiansProd_SPS/GPServer/AmphibiansProd_SPS',
[CONTEXTUAL_DATA]:
'https://heportal.esri.com/server/rest/services/Contextual_Prod3/GPServer/Contextual_Prod3',
};
Loading

0 comments on commit 8eadf9b

Please sign in to comment.