Skip to content

Commit

Permalink
Client - Detail panel / viewer improvement (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
luorlandini authored Jun 24, 2021
1 parent 1bb0fce commit e47d605
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function DetailsPanel({
}}>
<FaIcon name={icon}/>
</div>
{embedUrl
{embedUrl && !editThumbnail
? <iframe
key={embedUrl}
src={embedUrl}
Expand Down Expand Up @@ -256,7 +256,6 @@ function DetailsPanel({
{detailUrl && <Button
variant="default"
href={detailUrl}
target="_blank"
rel="noopener noreferrer">
<Message msgId={`gnhome.view${name || ''}`}/>
</Button>}
Expand Down
28 changes: 15 additions & 13 deletions geonode_mapstore_client/client/js/plugins/DetailViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import controls from '@mapstore/framework/reducers/controls';
import {toggleControl} from '@mapstore/framework/actions/controls';
import gnresource from '@js/reducers/gnresource';
import Message from '@mapstore/framework/components/I18N/Message';
import { userSelector } from '@mapstore/framework/selectors/security';
import { canEditResource } from '@js/selectors/gnresource';
import Button from '@js/components/Button';

const ConnectedDetailsPanel = connect(
Expand All @@ -37,24 +37,22 @@ const ConnectedDetailsPanel = connect(
}
)(DetailsPanel);

const ButtonViewer = ({user, onClick}) => {
const ButtonViewer = ({onClick}) => {

const handleClickButton = () => {
onClick();
};

return (user && <Button
return (<Button
variant="primary"
onClick={handleClickButton}
> <Message msgId="gnviewer.details"/>
</Button>);
};

const ConnectedButton = connect(
createSelector([userSelector],
(user) => ({
user
})),
createSelector([],
() => ({})),
{
onClick: toggleControl.bind(null, 'DetailViewer', null)
}
Expand All @@ -65,7 +63,9 @@ function DetailViewer({
enabled,
onEditResource,
onEditAbstractResource,
onEditThumbnail}) {
onEditThumbnail,
canEdit
}) {

const handleTitleValue = (val) => {
onEditResource(val);
Expand All @@ -87,11 +87,11 @@ function DetailViewer({
height: '100%'

}}>
{ enabled && <ConnectedDetailsPanel
{ !enabled && <ConnectedDetailsPanel
editTitle={handleTitleValue}
editAbstract={handleAbstractValue}
editThumbnail={handleEditThumbnail}
activeEditMode={enabled}
activeEditMode={!enabled && canEdit}
sectionStyle={{
width: '600px',
position: 'fixed'
Expand All @@ -103,9 +103,11 @@ function DetailViewer({

const DetailViewerPlugin = connect(
createSelector([
state => state?.controls?.DetailViewer?.enabled || false
], (enabled) => ({
enabled
state => state?.controls?.DetailViewer?.enabled || false,
canEditResource
], (enabled, canEdit) => ({
enabled,
canEdit
})),
{
onEditResource: editTitleResource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3042,6 +3042,7 @@
"map_viewer": [
{ "name": "ViewerLayout" },
{ "name": "ActionNavbar" },
{ "name": "DetailViewer"},
{ "name": "BrandNavbar" },
{
"name": "Map",
Expand Down Expand Up @@ -3407,6 +3408,7 @@
{ "name": "ViewerLayout" },
{ "name": "ActionNavbar" },
{ "name": "BrandNavbar" },
{ "name": "DetailViewer"},
{
"name": "GeoStory",
"cfg": {
Expand Down

0 comments on commit e47d605

Please sign in to comment.