change -1 to No Limit in View All Templates for # Instances Allowed
[clamp.git] / ui-react / src / components / dialogs / Tosca / ViewLoopTemplatesModal.js
index 962ab4b..eb6e70f 100644 (file)
@@ -92,13 +92,20 @@ export default class ViewLoopTemplatesModal extends React.Component {
        constructor(props, context) {
                super(props, context);
                this.handleClose = this.handleClose.bind(this);
+               this.renderSvg = this.renderSvg.bind(this);
                this.getLoopTemplate = this.getLoopTemplate.bind(this);
                this.getAllLoopTemplates();
        }
 
        getAllLoopTemplates() {
                TemplateService.getAllLoopTemplates().then(templatesData => {
-                   this.setState({ loopTemplatesData: templatesData })
+                       // replace -1 in maximumInstancesAllowed with more meaningful 'No Limit'
+                       for (let item in templatesData) {
+                               if (templatesData[item].maximumInstancesAllowed === -1) {
+                                       templatesData[item].maximumInstancesAllowed = 'No Limit';
+                               }
+                       } 
+                       this.setState({ loopTemplatesData: templatesData })
                });
        }
 
@@ -120,6 +127,12 @@ export default class ViewLoopTemplatesModal extends React.Component {
                this.props.history.push('/')
        }
 
+       renderSvg() {
+               return(
+                       <SvgGenerator loopCache={this.state.fakeLoopCacheWithTemplate} clickable={false} generatedFrom={SvgGenerator.GENERATED_FROM_TEMPLATE}/>
+               )
+       }
+
        render() {
     return (
                <ModalStyled size="xl" show={this.state.show} onHide={this.handleClose} backdrop="static"  keyboard={false}>
@@ -139,7 +152,7 @@ export default class ViewLoopTemplatesModal extends React.Component {
                           })
                       }}
                 />
-                   <SvgGenerator loopCache={this.state.fakeLoopCacheWithTemplate} clickable={false} generatedFrom={SvgGenerator.GENERATED_FROM_TEMPLATE}/>
+                   {this.renderSvg()}
                 </Modal.Body>
                 <Modal.Footer>
                        <Button variant="secondary" onClick={this.handleClose}>Close</Button>