Loading js-apps/meep-frontend/src/js/components/helper-components/cancel-apply-triplet.jsdeleted 100644 → 0 +0 −63 Original line number Diff line number Diff line /* * Copyright (c) 2019 InterDigital Communications, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import React from 'react'; import { Grid, GridInner, GridCell } from '@rmwc/grid'; import { Button } from '@rmwc/button'; import { MEEP_BTN_CANCEL, MEEP_BTN_APPLY, MEEP_BTN_DUPLICATE } from '../../meep-constants'; const buttonStyles = { marginRight: 10 }; const CancelApplyTriplet = props => { return ( <Grid style={{ marginTop: 10 }}> <GridInner align={'right'}> <GridCell span={12}> <Button outlined style={buttonStyles} onClick={props.onCancel} data-cy={MEEP_BTN_CANCEL} > {props.cancelText ? props.cancelText : 'Cancel'} </Button> <Button outlined style={buttonStyles} onClick={props.onApply} disabled={props.saveDisabled} data-cy={MEEP_BTN_APPLY} > {props.applyText ? props.applyText : 'Apply'} </Button> <Button outlined style={buttonStyles} onClick={props.onDuplicate} disabled={props.duplicateDisabled} data-cy={MEEP_BTN_DUPLICATE} > {props.duplicateText ? props.duplicateText : 'Duplicate'} </Button> </GridCell> </GridInner> </Grid> ); }; export default CancelApplyTriplet; js-apps/meep-frontend/src/js/containers/cfg/cfg-network-element-container.js +34 −26 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import { updateObject } from '../../util/object-util'; import { createUniqueName } from '../../util/elem-utils'; import IDSelect from '../../components/helper-components/id-select'; import CancelApplyTriplet from '../../components/helper-components/cancel-apply-triplet'; import CancelApplyPair from '../../components/helper-components/cancel-apply-pair'; import NCGroup from '../../components/helper-components/nc-group'; import { Loading Loading @@ -61,9 +61,9 @@ import { import { CFG_ELEM_MODE_NEW, CFG_ELEM_MODE_EDIT, CFG_ELEM_MODE_DUPLICATE, CFG_ELEM_MODE_CLONE, cfgElemUpdate, cfgElemDuplicate cfgElemClone } from '../../state/cfg'; import { Loading Loading @@ -119,6 +119,7 @@ import { CFG_ELEM_EGRESS_SVC_MAP, CFG_BTN_NEW_ELEM, CFG_BTN_DEL_ELEM, CFG_BTN_CLONE_ELEM, // Layout type MEEP_COMPONENT_TABLE_LAYOUT Loading Loading @@ -930,13 +931,14 @@ const ElementCfgButtons = ({ configuredElement, configMode, onNewElement, onDeleteElement onDeleteElement, onCloneElement }) => { const canCreateNewElement = () => { return !configuredElement; }; const canDeleteElement = () => { const canDeleteOrCloneElement = () => { return configuredElement && configMode === CFG_ELEM_MODE_EDIT; }; Loading @@ -957,10 +959,21 @@ const ElementCfgButtons = ({ data-cy={CFG_BTN_DEL_ELEM} style={buttonStyles} onClick={() => onDeleteElement()} disabled={!canDeleteElement()} disabled={!canDeleteOrCloneElement()} > DELETE </Button> <Button outlined data-cy={CFG_BTN_CLONE_ELEM} style={buttonStyles} onClick={() => onCloneElement()} disabled={!canDeleteOrCloneElement()} > CLONE </Button> </> ); }; Loading Loading @@ -1024,15 +1037,15 @@ export class CfgNetworkElementContainer extends Component { this.props.cfgElemUpdate(updatedElem); } // Element duplicate handler onDuplicateElement(newName) { var duplicatedElem = updateObject({}, this.props.configuredElement); setElemFieldVal(duplicatedElem, FIELD_NAME, newName); setElemFieldVal(duplicatedElem, FIELD_PARENT, null); var elementType = getElemFieldVal(duplicatedElem, FIELD_TYPE); duplicatedElem.parentElements = this.elementsOfType(getParentTypes(elementType)); // Element clone handler onCloneElement(newName) { var clonedElem = updateObject({}, this.props.configuredElement); setElemFieldVal(clonedElem, FIELD_NAME, newName); setElemFieldVal(clonedElem, FIELD_PARENT, null); var elementType = getElemFieldVal(clonedElem, FIELD_TYPE); clonedElem.parentElements = this.elementsOfType(getParentTypes(elementType)); this.props.cfgElemDuplicate(duplicatedElem); this.props.cfgElemClone(clonedElem); } // Retrieve names of elements with matching type Loading Loading @@ -1080,6 +1093,9 @@ export class CfgNetworkElementContainer extends Component { onDeleteElement={() => { this.props.onDeleteElement(element); }} onCloneElement={() => { this.onCloneElement(createUniqueName(this.props.tableData, getElemFieldVal(element, FIELD_NAME) + '-copy')); }} /> </GridCell> </GridInner> Loading @@ -1096,7 +1112,7 @@ export class CfgNetworkElementContainer extends Component { onUpdate={(name, val, err) => { this.onUpdateElement(name, val, err); }} typeDisabled={this.props.configMode === CFG_ELEM_MODE_DUPLICATE || this.props.configMode === CFG_ELEM_MODE_EDIT} typeDisabled={this.props.configMode === CFG_ELEM_MODE_CLONE || this.props.configMode === CFG_ELEM_MODE_EDIT} parentDisabled={this.props.configMode === CFG_ELEM_MODE_EDIT} nameDisabled={getElemFieldVal(element, FIELD_TYPE) === ELEMENT_TYPE_SCENARIO && this.props.configMode !== CFG_ELEM_MODE_NEW} /> Loading @@ -1115,19 +1131,11 @@ export class CfgNetworkElementContainer extends Component { {this.props.errorMessage} </div> <CancelApplyTriplet duplicateDisabled={ (element && this.props.configMode === CFG_ELEM_MODE_EDIT && this.props.isModified === false && getElemFieldVal(element, FIELD_TYPE) !== ELEMENT_TYPE_SCENARIO) ? false : true } <CancelApplyPair saveDisabled={(this.props.isModified === false) ? true : false} onCancel={this.props.onCancelElement} onApply={() => { (this.props.configMode === CFG_ELEM_MODE_DUPLICATE) ? this.props.onDuplicateElement(element) : this.props.onSaveElement(element); }} onDuplicate={() => { this.onDuplicateElement(createUniqueName(this.props.tableData, getElemFieldVal(element, FIELD_NAME) + '-copy')); (this.props.configMode === CFG_ELEM_MODE_CLONE) ? this.props.onApplyCloneElement(element) : this.props.onSaveElement(element); }} /> Loading Loading @@ -1170,7 +1178,7 @@ const mapStateToProps = state => { const mapDispatchToProps = dispatch => { return { cfgElemUpdate: element => dispatch(cfgElemUpdate(element)), cfgElemDuplicate: element => dispatch(cfgElemDuplicate(element)) cfgElemClone: element => dispatch(cfgElemClone(element)) }; }; Loading js-apps/meep-frontend/src/js/containers/cfg/cfg-page-container.js +38 −27 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import IDExportScenarioDialog from '../../components/dialogs/id-export-scenario- import { cfgElemNew, cfgElemClone, cfgElemEdit, cfgElemClear, cfgElemSetErrMsg, Loading Loading @@ -139,7 +140,7 @@ class CfgPageContainer extends Component { this.props.cfg.elementConfiguration.configurationMode === CFG_ELEM_MODE_NEW ) { this.props.newScenarioElem(element); this.props.newScenarioElem(element, true); } else { this.props.updateScenarioElem(element); } Loading @@ -148,8 +149,13 @@ class CfgPageContainer extends Component { this.props.cfgElemClear(); } // DUPLICATE ELEMENT, return new element name duplicateElement(element, newParentName, isRoot) { // CLONE onCloneElement() { this.props.cfgElemClone(); } // CLONE ELEMENT, return new element name cloneElement(element, newParentName, isRoot) { let newElement = deepCopy(element); var name = getElemFieldVal(element, FIELD_NAME); Loading @@ -161,20 +167,20 @@ class CfgPageContainer extends Component { // add new element to scenario // new id and label will be created as part of the addNewElementToScenario called by newScenarioElem this.props.newScenarioElem(newElement); this.props.newScenarioElem(newElement, false); return name; } // DUPLICATE onDuplicateElement(element) { // CLONE onApplyCloneElement(element) { // Validate network element if (this.validateNetworkElement(element) === false) { return; } // browse to find the root of the tree to duplicate // browse to find the root of the tree to clone var inDuplicateBranch = false; var inCloneBranch = false; var newZoneRootParentName = ''; var newNlRootParentName = ''; var newPlRootParentName = ''; Loading @@ -188,25 +194,25 @@ class CfgPageContainer extends Component { // Add domain to graph and table (ignore public domain) if (domain.id === element.id) { newZoneRootParentName = this.duplicateElement(element, getElemFieldVal(element, FIELD_PARENT), true); inDuplicateBranch = true; newZoneRootParentName = this.cloneElement(element, getElemFieldVal(element, FIELD_PARENT), true); inCloneBranch = true; } // Zones for (var j in domain.zones) { var zone = domain.zones[j]; if (inDuplicateBranch) { if (inCloneBranch) { if (zone.name.indexOf(COMMON_ZONE_TYPE_STR) !== -1) { newNlRootParentName = newZoneRootParentName + COMMON_ZONE_TYPE_STR; } else { elementFromScenario = getElementFromScenario(scenario, zone.name); newNlRootParentName = this.duplicateElement(elementFromScenario, newZoneRootParentName, false); newNlRootParentName = this.cloneElement(elementFromScenario, newZoneRootParentName, false); } } else { if (zone.id === element.id) { newNlRootParentName = this.duplicateElement(element, getElemFieldVal(element, FIELD_PARENT), true); inDuplicateBranch = true; newNlRootParentName = this.cloneElement(element, getElemFieldVal(element, FIELD_PARENT), true); inCloneBranch = true; } } Loading @@ -214,17 +220,17 @@ class CfgPageContainer extends Component { for (var k in zone.networkLocations) { var nl = zone.networkLocations[k]; if (inDuplicateBranch) { if (inCloneBranch) { if (nl.name.indexOf(DEFAULT_NL_TYPE_STR) !== -1) { newPlRootParentName = newNlRootParentName; } else { elementFromScenario = getElementFromScenario(scenario, nl.name); newPlRootParentName = this.duplicateElement(elementFromScenario, newNlRootParentName, false); newPlRootParentName = this.cloneElement(elementFromScenario, newNlRootParentName, false); } } else { if (nl.id === element.id) { newPlRootParentName = this.duplicateElement(element, getElemFieldVal(element, FIELD_PARENT, true)); inDuplicateBranch = true; newPlRootParentName = this.cloneElement(element, getElemFieldVal(element, FIELD_PARENT, true)); inCloneBranch = true; } } Loading @@ -232,13 +238,13 @@ class CfgPageContainer extends Component { for (var l in nl.physicalLocations) { var pl = nl.physicalLocations[l]; if (inDuplicateBranch) { if (inCloneBranch) { elementFromScenario = getElementFromScenario(scenario, pl.name); newProcessRootParentName = this.duplicateElement(elementFromScenario, newPlRootParentName, false); newProcessRootParentName = this.cloneElement(elementFromScenario, newPlRootParentName, false); } else { if (pl.id === element.id) { newProcessRootParentName = this.duplicateElement(element, getElemFieldVal(element, FIELD_PARENT, true)); inDuplicateBranch = true; newProcessRootParentName = this.cloneElement(element, getElemFieldVal(element, FIELD_PARENT, true)); inCloneBranch = true; } } Loading @@ -246,12 +252,12 @@ class CfgPageContainer extends Component { for (var m in pl.processes) { var proc = pl.processes[m]; if (inDuplicateBranch) { if (inCloneBranch) { elementFromScenario = getElementFromScenario(scenario, proc.name); this.duplicateElement(elementFromScenario, newProcessRootParentName, false); this.cloneElement(elementFromScenario, newProcessRootParentName, false); } else { if (proc.id === element.id) { this.duplicateElement(element, getElemFieldVal(element, FIELD_PARENT, true)); this.cloneElement(element, getElemFieldVal(element, FIELD_PARENT, true)); } } } Loading @@ -259,11 +265,14 @@ class CfgPageContainer extends Component { } } if(inDuplicateBranch) { if(inCloneBranch) { break; } } //force update on element to update the the visual aspect of the scenario this.props.updateScenarioElem(element); this.props.cfgElemClear(); } Loading Loading @@ -741,7 +750,7 @@ class CfgPageContainer extends Component { onNewElement={() => this.onNewElement()} onSaveElement={elem => this.onSaveElement(elem)} onDeleteElement={elem => this.onDeleteElement(elem)} onDuplicateElement={elem => this.onDuplicateElement(elem)} onApplyCloneElement={elem => this.onApplyCloneElement(elem)} onCancelElement={() => this.onCancelElement()} /> </Elevation> Loading @@ -755,6 +764,7 @@ class CfgPageContainer extends Component { onNewElement={() => this.onNewElement()} onEditElement={elem => this.onEditElement(elem)} onDeleteElement={() => this.onDeleteElement()} onApplyCloneElement={elem => this.onApplyCloneElement(elem)} /> </div> </> Loading Loading @@ -803,6 +813,7 @@ const mapStateToProps = state => { const mapDispatchToProps = dispatch => { return { cfgElemNew: elem => dispatch(cfgElemNew(elem)), cfgElemClone: elem => dispatch(cfgElemClone(elem)), cfgElemEdit: elem => dispatch(cfgElemEdit(elem)), cfgElemClear: elem => dispatch(cfgElemClear(elem)), cfgElemSetErrMsg: msg => dispatch(cfgElemSetErrMsg(msg)), Loading js-apps/meep-frontend/src/js/containers/meep-container.js +6 −4 Original line number Diff line number Diff line Loading @@ -385,15 +385,17 @@ class MeepContainer extends Component { } // Add new element to scenario newScenarioElem(pageType, element) { newScenarioElem(pageType, element, scenarioUpdate) { var scenario = pageType === TYPE_CFG ? this.props.cfg.scenario : this.props.exec.scenario; var updatedScenario = updateObject({}, scenario); addElementToScenario(updatedScenario, element); if (scenarioUpdate) { this.changeScenario(pageType, updatedScenario); } } // Update element in scenario updateScenarioElem(pageType, element) { Loading Loading @@ -433,8 +435,8 @@ class MeepContainer extends Component { deleteScenario={() => { this.deleteScenario(TYPE_CFG); }} newScenarioElem={elem => { this.newScenarioElem(TYPE_CFG, elem); newScenarioElem={(elem, update) => { this.newScenarioElem(TYPE_CFG, elem, update); }} updateScenarioElem={elem => { this.updateScenarioElem(TYPE_CFG, elem); Loading js-apps/meep-frontend/src/js/meep-constants.js +0 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ export const MEEP_TAB_SET = 'meep-tab-set'; export const MEEP_LBL_SCENARIO_NAME = 'meep-lbl-scenario-name'; export const MEEP_BTN_CANCEL = 'meep-btn-cancel'; export const MEEP_BTN_APPLY = 'meep-btn-apply'; export const MEEP_BTN_DUPLICATE = 'meep-btn-duplicate'; // Dialog IDs export const MEEP_DLG_NEW_SCENARIO = 'meep-dlg-new-scenario'; Loading Loading
js-apps/meep-frontend/src/js/components/helper-components/cancel-apply-triplet.jsdeleted 100644 → 0 +0 −63 Original line number Diff line number Diff line /* * Copyright (c) 2019 InterDigital Communications, Inc * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import React from 'react'; import { Grid, GridInner, GridCell } from '@rmwc/grid'; import { Button } from '@rmwc/button'; import { MEEP_BTN_CANCEL, MEEP_BTN_APPLY, MEEP_BTN_DUPLICATE } from '../../meep-constants'; const buttonStyles = { marginRight: 10 }; const CancelApplyTriplet = props => { return ( <Grid style={{ marginTop: 10 }}> <GridInner align={'right'}> <GridCell span={12}> <Button outlined style={buttonStyles} onClick={props.onCancel} data-cy={MEEP_BTN_CANCEL} > {props.cancelText ? props.cancelText : 'Cancel'} </Button> <Button outlined style={buttonStyles} onClick={props.onApply} disabled={props.saveDisabled} data-cy={MEEP_BTN_APPLY} > {props.applyText ? props.applyText : 'Apply'} </Button> <Button outlined style={buttonStyles} onClick={props.onDuplicate} disabled={props.duplicateDisabled} data-cy={MEEP_BTN_DUPLICATE} > {props.duplicateText ? props.duplicateText : 'Duplicate'} </Button> </GridCell> </GridInner> </Grid> ); }; export default CancelApplyTriplet;
js-apps/meep-frontend/src/js/containers/cfg/cfg-network-element-container.js +34 −26 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ import { updateObject } from '../../util/object-util'; import { createUniqueName } from '../../util/elem-utils'; import IDSelect from '../../components/helper-components/id-select'; import CancelApplyTriplet from '../../components/helper-components/cancel-apply-triplet'; import CancelApplyPair from '../../components/helper-components/cancel-apply-pair'; import NCGroup from '../../components/helper-components/nc-group'; import { Loading Loading @@ -61,9 +61,9 @@ import { import { CFG_ELEM_MODE_NEW, CFG_ELEM_MODE_EDIT, CFG_ELEM_MODE_DUPLICATE, CFG_ELEM_MODE_CLONE, cfgElemUpdate, cfgElemDuplicate cfgElemClone } from '../../state/cfg'; import { Loading Loading @@ -119,6 +119,7 @@ import { CFG_ELEM_EGRESS_SVC_MAP, CFG_BTN_NEW_ELEM, CFG_BTN_DEL_ELEM, CFG_BTN_CLONE_ELEM, // Layout type MEEP_COMPONENT_TABLE_LAYOUT Loading Loading @@ -930,13 +931,14 @@ const ElementCfgButtons = ({ configuredElement, configMode, onNewElement, onDeleteElement onDeleteElement, onCloneElement }) => { const canCreateNewElement = () => { return !configuredElement; }; const canDeleteElement = () => { const canDeleteOrCloneElement = () => { return configuredElement && configMode === CFG_ELEM_MODE_EDIT; }; Loading @@ -957,10 +959,21 @@ const ElementCfgButtons = ({ data-cy={CFG_BTN_DEL_ELEM} style={buttonStyles} onClick={() => onDeleteElement()} disabled={!canDeleteElement()} disabled={!canDeleteOrCloneElement()} > DELETE </Button> <Button outlined data-cy={CFG_BTN_CLONE_ELEM} style={buttonStyles} onClick={() => onCloneElement()} disabled={!canDeleteOrCloneElement()} > CLONE </Button> </> ); }; Loading Loading @@ -1024,15 +1037,15 @@ export class CfgNetworkElementContainer extends Component { this.props.cfgElemUpdate(updatedElem); } // Element duplicate handler onDuplicateElement(newName) { var duplicatedElem = updateObject({}, this.props.configuredElement); setElemFieldVal(duplicatedElem, FIELD_NAME, newName); setElemFieldVal(duplicatedElem, FIELD_PARENT, null); var elementType = getElemFieldVal(duplicatedElem, FIELD_TYPE); duplicatedElem.parentElements = this.elementsOfType(getParentTypes(elementType)); // Element clone handler onCloneElement(newName) { var clonedElem = updateObject({}, this.props.configuredElement); setElemFieldVal(clonedElem, FIELD_NAME, newName); setElemFieldVal(clonedElem, FIELD_PARENT, null); var elementType = getElemFieldVal(clonedElem, FIELD_TYPE); clonedElem.parentElements = this.elementsOfType(getParentTypes(elementType)); this.props.cfgElemDuplicate(duplicatedElem); this.props.cfgElemClone(clonedElem); } // Retrieve names of elements with matching type Loading Loading @@ -1080,6 +1093,9 @@ export class CfgNetworkElementContainer extends Component { onDeleteElement={() => { this.props.onDeleteElement(element); }} onCloneElement={() => { this.onCloneElement(createUniqueName(this.props.tableData, getElemFieldVal(element, FIELD_NAME) + '-copy')); }} /> </GridCell> </GridInner> Loading @@ -1096,7 +1112,7 @@ export class CfgNetworkElementContainer extends Component { onUpdate={(name, val, err) => { this.onUpdateElement(name, val, err); }} typeDisabled={this.props.configMode === CFG_ELEM_MODE_DUPLICATE || this.props.configMode === CFG_ELEM_MODE_EDIT} typeDisabled={this.props.configMode === CFG_ELEM_MODE_CLONE || this.props.configMode === CFG_ELEM_MODE_EDIT} parentDisabled={this.props.configMode === CFG_ELEM_MODE_EDIT} nameDisabled={getElemFieldVal(element, FIELD_TYPE) === ELEMENT_TYPE_SCENARIO && this.props.configMode !== CFG_ELEM_MODE_NEW} /> Loading @@ -1115,19 +1131,11 @@ export class CfgNetworkElementContainer extends Component { {this.props.errorMessage} </div> <CancelApplyTriplet duplicateDisabled={ (element && this.props.configMode === CFG_ELEM_MODE_EDIT && this.props.isModified === false && getElemFieldVal(element, FIELD_TYPE) !== ELEMENT_TYPE_SCENARIO) ? false : true } <CancelApplyPair saveDisabled={(this.props.isModified === false) ? true : false} onCancel={this.props.onCancelElement} onApply={() => { (this.props.configMode === CFG_ELEM_MODE_DUPLICATE) ? this.props.onDuplicateElement(element) : this.props.onSaveElement(element); }} onDuplicate={() => { this.onDuplicateElement(createUniqueName(this.props.tableData, getElemFieldVal(element, FIELD_NAME) + '-copy')); (this.props.configMode === CFG_ELEM_MODE_CLONE) ? this.props.onApplyCloneElement(element) : this.props.onSaveElement(element); }} /> Loading Loading @@ -1170,7 +1178,7 @@ const mapStateToProps = state => { const mapDispatchToProps = dispatch => { return { cfgElemUpdate: element => dispatch(cfgElemUpdate(element)), cfgElemDuplicate: element => dispatch(cfgElemDuplicate(element)) cfgElemClone: element => dispatch(cfgElemClone(element)) }; }; Loading
js-apps/meep-frontend/src/js/containers/cfg/cfg-page-container.js +38 −27 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import IDExportScenarioDialog from '../../components/dialogs/id-export-scenario- import { cfgElemNew, cfgElemClone, cfgElemEdit, cfgElemClear, cfgElemSetErrMsg, Loading Loading @@ -139,7 +140,7 @@ class CfgPageContainer extends Component { this.props.cfg.elementConfiguration.configurationMode === CFG_ELEM_MODE_NEW ) { this.props.newScenarioElem(element); this.props.newScenarioElem(element, true); } else { this.props.updateScenarioElem(element); } Loading @@ -148,8 +149,13 @@ class CfgPageContainer extends Component { this.props.cfgElemClear(); } // DUPLICATE ELEMENT, return new element name duplicateElement(element, newParentName, isRoot) { // CLONE onCloneElement() { this.props.cfgElemClone(); } // CLONE ELEMENT, return new element name cloneElement(element, newParentName, isRoot) { let newElement = deepCopy(element); var name = getElemFieldVal(element, FIELD_NAME); Loading @@ -161,20 +167,20 @@ class CfgPageContainer extends Component { // add new element to scenario // new id and label will be created as part of the addNewElementToScenario called by newScenarioElem this.props.newScenarioElem(newElement); this.props.newScenarioElem(newElement, false); return name; } // DUPLICATE onDuplicateElement(element) { // CLONE onApplyCloneElement(element) { // Validate network element if (this.validateNetworkElement(element) === false) { return; } // browse to find the root of the tree to duplicate // browse to find the root of the tree to clone var inDuplicateBranch = false; var inCloneBranch = false; var newZoneRootParentName = ''; var newNlRootParentName = ''; var newPlRootParentName = ''; Loading @@ -188,25 +194,25 @@ class CfgPageContainer extends Component { // Add domain to graph and table (ignore public domain) if (domain.id === element.id) { newZoneRootParentName = this.duplicateElement(element, getElemFieldVal(element, FIELD_PARENT), true); inDuplicateBranch = true; newZoneRootParentName = this.cloneElement(element, getElemFieldVal(element, FIELD_PARENT), true); inCloneBranch = true; } // Zones for (var j in domain.zones) { var zone = domain.zones[j]; if (inDuplicateBranch) { if (inCloneBranch) { if (zone.name.indexOf(COMMON_ZONE_TYPE_STR) !== -1) { newNlRootParentName = newZoneRootParentName + COMMON_ZONE_TYPE_STR; } else { elementFromScenario = getElementFromScenario(scenario, zone.name); newNlRootParentName = this.duplicateElement(elementFromScenario, newZoneRootParentName, false); newNlRootParentName = this.cloneElement(elementFromScenario, newZoneRootParentName, false); } } else { if (zone.id === element.id) { newNlRootParentName = this.duplicateElement(element, getElemFieldVal(element, FIELD_PARENT), true); inDuplicateBranch = true; newNlRootParentName = this.cloneElement(element, getElemFieldVal(element, FIELD_PARENT), true); inCloneBranch = true; } } Loading @@ -214,17 +220,17 @@ class CfgPageContainer extends Component { for (var k in zone.networkLocations) { var nl = zone.networkLocations[k]; if (inDuplicateBranch) { if (inCloneBranch) { if (nl.name.indexOf(DEFAULT_NL_TYPE_STR) !== -1) { newPlRootParentName = newNlRootParentName; } else { elementFromScenario = getElementFromScenario(scenario, nl.name); newPlRootParentName = this.duplicateElement(elementFromScenario, newNlRootParentName, false); newPlRootParentName = this.cloneElement(elementFromScenario, newNlRootParentName, false); } } else { if (nl.id === element.id) { newPlRootParentName = this.duplicateElement(element, getElemFieldVal(element, FIELD_PARENT, true)); inDuplicateBranch = true; newPlRootParentName = this.cloneElement(element, getElemFieldVal(element, FIELD_PARENT, true)); inCloneBranch = true; } } Loading @@ -232,13 +238,13 @@ class CfgPageContainer extends Component { for (var l in nl.physicalLocations) { var pl = nl.physicalLocations[l]; if (inDuplicateBranch) { if (inCloneBranch) { elementFromScenario = getElementFromScenario(scenario, pl.name); newProcessRootParentName = this.duplicateElement(elementFromScenario, newPlRootParentName, false); newProcessRootParentName = this.cloneElement(elementFromScenario, newPlRootParentName, false); } else { if (pl.id === element.id) { newProcessRootParentName = this.duplicateElement(element, getElemFieldVal(element, FIELD_PARENT, true)); inDuplicateBranch = true; newProcessRootParentName = this.cloneElement(element, getElemFieldVal(element, FIELD_PARENT, true)); inCloneBranch = true; } } Loading @@ -246,12 +252,12 @@ class CfgPageContainer extends Component { for (var m in pl.processes) { var proc = pl.processes[m]; if (inDuplicateBranch) { if (inCloneBranch) { elementFromScenario = getElementFromScenario(scenario, proc.name); this.duplicateElement(elementFromScenario, newProcessRootParentName, false); this.cloneElement(elementFromScenario, newProcessRootParentName, false); } else { if (proc.id === element.id) { this.duplicateElement(element, getElemFieldVal(element, FIELD_PARENT, true)); this.cloneElement(element, getElemFieldVal(element, FIELD_PARENT, true)); } } } Loading @@ -259,11 +265,14 @@ class CfgPageContainer extends Component { } } if(inDuplicateBranch) { if(inCloneBranch) { break; } } //force update on element to update the the visual aspect of the scenario this.props.updateScenarioElem(element); this.props.cfgElemClear(); } Loading Loading @@ -741,7 +750,7 @@ class CfgPageContainer extends Component { onNewElement={() => this.onNewElement()} onSaveElement={elem => this.onSaveElement(elem)} onDeleteElement={elem => this.onDeleteElement(elem)} onDuplicateElement={elem => this.onDuplicateElement(elem)} onApplyCloneElement={elem => this.onApplyCloneElement(elem)} onCancelElement={() => this.onCancelElement()} /> </Elevation> Loading @@ -755,6 +764,7 @@ class CfgPageContainer extends Component { onNewElement={() => this.onNewElement()} onEditElement={elem => this.onEditElement(elem)} onDeleteElement={() => this.onDeleteElement()} onApplyCloneElement={elem => this.onApplyCloneElement(elem)} /> </div> </> Loading Loading @@ -803,6 +813,7 @@ const mapStateToProps = state => { const mapDispatchToProps = dispatch => { return { cfgElemNew: elem => dispatch(cfgElemNew(elem)), cfgElemClone: elem => dispatch(cfgElemClone(elem)), cfgElemEdit: elem => dispatch(cfgElemEdit(elem)), cfgElemClear: elem => dispatch(cfgElemClear(elem)), cfgElemSetErrMsg: msg => dispatch(cfgElemSetErrMsg(msg)), Loading
js-apps/meep-frontend/src/js/containers/meep-container.js +6 −4 Original line number Diff line number Diff line Loading @@ -385,15 +385,17 @@ class MeepContainer extends Component { } // Add new element to scenario newScenarioElem(pageType, element) { newScenarioElem(pageType, element, scenarioUpdate) { var scenario = pageType === TYPE_CFG ? this.props.cfg.scenario : this.props.exec.scenario; var updatedScenario = updateObject({}, scenario); addElementToScenario(updatedScenario, element); if (scenarioUpdate) { this.changeScenario(pageType, updatedScenario); } } // Update element in scenario updateScenarioElem(pageType, element) { Loading Loading @@ -433,8 +435,8 @@ class MeepContainer extends Component { deleteScenario={() => { this.deleteScenario(TYPE_CFG); }} newScenarioElem={elem => { this.newScenarioElem(TYPE_CFG, elem); newScenarioElem={(elem, update) => { this.newScenarioElem(TYPE_CFG, elem, update); }} updateScenarioElem={elem => { this.updateScenarioElem(TYPE_CFG, elem); Loading
js-apps/meep-frontend/src/js/meep-constants.js +0 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ export const MEEP_TAB_SET = 'meep-tab-set'; export const MEEP_LBL_SCENARIO_NAME = 'meep-lbl-scenario-name'; export const MEEP_BTN_CANCEL = 'meep-btn-cancel'; export const MEEP_BTN_APPLY = 'meep-btn-apply'; export const MEEP_BTN_DUPLICATE = 'meep-btn-duplicate'; // Dialog IDs export const MEEP_DLG_NEW_SCENARIO = 'meep-dlg-new-scenario'; Loading