summaryrefslogtreecommitdiff
path: root/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2020-11-10 22:02:48 +0100
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-11-10 22:02:48 +0100
commitd0e07a0fc06a83ed45dd7c491e1475e340aa564e (patch)
tree0f70522dc6869afb0f467ff5375bc75e27ea8f44 /frontend/src/components/modals/custom-components/NewScenarioModalComponent.js
parent2cf9276550b49bc102fb84a6debbbbac694d3e92 (diff)
Perform form validation in modals
This change updates the modal components to perform validation before submitting the request.
Diffstat (limited to 'frontend/src/components/modals/custom-components/NewScenarioModalComponent.js')
-rw-r--r--frontend/src/components/modals/custom-components/NewScenarioModalComponent.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js b/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js
index 631082a2..01a5719c 100644
--- a/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js
+++ b/frontend/src/components/modals/custom-components/NewScenarioModalComponent.js
@@ -13,6 +13,7 @@ const NewScenarioModalComponent = ({
topologies,
schedulers,
}) => {
+ const form = useRef(null)
const textInput = useRef(null)
const traceSelect = useRef(null)
const traceLoadInput = useRef(null)
@@ -22,6 +23,9 @@ const NewScenarioModalComponent = ({
const schedulerSelect = useRef(null)
const onSubmit = () => {
+ if (!form.current.reportValidity()) {
+ return false
+ }
callback(
textInput.current.value,
currentPortfolioId,
@@ -38,6 +42,7 @@ const NewScenarioModalComponent = ({
schedulerName: schedulerSelect.current.value,
}
)
+ return true
}
const onCancel = () => {
callback(undefined)
@@ -50,6 +55,7 @@ const NewScenarioModalComponent = ({
e.preventDefault()
onSubmit()
}}
+ innerRef={form}
>
<FormGroup>
<Label for="name">Name</Label>