Skip to content

Commit e5697d4

Browse files
committed
FEATURE: documentNodesOnly
1 parent d281d38 commit e5697d4

4 files changed

Lines changed: 57 additions & 22 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ Neos:
4141
restrictCreation:
4242
mode: warn
4343
originPreset: en_US
44+
documentNodesOnly: true
4445
```
4546

4647
`mode: warn` would only give a warning about creating a node in a possible wrong dimensiong.
4748
`mode: disallow` would completely forbid creating new nodes in a certain dimension.
49+
`documentNodesOnly: true` would trigger the warning only for document nodes: you would be able to create content nodes as usual, but creating document nodes in that dimension would be blocked/warned.
4850

4951
## Acknowledgments
5052

Resources/Private/RestrictCreation/src/sagas.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {takeLatest, take, select, call, put, race} from 'redux-saga/effects';
22
import {$get} from 'plow-js';
3-
import {actionTypes} from '@neos-project/neos-ui-redux-store';
3+
import {actionTypes, selectors} from '@neos-project/neos-ui-redux-store';
44
import {actions as localActions, actionTypes as localActionTypes, selectors as localSelectors} from './redux';
55
import {crNodeOperations} from '@neos-project/neos-ui-sagas';
66

@@ -12,14 +12,25 @@ export function * addNode({globalRegistry}) {
1212

1313
const state = yield select();
1414
const restrictCreationPreset = localSelectors.restrictCreationSelector(state);
15-
const restrictCreationMode = $get('restrictCreation.mode', restrictCreationPreset);
15+
16+
// Show restrict creation dialog if mode is not null
17+
let showRestrictCreationDialog = Boolean($get('restrictCreation.mode', restrictCreationPreset));
18+
const documentNodesOnly = $get('restrictCreation.documentNodesOnly', restrictCreationPreset);
19+
20+
if (documentNodesOnly) {
21+
const getNodeByContextPathSelector = selectors.CR.Nodes.makeGetNodeByContextPathSelector(referenceNodeContextPath);
22+
const referenceNode = yield select(getNodeByContextPathSelector);
23+
const isDocument = nodeTypesRegistry.hasRole($get('nodeType', referenceNode), 'document');
24+
// Skip the dialog if not document node
25+
showRestrictCreationDialog = isDocument;
26+
}
1627

1728
const context = {
1829
nodeTypesRegistry,
1930
referenceNodeContextPath,
2031
referenceNodeFusionPath
2132
};
22-
if (restrictCreationMode) {
33+
if (showRestrictCreationDialog) {
2334
yield put(localActions.openDialog());
2435
const waitForNextAction = yield race([
2536
take(localActionTypes.OPEN_DIALOG),

Resources/Public/JavaScript/RestrictCreation/Plugin.js

Lines changed: 40 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Resources/Public/JavaScript/RestrictCreation/Plugin.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)