diff options
| author | jc0b <j@jc0b.computer> | 2020-07-22 16:28:47 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:48:21 +0200 |
| commit | d7469b9ebb01cf36a78cc98aab31fa8f307c4f65 (patch) | |
| tree | d0535fa0cfe95001302fbd2b0d046d51caab6ffd /frontend/src/components/modals/custom-components | |
| parent | 67b6ec800df8e023efadb60ae5f7919030b19789 (diff) | |
| parent | 9e7cb3bd367607b32e102c3a87b68b33c53dec46 (diff) | |
Merge branch 'master' onto working copy
Diffstat (limited to 'frontend/src/components/modals/custom-components')
3 files changed, 41 insertions, 39 deletions
diff --git a/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js b/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js index ace2d751..2d001302 100644 --- a/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js +++ b/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js @@ -20,20 +20,17 @@ class NewPortfolioModalComponent extends React.Component { reset() { this.textInput.value = '' - AVAILABLE_METRICS.forEach(metric => { + AVAILABLE_METRICS.forEach((metric) => { this.metricCheckboxes[metric].checked = true }) this.repeatsInput.value = 1 } onSubmit() { - this.props.callback( - this.textInput.value, - { - enabledMetrics: AVAILABLE_METRICS.filter(metric => this.metricCheckboxes[metric].checked), - repeatsPerScenario: parseInt(this.repeatsInput.value), - }, - ) + this.props.callback(this.textInput.value, { + enabledMetrics: AVAILABLE_METRICS.filter((metric) => this.metricCheckboxes[metric].checked), + repeatsPerScenario: parseInt(this.repeatsInput.value), + }) this.reset() } @@ -51,7 +48,7 @@ class NewPortfolioModalComponent extends React.Component { onCancel={this.onCancel.bind(this)} > <form - onSubmit={e => { + onSubmit={(e) => { e.preventDefault() this.onSubmit() }} @@ -62,19 +59,19 @@ class NewPortfolioModalComponent extends React.Component { type="text" className="form-control" required - ref={textInput => (this.textInput = textInput)} + ref={(textInput) => (this.textInput = textInput)} /> </div> <h4>Targets</h4> <h5>Metrics</h5> <div className="form-group"> - {AVAILABLE_METRICS.map(metric => ( + {AVAILABLE_METRICS.map((metric) => ( <div className="form-check" key={metric}> <label className="form-check-label"> <input type="checkbox" className="form-check-input" - ref={checkbox => (this.metricCheckboxes[metric] = checkbox)} + ref={(checkbox) => (this.metricCheckboxes[metric] = checkbox)} /> <code>{metric}</code> </label> @@ -87,7 +84,7 @@ class NewPortfolioModalComponent extends React.Component { type="number" className="form-control" required - ref={repeatsInput => (this.repeatsInput = repeatsInput)} + ref={(repeatsInput) => (this.repeatsInput = repeatsInput)} /> </div> </form> diff --git a/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js b/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js index 4c2df2f6..d7d99982 100644 --- a/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js +++ b/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js @@ -7,6 +7,7 @@ class NewScenarioModalComponent extends React.Component { static propTypes = { show: PropTypes.bool.isRequired, currentPortfolioId: PropTypes.string.isRequired, + currentPortfolioScenarioIds: PropTypes.arrayOf(PropTypes.string), traces: PropTypes.arrayOf(Shapes.Trace), topologies: PropTypes.arrayOf(Shapes.Topology), schedulers: PropTypes.arrayOf(Shapes.Scheduler), @@ -17,8 +18,16 @@ class NewScenarioModalComponent extends React.Component { this.reset() } + componentDidUpdate() { + if (this.props.currentPortfolioScenarioIds.length === 0) { + this.textInput.value = 'Base scenario' + } else if (this.textInput.value === 'Base scenario') { + this.textInput.value = '' + } + } + reset() { - this.textInput.value = '' + this.textInput.value = this.props.currentPortfolioScenarioIds.length === 0 ? 'Base scenario' : '' this.traceSelect.selectedIndex = 0 this.traceLoadInput.value = 1.0 this.topologySelect.selectedIndex = 0 @@ -36,13 +45,13 @@ class NewScenarioModalComponent extends React.Component { loadSamplingFraction: parseFloat(this.traceLoadInput.value), }, { - topologyId: this.topologySelect.value + topologyId: this.topologySelect.value, }, { failuresEnabled: this.failuresCheckbox.checked, performanceInterferenceEnabled: this.performanceInterferenceCheckbox.checked, schedulerName: this.schedulerSelect.value, - }, + } ) this.reset() } @@ -61,7 +70,7 @@ class NewScenarioModalComponent extends React.Component { onCancel={this.onCancel.bind(this)} > <form - onSubmit={e => { + onSubmit={(e) => { e.preventDefault() this.onSubmit() }} @@ -72,17 +81,15 @@ class NewScenarioModalComponent extends React.Component { type="text" className="form-control" required - ref={textInput => (this.textInput = textInput)} + disabled={this.props.currentPortfolioScenarioIds.length === 0} + ref={(textInput) => (this.textInput = textInput)} /> </div> <h4>Trace</h4> <div className="form-group"> <label className="form-control-label">Trace</label> - <select - className="form-control" - ref={traceSelect => (this.traceSelect = traceSelect)} - > - {this.props.traces.map(trace => ( + <select className="form-control" ref={(traceSelect) => (this.traceSelect = traceSelect)}> + {this.props.traces.map((trace) => ( <option value={trace._id} key={trace._id}> {trace.name} </option> @@ -95,7 +102,7 @@ class NewScenarioModalComponent extends React.Component { type="number" className="form-control" required - ref={traceLoadInput => (this.traceLoadInput = traceLoadInput)} + ref={(traceLoadInput) => (this.traceLoadInput = traceLoadInput)} /> </div> <h4>Topology</h4> @@ -103,9 +110,9 @@ class NewScenarioModalComponent extends React.Component { <label className="form-control-label">Topology</label> <select className="form-control" - ref={topologySelect => (this.topologySelect = topologySelect)} + ref={(topologySelect) => (this.topologySelect = topologySelect)} > - {this.props.topologies.map(topology => ( + {this.props.topologies.map((topology) => ( <option value={topology._id} key={topology._id}> {topology.name} </option> @@ -118,7 +125,7 @@ class NewScenarioModalComponent extends React.Component { <input type="checkbox" className="form-check-input" - ref={failuresCheckbox => (this.failuresCheckbox = failuresCheckbox)} + ref={(failuresCheckbox) => (this.failuresCheckbox = failuresCheckbox)} /> <span className="ml-2">Enable failures</span> </label> @@ -128,7 +135,9 @@ class NewScenarioModalComponent extends React.Component { <input type="checkbox" className="form-check-input" - ref={performanceInterferenceCheckbox => (this.performanceInterferenceCheckbox = performanceInterferenceCheckbox)} + ref={(performanceInterferenceCheckbox) => + (this.performanceInterferenceCheckbox = performanceInterferenceCheckbox) + } /> <span className="ml-2">Enable performance interference</span> </label> @@ -137,9 +146,9 @@ class NewScenarioModalComponent extends React.Component { <label className="form-control-label">Scheduler</label> <select className="form-control" - ref={schedulerSelect => (this.schedulerSelect = schedulerSelect)} + ref={(schedulerSelect) => (this.schedulerSelect = schedulerSelect)} > - {this.props.schedulers.map(scheduler => ( + {this.props.schedulers.map((scheduler) => ( <option value={scheduler.name} key={scheduler.name}> {scheduler.name} </option> diff --git a/frontend/src/components/modals/custom-components/NewTopologyModalComponent.js b/frontend/src/components/modals/custom-components/NewTopologyModalComponent.js index a0d736a1..a244b730 100644 --- a/frontend/src/components/modals/custom-components/NewTopologyModalComponent.js +++ b/frontend/src/components/modals/custom-components/NewTopologyModalComponent.js @@ -31,10 +31,7 @@ class NewTopologyModalComponent extends React.Component { } onDuplicate() { - this.props.onCreateTopology( - this.textInput.value, - this.originTopology.value, - ) + this.props.onDuplicateTopology(this.textInput.value, this.originTopology.value) this.reset() } @@ -52,7 +49,7 @@ class NewTopologyModalComponent extends React.Component { onCancel={this.onCancel.bind(this)} > <form - onSubmit={e => { + onSubmit={(e) => { e.preventDefault() this.onSubmit() }} @@ -63,20 +60,19 @@ class NewTopologyModalComponent extends React.Component { type="text" className="form-control" required - ref={textInput => (this.textInput = textInput)} + ref={(textInput) => (this.textInput = textInput)} /> </div> <div className="form-group"> <label className="form-control-label">Topology to duplicate (not supported yet)</label> <select className="form-control" - disabled - ref={originTopology => (this.originTopology = originTopology)} + ref={(originTopology) => (this.originTopology = originTopology)} > <option value={-1} key={-1}> None - start from scratch </option> - {this.props.topologies.map(topology => ( + {this.props.topologies.map((topology) => ( <option value={topology._id} key={topology._id}> {topology.name} </option> |
