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

9.0: Fix dimension switching #3173

Merged
merged 4 commits into from
Aug 19, 2022
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
3 changes: 2 additions & 1 deletion Classes/Controller/BackendServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,9 @@ public function cutNodesAction(array $nodes): void

public function getWorkspaceInfoAction(): void
{
$contentRepositoryIdentifier = SiteDetectionResult::fromRequest($this->request->getHttpRequest())->contentRepositoryIdentifier;
$workspaceHelper = new WorkspaceHelper();
$personalWorkspaceInfo = $workspaceHelper->getPersonalWorkspace();
$personalWorkspaceInfo = $workspaceHelper->getPersonalWorkspace($contentRepositoryIdentifier);
$this->view->assign('value', $personalWorkspaceInfo);
}

Expand Down
5 changes: 0 additions & 5 deletions packages/neos-ui-backend-connector/src/Endpoints/Helpers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
export const getContextString = (uri: string) => {
const decodedUri = unescape(uri);
const uriParts = decodedUri.split('@');
return uriParts ? uriParts[1].split('.')[0] : '';
};

/**
*
Expand Down
13 changes: 4 additions & 9 deletions packages/neos-ui-backend-connector/src/Endpoints/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {getElementInnerText, getElementAttributeValue, getContextString} from './Helpers';
import {getElementInnerText, getElementAttributeValue} from './Helpers';
import {isNil} from '@neos-project/utils-helpers';
import {urlWithParams, encodeAsQueryString} from '@neos-project/utils-helpers/src/urlWithParams';

Expand Down Expand Up @@ -475,16 +475,11 @@ export default (routes: Routes) => {
throw new Error('.node-frontend-uri does not contain a valid href attribut');
}

const nodePath = d.querySelector('.node-path');
if (!nodePath) {
throw new Error('.node-path is not found in the result');
const nodeContextPath = d.querySelector('.node-context-path');
if (!nodeContextPath) {
throw new Error('.node-context-path is not found in the result');
}

// Hackish way to get context string from uri
const contextString = getContextString(nodeFrontendUri);
// TODO: Temporary hack due to missing contextPath in the API response
const nodeContextPath = `${nodePath.innerHTML}@${contextString}`;

return {
nodeFound: true,
nodeFrontendUri,
Expand Down
24 changes: 24 additions & 0 deletions packages/neos-ui-redux-store/src/UI/PageTree/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,32 @@ import {createSelector} from 'reselect';

import {siteNodeContextPathSelector, siteNodeSelector, nodesByContextPathSelector} from '@neos-project/neos-ui-redux-store/src/CR/Nodes/selectors';
import {isNodeCollapsed} from '@neos-project/neos-ui-redux-store/src/CR/Nodes/helpers';
import {NodeContextPath, NodeMap} from '@neos-project/neos-ts-interfaces';

// contextPath for Neos >= 9.0 is a NodeAddress without hierarchy infos; so we need to traverse the "parent" links.
function rootlineForNode(contextPath: NodeContextPath, nodesByContextPath: NodeMap): string[] {
const node = nodesByContextPath[contextPath];
if (node && node.parent) {
return [...rootlineForNode(node.parent, nodesByContextPath), node.identifier];
}
return [];
}

export const getAllFocused = (state: GlobalState) => $get(['ui', 'pageTree', 'focused'], state);
export const areFocusedNodesNestedInEachOther = createSelector(
[
getAllFocused,
nodesByContextPathSelector
],
(focusedNodesContextPaths, nodesByContextPath) => {
const rootlinesOfFocusedNodes = focusedNodesContextPaths.map((contextPath: NodeContextPath) => rootlineForNode(contextPath, nodesByContextPath).join('/'));

return !rootlinesOfFocusedNodes.every((pathA: string) => {
return rootlinesOfFocusedNodes.every((pathB: string) => !(pathB.indexOf(pathA) === 0 && pathA !== pathB));
});
}
);

export const getFocused = (state: GlobalState) => {
const focused = getAllFocused(state);
return focused && focused[0] ? focused[0] : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import {actions, selectors} from '@neos-project/neos-ui-redux-store';
import {isNodeCollapsed} from '@neos-project/neos-ui-redux-store/src/CR/Nodes/helpers';
import {neos} from '@neos-project/neos-ui-decorators';

import {hasNestedNodes} from '@neos-project/neos-ui/src/Containers/LeftSideBar/NodeTree/helpers';

import hashSum from 'hash-sum';
import moment from 'moment';
import {urlWithParams} from '@neos-project/utils-helpers/src/urlWithParams';
Expand Down Expand Up @@ -74,6 +72,8 @@ export default class Node extends PureComponent {
canBeInsertedAlongside: PropTypes.bool,
canBeInsertedInto: PropTypes.bool,
isNodeDirty: PropTypes.bool.isRequired,

areFocusedNodesNestedInEachOther: PropTypes.bool,
isWorkspaceReadOnly: PropTypes.bool,

nodeTypesRegistry: PropTypes.object.isRequired,
Expand Down Expand Up @@ -281,6 +281,7 @@ export default class Node extends PureComponent {
currentlyDraggedNodes,
isContentTreeNode,
focusedNodesContextPaths,
areFocusedNodesNestedInEachOther,
isWorkspaceReadOnly
} = this.props;

Expand All @@ -298,7 +299,7 @@ export default class Node extends PureComponent {

// Autocreated or we have nested nodes and the node that we are dragging belongs to the selection
// For read only workspaces we also forbid drag and drop
const dragForbidden = isWorkspaceReadOnly || node.isAutoCreated || (hasNestedNodes(focusedNodesContextPaths) && focusedNodesContextPaths.includes(node.contextPath));
const dragForbidden = isWorkspaceReadOnly || node.isAutoCreated || (areFocusedNodesNestedInEachOther && focusedNodesContextPaths.includes(node.contextPath));

return (
<Tree.Node aria-expanded={this.isCollapsed() ? 'false' : 'true'} aria-labelledby={labelIdentifier}>
Expand Down Expand Up @@ -409,6 +410,7 @@ export const PageTreeNode = withNodeTypeRegistryAndI18nRegistry(connect(
return ({
isContentTreeNode: false,
focusedNodesContextPaths: selectors.UI.PageTree.getAllFocused(state),
areFocusedNodesNestedInEachOther: selectors.UI.PageTree.areFocusedNodesNestedInEachOther(state),
rootNode: selectors.CR.Nodes.siteNodeSelector(state),
loadingDepth: neos.configuration.nodeTree.loadingDepth,
childNodes: childrenOfSelector(state, getContextPath(node)),
Expand Down Expand Up @@ -457,6 +459,7 @@ export const ContentTreeNode = withNodeTypeRegistryAndI18nRegistry(connect(
return ({
isContentTreeNode: true,
focusedNodesContextPaths: selectors.UI.PageTree.getAllFocused(state),
areFocusedNodesNestedInEachOther: selectors.UI.PageTree.areFocusedNodesNestedInEachOther(state),
rootNode: selectors.CR.Nodes.documentNodeSelector(state),
loadingDepth: neos.configuration.structureTree.loadingDepth,
childNodes: childrenOfSelector(state, getContextPath(node)),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {$transform, $get, $contains} from 'plow-js';
import {isEqualSet} from '@neos-project/utils-helpers';
import {neos} from '@neos-project/neos-ui-decorators';
import {selectors, actions} from '@neos-project/neos-ui-redux-store';
import {hasNestedNodes} from '@neos-project/neos-ui/src/Containers/LeftSideBar/NodeTree/helpers';
import {InsertPosition} from '@neos-project/neos-ts-interfaces';

import {
Expand Down Expand Up @@ -302,9 +301,9 @@ const makeMapStateToProps = isDocument => (state, {nodeTypesRegistry}) => {
});
}

const selectionHasNestedNodes = hasNestedNodes(focusedNodesContextPaths);
const areFocusedNodesNestedInEachOther = selectors.UI.PageTree.areFocusedNodesNestedInEachOther(state);

const canBeDeleted = (removeAllowed(focusedNodesContextPaths, state) && !selectionHasNestedNodes) || false;
const canBeDeleted = (removeAllowed(focusedNodesContextPaths, state) && !areFocusedNodesNestedInEachOther) || false;
const visibilityCanBeToggled = visibilityToggleAllowed(focusedNodesContextPaths, state);
const canBeEdited = editingAllowed(focusedNodesContextPaths, state);

Expand All @@ -324,7 +323,7 @@ const makeMapStateToProps = isDocument => (state, {nodeTypesRegistry}) => {
isDocument ?
selectors.UI.PageTree.destructiveOperationsAreDisabledForPageTreeSelector(state) :
selectors.CR.Nodes.destructiveOperationsAreDisabledForContentTreeSelector(state)
) || selectionHasNestedNodes;
) || areFocusedNodesNestedInEachOther;
const isLoading = isDocument ? selectors.UI.PageTree.getIsLoading(state) : selectors.UI.ContentTree.getIsLoading(state);

return {
Expand Down