Skip to content

Commit

Permalink
[Fixes #976] Fix missing required accessToken for MapBox background w…
Browse files Browse the repository at this point in the history
…hen adding a map to a geostory (#1014) (#1041)
  • Loading branch information
allyoucanmap authored Jun 20, 2022
1 parent a798b15 commit 22f3b72
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion geonode_mapstore_client/client/MapStore2
Submodule MapStore2 updated 334 files
14 changes: 12 additions & 2 deletions geonode_mapstore_client/client/js/plugins/Share.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/

import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useRef } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
Expand Down Expand Up @@ -97,6 +97,14 @@ function Share({
embedUrl
}) {

const isMounted = useRef(false);
useEffect(() => {
isMounted.current = true;
return () => {
isMounted.current = false;
};
}, []);

const [permissionsObject, setPermissionsObject] = useState({});
useEffect(() => {
getResourceTypes().then((data) => {
Expand All @@ -107,7 +115,9 @@ function Share({
} else { // set a default permission object
responseOptions = getResourcePermissions(data[0].allowed_perms.compact);
}
setPermissionsObject(responseOptions);
if (isMounted.current) {
setPermissionsObject(responseOptions);
}
});
}, [availableResourceTypes]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Button from '@js/components/Button';
import IntlNumberFormControl from '@mapstore/framework/components/I18N/IntlNumberFormControl';
import Message from '@mapstore/framework/components/I18N/Message';
import InfoPopover from '@mapstore/framework/components/widgets/widget/InfoPopover';
import { DEFAULT_FORMAT_WMS, getSupportedFormat } from '@mapstore/framework/utils/CatalogUtils';
import { DEFAULT_FORMAT_WMS, getSupportedFormat } from '@mapstore/framework/api/WMS';
import { getConfigProp } from '@mapstore/framework/utils/ConfigUtils';
import LegendImage from '@mapstore/framework/components/TOC/fragments/legend/Legend';
import Select from 'react-select';
Expand Down
3 changes: 2 additions & 1 deletion geonode_mapstore_client/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"author": "GeoSolutions",
"license": "BSD-2-Clause",
"devDependencies": {
"@mapstore/project": "1.0.21",
"@mapstore/project": "1.0.23",
"dotenv": "10.0.0",
"jsdoc-to-markdown": "7.1.0"
},
Expand All @@ -37,6 +37,7 @@
"font-awesome": "4.7.0",
"mapstore": "file:MapStore2",
"react-helmet": "6.1.0",
"react-intl": "2.3.0",
"three": "0.136.0"
},
"mapstore": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
{% generate_proxyurl PROXY_URL|default:"/proxy/?url=" request as UPDATED_PROXY_URL %}
{% retrieve_apikey request as user_apikey %}

{% mapbox_access_token as MAPBOX_ACCESS_TOKEN %}

<script>
(function(){

Expand Down Expand Up @@ -102,6 +104,7 @@
extensionsFolder: extensionsFolder,
printUrl: geoServerPublicLocation + 'pdf/info.json',
bingApiKey: '{% bing_api_key %}',
mapboxAccessToken: '{{ MAPBOX_ACCESS_TOKEN }}',
geoNodeApi: {
endpointV1: siteUrl + 'api',
endpointV2: siteUrl + 'api/v2'
Expand Down

0 comments on commit 22f3b72

Please sign in to comment.