summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopologyModal.js
diff options
context:
space:
mode:
authorvincent van beek <vincent@vlogic.nl>2026-03-27 16:49:40 +0100
committerGitHub <noreply@github.com>2026-03-27 15:49:40 +0000
commit048bf777997bdbf599240645fc66612c98abf3c2 (patch)
treec04e999cb981c98ae9dc0fd83ea70aec9eaa419c /opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopologyModal.js
parent235057cd170f1583db14bf93ea7d2de39e492356 (diff)
Add import topology (#393)
* add a the posibility to import and export topogies in JSON format * fix web-runner integration, there were several bugs and mismatches between new implementations in OpenDC and the UI
Diffstat (limited to 'opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopologyModal.js')
-rw-r--r--opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopologyModal.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopologyModal.js b/opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopologyModal.js
index 780ec034..68b7f150 100644
--- a/opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopologyModal.js
+++ b/opendc-web/opendc-web-server/src/main/webui/components/projects/NewTopologyModal.js
@@ -54,7 +54,10 @@ const NewTopologyModal = ({ projectId, isOpen, onSubmit: onSubmitUpstream, onCan
const name = nameInput.current.value
if (!name) {
- setErrors({ name: true })
+ setErrors({ name: 'empty' })
+ return false
+ } else if (topologies.some((topology) => topology.name === name)) {
+ setErrors({ name: 'duplicate' })
return false
} else {
const candidate = topologies.find((topology) => topology.id === originTopology) || { rooms: [] }
@@ -83,7 +86,11 @@ const NewTopologyModal = ({ projectId, isOpen, onSubmit: onSubmitUpstream, onCan
fieldId="name"
isRequired
validated={isSubmitted && errors.name ? 'error' : 'default'}
- helperTextInvalid="This field cannot be empty"
+ helperTextInvalid={
+ errors.name === 'empty'
+ ? 'This field cannot be empty'
+ : 'This topology name already exists'
+ }
>
<TextInput id="name" name="name" type="text" isRequired ref={nameInput} />
</FormGroup>