import PropTypes from 'prop-types' import React from 'react' import Shapes from '../../../shapes' import Modal from '../Modal' 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), callback: PropTypes.func.isRequired, } componentDidMount() { 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.props.currentPortfolioScenarioIds.length === 0 ? 'Base scenario' : '' this.traceSelect.selectedIndex = 0 this.traceLoadInput.value = 1.0 this.topologySelect.selectedIndex = 0 this.failuresCheckbox.checked = false this.performanceInterferenceCheckbox.checked = false this.schedulerSelect.selectedIndex = 0 } onSubmit() { this.props.callback( this.textInput.value, this.props.currentPortfolioId, { traceId: this.traceSelect.value, loadSamplingFraction: parseFloat(this.traceLoadInput.value), }, { topologyId: this.topologySelect.value, }, { failuresEnabled: this.failuresCheckbox.checked, performanceInterferenceEnabled: this.performanceInterferenceCheckbox.checked, schedulerName: this.schedulerSelect.value, } ) this.reset() } onCancel() { this.props.callback(undefined) this.reset() } render() { return (
{ e.preventDefault() this.onSubmit() }} >
(this.textInput = textInput)} />

Trace

(this.traceLoadInput = traceLoadInput)} />

Topology

Operational Phenomena

) } } export default NewScenarioModalComponent