Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BACKLOG-23413 Using small breadcrumbs dropdown in edit boxes in PC #1392

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/javascript/JContent/EditFrame/Box.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export const Box = React.memo(({
jahiatype="footer" // eslint-disable-line react/no-unknown-property
onClick={onClick}
>
<Breadcrumbs nodes={breadcrumbs} isResponsiveMode={element.getBoundingClientRect().width < 350} setCurrentElement={setCurrentElement} onSelect={onSelect}/>
<Breadcrumbs nodes={breadcrumbs} setCurrentElement={setCurrentElement} onSelect={onSelect}/>
</div>}
</div>
</div>
Expand Down
43 changes: 14 additions & 29 deletions src/javascript/JContent/EditFrame/Breadcrumbs/Breadcrumbs.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, {useCallback} from 'react';
import PropTypes from 'prop-types';
import {Breadcrumb, BreadcrumbItem, Dropdown} from '@jahia/moonstone';
import {Dropdown} from '@jahia/moonstone';
import {useTranslation} from 'react-i18next';
import {shallowEqual, useSelector} from 'react-redux';
import {NodeIcon} from '~/utils';

export const Breadcrumbs = ({nodes, setCurrentElement, onSelect, isResponsiveMode}) => {
export const Breadcrumbs = ({nodes, setCurrentElement, onSelect}) => {
const {t} = useTranslation('jcontent');
const {selection} = useSelector(state => ({
selection: state.jcontent.selection
Expand All @@ -26,39 +26,24 @@ export const Breadcrumbs = ({nodes, setCurrentElement, onSelect, isResponsiveMod
return false;
}, [onSelect, selection.length, setCurrentElement]);

if (isResponsiveMode) {
const data = nodes.map(n => ({
label: n.name,
value: n.path,
image: <NodeIcon node={n}/>
}));

return (
<Dropdown data={data}
placeholder={t('jcontent:label.contentManager.pageBuilder.breadcrumbs.dropdownLabel')}
onChange={(e, v) => {
handleItemOnClick(e, v.value);
}}
/>
);
}
const data = nodes.toReversed().map((n, index) => ({
label: n.name,
value: n.path,
image: <NodeIcon node={n} style={{marginLeft: 8 * index}}/>
}));
gflores-jahia marked this conversation as resolved.
Show resolved Hide resolved

return (
<Breadcrumb data-sel-role="pagebuilder-breadcrumb">
{nodes.map(n => (
<BreadcrumbItem key={n.path}
label={n.name}
icon={<NodeIcon node={n}/>}
onClick={event => handleItemOnClick(event, n.path)}
/>
))}
</Breadcrumb>
<Dropdown data={data}
placeholder={t('jcontent:label.contentManager.pageBuilder.breadcrumbs.dropdownLabel')}
onChange={(e, v) => {
handleItemOnClick(e, v.value);
}}
/>
);
};

Breadcrumbs.propTypes = {
nodes: PropTypes.array,
setCurrentElement: PropTypes.func,
onSelect: PropTypes.func,
isResponsiveMode: PropTypes.bool
onSelect: PropTypes.func
};
Loading