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
node.context.InBackend is set wrong when previewing content #3019
Comments
If that's hard to fix right now, I would love a discussion about workarounds and if they are valid:
|
Not a full answer but does it already help to check the workspace instead via |
Hey everybody, We've just analyzed the issue a bit further:
I'd say both of the behavior is not correct; or what the user expects. What do we want to archive?When clicking the preview, the editor wants to see the current editing state of his personal workspace, as if it were live (even if the workspace is not published). This means:
Suggested behavior change
@markusguenther @bwaidelich @Sebobo @kitsunet @paavolimbo What do you think about this proposal? Open QuestionFor what release do we want to fix this? I'd say 5.3, because we changed the behavior in this area (and would need to build the fix twice otherwise) All the best, |
(reminder to self: Timebox for the project: 4h) |
I recently fixed some stuff in that regard, where the preview link did not update after changes were made and the resulting url was broken: neos/neos-ui#2744 The problem was that there are several cases. We need to make clear which mode we want, which dimension, which workspace, lots of stuff. So a fix should go to the same version, I think 5.2 possibly. But the preview link was never fully correct. |
Additional Brain-Dump related to node.context.inBackend |
For me the preview link points to (this doesn't make sense either of course, but I can't reproduce what you described) In any case I support the idea of introducing yet another route for the actual preview (naming that new route "preview" wasn't a good idea of mine – I was thinking of the editor preview in the iFrame) |
I think the following solution would make sense:
Alternative to 2b the One advantage of that approach would be that the preview link URL would be fixed (no need to update it on the client side when changes were published/discarded) |
@bwaidelich totally makes sense :) |
FYI: I plan to work on this on Monday // fix it. |
After talking to @skurfuerst we realized that it has to be a separate route because we need to stay in the "preview" mode even if you navigate through the page (otherwise you'd be "caught" in live mode once you navigate to a node without unpublished changes). Ultimately we'll probably need two buttons (or a split button or whatever makes sense UX wise). One to open the current page in the live mode (if the node exists in live) and one to get a preview of the current page. And the preview mode could get some "PREVIEW" badge, potentially with a link to the live version. Some more things we discussed (memory aid):
This probably sounds like more work than it (hopefully) is. But it will contain profound changes so it can only be implemented with the next major release (due in December). |
Yes, sounds like a good "temporary solution" as this is what the user (our users) expect. |
Yep, that seems like a valid temporary solution! Okay with me and I like your long term solution for the next major 👍 Thanks! |
The further plans (split button to choose live/preview of own workspace (without hidden content nodes)) sounds like great plan, looking forward to that. |
OK, I dug a bit deeper and implemented a first draft: ...only to realize that we already have in fact a preview mode: So, this would be my new favorite solution: Short term (bugfix)The following three lines actually led to the bug, since the UI replaces the preview link target once the current node is published: https://github.com/neos/neos-ui/blob/5.3.0/packages/neos-ui-sagas/src/Publish/index.js#L24-L27 For a started those lines could just be removed. But that would mean that the user has to re-navigate to a newly generated document node (or refresh the browser) after it has been published because otherwise the preview link will stay inactive. The "invalid" URL is generated here: https://github.com/neos/neos-ui/blob/5.3.0/Classes/Fusion/Helper/NodeInfoHelper.php#L189 and put into the AJAX feedback. Those lines can be removed anyways, since changing the Long term
|
I totally agree with @DrillSergeant Thanks for your work @bwaidelich 👍 |
I'm happy to see this issue progress so dynamically! :) ❤️ Thanks for all your efforts! In my head this workflow makes sense:
Thus I'm not a fan of a split button, one to "live" and one to "preview", it introduces yet another variant to something that in my point of view does not have a common use case. I cannot imagine explaining the value of this to my customers. If they want to see the live site, they would open the public url and navigate there. That would be a very clear separation of concerns in my head. Live means taking the way the customers do surfing to the live site (easy to grasp concept, just do it like they do and you get what they see ;) ) and anything from Neos is edit/preview-related. As Neos follows a WYSIWYG idea, that would mean "I see and can check/control what I get for my users before publishing" -> this gives control to even more insecure editors before they commit to their edits and hundrets of customers see what they've been working on. Consequently, the route |
With this change the `PreviewButton` of the UI never links to a preview of the node in the personal user workspace. Instead it: * Is disbled if the node is hidden/missing in the base workspace * Points to a `/neos/redirect?<node-in-base-workspace>` URL that redirects to the current node in its base workspace For the "usual editing case" (personal workspace with target == `live`) that means, that clicking the button will lead to the version in the live workspace (i.e. `/the/final/url.html`). For shared workspaces the redirect will point to a preview URL for that workspace (i.e. `/neos/preview?node=<node-in-shared-workspace>`) Fixes: neos/neos-development-collection#3019
Thanks again for all your feedback. There has been some confusion (partly because I got things wrong), but I worked on a PR that fixes the described bug (I hope): neos/neos-ui#2777 To recap the current behavior (with the fix applied):
The bug itself led to the redirect pointing to the edit mode of the personal user workspace in some cases (e.g. when changes where published and the browser wasn't reloaded, the preview URL was updated to point to the wrong target) Note: I concentrated on fixing the current behavior. We could discuss the general usefulness of the whole behavior. But that should belong to a separate issue and be synced with the UX guild! |
With this change the `PreviewButton` of the UI never links to a preview of the node in the personal user workspace. Instead it: * Is disabled if the node is hidden/missing in the base workspace * Points to a `/neos/redirect?<node-in-base-workspace>` URL that redirects to the current node in its base workspace For the "usual editing case" (personal workspace with target == `live`) that means, that clicking the button will lead to the version in the live workspace (i.e. `/the/final/url.html`). For shared workspaces the redirect will point to a preview URL for that workspace (i.e. `/neos/preview?node=<node-in-shared-workspace>`) Fixes: neos/neos-development-collection#3019
aaand finally: neos/neos-ui#2781 includes some fixes @skurfuerst came up with and is created against the lowest affected branch (5.1) |
Hey @klfman @DrillSergeant @paavo , as already explained by @bwaidelich , what we have fixed here is not 100% what I originally intended to change in the original proposal. However, we found numerous code reasons why the "preview" mode as I imagined it originally was error-prone and would likely lead to more subtle bugs, not less. Additionally, we felt that duplicating functionality (i.e. "preview modes" vs "show base workspace in new tab") was not the right direction to take without further thought. Thus, we now fixed the link to always point to the base workspace version (i.e. live or a review workspace); and we suggest to use the condition That leaves one difficult to solve case still open: The preview mode does not hide hidden nodes. This is kinda hard to solve, but I just tried a Fusion workaround which seems to work well:
You can try out this, and see if that works for you :) If it does work well, we can document this on docs.neos.io. All the best, |
@bwaidelich and @skurfuerst thank you guys for fixing the preview-button. Looking forward for the release to roll it out to our customers. About the hidden nodes in preview-mode: This was not an issue for our editors so far. If this comes up, I will dig into it and try you code example. |
…#2781) * BUGFIX: Prevent preview button to link to the personal user workspace With this change the `PreviewButton` of the UI never links to a preview of the node in the personal user workspace. Instead it: * Is disabled if the node is hidden/missing in the base workspace * Points to a `/neos/redirect?<node-in-base-workspace>` URL that redirects to the current node in its base workspace For the "usual editing case" (personal workspace with target == `live`) that means, that clicking the button will lead to the version in the live workspace (i.e. `/the/final/url.html`). For shared workspaces the redirect will point to a preview URL for that workspace (i.e. `/neos/preview?node=<node-in-shared-workspace>`) Fixes: neos/neos-development-collection#3019 * Remove obsolete workspace check from NodeInfoHelper::createRedirectToNode() * Respect the published node when updating the previewUrl In order to prevent the preview button to point to a wrong node after publishing all pending changes
I just tested and merged the change but I want to thank all participants here for the very fruitful discussion. Would be so cool have this on more issues 😄 🥇 for all of you :) |
@paavo Does |
Im using a Helper like this @lorenzulrich what returns
|
I was talking about "Preview Central" @lorenzulrich 😆 |
@paavo Thanks, but your preview is a preview of the LIVE workspace, not a restricted workspace. Maybe I need to post steps to reproduce. |
restricted workspace? the ones published by |
Description
In the Neos backend I often change the rendering of node types to make it easier for the editor to see what they are editing. When they click the "preview" button in the top right of the Neos backend, they expect to see the page as a visitor of their page would see it.
However, in certain cases the value of
node.context.InBackend
istrue
when previewing content. As I use this value in aNeos.Fusion:Case
to determine which rendering should be used (the Neos backend- or the frontend-representation) the content looks "broken" (a.k.a like in the Neos backend) when previewing.I made some tests and found out that this phenomenon appears in cases where the preview url contains the username of the currently logged in user in the backend. Two versions of urls seem to be generated, when editors hit the "preview" button in the top right.
In case 1) everything looks fine and
node.context.InBackend
isfalse
.In case 2)
node.context.InBackend
is unexpectedlytrue
, which breaks my content that relies on that detection mechanism.A thing that I cannot pinpoint is: When and why is
@user-admin
(or any other user likeadmin
) added to the URL. It seems to be added only sometimes.Steps to Reproduce
user-username
part, just add it manuallynode.context.InBackend
is true, even if we are looking at a frontend previewExpected behavior
node.context.InBackend
should never be true in the frontend previewAffected Versions
The text was updated successfully, but these errors were encountered: