Skip to content

Commit

Permalink
TASK: remove separate setSiteNode action, as it's dangerous to set it…
Browse files Browse the repository at this point in the history
… separately
  • Loading branch information
dimaip committed Dec 15, 2018
1 parent 53c895e commit 8404fd3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
3 changes: 1 addition & 2 deletions packages/neos-ui-guest-frame/src/initializeGuestFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
32 changes: 11 additions & 21 deletions packages/neos-ui-redux-store/src/CR/Nodes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -285,7 +275,6 @@ export const actions = {
abortRemoval,
confirmRemoval,
remove,
setSiteNode,
setDocumentNode,
setState,
reloadState,
Expand Down Expand Up @@ -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
Expand All @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion packages/neos-ui-sagas/src/Browser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion packages/neos-ui-sagas/src/UI/PageTree/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 8404fd3

Please sign in to comment.