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-23170 Use path to block actions for category root, prevent sy… #1337

Merged
merged 1 commit into from
Nov 13, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Constants} from '~/ContentEditor/ContentEditor.constants';

const isContentOrFileNode = formData => {
const pattern = '^/sites/[^/]*/(contents|files)$';
const isContentOrFileOrCategoriesNode = formData => {
const pattern = '^/sites/[^/]*/(contents|files|categories)$';
const regex = RegExp(pattern);
return formData.technicalInfo.filter(info => {
return regex.test(info.value);
Expand All @@ -18,7 +18,7 @@ export const adaptSystemNameField = (formData, primaryNodeType) => {

if (systemNameField) {
// System name should be readonly for this specific nodetypes / should be in json overrides
if (Constants.systemName.READONLY_FOR_NODE_TYPES.includes(primaryNodeType.name) || isContentOrFileNode(formData)) {
if (Constants.systemName.READONLY_FOR_NODE_TYPES.includes(primaryNodeType.name) || isContentOrFileOrCategoriesNode(formData)) {
systemNameField.readOnly = true;
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/javascript/JContent/JContent.actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ import {SelectionActionComponent} from './actions/selectionAction';
import {MenuItemRenderer} from './MenuItemRenderer';
import {MenuRenderer} from './MenuRenderer';
import {triggerRefetchAll} from './JContent.refetches';
import {ACTION_PERMISSIONS, PATH_CONTENTS_ITSELF, PATH_FILES_ITSELF} from './actions/actions.constants';
import {
ACTION_PERMISSIONS,
PATH_CATEGORIES_ITSELF,
PATH_CONTENTS_ITSELF,
PATH_FILES_ITSELF
} from './actions/actions.constants';
import {ViewUsagesComponent} from '~/JContent/actions/viewUsages';
import {OpenInPageBuilderActionComponent} from '~/JContent/actions/openInPageBuilderAction';
import {CopyMenuComponent} from '~/JContent/actions/copyPaste/CopyMenuComponent';
Expand Down Expand Up @@ -272,7 +277,7 @@ export const jContentActions = registry => {
targets: ['contentActions:3.9', 'accordionContentActions:3.9', 'selectedContentActions:3.9', 'narrowHeaderSelectionMenu:3.9'],
copyCutType: 'cut',
hideOnNodeTypes: ['jnt:virtualsite', 'jmix:hideDeleteAction', 'jmix:isAreaList'],
hideForPaths: [PATH_FILES_ITSELF, PATH_CONTENTS_ITSELF],
hideForPaths: [PATH_FILES_ITSELF, PATH_CONTENTS_ITSELF, PATH_CATEGORIES_ITSELF],
component: CopyCutActionComponent
});
registry.add('action', 'paste', {
Expand Down
1 change: 1 addition & 0 deletions src/javascript/JContent/actions/actions.constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const PATH_CONTENTS_ITSELF = '^/sites/((?!/).)+/contents/?$';
export const PATH_FILES_ITSELF = '^/sites/((?!/).)+/files/?$';
export const PATH_CATEGORIES_ITSELF = '^/sites/((?!/).)+/categories/?$';

export const ACTION_PERMISSIONS = {
copyAction: 'copyAction',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {useSelector} from 'react-redux';
import {useNodeChecks} from '@jahia/data-helper';
import PropTypes from 'prop-types';
import React, {useContext} from 'react';
import {PATH_CONTENTS_ITSELF, PATH_FILES_ITSELF} from '../actions.constants';
import {PATH_CATEGORIES_ITSELF, PATH_CONTENTS_ITSELF, PATH_FILES_ITSELF} from '../actions.constants';
import Delete from './Delete';
import {ComponentRendererContext} from '@jahia/ui-extender';

Expand All @@ -22,7 +22,7 @@ export const DeleteActionComponent = ({path, paths, buttonProps, onDeleted, rend
getDisplayName: true,
getOperationSupport: true,
requiredPermission: ['jcr:removeNode'],
hideForPaths: [PATH_FILES_ITSELF, PATH_CONTENTS_ITSELF],
hideForPaths: [PATH_FILES_ITSELF, PATH_CONTENTS_ITSELF, PATH_CATEGORIES_ITSELF],
getLockInfo: true,
...others
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {useNodeChecks} from '@jahia/data-helper';
import PropTypes from 'prop-types';
import {isMarkedForDeletion} from '../../JContent.utils';
import {useSelector} from 'react-redux';
import {PATH_CONTENTS_ITSELF, PATH_FILES_ITSELF} from './../actions.constants';
import {PATH_CATEGORIES_ITSELF, PATH_CONTENTS_ITSELF, PATH_FILES_ITSELF} from './../actions.constants';
import Delete from './Delete';
import {ComponentRendererContext} from '@jahia/ui-extender';

Expand Down Expand Up @@ -35,7 +35,7 @@ export const DeletePermanentlyActionComponent = ({path, paths, buttonProps, onDe
getOperationSupport: true,
requiredPermission: ['jcr:removeNode'],
hideOnNodeTypes: ['jnt:virtualsite'],
hideForPaths: [PATH_FILES_ITSELF, PATH_CONTENTS_ITSELF]
hideForPaths: [PATH_FILES_ITSELF, PATH_CONTENTS_ITSELF, PATH_CATEGORIES_ITSELF]
},
{
fetchPolicy: 'network-only'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {useSelector} from 'react-redux';
import {useNodeChecks} from '@jahia/data-helper';
import PropTypes from 'prop-types';
import React, {useContext} from 'react';
import {PATH_CONTENTS_ITSELF, PATH_FILES_ITSELF} from '../actions.constants';
import {PATH_CATEGORIES_ITSELF, PATH_CONTENTS_ITSELF, PATH_FILES_ITSELF} from '../actions.constants';
import {ComponentRendererContext} from '@jahia/ui-extender';
import Delete from './Delete';

Expand All @@ -23,7 +23,7 @@ export const UndeleteActionComponent = ({path, paths, buttonProps, onDeleted, re
getOperationSupport: true,
requiredPermission: ['jcr:removeNode'],
hideOnNodeTypes: ['jnt:virtualsite'],
hideForPaths: [PATH_FILES_ITSELF, PATH_CONTENTS_ITSELF]
hideForPaths: [PATH_FILES_ITSELF, PATH_CONTENTS_ITSELF, PATH_CATEGORIES_ITSELF]
},
{
fetchPolicy: 'network-only'
Expand Down
3 changes: 2 additions & 1 deletion src/javascript/JContent/dnd/useNodeDrag.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {shallowEqual, useSelector} from 'react-redux';
import {useNodeChecks} from '@jahia/data-helper';
import {PATH_CONTENTS_ITSELF, PATH_FILES_ITSELF} from '~/JContent/actions/actions.constants';
import {JahiaAreasUtil} from '../JContent.utils';
import {PATH_CATEGORIES_ITSELF} from '../actions/actions.constants';

export function useNodeDrag({dragSource}) {
const {selection, language, displayLanguage} = useSelector(state => ({
Expand All @@ -21,7 +22,7 @@ export function useNodeDrag({dragSource}) {
getPrimaryNodeType: true,
requiredPermission: ['jcr:removeNode'],
hideOnNodeTypes: ['jnt:virtualsite', 'jmix:hideDeleteAction', 'jmix:blockUiMove'],
hideForPaths: [PATH_FILES_ITSELF, PATH_CONTENTS_ITSELF],
hideForPaths: [PATH_FILES_ITSELF, PATH_CONTENTS_ITSELF, PATH_CATEGORIES_ITSELF],
getLockInfo: true
}
);
Expand Down
Loading