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

[Fixes #976] Fix missing required accessToken for MapBox background when adding a map to a geostory #1014

Merged
merged 2 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 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.22",
allyoucanmap marked this conversation as resolved.
Show resolved Hide resolved
"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