diff --git a/packages/neos-ui-guest-frame/src/initializeGuestFrame.js b/packages/neos-ui-guest-frame/src/initializeGuestFrame.js index cf914be9fa..1e85f251f0 100644 --- a/packages/neos-ui-guest-frame/src/initializeGuestFrame.js +++ b/packages/neos-ui-guest-frame/src/initializeGuestFrame.js @@ -52,8 +52,7 @@ export default ({globalRegistry, store}) => function * initializeGuestFrame() { // Remove the inline scripts after initialization Array.prototype.forEach.call(guestFrameWindow.document.querySelectorAll('script[data-neos-nodedata]'), element => element.parentElement.removeChild(element)); - yield put(actions.CR.Nodes.setSiteNode(documentInformation.metaData.siteNode)); - yield put(actions.CR.Nodes.setDocumentNode(documentInformation.metaData.documentNode)); + yield put(actions.CR.Nodes.setDocumentNode(documentInformation.metaData.documentNode, documentInformation.metaData.siteNode)); yield put(actions.UI.ContentCanvas.setPreviewUrl(documentInformation.metaData.previewUrl)); yield put(actions.CR.ContentDimensions.setActive(documentInformation.metaData.contentDimensions.active)); // The user may have navigated by clicking an inline link - that's why we need to update the contentCanvas URL to be in sync with the shown content. diff --git a/packages/neos-ui-redux-store/src/CR/Nodes/index.ts b/packages/neos-ui-redux-store/src/CR/Nodes/index.ts index ebf2d13c6f..096d71fc9e 100644 --- a/packages/neos-ui-redux-store/src/CR/Nodes/index.ts +++ b/packages/neos-ui-redux-store/src/CR/Nodes/index.ts @@ -59,7 +59,6 @@ export enum actionTypes { REMOVAL_ABORTED = '@neos/neos-ui/CR/Nodes/REMOVAL_ABORTED', REMOVAL_CONFIRMED = '@neos/neos-ui/CR/Nodes/REMOVAL_CONFIRMED', REMOVE = '@neos/neos-ui/CR/Nodes/REMOVE', - SET_SITE_NODE = '@neos/neos-ui/CR/Nodes/SET_SITE_NODE', SET_DOCUMENT_NODE = '@neos/neos-ui/CR/Nodes/SET_DOCUMENT_NODE', SET_STATE = '@neos/neos-ui/CR/Nodes/SET_STATE', RELOAD_STATE = '@neos/neos-ui/CR/Nodes/RELOAD_STATE', @@ -150,18 +149,9 @@ const confirmRemoval = () => createAction(actionTypes.REMOVAL_CONFIRMED); const remove = (contextPath: NodeContextPath) => createAction(actionTypes.REMOVE, contextPath); /** - * Set site node - * - * @param {String} contextPath The context path of the site node - */ -const setSiteNode = (contextPath: NodeContextPath) => createAction(actionTypes.SET_SITE_NODE, contextPath); - -/** - * Set the document node - * - * @param {String} contextPath The context path of the document node + * Set the document node and optionally site node */ -const setDocumentNode = (contextPath: NodeContextPath) => createAction(actionTypes.SET_DOCUMENT_NODE, contextPath); +const setDocumentNode = (documentNode: NodeContextPath, siteNode?: NodeContextPath) => createAction(actionTypes.SET_DOCUMENT_NODE, {documentNode, siteNode}); /** * Set CR state on page load or after dimensions or workspaces switch @@ -249,7 +239,7 @@ const paste = (contextPath: NodeContextPath, fusionPath: string) => createAction const commitPaste = (clipboardMode: ClipboardMode) => createAction(actionTypes.COMMIT_PASTE, clipboardMode); /** - * Hide the given node + * Hide the given node draft.documentNode !== action.payload * * @param {String} contextPath The context path of the node to be hidden */ @@ -285,7 +275,6 @@ export const actions = { abortRemoval, confirmRemoval, remove, - setSiteNode, setDocumentNode, setState, reloadState, @@ -420,13 +409,12 @@ export const subReducer = (state: State = defaultState, action: InitAction | Act delete draft.byContextPath[action.payload]; break; } - case actionTypes.SET_SITE_NODE: { - draft.siteNode = action.payload; - break; - } case actionTypes.SET_DOCUMENT_NODE: { - if (draft.documentNode !== action.payload) { - draft.documentNode = action.payload; + if (action.payload.siteNode) { + draft.siteNode = action.payload.siteNode; + } + if (draft.documentNode !== action.payload.documentNode) { + draft.documentNode = action.payload.documentNode; // If context path changed, ensure to reset the "focused node". Otherwise, when switching // to different Document nodes and having a (content) node selected previously, the Inspector // does not properly refresh. We just need to ensure that everytime we switch pages, we @@ -442,7 +430,9 @@ export const subReducer = (state: State = defaultState, action: InitAction | Act draft.documentNode = documentNodeContextPath; draft.focused.contextPath = null; draft.focused.fusionPath = null; - draft.byContextPath = merge ? mergeDeepRight(draft.byContextPath, nodes) : nodes; + if (nodes) { + draft.byContextPath = merge ? mergeDeepRight(draft.byContextPath, nodes) : nodes; + } break; } case actionTypes.COPY: { diff --git a/packages/neos-ui-sagas/src/Browser/index.js b/packages/neos-ui-sagas/src/Browser/index.js index b06aab335b..a81a8a5c52 100644 --- a/packages/neos-ui-sagas/src/Browser/index.js +++ b/packages/neos-ui-sagas/src/Browser/index.js @@ -2,7 +2,7 @@ import {call, takeEvery} from 'redux-saga/effects'; import {actionTypes} from '@neos-project/neos-ui-redux-store'; export function * reflectChangeInAddressBar(action) { - yield call([history, history.replaceState], {}, '', `?node=${encodeURIComponent(action.payload)}`); + yield call([history, history.replaceState], {}, '', `?node=${encodeURIComponent(action.payload.documentNode)}`); } export function * watchContentURIChange() { diff --git a/packages/neos-ui-sagas/src/UI/PageTree/index.js b/packages/neos-ui-sagas/src/UI/PageTree/index.js index 9d20ad293c..f009a1beb4 100644 --- a/packages/neos-ui-sagas/src/UI/PageTree/index.js +++ b/packages/neos-ui-sagas/src/UI/PageTree/index.js @@ -80,7 +80,7 @@ export function * watchNodeCreated() { export function * watchCurrentDocument({configuration}) { yield takeLatest(actionTypes.CR.Nodes.SET_DOCUMENT_NODE, function * loadDocumentRootLine(action) { - const contextPath = action.payload; + const contextPath = action.payload.documentNode; const siteNodeContextPath = yield select($get('cr.nodes.siteNode')); const {q} = backend.get();