Skip to content

Commit

Permalink
Add overlay panel for detail viewer (#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
allyoucanmap authored Jul 29, 2021
1 parent fd8596c commit 7880f7e
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ const ActionNavbar = forwardRef(({
formatHref,
cfg,
variant,
size
size,
children
}, ref) => {

return (
Expand All @@ -130,7 +131,7 @@ const ActionNavbar = forwardRef(({
size={size}
/>
}

{children}
{

rightItems.length > 0 &&
Expand Down
21 changes: 15 additions & 6 deletions geonode_mapstore_client/client/js/plugins/ActionNavbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import { createPlugin } from '@mapstore/framework/utils/PluginsUtils';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import ActionNavbar from '@js/components/ActionNavbar';
import FaIcon from '@js/components/FaIcon';
import usePluginItems from '@js/hooks/usePluginItems';
import { getResourcePerms, canAddResource } from '@js/selectors/resource';
import { getResourcePerms, canAddResource, getResourceData } from '@js/selectors/resource';
import { hasPermissionsTo, reduceArrayRecursive } from '@js/utils/MenuUtils';
import { getResourceTypesInfo } from '@js/utils/ResourceUtils';

function checkResourcePerms(menuItem, resourcePerms) {
if (menuItem.type && menuItem.perms) {
Expand All @@ -26,9 +28,12 @@ function checkResourcePerms(menuItem, resourcePerms) {
function ActionNavbarPlugin({
items,
leftMenuItems,
resourcePerms
resourcePerms,
resource
}, context) {

const types = getResourceTypesInfo();
const { icon } = types[resource?.resource_type] || {};
const { loadedPlugins } = context;
const configuredItems = usePluginItems({ items, loadedPlugins });

Expand All @@ -51,7 +56,9 @@ function ActionNavbarPlugin({
leftItems={leftItems}
variant="default"
size="sm"
/>
>
<h1 className="gn-action-navbar-title">{icon && <FaIcon name={icon}/>}{' '}{resource?.title}</h1>
</ActionNavbar>
);
}

Expand All @@ -68,11 +75,13 @@ ActionNavbarPlugin.defaultProps = {
const ConnectedActionNavbarPlugin = connect(
createSelector([
getResourcePerms,
canAddResource
], (resourcePerms, userCanAddResource) => ({
canAddResource,
getResourceData
], (resourcePerms, userCanAddResource, resource) => ({
resourcePerms: (resourcePerms.length > 0 ) ?
resourcePerms : ((userCanAddResource)
? [ "change_resourcebase"] : [] )
? [ "change_resourcebase"] : [] ),
resource
}))
)(ActionNavbarPlugin);

Expand Down
6 changes: 3 additions & 3 deletions geonode_mapstore_client/client/js/plugins/DetailViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ function DetailViewer({
height: '100%'

}}>
{ !enabled && <ConnectedDetailsPanel
{ enabled && <ConnectedDetailsPanel
editTitle={handleTitleValue}
editAbstract={handleAbstractValue}
editThumbnail={handleEditThumbnail}
activeEditMode={!enabled && canEdit}
activeEditMode={enabled && canEdit}
enableFavorite={!!user}
sectionStyle={{
width,
Expand Down Expand Up @@ -164,7 +164,7 @@ export default createPlugin('DetailViewer', {
containers: {
ViewerLayout: {
name: 'DetailViewer',
target: 'rightColumn',
target: 'rightOverlay',
priority: 1
},
ActionNavbar: {
Expand Down
13 changes: 13 additions & 0 deletions geonode_mapstore_client/client/js/plugins/ViewerLayout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ function ViewerLayout({
.map(({ Component, name }) => <Component key={name} />)}
</div>
</div>
<div
className="gn-viewer-right-overlay shadow-far"
style={{
position: 'absolute',
right: 0,
height: '100%',
zIndex: 2000,
transform: 'all 0.3s'
}}>
{configuredItems
.filter(({ target }) => target === 'rightOverlay')
.map(({ Component, name }) => <Component key={name} />)}
</div>
<footer>
{configuredItems
.filter(({ target }) => target === 'footer')
Expand Down
4 changes: 4 additions & 0 deletions geonode_mapstore_client/client/js/selectors/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ export const canAddResource = (state) => {
export const isNewResource = (state) => {
return !!state?.gnresource?.isNew;
};

export const getResourceData = (state) => {
return state?.gnresource?.data;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2603,8 +2603,7 @@
"name": "MapFooter",
"override": {
"ViewerLayout": {
"priority": 1,
"target": "footer"
"priority": 1
}
}
},
Expand Down Expand Up @@ -2834,8 +2833,7 @@
"name": "MapFooter",
"override": {
"ViewerLayout": {
"priority": 1,
"target": "footer"
"priority": 1
}
}
},
Expand Down Expand Up @@ -2935,8 +2933,7 @@
"name": "MapFooter",
"override": {
"ViewerLayout": {
"priority": 1,
"target": "footer"
"priority": 1
}
}
},
Expand Down Expand Up @@ -3164,8 +3161,7 @@
"name": "MapFooter",
"override": {
"ViewerLayout": {
"priority": 1,
"target": "footer"
"priority": 1
}
}
},
Expand Down
7 changes: 7 additions & 0 deletions geonode_mapstore_client/client/themes/geonode/less/_menu.less
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@
z-index: 10;
}

.gn-action-navbar-title {
margin: 0;
font-weight: 400;
font-size: 1rem;
padding: 0 0.5rem;
}

.gn-language-selector {
margin-left: 0.4rem;
}
23 changes: 23 additions & 0 deletions geonode_mapstore_client/client/themes/geonode/less/ms-theme.less
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,26 @@
.input-sm {
height: 1.75rem;
}

// fix share modal style
.gn-share-modal {
overflow: visible;
.modal-dialog,
.ms-resizable-modal > .modal-content > .modal-body > div {
overflow: visible;
}
.col-md-4 {
padding-left: 0;
padding-right: 0;
}
.row {
margin-left: 0;
margin-right: 0;
}
.modal-body {
margin: 8px;
}
.modal-footer {
display: none;
}
}

0 comments on commit 7880f7e

Please sign in to comment.