Skip to content

Commit

Permalink
Merge pull request neos#1724 from neos/dimaip-fix-plugin-views
Browse files Browse the repository at this point in the history
BUGFIX: fix plugin editors
  • Loading branch information
dimaip authored Mar 28, 2018
2 parents f400525 + a8abf66 commit 1f5b705
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
4 changes: 0 additions & 4 deletions packages/neos-ui-editors/src/Editors/MasterPlugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ class MasterPluginEditor extends React.PureComponent {
}

componentDidMount() {
if (!this.props.value) {
return;
}

const {loadMasterPlugins} = backend.get().endpoints;
const {personalWorkspace, activeContentDimensions} = this.props;

Expand Down
22 changes: 16 additions & 6 deletions packages/neos-ui-editors/src/Editors/PluginView/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import backend from '@neos-project/neos-ui-backend-connector';
import {neos} from '@neos-project/neos-ui-decorators';
import {connect} from 'react-redux';
import {selectors} from '@neos-project/neos-ui-redux-store';
import {$transform} from 'plow-js';
import {$transform, $get} from 'plow-js';

@neos(globalRegistry => {
return {
Expand All @@ -16,7 +16,8 @@ import {$transform} from 'plow-js';
@connect($transform({
activeContentDimensions: selectors.CR.ContentDimensions.active,
personalWorkspace: selectors.CR.Workspaces.personalWorkspaceNameSelector,
focusedNode: selectors.CR.Nodes.focusedSelector
focusedNode: selectors.CR.Nodes.focusedSelector,
transientValues: selectors.UI.Inspector.transientValues
}))

class PluginViewEditor extends React.PureComponent {
Expand All @@ -27,7 +28,8 @@ class PluginViewEditor extends React.PureComponent {
i18nRegistry: PropTypes.object.isRequired,
activeContentDimensions: PropTypes.object.isRequired,
personalWorkspace: PropTypes.string,
focusedNode: PropTypes.instanceOf(PluginViewEditor).isRequired
focusedNode: PropTypes.object.isRequired,
transientValues: PropTypes.object
};

state = {
Expand All @@ -54,17 +56,25 @@ class PluginViewEditor extends React.PureComponent {
}

componentDidMount() {
const {personalWorkspace, activeContentDimensions, focusedNode} = this.props;
this.loadOptions(this.props);
}
componentWillReceiveProps(nextProps) {
if ($get('plugin.value', nextProps.transientValues) !== $get('plugin.value', this.props.transientValues)) {
this.loadOptions(nextProps);
}
}

loadOptions(props) {
const {personalWorkspace, activeContentDimensions, focusedNode, transientValues} = props;
if (!focusedNode) {
return;
}

const {loadPluginViews} = backend.get().endpoints;
const pluginNode = focusedNode.get('properties');

if (!this.state.options.length && pluginNode.size > 0) {
const pluginNodeIdentifier = pluginNode.get('plugin');
if (pluginNode.size > 0) {
const pluginNodeIdentifier = $get('plugin.value', transientValues) === undefined ? pluginNode.get('plugin') : $get('plugin.value', transientValues);
this.setState({isLoading: true});

loadPluginViews(pluginNodeIdentifier, personalWorkspace, activeContentDimensions.toJS())
Expand Down

0 comments on commit 1f5b705

Please sign in to comment.