Skip to content

Commit

Permalink
Merge pull request #9 from Sebobo/task/add-node-after-create
Browse files Browse the repository at this point in the history
TASK: Refresh node list after a node is created
  • Loading branch information
Sebastian Helzle authored Apr 27, 2018
2 parents b8c3d39 + bdef0e7 commit 5f75097
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
18 changes: 16 additions & 2 deletions Resources/Private/FlatNav/src/FlatNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import {$get, $transform} from 'plow-js';
import {Button, Icon, IconButton, Tabs} from '@neos-project/react-ui-components';
import {connect} from 'react-redux';
import {actions} from '@neos-project/neos-ui-redux-store';
import {actions, selectors} from '@neos-project/neos-ui-redux-store';
import {neos} from '@neos-project/neos-ui-decorators';
import {fetchWithErrorHandling} from '@neos-project/neos-ui-backend-connector';
import HideSelectedNode from './HideSelectedNode';
Expand Down Expand Up @@ -150,7 +150,8 @@ const makeFlatNavContainer = OriginalPageTree => {
export default makeFlatNavContainer;

@neos(globalRegistry => ({
nodeTypesRegistry: globalRegistry.get('@neos-project/neos-ui-contentrepository')
nodeTypesRegistry: globalRegistry.get('@neos-project/neos-ui-contentrepository'),
serverFeedbackHandlers: globalRegistry.get('serverFeedbackHandlers')
}))
@connect($transform({
nodeData: $get('cr.nodes.byContextPath'),
Expand Down Expand Up @@ -181,6 +182,19 @@ class FlatNav extends Component {
this.props.fetchNewReferenceNodePath();
}
}
this.props.serverFeedbackHandlers.set('Neos.Neos.Ui:NodeCreated/DocumentAdded', this.handleNodeWasCreated, 'after Neos.Neos.Ui:NodeCreated/Main');
}

handleNodeWasCreated = (feedbackPayload, {store}) => {
const state = store.getState();

const getNodeByContextPathSelector = selectors.CR.Nodes.makeGetNodeByContextPathSelector(feedbackPayload.contextPath);
const node = getNodeByContextPathSelector(state);
const nodeTypeName = $get('nodeType', node);

if (nodeTypeName === this.props.preset.newNodeType) {
this.refreshFlatNav();
}
}

createNode = () => {
Expand Down
21 changes: 18 additions & 3 deletions Resources/Public/JavaScript/FlatNav/Plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Resources/Public/JavaScript/FlatNav/Plugin.js.map

Large diffs are not rendered by default.

0 comments on commit 5f75097

Please sign in to comment.