Skip to content

Commit

Permalink
replace share url with embed_url property (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored Aug 13, 2021
1 parent b4e0f7d commit 451c6a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 34 deletions.
39 changes: 10 additions & 29 deletions geonode_mapstore_client/client/js/plugins/Share.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import Button from '@js/components/Button';
import { mapInfoSelector } from '@mapstore/framework/selectors/map';
import { layersSelector } from '@mapstore/framework/selectors/layers';
import OverlayContainer from '@js/components/OverlayContainer';
import url from 'url';
import {
isNewResource,
getResourceId,
getCompactPermissions,
canEditPermissions
canEditPermissions,
getResourceData
} from '@js/selectors/resource';
import { updateResourceCompactPermissions } from '@js/actions/gnresource';
import FaIcon from '@js/components/FaIcon/FaIcon';
Expand All @@ -34,22 +34,6 @@ import SharePageLink from '@js/plugins/share/SharePageLink';
import ShareEmbedLink from '@js/plugins/share/ShareEmbedLink';
import { getCurrentResourcePermissionsLoading } from '@js/selectors/resourceservice';

function getShareUrl({
resourceId,
pathTemplate
}) {
const {
host,
protocol
} = url.parse(location.href);
const pathname = pathTemplate.replace(/\{id\}/g, resourceId);
return url.format({
host,
protocol,
pathname
});
}

const entriesTabs = [
{
id: 'user',
Expand Down Expand Up @@ -102,7 +86,6 @@ function Share({
width,
permissionsOptions,
resourceId,
pathTemplate,
compactPermissions,
layers,
onChangePermissions,
Expand All @@ -111,13 +94,11 @@ function Share({
canEdit,
permissionsGroupOptions,
permissionsDefaultGroupOptions,
permissionsLoading
permissionsLoading,
embedUrl
}) {

const shareUrl = getShareUrl({
resourceId,
pathTemplate
});
const shareUrl = embedUrl;

return (
<OverlayContainer
Expand Down Expand Up @@ -161,7 +142,6 @@ function Share({

Share.propTypes = {
resourceId: PropTypes.oneOfType([ PropTypes.number, PropTypes.string ]),
pathTemplate: PropTypes.string,
enabled: PropTypes.bool,
onClose: PropTypes.func,
width: PropTypes.number,
Expand All @@ -172,7 +152,6 @@ Share.propTypes = {

Share.defaultProps = {
resourceId: null,
pathTemplate: '/apps/{id}/embed',
enabled: false,
onClose: () => {},
width: 800,
Expand Down Expand Up @@ -238,14 +217,16 @@ const SharePlugin = connect(
getCompactPermissions,
layersSelector,
canEditPermissions,
getCurrentResourcePermissionsLoading
], (enabled, resourceId, mapInfo, compactPermissions, layers, canEdit, permissionsLoading) => ({
getCurrentResourcePermissionsLoading,
getResourceData
], (enabled, resourceId, mapInfo, compactPermissions, layers, canEdit, permissionsLoading, resource) => ({
enabled,
resourceId: resourceId || mapInfo?.id,
compactPermissions,
layers,
canEdit,
permissionsLoading
permissionsLoading,
embedUrl: resource?.embed_url
})),
{
onClose: setControlProperty.bind(null, 'rightOverlay', 'enabled', false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,6 @@
{
"name": "Share",
"cfg": {
"pathTemplate": "/datasets/{id}/embed",
"enableGeoLimits": true
}
},
Expand Down Expand Up @@ -1728,10 +1727,7 @@
"name": "Notifications"
},
{
"name": "Share",
"cfg": {
"pathTemplate": "/maps/{id}/embed"
}
"name": "Share"
},
{
"name": "Swipe"
Expand Down

0 comments on commit 451c6a7

Please sign in to comment.