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

BUGFIX: Allow auto-created child nodes to be hidden #3004

Closed
Closed
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
10 changes: 8 additions & 2 deletions Classes/Fusion/Helper/NodeInfoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,23 @@ protected function getUriInformation(NodeInterface $node, ControllerContext $con
*/
protected function getBasicNodeInformation(NodeInterface $node): array
{
$parent = $node->getParent();
$isAutoCreated = $node->isTethered();
$parentConfiguration = $parent ? $parent->getNodeType()->getFullConfiguration() : [];
$isHidableAutoCreatedChild = (bool)$parentConfiguration['childNodes'][(string)$node->getNodeName()]['hideable'] ?? false;
$policyForbidsHiding = in_array('_hidden', $this->nodePolicyService->getDisallowedProperties($node));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: We should check whether this is a performance issue

return [
'contextPath' => $node->getContextPath(),
'name' => $node->getName(),
'identifier' => $node->getIdentifier(),
'nodeType' => $node->getNodeType()->getName(),
'label' => $node->getLabel(),
'isAutoCreated' => $node->isAutoCreated(),
'isAutoCreated' => $isAutoCreated,
'disableChangeVisibility' => $policyForbidsHiding || ($isAutoCreated && $isHidableAutoCreatedChild === false),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably use a non negated variable name like isHidable
(with inverted value) as a more descriptive name than: disableChangeVisibility.

'depth' => $node->getDepth(),
'children' => [],
// In some rare cases the parent node cannot be resolved properly
'parent' => ($node->getParent() ? $node->getParent()->getContextPath() : null),
'parent' => ($parent ? $parent->getContextPath() : null),
'matchesCurrentDimensions' => ($node instanceof Node && $node->dimensionsAreMatchingTargetDimensionValues())
];
}
Expand Down
1 change: 1 addition & 0 deletions packages/neos-ts-interfaces/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export interface Node {
nodeType: NodeTypeName;
label: string;
isAutoCreated: boolean;
disableChangeVisibility: boolean;
depth: number;
children: NodeChildren;
matchesCurrentDimensions: boolean;
Expand Down
4 changes: 2 additions & 2 deletions packages/neos-ui-guest-frame/src/InlineUI/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import {$transform, $get, $contains} from 'plow-js';
import {$transform, $get} from 'plow-js';
import {actions, selectors} from '@neos-project/neos-ui-redux-store';
import {neos} from '@neos-project/neos-ui-decorators';

Expand Down Expand Up @@ -65,7 +65,7 @@ export default class InlineUI extends PureComponent {
const isCopied = allFocusedNodesAreInClipboard && clipboardMode === 'Copy';
const canBeDeleted = $get('policy.canRemove', this.props.focusedNode) || false;
const canBeEdited = $get('policy.canEdit', this.props.focusedNode) || false;
const visibilityCanBeToggled = !$contains('_hidden', 'policy.disallowedProperties', this.props.focusedNode);
const visibilityCanBeToggled = !$get('disableChangeVisibility', this.props.focusedNode);

return (
<div className={style.inlineUi} data-__neos__inline-ui="TRUE">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';
import {$transform, $get, $contains} from 'plow-js';
import {$transform, $get} from 'plow-js';

import {isEqualSet} from '@neos-project/utils-helpers';
import {neos} from '@neos-project/neos-ui-decorators';
Expand Down Expand Up @@ -189,7 +189,6 @@ export default class NodeTreeToolBar extends PureComponent {
focusedNodeContextPath={focusedNodeContextPath}
disabled={
isWorkspaceReadOnly ||
destructiveOperationsAreDisabled ||
!canBeEdited ||
!visibilityCanBeToggled
}
Expand Down Expand Up @@ -269,7 +268,7 @@ const removeAllowed = (focusedNodesContextPaths, state) => focusedNodesContextPa
const visibilityToggleAllowed = (focusedNodesContextPaths, state) => focusedNodesContextPaths.every(contextPath => {
const getNodeByContextPathSelector = selectors.CR.Nodes.makeGetNodeByContextPathSelector(contextPath);
const focusedNode = getNodeByContextPathSelector(state);
return !$contains('_hidden', 'policy.disallowedProperties', focusedNode);
return !$get('disableChangeVisibility', focusedNode);
});
const editingAllowed = (focusedNodesContextPaths, state) => focusedNodesContextPaths.every(contextPath => {
const getNodeByContextPathSelector = selectors.CR.Nodes.makeGetNodeByContextPathSelector(contextPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class InspectorEditorEnvelope extends PureComponent {
get options() {
// This makes sure that auto-created child nodes cannot be hidden
// via the insprector (see: #2282)
if (this.props.isWorkspaceReadOnly || ($get('isAutoCreated', this.props.node) === true && this.props.id === '_hidden')) {
if (this.props.isWorkspaceReadOnly || ($get('disableChangeVisibility', this.props.node) === true && this.props.id === '_hidden')) {
return {...this.props.options, disabled: true};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ export default class Inspector extends PureComponent {
return true;
}

if ($get('hidden', item) || ($get('isAutoCreated', focusedNode) === true && item.id === '_hidden')) {
if ($get('hidden', item) || ($get('disableChangeVisibility', focusedNode) === true && item.id === '_hidden')) {
// This accounts for the fact that auto-created child nodes cannot
// be hidden via the insprector (see: #2282)
// be hidden via the insprector (see: #2282) if not explicitly allowed
return false;
}

Expand Down
Loading