44 Button ,
55 Form ,
66 FormGroup ,
7+ HelperText ,
8+ HelperTextItem ,
79 Stack ,
810 StackItem ,
911 TextInput ,
@@ -26,16 +28,23 @@ import { TrackingOutcome } from '#~/concepts/analyticsTracking/trackingPropertie
2628
2729type CreateExperimentModalProps = {
2830 onClose : ( experiment ?: ExperimentKF ) => void ;
31+ existingNames ?: string [ ] ;
2932} ;
3033
3134const eventName = 'Experiment Created' ;
32- const CreateExperimentModal : React . FC < CreateExperimentModalProps > = ( { onClose } ) => {
35+ const CreateExperimentModal : React . FC < CreateExperimentModalProps > = ( {
36+ onClose,
37+ existingNames = [ ] ,
38+ } ) => {
3339 const { project, api, apiAvailable } = usePipelinesAPI ( ) ;
3440 const [ submitting , setSubmitting ] = React . useState ( false ) ;
3541 const [ error , setError ] = React . useState < Error | undefined > ( ) ;
3642 const [ { name, description } , setData , resetData ] = useCreateExperimentData ( ) ;
3743
38- const haveEnoughData = ! ! name ;
44+ const isDuplicate = existingNames . some (
45+ ( existing ) => existing . toLowerCase ( ) === name . trim ( ) . toLowerCase ( ) ,
46+ ) ;
47+ const haveEnoughData = ! ! name && ! isDuplicate ;
3948
4049 const onBeforeClose = ( experiment ?: ExperimentKF ) => {
4150 onClose ( experiment ) ;
@@ -72,11 +81,19 @@ const CreateExperimentModal: React.FC<CreateExperimentModalProps> = ({ onClose }
7281 id = "experiment-name"
7382 name = "experiment-name"
7483 value = { name }
84+ validated = { isDuplicate ? 'error' : 'default' }
7585 onChange = { ( _ , value ) => setData ( 'name' , value ) }
7686 maxLength = { NAME_CHARACTER_LIMIT }
7787 />
78-
79- < CharLimitHelperText limit = { NAME_CHARACTER_LIMIT } currentLength = { name . length } />
88+ { isDuplicate ? (
89+ < HelperText >
90+ < HelperTextItem variant = "error" >
91+ A run group with this name already exists.
92+ </ HelperTextItem >
93+ </ HelperText >
94+ ) : (
95+ < CharLimitHelperText limit = { NAME_CHARACTER_LIMIT } currentLength = { name . length } />
96+ ) }
8097 </ FormGroup >
8198 </ StackItem >
8299 < StackItem >
0 commit comments