Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/bug fixes for bugs #3688

Merged
merged 3 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/javascript/assets/icons/biodiversity.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/javascript/assets/icons/climate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/javascript/assets/icons/explore.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/javascript/assets/icons/forest-change.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/javascript/assets/icons/land-cover.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/javascript/assets/icons/land-use.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ class MapMenu extends PureComponent {
setMenuSettings={setMenuSettings}
onToggleLayer={this.onToggleLayer}
{...props}
{...rest}
{...menuSection === 'datasets' && {
...rest
}}
/>
)}
</MenuPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class RecentImageryContainer extends PureComponent {
});
}
// get the rest of the tiles
if (!dataStatus.haveAllData && !loadingMoreTiles && active) {
if (dataStatus && !dataStatus.haveAllData && !loadingMoreTiles && active) {
getMoreTiles({
sources,
dataStatus,
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/components/modals/meta/meta-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ export const setModalMeta = createThunkAction(
'setModalMeta',
(metaKey, metaWhitelist, tableWhitelist, customCitation) => (
dispatch,
state
getState
) => {
if (!state().modalMeta.loading) {
const { modalMeta } = getState();
if (modalMeta && !modalMeta.loading) {
dispatch(
setModalMetaLoading({ loading: true, error: false, open: true })
);
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/components/modals/modal/modal-component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CustomModal extends PureComponent {
}

CustomModal.propTypes = {
isOpen: PropTypes.bool.isRequired,
isOpen: PropTypes.bool,
onRequestClose: PropTypes.func.isRequired,
contentLabel: PropTypes.string,
customStyles: PropTypes.object,
Expand Down
15 changes: 9 additions & 6 deletions app/javascript/providers/country-data-provider/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ export const getCountries = createThunkAction(

export const getRegions = createThunkAction(
'getRegions',
country => (dispatch, state) => {
if (!state().countryData.isRegionsLoading) {
country => (dispatch, getState) => {
const { countryData } = getState();
if (countryData && !countryData.isRegionsLoading) {
dispatch(setRegionsLoading(true));
getRegionsProvider(country)
.then(response => {
Expand All @@ -74,8 +75,9 @@ export const getRegions = createThunkAction(

export const getSubRegions = createThunkAction(
'getSubRegions',
({ adm0, adm1 }) => (dispatch, state) => {
if (!state().countryData.isSubRegionsLoading) {
({ adm0, adm1 }) => (dispatch, getState) => {
const { countryData } = getState();
if (countryData && !countryData.isSubRegionsLoading) {
dispatch(setSubRegionsLoading(true));
getSubRegionsProvider(adm0, adm1)
.then(subRegions => {
Expand All @@ -100,8 +102,9 @@ export const getSubRegions = createThunkAction(

export const getCountryLinks = createThunkAction(
'getCountryLinks',
() => (dispatch, state) => {
if (!state().countryData.isCountryLinksLoading) {
() => (dispatch, getState) => {
const { countryData } = getState();
if (countryData && !countryData.isCountryLinksLoading) {
dispatch(setCountryLinksLoading(true));
getCountryLinksProvider()
.then(response => {
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/providers/geostore-provider/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export const setGeostore = createAction('setGeostore');

export const getGeostore = createThunkAction(
'getGeostore',
({ type, adm0, adm1, adm2, token }) => (dispatch, state) => {
if (!state().geostore.loading) {
({ type, adm0, adm1, adm2, token }) => (dispatch, getState) => {
const { geostore } = getState();
if (geostore && !geostore.loading) {
dispatch(setGeostoreLoading({ loading: true, error: false }));
getGeostoreProvider({ type, adm0, adm1, adm2, token })
.then(response => {
Expand Down
44 changes: 24 additions & 20 deletions app/javascript/providers/ptw-provider/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@ import { getPTWProvider } from 'services/places-to-watch';
export const setPTWLoading = createAction('setPTWLoading');
export const setPTW = createAction('setPTW');

export const getPTW = createThunkAction('getPTW', () => (dispatch, state) => {
if (!state().ptw.loading) {
dispatch(setPTWLoading(true));
getPTWProvider()
.then(response => {
const { rows } = response.data;
if (rows && !!rows.length) {
const ptw = uniqBy(rows, 'cartodb_id').map(p => ({
...p,
bbox: reverseLatLng(JSON.parse(p.bbox).coordinates[0])
}));
dispatch(setPTW(uniqBy(ptw, 'cartodb_id')));
}
dispatch(setPTWLoading(false));
})
.catch(error => {
dispatch(setPTWLoading(false));
console.info(error);
});
export const getPTW = createThunkAction(
'getPTW',
() => (dispatch, getState) => {
const { ptw } = getState();
if (ptw && !ptw.loading) {
dispatch(setPTWLoading(true));
getPTWProvider()
.then(response => {
const { rows } = response.data;
if (rows && !!rows.length) {
const ptwResponse = uniqBy(rows, 'cartodb_id').map(p => ({
...p,
bbox: reverseLatLng(JSON.parse(p.bbox).coordinates[0])
}));
dispatch(setPTW(uniqBy(ptwResponse, 'cartodb_id')));
}
dispatch(setPTWLoading(false));
})
.catch(error => {
dispatch(setPTWLoading(false));
console.info(error);
});
}
}
});
);
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export const setRegionWhitelist = createAction('setRegionWhitelist');

export const getCountryWhitelist = createThunkAction(
'getCountryWhitelist',
adm0 => (dispatch, state) => {
if (!state().whitelists.countriesLoading) {
adm0 => (dispatch, getState) => {
const { whitelists } = getState();
if (whitelists && !whitelists.countriesLoading) {
dispatch(setCountryWhitelistLoading(true));
getCountryWhitelistProvider(adm0)
.then(response => {
Expand All @@ -36,8 +37,9 @@ export const getCountryWhitelist = createThunkAction(

export const getRegionWhitelist = createThunkAction(
'getRegionWhitelist',
({ adm0, adm1, adm2 }) => (dispatch, state) => {
if (!state().whitelists.regionsLoading) {
({ adm0, adm1, adm2 }) => (dispatch, getState) => {
const { whitelists } = getState();
if (whitelists && !whitelists.regionsLoading) {
dispatch(setRegionWhitelistLoading(true));
getRegionWhitelistProvider(adm0, adm1, adm2)
.then(response => {
Expand Down