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

FEATURE: Make document tree clickable #3440

Merged

Conversation

pKallert
Copy link
Contributor

@pKallert pKallert commented Mar 22, 2023

What I did
I changed the document tree elements into links so that we can open them with right/middle click

How I did it
Since I was not sure how to get the URL (neos/content) from the Node I tried around a little bit and changed the NodeInfoHelper to add the backendUri. I tried to adhere as much as possible to the currently existing "uri" property in the node. If there is a better place for this, I am ready to learn 😄

Some googling told me that a tags without href are valid so I chose to exchange all of the spans into a-tag. Works still as expected.

How to verify it

Links now show up in the left document tree:

Bildschirmfoto 2023-03-22 um 16 15 50

closes #3353

@github-actions github-actions bot added Feature Label to mark the change as feature 8.3 labels Mar 22, 2023
@mhsdesign
Copy link
Member

mhsdesign commented Mar 22, 2023

Nice one, noticed that also here: #3241 (comment)

Im not sure why we need another uri (the backenduri) on the node (seems like a bad idea performance wise and also technically) but have to look into this deeper

Classes/Fusion/Helper/NodeInfoHelper.php Outdated Show resolved Hide resolved
Classes/Fusion/Helper/NodeInfoHelper.php Outdated Show resolved Hide resolved
Classes/Fusion/Helper/NodeInfoHelper.php Outdated Show resolved Hide resolved
@pKallert
Copy link
Contributor Author

pKallert commented Mar 23, 2023

Nice one, noticed that also here: #3241 (comment)

Im not sure why we need another uri (the backenduri) on the node (seems like a bad idea performance wise and also technically) but have to look into this deeper

@mhsdesign
I thought adding it to the node would be cleaner and reusable but if there is concern about the impact on the performance I can also use the solution from the alt+click from here: https://github.com/neos/neos-ui/blob/8.3/packages/neos-ui/src/Containers/LeftSideBar/NodeTree/index.js#L62

@markusguenther
Copy link
Member

The end to end tests failed because the fluid version is not working. TYPO3/Fluid@24f4494

But guess a new build would work since today 2.7.4 has been released.

@crydotsnake crydotsnake self-requested a review March 24, 2023 19:18
@pKallert pKallert requested a review from Sebobo April 3, 2023 14:35
@markusguenther
Copy link
Member

Will check it later today

@mhsdesign
Copy link
Member

mhsdesign commented Apr 5, 2023

question is, what to do with the legacy onClick logic?

onClick

handleNodeClick = e => {
const {node, onNodeFocus, onNodeClick, isFocused, reload} = this.props;
const metaKeyPressed = e.metaKey || e.ctrlKey;
const shiftKeyPressed = e.shiftKey;
const altKeyPressed = e.altKey;
// Trigger reload if clicking on the current document node
if (isFocused && reload) {
reload();
}
// Append presetBaseNodeType param to src
const srcWithBaseNodeType = this.props.filterNodeType ? urlWithParams(
$get('uri', node),
{presetBaseNodeType: this.props.filterNodeType}
) : $get('uri', node);
onNodeFocus(node.contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed);
onNodeClick(srcWithBaseNodeType, node.contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed);
}

onNodeClick

handleClick = (src, contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed) => {
const {setActiveContentCanvasSrc, setActiveContentCanvasContextPath, requestScrollIntoView} = this.props;
if (altKeyPressed) {
window.open(window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '') + window.location.pathname + '?node=' + contextPath);
return;
}
if (metaKeyPressed || shiftKeyPressed) {
return;
}
// Set a flag that will imperatively tell ContentCanvas to scroll to focused node
if (requestScrollIntoView) {
requestScrollIntoView(true);
}
if (setActiveContentCanvasSrc) {
setActiveContentCanvasSrc(src);
}
if (setActiveContentCanvasContextPath) {
setActiveContentCanvasContextPath(contextPath);
}

pKallert and others added 5 commits April 11, 2023 13:17
Co-authored-by: Marc Henry Schultz <85400359+mhsdesign@users.noreply.github.com>
Co-authored-by: Marc Henry Schultz <85400359+mhsdesign@users.noreply.github.com>
@markusguenther markusguenther force-pushed the feature/makeContentTreeClickableLink branch from 92aa7aa to a9d3b88 Compare April 11, 2023 11:17
@markusguenther
Copy link
Member

markusguenther commented Apr 12, 2023

While testing and fixing the End-to-end tests I stumbled over the issue that the multiple move of nodes is broken. Will try to fix that.

Only via Toolbar it is not working yet.
https://app.circleci.com/pipelines/github/neos/neos-ui/3370/workflows/48dac434-bd95-42bf-92bc-67948b9a2c53/jobs/15353

@markusguenther markusguenther force-pushed the feature/makeContentTreeClickableLink branch from 6a1d841 to e3d185e Compare April 12, 2023 19:47
@markusguenther
Copy link
Member

markusguenther commented Apr 12, 2023

@markusguenther markusguenther merged commit 69564eb into neos:8.3 Apr 12, 2023
@markusguenther
Copy link
Member

question is, what to do with the legacy onClick logic?

onClick

handleNodeClick = e => {
const {node, onNodeFocus, onNodeClick, isFocused, reload} = this.props;
const metaKeyPressed = e.metaKey || e.ctrlKey;
const shiftKeyPressed = e.shiftKey;
const altKeyPressed = e.altKey;
// Trigger reload if clicking on the current document node
if (isFocused && reload) {
reload();
}
// Append presetBaseNodeType param to src
const srcWithBaseNodeType = this.props.filterNodeType ? urlWithParams(
$get('uri', node),
{presetBaseNodeType: this.props.filterNodeType}
) : $get('uri', node);
onNodeFocus(node.contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed);
onNodeClick(srcWithBaseNodeType, node.contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed);
}

onNodeClick

handleClick = (src, contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed) => {
const {setActiveContentCanvasSrc, setActiveContentCanvasContextPath, requestScrollIntoView} = this.props;
if (altKeyPressed) {
window.open(window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '') + window.location.pathname + '?node=' + contextPath);
return;
}
if (metaKeyPressed || shiftKeyPressed) {
return;
}
// Set a flag that will imperatively tell ContentCanvas to scroll to focused node
if (requestScrollIntoView) {
requestScrollIntoView(true);
}
if (setActiveContentCanvasSrc) {
setActiveContentCanvasSrc(src);
}
if (setActiveContentCanvasContextPath) {
setActiveContentCanvasContextPath(contextPath);
}

This logic is still used on a higher layer for the multi operations on nodes.
Have tested the feature and made the tests work again.

@mhsdesign
Copy link
Member

question is, what to do with the legacy onClick logic?
onClick

handleNodeClick = e => {
const {node, onNodeFocus, onNodeClick, isFocused, reload} = this.props;
const metaKeyPressed = e.metaKey || e.ctrlKey;
const shiftKeyPressed = e.shiftKey;
const altKeyPressed = e.altKey;
// Trigger reload if clicking on the current document node
if (isFocused && reload) {
reload();
}
// Append presetBaseNodeType param to src
const srcWithBaseNodeType = this.props.filterNodeType ? urlWithParams(
$get('uri', node),
{presetBaseNodeType: this.props.filterNodeType}
) : $get('uri', node);
onNodeFocus(node.contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed);
onNodeClick(srcWithBaseNodeType, node.contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed);
}

onNodeClick

handleClick = (src, contextPath, metaKeyPressed, altKeyPressed, shiftKeyPressed) => {
const {setActiveContentCanvasSrc, setActiveContentCanvasContextPath, requestScrollIntoView} = this.props;
if (altKeyPressed) {
window.open(window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '') + window.location.pathname + '?node=' + contextPath);
return;
}
if (metaKeyPressed || shiftKeyPressed) {
return;
}
// Set a flag that will imperatively tell ContentCanvas to scroll to focused node
if (requestScrollIntoView) {
requestScrollIntoView(true);
}
if (setActiveContentCanvasSrc) {
setActiveContentCanvasSrc(src);
}
if (setActiveContentCanvasContextPath) {
setActiveContentCanvasContextPath(contextPath);
}

This logic is still used on a higher layer for the multi operations on nodes. Have tested the feature and made the tests work again.

This legacy second way now introduces a lot of complexity — and we must clean it up please 😅 (or share the logic, comment it and explain how things work and why this would be necessary) otherwise it’s really hard for future people to make sense of the code

This pr is only okay as intermediate step …

@markusguenther
Copy link
Member

This legacy second way now introduces a lot of complexity — and we must clean it up please 😅 (or share the logic, comment it and explain how things work and why this would be necessary) otherwise it’s really hard for future people to make sense of the code

This pr is only okay as intermediate step …

Indeed ... we have an issue for making the tree accessible and as I watched into it some months ago I realized that it will need a bit further adjustments on the markup to achieve that. With the change from Paula, we have a first step.

#2938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.3 Feature Label to mark the change as feature
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Feature: Make documents in pagetree into a link
4 participants