From 4da21c8300e03ed2d2d1a80cab01f6583e186ae5 Mon Sep 17 00:00:00 2001 From: Felix Gertz Date: Thu, 10 Mar 2016 18:35:56 +0100 Subject: [PATCH] Check if component is set at place id --- ...ionalPortsAndServiceDiscoveryComponent.jsx | 23 ++++++++++++------- src/js/stores/PluginComponentStore.js | 4 ++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/js/components/OptionalPortsAndServiceDiscoveryComponent.jsx b/src/js/components/OptionalPortsAndServiceDiscoveryComponent.jsx index de8b5d1cf..b4770a8d9 100644 --- a/src/js/components/OptionalPortsAndServiceDiscoveryComponent.jsx +++ b/src/js/components/OptionalPortsAndServiceDiscoveryComponent.jsx @@ -7,6 +7,7 @@ import DuplicableRowsMixin from "../mixins/DuplicableRowsMixin"; import FormActions from "../actions/FormActions"; import FormGroupComponent from "../components/FormGroupComponent"; import PortInputAttributes from "../constants/PortInputAttributes"; +import PluginComponentStore from "../stores/PluginComponentStore"; import PluginMountPointComponent from "../components/PluginMountPointComponent"; import PluginMountPoints from "../plugin/shared/PluginMountPoints"; @@ -233,13 +234,15 @@ var OptionalPortsAndServiceDiscoveryComponent = React.createClass({ ); }, - getPortDefinitionRows: function () { - return ( - - ); + getPortDefinitionRows: function (hasPlaceIdSet = false) { + if (hasPlaceIdSet) { + return ( + + ); + } - var rows = this.state.rows[fieldsetId]; + let rows = this.state.rows[fieldsetId]; if (rows == null) { return null; @@ -254,7 +257,11 @@ var OptionalPortsAndServiceDiscoveryComponent = React.createClass({ }, render: function () { - if (isTooComplexStructure(this.props.fields)) { + var hasPlaceIdSet = PluginComponentStore.hasComponentAtPlaceId( + PluginMountPoints.OPTIONAL_PORTS_AND_SERVICE_DISCOVERY + ); + + if (!hasPlaceIdSet && isTooComplexStructure(this.props.fields)) { return (
Looks like your ports & service discovery configuration @@ -270,7 +277,7 @@ var OptionalPortsAndServiceDiscoveryComponent = React.createClass({ return (
- {this.getPortDefinitionRows()} + {this.getPortDefinitionRows(hasPlaceIdSet)}
{this.getGeneralErrorBlock(fieldsetId)} {this.getHelpText()} diff --git a/src/js/stores/PluginComponentStore.js b/src/js/stores/PluginComponentStore.js index db2a6554b..bc92a6e5f 100644 --- a/src/js/stores/PluginComponentStore.js +++ b/src/js/stores/PluginComponentStore.js @@ -12,6 +12,10 @@ var components = []; var PluginComponentStore = Util.extendObject(EventEmitter.prototype, { get components() { return components; + }, + + hasComponentAtPlaceId: function (placeId) { + return components.some(component => component.placeId === placeId); } });