@@ -11,13 +11,9 @@ import {
1111 Stack ,
1212 Spinner ,
1313 TextInput ,
14- Modal ,
15- ModalBody ,
16- ModalHeader ,
17- ModalFooter ,
1814} from '@patternfly/react-core' ;
1915import SimpleSelect , { SimpleSelectOption } from '#~/components/SimpleSelect' ;
20- import DashboardModalFooter from '#~/concepts/dashboard/DashboardModalFooter ' ;
16+ import ContentModal from '#~/components/modals/ContentModal ' ;
2117import { ModelRegistryKind } from '#~/k8sTypes' ;
2218import { ModelRegistryModel } from '#~/api' ;
2319import {
@@ -54,6 +50,7 @@ import {
5450 DEFAULT_DATABASE_NAME ,
5551 DEFAULT_MYSQL_PORT ,
5652 DEFAULT_POSTGRES_PORT ,
53+ MAX_MODEL_REGISTRY_NAME_LENGTH ,
5754 ResourceType ,
5855 SecureDBRType ,
5956} from './const' ;
@@ -390,9 +387,8 @@ const CreateModal: React.FC<CreateModalProps> = ({ onClose, refresh, modelRegist
390387 const hasContent = ( value : string ) : boolean => ! ! value . trim ( ) . length ;
391388
392389 const canSubmit = ( ) => {
393- const isValidName = isValidK8sName (
394- nameDesc . k8sName . value || translateDisplayNameForK8s ( nameDesc . name ) ,
395- ) ;
390+ const k8sName = nameDesc . k8sName . value || translateDisplayNameForK8s ( nameDesc . name ) ;
391+ const isValidName = isValidK8sName ( k8sName ) && k8sName . length <= MAX_MODEL_REGISTRY_NAME_LENGTH ;
396392
397393 if ( databaseSource === DatabaseSource . DEFAULT ) {
398394 // For default database, only name is required
@@ -419,11 +415,36 @@ const CreateModal: React.FC<CreateModalProps> = ({ onClose, refresh, modelRegist
419415 ] ;
420416
421417 return (
422- < Modal isOpen onClose = { onCancelClose } variant = "medium" >
423- < ModalHeader title = { `${ mr ? 'Edit' : 'Create' } model registry` } />
424- < ModalBody >
418+ < ContentModal
419+ onClose = { onCancelClose }
420+ variant = "medium"
421+ title = { `${ mr ? 'Edit' : 'Create' } model registry` }
422+ error = { error }
423+ alertTitle = { `Error ${ mr ? 'updating' : 'creating' } model registry` }
424+ buttonActions = { [
425+ {
426+ label : mr ? 'Update' : 'Create' ,
427+ onClick : onSubmit ,
428+ variant : 'primary' ,
429+ isLoading : isSubmitting ,
430+ isDisabled : ! canSubmit ( ) ,
431+ dataTestId : 'modal-submit-button' ,
432+ } ,
433+ {
434+ label : 'Cancel' ,
435+ onClick : onCancelClose ,
436+ variant : 'link' ,
437+ dataTestId : 'modal-cancel-button' ,
438+ } ,
439+ ] }
440+ contents = {
425441 < Form >
426- < K8sNameDescriptionField dataTestId = "mr" data = { nameDesc } onDataChange = { setNameDesc } />
442+ < K8sNameDescriptionField
443+ dataTestId = "mr"
444+ data = { nameDesc }
445+ onDataChange = { setNameDesc }
446+ maxLength = { MAX_MODEL_REGISTRY_NAME_LENGTH }
447+ />
427448 < FormSection title = "Database" description = "Choose where to store model data." >
428449 < FormGroup role = "radiogroup" fieldId = "mr-database-source" >
429450 < Stack hasGutter >
@@ -632,19 +653,8 @@ const CreateModal: React.FC<CreateModalProps> = ({ onClose, refresh, modelRegist
632653 ) }
633654 </ FormSection >
634655 </ Form >
635- </ ModalBody >
636- < ModalFooter >
637- < DashboardModalFooter
638- onCancel = { onCancelClose }
639- onSubmit = { onSubmit }
640- submitLabel = { mr ? 'Update' : 'Create' }
641- isSubmitLoading = { isSubmitting }
642- isSubmitDisabled = { ! canSubmit ( ) }
643- error = { error }
644- alertTitle = { `Error ${ mr ? 'updating' : 'creating' } model registry` }
645- />
646- </ ModalFooter >
647- </ Modal >
656+ }
657+ />
648658 ) ;
649659} ;
650660
0 commit comments