From d1d2eb9ca7dba7402aac9e2dd840ee09c0c2e851 Mon Sep 17 00:00:00 2001 From: Elias Kuiter Date: Sun, 26 Aug 2018 18:33:12 +0200 Subject: [PATCH] Fixed circular dependency --- .../featureDiagram/treeLayout/AbstractTreeLayout.js | 3 ++- client/src/components/overlays/FeatureCallout.js | 3 ++- client/src/components/overlays/FeatureContextualMenu.js | 3 ++- client/src/components/overlays/FeaturePanel.js | 2 +- client/src/components/overlays/FeatureRenameDialog.js | 2 +- .../components/overlays/FeatureSetDescriptionDialog.js | 2 +- client/src/server/FeatureModel.js | 9 +++++++-- client/src/types.js | 3 --- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/client/src/components/featureDiagram/treeLayout/AbstractTreeLayout.js b/client/src/components/featureDiagram/treeLayout/AbstractTreeLayout.js index 83e0764d..f28cf158 100644 --- a/client/src/components/featureDiagram/treeLayout/AbstractTreeLayout.js +++ b/client/src/components/featureDiagram/treeLayout/AbstractTreeLayout.js @@ -9,8 +9,9 @@ import '../../../stylesheets/treeLayout.css'; import {overlayTypes} from '../../../types'; import PropTypes from 'prop-types'; import exact from 'prop-types-exact'; -import {FeatureModelType, OverlayType} from '../../../types'; +import {OverlayType} from '../../../types'; import {SettingsType} from '../../../types'; +import {FeatureModelType} from '../../../server/FeatureModel'; class AbstractTreeLayout extends React.Component { static defaultProps = {fitOnResize: false}; diff --git a/client/src/components/overlays/FeatureCallout.js b/client/src/components/overlays/FeatureCallout.js index 4341468c..29e007aa 100644 --- a/client/src/components/overlays/FeatureCallout.js +++ b/client/src/components/overlays/FeatureCallout.js @@ -4,8 +4,9 @@ import {getSetting} from '../../store/settings'; import contextualMenuItems from '../contextualMenuItems'; import {CommandBar} from 'office-ui-fabric-react/lib/CommandBar'; import PropTypes from 'prop-types'; -import {FeatureModelType, layoutTypes} from '../../types'; +import {layoutTypes} from '../../types'; import {LayoutType, SettingsType} from '../../types'; +import {FeatureModelType} from '../../server/FeatureModel'; class FeatureCallout extends React.Component { componentDidMount() { diff --git a/client/src/components/overlays/FeatureContextualMenu.js b/client/src/components/overlays/FeatureContextualMenu.js index 658f242b..82fb0307 100644 --- a/client/src/components/overlays/FeatureContextualMenu.js +++ b/client/src/components/overlays/FeatureContextualMenu.js @@ -4,8 +4,9 @@ import {ContextualMenu, ContextualMenuItemType} from 'office-ui-fabric-react/lib import contextualMenuItems from '../contextualMenuItems'; import {getSetting} from '../../store/settings'; import PropTypes from 'prop-types'; -import {FeatureModelType, layoutTypes} from '../../types'; +import {layoutTypes} from '../../types'; import {LayoutType, SettingsType} from '../../types'; +import {FeatureModelType} from '../../server/FeatureModel'; export const selectMultipleFeaturesContextualMenuItems = (selectedFeatureNames, onSelectAllFeatures, onDeselectAllFeatures, featureModel) => [ contextualMenuItems.featureDiagram.features.selectAll(onSelectAllFeatures), diff --git a/client/src/components/overlays/FeaturePanel.js b/client/src/components/overlays/FeaturePanel.js index 52c5c0ba..2c0baff7 100644 --- a/client/src/components/overlays/FeaturePanel.js +++ b/client/src/components/overlays/FeaturePanel.js @@ -4,7 +4,7 @@ import i18n from '../../i18n'; import {CommandBar} from 'office-ui-fabric-react/lib/CommandBar'; import contextualMenuItems from '../contextualMenuItems'; import PropTypes from 'prop-types'; -import {FeatureModelType} from '../../types'; +import {FeatureModelType} from '../../server/FeatureModel'; const buttonStyles = {root: {backgroundColor: 'transparent'}}, transparentItems = items => items; diff --git a/client/src/components/overlays/FeatureRenameDialog.js b/client/src/components/overlays/FeatureRenameDialog.js index e4e99eb5..d9026560 100644 --- a/client/src/components/overlays/FeatureRenameDialog.js +++ b/client/src/components/overlays/FeatureRenameDialog.js @@ -3,7 +3,7 @@ import i18n from '../../i18n'; import actions from '../../store/actions'; import {TextFieldDialog} from '../../helpers/Dialog'; import PropTypes from 'prop-types'; -import {FeatureModelType} from '../../types'; +import {FeatureModelType} from '../../server/FeatureModel'; const FeatureRenameDialog = ({featureName, featureModel, ...props}) => { const feature = featureModel && featureModel.getFeatureOrDismiss(featureName, props.isOpen, props.onDismiss); diff --git a/client/src/components/overlays/FeatureSetDescriptionDialog.js b/client/src/components/overlays/FeatureSetDescriptionDialog.js index 938e2d41..fcde2469 100644 --- a/client/src/components/overlays/FeatureSetDescriptionDialog.js +++ b/client/src/components/overlays/FeatureSetDescriptionDialog.js @@ -3,7 +3,7 @@ import i18n from '../../i18n'; import actions from '../../store/actions'; import {TextFieldDialog} from '../../helpers/Dialog'; import PropTypes from 'prop-types'; -import {FeatureModelType} from '../../types'; +import {FeatureModelType} from '../../server/FeatureModel'; const FeatureSetDescriptionDialog = ({featureName, featureModel, ...props}) => { const feature = featureModel && featureModel.getFeatureOrDismiss(featureName, props.isOpen, props.onDismiss); diff --git a/client/src/server/FeatureModel.js b/client/src/server/FeatureModel.js index 66249e6e..dad6e204 100644 --- a/client/src/server/FeatureModel.js +++ b/client/src/server/FeatureModel.js @@ -1,5 +1,6 @@ import {hierarchy as d3Hierarchy} from 'd3-hierarchy'; import constants from '../constants'; +import PropTypes from 'prop-types'; const serialization = constants.server.featureModel.serialization; @@ -24,7 +25,7 @@ d3Hierarchy.prototype.feature = function() { }); }; -export default class { +class FeatureModel { // 'data' as supplied by FEATURE_MODEL messages from the server constructor(featureModel) { if (!featureModel) @@ -83,4 +84,8 @@ export default class { .map(node => node.parent); return parents.every(parent => parent === parents[0]); } -}; \ No newline at end of file +} + +export const FeatureModelType = PropTypes.instanceOf(FeatureModel); + +export default FeatureModel; \ No newline at end of file diff --git a/client/src/types.js b/client/src/types.js index 1b5f8a79..0c5cb325 100644 --- a/client/src/types.js +++ b/client/src/types.js @@ -1,5 +1,4 @@ import PropTypes from 'prop-types'; -import FeatureModel from './server/FeatureModel'; export const layoutTypes = { @@ -10,8 +9,6 @@ export const SettingsType = PropTypes.object, - FeatureModelType = PropTypes.instanceOf(FeatureModel), - overlayTypes = { settingsPanel: 'settingsPanel', aboutPanel: 'aboutPanel',