Skip to content

Commit

Permalink
use the detail_url from the resource object (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored Aug 23, 2021
1 parent 1e28765 commit 36eda4b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,11 @@ const ResourceCard = forwardRef(({
</Dropdown.Item>
);
}
const viewResourcebase = opt.perms.filter(obj => {
return obj.value === "view_resourcebase";
});

return (
<Dropdown.Item
key={opt.href}
href={
(viewResourcebase.length > 0 ) ? formatHref({
pathname: `/${res.resource_type}/${res.pk}`
}) : buildHrefByTemplate(res, opt.href)
}
href={buildHrefByTemplate(res, opt.href)}
>
<FaIcon name={opt.icon} /> <Message msgId={opt.labelId}/>
</Dropdown.Item>
Expand Down
19 changes: 14 additions & 5 deletions geonode_mapstore_client/client/js/plugins/FitBounds.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,28 @@

import React from 'react';
import { createPlugin } from '@mapstore/framework/utils/PluginsUtils';
import { projectionSelector } from '@mapstore/framework/selectors/map';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import isEqual from 'lodash/isEqual';
import FitBounds from '@mapstore/framework/components/geostory/common/map/FitBounds';

function FitBoundsPlugin(props) {
return (<FitBounds active { ...props }/>);
const MAX_EXTENT_WEB_MERCATOR = [-180, -85.06, 180, 85.06];

function FitBoundsPlugin({ mapProjection, ...props }) {
const geometry = ['EPSG:900913', 'EPSG:3857'].includes(mapProjection) && isEqual(props.geometry, [-180, -90, 180, 90])
? MAX_EXTENT_WEB_MERCATOR
: props.geometry;
return (<FitBounds active { ...props } geometry={geometry}/>);
}

const ConnectedFitBoundsPlugin = connect(
createSelector([
state => state?.controls?.fitBounds?.geometry
], (geometry) => ({
geometry
state => state?.controls?.fitBounds?.geometry,
projectionSelector
], (geometry, mapProjection) => ({
geometry,
mapProjection
}))
)(FitBoundsPlugin);

Expand Down
10 changes: 5 additions & 5 deletions geonode_mapstore_client/client/js/utils/ResourceUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const getResourceTypesInfo = () => ({
formatEmbedUrl: (resource) => parseDevHostname(updateUrlQueryParameter(resource.embed_url, {
config: 'dataset_preview'
})),
formatDetailUrl: (resource) => (`/catalogue/#/dataset/${resource.pk}`),
formatDetailUrl: (resource) => resource?.detail_url && parseDevHostname(resource.detail_url),
name: 'Dataset',
formatMetadataUrl: (resource) => (`/datasets/${resource.alternate}/metadata`)
},
Expand All @@ -185,28 +185,28 @@ export const getResourceTypesInfo = () => ({
formatEmbedUrl: (resource) => parseDevHostname(updateUrlQueryParameter(resource.embed_url, {
config: 'map_preview'
})),
formatDetailUrl: (resource) => (`/catalogue/#/map/${resource.pk}`),
formatDetailUrl: (resource) => resource?.detail_url && parseDevHostname(resource.detail_url),
formatMetadataUrl: (resource) => (`/maps/${resource.pk}/metadata`)
},
[ResourceTypes.DOCUMENT]: {
icon: 'file',
name: 'Document',
formatEmbedUrl: (resource) => resource?.embed_url && parseDevHostname(resource.embed_url),
formatDetailUrl: (resource) => (`/catalogue/#/document/${resource.pk}`),
formatDetailUrl: (resource) => resource?.detail_url && parseDevHostname(resource.detail_url),
formatMetadataUrl: (resource) => (`/documents/${resource.pk}/metadata`)
},
[ResourceTypes.GEOSTORY]: {
icon: 'book',
name: 'GeoStory',
formatEmbedUrl: (resource) => resource?.embed_url && parseDevHostname(resource.embed_url),
formatDetailUrl: (resource) => (`/catalogue/#/geostory/${resource.pk}`),
formatDetailUrl: (resource) => resource?.detail_url && parseDevHostname(resource.detail_url),
formatMetadataUrl: (resource) => (`/apps/${resource.pk}/metadata`)
},
[ResourceTypes.DASHBOARD]: {
icon: 'dashboard',
name: 'Dashboard',
formatEmbedUrl: (resource) => resource?.embed_url && parseDevHostname(resource.embed_url),
formatDetailUrl: (resource) => (`/catalogue/#/dashboard/${resource.pk}`),
formatDetailUrl: (resource) => resource?.detail_url && parseDevHostname(resource.detail_url),
formatMetadataUrl: (resource) => (`/apps/${resource.pk}/metadata`)
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,8 @@ div#mapstore-globalspinner {
margin: auto !important;
}
}

// height has an incorrect value in rem so we need to override it
.feature-grid-container .ms2-border-layout-body .react-grid-HeaderRow .react-grid-HeaderCell .rw-datetimepicker.rw-widget input {
height: auto;
}

0 comments on commit 36eda4b

Please sign in to comment.