Skip to content

Commit

Permalink
#1557: Title in the viewer page is updated (#1558)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsuren1 authored Sep 13, 2023
1 parent e82d559 commit 99ceada
Show file tree
Hide file tree
Showing 22 changed files with 61 additions and 210 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import PropTypes from 'prop-types';
import Menu from '@js/components/Menu';
import BurgerMenu from '@js/components/Menu/BurgerMenu';
import useResizeElement from '@js/hooks/useResizeElement';
import BreadCrumb from '@js/components/BreadCrumb';

const LeftContentMenu = ({ items, formatHref, query, variant, size, resourceName }) => {
const navbarContentLeft = useRef();
Expand Down Expand Up @@ -79,20 +78,14 @@ const ActionNavbar = forwardRef(
formatHref,
variant,
size,
resource,
titleItems,
disableTitle
resource
},
ref
) => {
return (
<nav ref={ref} className={`gn-menu gn-${variant}`} style={style}>
<div className="gn-menu-container">
<div className="gn-menu-content">
{!disableTitle && <BreadCrumb
resource={resource}
titleItems={titleItems}
/>}
{leftItems.length > 0 && (
<LeftContentMenu
items={leftItems}
Expand Down Expand Up @@ -125,18 +118,15 @@ ActionNavbar.propTypes = {
rightItems: PropTypes.array,
query: PropTypes.object,
formatHref: PropTypes.func,
variant: PropTypes.string,
disableTitle: PropTypes.bool
variant: PropTypes.string
};

ActionNavbar.defaultProps = {
leftItems: [],
rightItems: [],
titleItems: [],
query: {},
formatHref: () => '#',
variant: 'primary',
disableTitle: false
variant: 'primary'
};

export default ActionNavbar;
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ import ActionNavbar from '../ActionNavbar';


const conf = {
titleNavbarItems: [
{
"type": "plugin",
"name": "DetailViewerButton",
"Component": 'i'
}
],
leftItems: [
{
"labelId": "gnhome.data",
Expand Down Expand Up @@ -201,23 +194,11 @@ describe('Test GeoNode action navbar component', () => {
ReactDOM.render( <ActionNavbar
leftItems={conf.leftItems.items}
rightItems={conf.rightItems.items}
titleItems={conf.titleNavbarItems}
/>, document.getElementById("container"));

const el = document.querySelector('.gn-menu');
expect(el).toExist();
const navBarContent = document.querySelector('.gn-menu-content');
expect(navBarContent).toExist();
});
it('should not render breadcrumb on new or edit resource', () => {
ReactDOM.render(
<ActionNavbar
disableTitle
titleItems={conf.titleNavbarItems}
/>,
document.getElementById('container')
);
const el = document.querySelector('.gn-action-navbar-title');
expect(el).toNotExist();
});
});

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion geonode_mapstore_client/client/js/components/Menu/Menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Menu = forwardRef(({
<MenuItem
variant={item.variant || variant}
item={{ ...item, id: item.id || idx }}
size={size}
size={item.size || size}
alignRight={alignRight}
menuItemsProps={{
query,
Expand Down
26 changes: 3 additions & 23 deletions geonode_mapstore_client/client/js/plugins/ActionNavbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ function ActionNavbarPlugin(
resourcePerms,
resource,
isDirtyState,
selectedLayerPermissions,
titleItems,
disableTitle
selectedLayerPermissions
},
context
) {
Expand Down Expand Up @@ -79,15 +77,6 @@ function ActionNavbarPlugin(
}
);

const titleItemsPlugins = reduceArrayRecursive(titleItems, (item) => {
configuredItems.find((plugin) => {
if (item.type === 'plugin' && plugin.name === item.name) {
item.Component = plugin?.Component;
}
});
return item;
});

const leftItems = reduceArrayRecursive(leftMenuItemsPlugins, (menuItem) =>
checkResourcePerms(menuItem, resourcePerms)
);
Expand All @@ -96,36 +85,27 @@ function ActionNavbarPlugin(
checkResourcePerms(menuItem, resourcePerms)
);

const titleNavbarItems = reduceArrayRecursive(
titleItemsPlugins,
(menuItem) => checkResourcePerms(menuItem, resourcePerms)
);

return (
<ActionNavbar
leftItems={leftItems}
rightItems={rightItems}
variant="primary"
size="sm"
resource={resource}
titleItems={titleNavbarItems}
disableTitle={disableTitle}
/>
);
}

ActionNavbarPlugin.propTypes = {
items: PropTypes.array,
leftMenuItems: PropTypes.array,
rightMenuItems: PropTypes.array,
titleItems: PropTypes.array
rightMenuItems: PropTypes.array
};

ActionNavbarPlugin.defaultProps = {
items: [],
leftMenuItems: [],
rightMenuItems: [],
titleItems: []
rightMenuItems: []
};

const ConnectedActionNavbarPlugin = connect(
Expand Down
2 changes: 1 addition & 1 deletion geonode_mapstore_client/client/js/plugins/DetailViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const ButtonViewer = ({ onClick, hide, variant, size, showMessage }) => {
size={size}
onClick={handleClickButton}
>
{!showMessage ? <FaIcon name="info-circle" /> : <Message msgId="gnviewer.editInfo"/>}
{!showMessage ? <FaIcon name="info-circle" /> : <Message msgId="gnviewer.viewInfo"/>}
</Button>
) : null;
};
Expand Down
Loading

0 comments on commit 99ceada

Please sign in to comment.