summaryrefslogtreecommitdiff
path: root/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/components/modals/custom-components/NewScenarioModalComponent.js')
-rw-r--r--frontend/src/components/modals/custom-components/NewScenarioModalComponent.js43
1 files changed, 26 insertions, 17 deletions
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>