Skip to content

Commit

Permalink
BACKLOG-23339 Remove Menu title switch to listView dialog (#1340)
Browse files Browse the repository at this point in the history
* BACKLOG-23339 Remove Menu title switch to listView dialog

* BACKLOG-23339 Disable Menu title if not displayable

* BACKLOG-23339 Fix lint

* BACKLOG-23339 Narrow down disable condition

* BACKLOG-23339 Remove unused tests

* BACKLOG-23339 Remove unused tests

* BACKLOG-23339 Handle dialog removal in tests
  • Loading branch information
AKarmanov authored Nov 18, 2024
1 parent f39183b commit 8c8c420
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 28 deletions.
9 changes: 3 additions & 6 deletions src/javascript/JContent/ContentTree/ContentTree.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {useNodeDrop} from '~/JContent/dnd/useNodeDrop';
import {useNodeDrag} from '~/JContent/dnd/useNodeDrag';
import {useFileDrop} from '~/JContent/dnd/useFileDrop';
import JContentConstants from '~/JContent/JContent.constants';
import {NonDisplayableNodeDialog, LinkDialog, useNodeDialog} from '~/JContent/NavigationDialogs';
import {LinkDialog, useNodeDialog} from '~/JContent/NavigationDialogs';
import {useTranslation} from 'react-i18next';

export const accordionPropType = PropTypes.shape({
Expand Down Expand Up @@ -106,7 +106,6 @@ export const ContentTree = ({setPathAction, openPathAction, closePathAction, ite
const {t} = useTranslation('jcontent');
const {lang, siteKey, path, openPaths, viewMode} = useSelector(selector, shallowEqual);
const {openDialog: openLinkDialog, ...linkDialogProps} = useNodeDialog();
const {openDialog: openNonDisplayableNodeDialog, ...nonDisplayableNodeDialogProps} = useNodeDialog();
const rootPath = item.getRootPath(siteKey);
const ulRef = useRef(null);
const ulScrollRef = useRef(0);
Expand Down Expand Up @@ -192,7 +191,8 @@ export const ContentTree = ({setPathAction, openPathAction, closePathAction, ite
selected: path,
isReversed,
contentMenu: contextualMenuAction,
itemProps: {item}
itemProps: {item},
viewMode: viewMode
})}
openedItems={openPaths}
highlightedItems={highlighted}
Expand All @@ -208,8 +208,6 @@ export const ContentTree = ({setPathAction, openPathAction, closePathAction, ite
const {node} = object.treeItemProps;
if (['jnt:externalLink', 'jnt:nodeLink'].includes(node.primaryNodeType.name)) {
openLinkDialog(node);
} else if (node.primaryNodeType.name !== 'jnt:page' && !node.isMainResource && viewMode === 'pageBuilder') {
openNonDisplayableNodeDialog(node);
} else {
dispatch(setPathAction(object.id, {sub: false}));
}
Expand All @@ -223,7 +221,6 @@ export const ContentTree = ({setPathAction, openPathAction, closePathAction, ite
onCloseItem={object => dispatch(closePathAction(object.id))}
/>
<LinkDialog {...linkDialogProps}/>
<NonDisplayableNodeDialog {...nonDisplayableNodeDialogProps} setPathAction={setPathAction}/>
{item.treeConfig.showContextMenuOnRootPath && (
<>
<ContextualMenu setOpenRef={rootContextualMenu} actionKey="rootContentMenu"/>
Expand Down
5 changes: 3 additions & 2 deletions src/javascript/JContent/ContentTree/ContentTree.utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function findInTree(tree, id) {
}
}

function convertPathsToTree({treeEntries, selected, isReversed, contentMenu, itemProps}) {
function convertPathsToTree({treeEntries, selected, isReversed, contentMenu, itemProps, viewMode}) {
const tree = [];
if (treeEntries.length === 0) {
return tree;
Expand Down Expand Up @@ -79,7 +79,8 @@ function convertPathsToTree({treeEntries, selected, isReversed, contentMenu, ite
node: treeEntry.node,
treeEntries,
...itemProps
}
},
isDisabled: treeEntry.node.primaryNodeType.name === 'jnt:navMenuText' && viewMode === 'pageBuilder'
};
const parent = findInTree(tree, parentPath);
if (parent !== undefined && !findInTree(parent, element.id)) {
Expand Down
19 changes: 0 additions & 19 deletions tests/cypress/e2e/jcontent/links.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,25 +126,6 @@ describe('Links in jcontent', () => {
getComponentByRole(Button, 'backButton').click();
});

it('Open modal when clicking on menu title', function () {
const pageAccordion = jcontent.getAccordionItem('pages');
pageAccordion.expandTreeItem('home');
pageAccordion.getTreeItem('menu-entry').click();
cy.get('div[role=dialog]');
cy.contains('Menu titles are used to organize pages and cannot be displayed in the current view. Switch to list view instead');
getComponentByRole(Button, 'cancel-button').click();
});

it('Open modal when clicking on menu title and can edit entry from list view', function () {
const pageAccordion = jcontent.getAccordionItem('pages');
pageAccordion.expandTreeItem('home');
pageAccordion.getTreeItem('menu-entry').click();
cy.get('div[role=dialog]');
cy.contains('Menu titles are used to organize pages and cannot be displayed in the current view. Switch to list view instead');
getComponentByRole(Button, 'view-list').click();
jcontent.getTable().getRowByLabel('Sub Menu Entry Page').get().should('be.visible');
});

it('Trying to access legacy page composer redirect to page builder', () => {
PageComposer.visit('jcontentSite', 'en', 'home.html');
jcontent.switchToListMode().getTable().getRowByLabel('test-content5');
Expand Down
1 change: 0 additions & 1 deletion tests/cypress/e2e/jcontent/navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ describe('Content navigation', () => {
jc.switchToPageBuilder();
cy.frameLoaded('#page-builder-frame-1');
jc.getAccordionItem('content-folders').getTreeItem('contents').click();
cy.get('button[data-sel-role="view-list"]').should('be.visible').click();
cy.get('.moonstone-chip').find('span').contains('Content Folder').should('be.visible');
cy.get('h1').contains('contents');
});
Expand Down

0 comments on commit 8c8c420

Please sign in to comment.