Skip to content

Commit 7020c93

Browse files
committed
TASK: Remove plow-js from @neos-project/neos-ui-sagas
1 parent 1f4766c commit 7020c93

File tree

17 files changed

+114
-86
lines changed

17 files changed

+114
-86
lines changed

packages/neos-ui-sagas/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"@neos-project/neos-ui-redux-store": "workspace:*",
2626
"lodash.escaperegexp": "^4.1.2",
2727
"mousetrap": "^1.6.3",
28-
"plow-js": "^2.2.0",
2928
"redux-saga": "^0.15.0"
3029
},
3130
"license": "GNU GPLv3",

packages/neos-ui-sagas/src/CR/ContentDimensions/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {put, select, race, take, takeLatest, takeEvery, call} from 'redux-saga/effects';
2-
import {$get} from 'plow-js';
32

43
import {actions, actionTypes, selectors} from '@neos-project/neos-ui-redux-store';
54
import backend from '@neos-project/neos-ui-backend-connector';
@@ -22,7 +21,7 @@ export function * watchSelectPreset() {
2221
yield take(actionTypes.CR.ContentDimensions.SELECT_PRESET);
2322
const targetDimensions = yield select(selectors.CR.ContentDimensions.active);
2423
const currentContentCanvasNode = yield select(selectors.CR.Nodes.documentNodeSelector);
25-
const currentContentCanvasNodeIdentifier = $get('identifier', currentContentCanvasNode);
24+
const currentContentCanvasNodeIdentifier = currentContentCanvasNode?.identifier;
2625

2726
const informationAboutNodeInTargetDimension = yield call(ensureNodeInSelectedDimension, {
2827
nodeIdentifier: currentContentCanvasNodeIdentifier,
@@ -67,7 +66,9 @@ function * ensureNodeInSelectedDimension({nodeIdentifier, sourceDimensions, targ
6766
getSingleNode,
6867
adoptNodeToOtherDimension
6968
} = backend.get().endpoints;
70-
const currentWorkspaceName = yield select($get('cr.workspaces.personalWorkspace.name'));
69+
const currentWorkspaceName = yield select(
70+
(state) => state?.cr?.workspaces?.personalWorkspace?.name
71+
);
7172

7273
const {
7374
nodeFound,

packages/neos-ui-sagas/src/CR/NodeOperations/addNode.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {takeLatest, take, put, race, call, select} from 'redux-saga/effects';
2-
import {$get} from 'plow-js';
32

43
import {actions, actionTypes, selectors} from '@neos-project/neos-ui-redux-store';
54

@@ -54,8 +53,8 @@ function * nodeCreationWorkflow(context, step = STEP_SELECT_NODETYPE, workflowDa
5453
}
5554
case STEP_NODE_CREATION_DIALOG: {
5655
const nodeType = nodeTypesRegistry.get(workflowData.nodeType);
57-
const label = $get('label', nodeType);
58-
const configuration = $get('ui.creationDialog', nodeType);
56+
const label = nodeType?.label;
57+
const configuration = nodeType?.ui?.creationDialog;
5958
if (configuration) {
6059
//
6160
// This node type has a creationDialog configuration,
@@ -97,7 +96,9 @@ function * nodeCreationWorkflow(context, step = STEP_SELECT_NODETYPE, workflowDa
9796

9897
const referenceNodeSelector = selectors.CR.Nodes.makeGetNodeByContextPathSelector(referenceNodeContextPath);
9998
const referenceNode = yield select(referenceNodeSelector);
100-
const baseNodeType = yield select($get('ui.pageTree.filterNodeType'));
99+
const baseNodeType = yield select(
100+
(state) => state?.ui?.pageTree?.filterNodeType
101+
);
101102
const data = yield * applySaveHooksForTransientValuesMap(transientValues, saveHooksRegistry);
102103

103104
return yield put(actions.Changes.persistChanges([{

packages/neos-ui-sagas/src/CR/NodeOperations/moveDroppedNode.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {takeEvery, put, select} from 'redux-saga/effects';
2-
import {$get} from 'plow-js';
32

43
import {actions, actionTypes, selectors} from '@neos-project/neos-ui-redux-store';
54

@@ -11,7 +10,9 @@ export default function * moveDroppedNode() {
1110

1211
const referenceNodeSelector = selectors.CR.Nodes.makeGetNodeByContextPathSelector(reference);
1312
const referenceNode = yield select(referenceNodeSelector);
14-
const baseNodeType = yield select($get('ui.pageTree.filterNodeType'));
13+
const baseNodeType = yield select(
14+
(state) => state?.ui?.pageTree?.filterNodeType
15+
);
1516

1617
yield put(actions.Changes.persistChanges([{
1718
type: calculateChangeTypeFromMode(position, 'Move'),

packages/neos-ui-sagas/src/CR/NodeOperations/pasteNode.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {takeEvery, put, select, call} from 'redux-saga/effects';
2-
import {$get} from 'plow-js';
32

43
import {selectors, actions, actionTypes} from '@neos-project/neos-ui-redux-store';
54

@@ -13,7 +12,9 @@ export default function * pasteNode({globalRegistry}) {
1312

1413
yield takeEvery(actionTypes.CR.Nodes.PASTE, function * waitForPaste(action) {
1514
const subject = yield select(selectors.CR.Nodes.clipboardNodesContextPathsSelector);
16-
const clipboardMode = yield select($get('cr.nodes.clipboardMode'));
15+
const clipboardMode = yield select(
16+
(state) => state?.cr?.nodes?.clipboardMode
17+
);
1718

1819
const {contextPath: reference, fusionPath} = action.payload;
1920
const state = yield select();
@@ -38,7 +39,9 @@ export default function * pasteNode({globalRegistry}) {
3839
if (mode) {
3940
const referenceNodeSelector = selectors.CR.Nodes.makeGetNodeByContextPathSelector(reference);
4041
const referenceNode = yield select(referenceNodeSelector);
41-
const baseNodeType = yield select($get('ui.pageTree.filterNodeType'));
42+
const baseNodeType = yield select(
43+
(state) => state?.ui?.pageTree?.filterNodeType
44+
);
4245

4346
yield put(actions.CR.Nodes.commitPaste(clipboardMode));
4447
const changes = subject.map(contextPath => ({

packages/neos-ui-sagas/src/CR/NodeOperations/reloadState.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {takeLatest, put, select} from 'redux-saga/effects';
2-
import {$get} from 'plow-js';
2+
33
import backend from '@neos-project/neos-ui-backend-connector';
44

55
import {selectors, actions, actionTypes} from '@neos-project/neos-ui-redux-store';
@@ -8,11 +8,15 @@ export default function * watchReloadState({configuration}) {
88
yield takeLatest(actionTypes.CR.Nodes.RELOAD_STATE, function * reloadState(action) {
99
const {q} = backend.get();
1010

11-
const currentSiteNodeContextPath = yield select($get('cr.nodes.siteNode'));
11+
const currentSiteNodeContextPath = yield select(
12+
(state) => state?.cr?.nodes?.siteNode
13+
);
1214
const clipboardNodesContextPaths = yield select(selectors.CR.Nodes.clipboardNodesContextPathsSelector);
13-
const toggledNodes = yield select($get('ui.pageTree.toggled'));
14-
const siteNodeContextPath = $get('payload.siteNodeContextPath', action) || currentSiteNodeContextPath;
15-
const documentNodeContextPath = yield $get('payload.documentNodeContextPath', action) || select($get('cr.nodes.documentNode'));
15+
const toggledNodes = yield select(
16+
(state) => state?.ui?.pageTree?.toggled
17+
);
18+
const siteNodeContextPath = action?.payload?.siteNodeContextPath || currentSiteNodeContextPath;
19+
const documentNodeContextPath = yield action?.payload?.documentNodeContextPath || select((state) => state?.cr?.nodes?.documentNode);
1620
yield put(actions.CR.Nodes.setDocumentNode(documentNodeContextPath, currentSiteNodeContextPath));
1721
yield put(actions.UI.PageTree.setAsLoading(currentSiteNodeContextPath));
1822
const nodes = yield q([siteNodeContextPath, documentNodeContextPath]).neosUiDefaultNodes(
@@ -22,14 +26,14 @@ export default function * watchReloadState({configuration}) {
2226
clipboardNodesContextPaths
2327
).getForTree();
2428
const nodeMap = nodes.reduce((nodeMap, node) => {
25-
nodeMap[$get('contextPath', node)] = node;
29+
nodeMap[node?.contextPath] = node;
2630
return nodeMap;
2731
}, {});
2832
yield put(actions.CR.Nodes.setState({
2933
siteNodeContextPath,
3034
documentNodeContextPath,
3135
nodes: nodeMap,
32-
merge: $get('payload.merge', action)
36+
merge: action?.payload?.merge
3337
}));
3438
yield put(actions.UI.PageTree.setAsLoaded(currentSiteNodeContextPath));
3539
});

packages/neos-ui-sagas/src/CR/NodeOperations/removeNodeIfConfirmed.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {takeLatest, take, put, race, select} from 'redux-saga/effects';
2-
import {$get} from 'plow-js';
32

43
import {actions, actionTypes} from '@neos-project/neos-ui-redux-store';
54

@@ -17,7 +16,7 @@ export default function * removeNodeIfConfirmed() {
1716
}
1817

1918
if (nextAction.type === actionTypes.CR.Nodes.REMOVAL_CONFIRMED) {
20-
const nodesToBeRemovedContextPath = $get('cr.nodes.toBeRemoved', state);
19+
const nodesToBeRemovedContextPath = state?.cr?.nodes?.toBeRemoved;
2120
const changes = nodesToBeRemovedContextPath.map(nodeToBeRemovedContextPath => ({
2221
type: 'Neos.Neos.Ui:RemoveNode',
2322
subject: nodeToBeRemovedContextPath

packages/neos-ui-sagas/src/CR/Policies/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {select, take, put, fork} from 'redux-saga/effects';
2-
import {$get} from 'plow-js';
2+
33
import {actions, actionTypes, selectors} from '@neos-project/neos-ui-redux-store';
44
import backend from '@neos-project/neos-ui-backend-connector';
55

@@ -30,11 +30,11 @@ export function * watchNodeInformationChanges() {
3030
const nodesWithoutAdditionalMetadata = Object.keys(nodeMap).filter(contextPath => {
3131
const node = selectors.CR.Nodes.nodeByContextPath(state)(contextPath);
3232

33-
if ($get('properties._removed', node)) {
33+
if (node?.properties?._removed) {
3434
return false;
3535
}
3636

37-
const policyInfo = $get('policy', node);
37+
const policyInfo = node?.policy;
3838
return (!policyInfo);
3939
});
4040

packages/neos-ui-sagas/src/Changes/index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {takeEvery, put, call, select} from 'redux-saga/effects';
2-
import {$get} from 'plow-js';
32

43
import {actionTypes, actions, selectors} from '@neos-project/neos-ui-redux-store';
54
import backend from '@neos-project/neos-ui-backend-connector';
@@ -16,12 +15,12 @@ function * persistChanges(changes) {
1615
yield put(actions.ServerFeedback.handleServerFeedback(feedback));
1716

1817
const state = yield select();
19-
const isAutoPublishingEnabled = $get('user.settings.isAutoPublishingEnabled', state);
18+
const isAutoPublishingEnabled = state?.user?.settings?.isAutoPublishingEnabled ?? false;
2019

2120
if (isAutoPublishingEnabled) {
2221
const baseWorkspace = baseWorkspaceSelector(state);
2322
const publishableNodesInDocument = publishableNodesInDocumentSelector(state);
24-
yield put(actions.CR.Workspaces.publish(publishableNodesInDocument.map($get('contextPath')), baseWorkspace));
23+
yield put(actions.CR.Workspaces.publish(publishableNodesInDocument.map((node) => node?.contextPath), baseWorkspace));
2524
}
2625
} catch (error) {
2726
console.error('Failed to persist changes', error);
@@ -54,7 +53,7 @@ export function * watchPersist() {
5453
// If there's already a pending request, don't start the new one;
5554
// the data will be stored in `changes` closure and when the current request finishes saving
5655
// it will be re-triggered by FINISH_SAVING
57-
if (changes.length > 0 && !$get('ui.remote.isSaving', state)) {
56+
if (changes.length > 0 && !state?.ui?.remote?.isSaving) {
5857
// we need to clear out the changes array before yield, so the best I could think of is this
5958
const clonedChanges = changes.slice(0);
6059
changes = [];

packages/neos-ui-sagas/src/Publish/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {put, call, select, takeEvery, takeLatest, take, race} from 'redux-saga/effects';
2-
import {$get} from 'plow-js';
32

43
import {actionTypes, actions, selectors} from '@neos-project/neos-ui-redux-store';
54
import backend from '@neos-project/neos-ui-backend-connector';
@@ -30,11 +29,11 @@ export function * watchPublish() {
3029
export function * watchToggleAutoPublish() {
3130
yield takeEvery(actionTypes.User.Settings.TOGGLE_AUTO_PUBLISHING, function * publishInitially() {
3231
const state = yield select();
33-
const isAutoPublishingEnabled = $get('user.settings.isAutoPublishingEnabled', state);
32+
const isAutoPublishingEnabled = state?.user?.settings?.isAutoPublishingEnabled;
3433

3534
if (isAutoPublishingEnabled) {
3635
const publishableNodesInDocument = publishableNodesInDocumentSelector(state);
37-
yield put(actions.CR.Workspaces.publish(publishableNodesInDocument.map($get('contextPath')), 'live'));
36+
yield put(actions.CR.Workspaces.publish(publishableNodesInDocument.map((node) => node?.contextPath), 'live'));
3837
}
3938
});
4039
}
@@ -43,7 +42,9 @@ export function * watchChangeBaseWorkspace() {
4342
const {changeBaseWorkspace} = backend.get().endpoints;
4443
yield takeEvery(actionTypes.CR.Workspaces.CHANGE_BASE_WORKSPACE, function * change(action) {
4544
try {
46-
const documentNode = yield select($get('cr.nodes.documentNode'));
45+
const documentNode = yield select(
46+
(state) => state?.cr?.nodes?.documentNode
47+
);
4748
const feedback = yield call(changeBaseWorkspace, action.payload, documentNode);
4849
yield put(actions.ServerFeedback.handleServerFeedback(feedback));
4950

@@ -71,7 +72,7 @@ export function * discardIfConfirmed() {
7172

7273
if (nextAction.type === actionTypes.CR.Workspaces.DISCARD_CONFIRMED) {
7374
yield put(actions.UI.Remote.startDiscarding());
74-
const nodesToBeDiscarded = $get('cr.workspaces.toBeDiscarded', state);
75+
const nodesToBeDiscarded = state?.cr?.workspaces?.toBeDiscarded;
7576

7677
try {
7778
const currentContentCanvasContextPath = yield select(selectors.CR.Nodes.documentNodeContextPathSelector);

packages/neos-ui-sagas/src/UI/ContentCanvas/index.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {delay} from 'redux-saga';
22
import {takeLatest, put, select, take, race} from 'redux-saga/effects';
3-
import {$get} from 'plow-js';
3+
44
import {getGuestFrameDocument} from '@neos-project/neos-ui-guest-frame/src/dom';
55

66
import {actionTypes, actions} from '@neos-project/neos-ui-redux-store';
@@ -11,9 +11,11 @@ import {actionTypes, actions} from '@neos-project/neos-ui-redux-store';
1111
export function * watchNodeCreated() {
1212
yield takeLatest(actionTypes.UI.Remote.DOCUMENT_NODE_CREATED, function * nodeCreated(action) {
1313
const {contextPath} = action.payload;
14-
const node = yield select($get(['cr', 'nodes', 'byContextPath', contextPath]));
14+
const node = yield select(
15+
(state) => state?.cr?.nodes?.byContextPath?.[contextPath]
16+
);
1517
yield put(actions.CR.Nodes.setDocumentNode(contextPath));
16-
yield put(actions.UI.ContentCanvas.setSrc($get('uri', node)));
18+
yield put(actions.UI.ContentCanvas.setSrc(node?.uri));
1719
});
1820
}
1921
/**
@@ -44,7 +46,9 @@ export function * watchStopLoading({globalRegistry, store}) {
4446
export function * watchReload() {
4547
yield takeLatest(actionTypes.UI.ContentCanvas.RELOAD, function * (action) {
4648
const {uri} = action.payload;
47-
const currentIframeUrl = yield select($get('ui.contentCanvas.src'));
49+
const currentIframeUrl = yield select(
50+
(state) => state?.ui?.contentCanvas?.src
51+
);
4852

4953
[].slice.call(document.querySelectorAll(`iframe[name=neos-content-main]`)).forEach(iframe => {
5054
const iframeWindow = iframe.contentWindow || iframe;
@@ -65,7 +69,9 @@ export function * watchControlOverIFrame() {
6569
yield take(actionTypes.System.READY);
6670

6771
while (true) { //eslint-disable-line
68-
const src = yield select($get('ui.contentCanvas.src'));
72+
const src = yield select(
73+
(state) => state?.ui?.contentCanvas?.src
74+
);
6975
const waitForNextAction = yield race([
7076
take(actionTypes.UI.ContentCanvas.SET_SRC),
7177
take(actionTypes.UI.ContentCanvas.REQUEST_REGAIN_CONTROL),

0 commit comments

Comments
 (0)