Skip to content

Commit

Permalink
BACKLOG-20282: do not render view mode outside the allowed list of mo…
Browse files Browse the repository at this point in the history
…des (#918)
  • Loading branch information
cedmail authored Aug 2, 2023
1 parent e36b509 commit 5a4e0e3
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ export const ViewModeSelector = ({selector, setTableViewModeAction}) => {
skip: !path // Skips if path is not defined
});

let showPCAndPreviewSelector = false;
let showPageBuilderView = false;

if (!loading && !error && data?.jcr?.node) {
showPCAndPreviewSelector = mode === JContentConstants.mode.PAGES && booleanValue(contextJsParameters.config.jcontent?.showPageComposer) && data.jcr.node.isDisplayableNode;
showPageBuilderView = (mode === JContentConstants.mode.PAGES) && booleanValue(contextJsParameters.config.jcontent?.showPageComposer) && data.jcr.node.isDisplayableNode;
}

const onChange = vm => dispatch(setTableViewModeAction(vm));
Expand All @@ -63,16 +63,18 @@ export const ViewModeSelector = ({selector, setTableViewModeAction}) => {
localStorage.setItem(VIEW_MODE, selectedViewMode);
};

const allButtons = showPCAndPreviewSelector ? pagesButtons : buttons;
const allButtons = showPageBuilderView ? pagesButtons : buttons;

const selectedMode = allButtons.indexOf(viewMode) === -1 ? allButtons[0] : viewMode;

return (
<Dropdown className={classes.dropdown}
size="small"
data={tableViewDropdownData(t, viewMode, allButtons)}
data={tableViewDropdownData(t, selectedMode, allButtons)}
data-sel-role="sel-view-mode-dropdown"
label={t(`jcontent:label.contentManager.view.${viewMode}`)}
value={viewMode}
icon={icons[viewMode]}
label={t(`jcontent:label.contentManager.view.${selectedMode}`)}
value={selectedMode}
icon={icons[selectedMode]}
onChange={(e, item) => handleChange(item.value)}
/>
);
Expand Down

0 comments on commit 5a4e0e3

Please sign in to comment.