@@ -383,17 +383,33 @@ function NewContainerController(
383383 } ;
384384
385385 NCC . canCreateBuild = function ( ) {
386- return keypather . get ( NCC , 'state.instanceName.length' ) && ! keypather . get ( NCC , 'nameForm.$invalid' ) &&
387- ! $rootScope . isLoading . newContainerSingleRepo && ! $rootScope . isLoading . creatingDockerCompose && ( NCC . state . templateSource ||
388- ! $scope . $root . featureFlags . composeNewService || NCC . validateDockerComposeBuild ( ) ) ;
386+ var hasInstances = keypather . get ( NCC , 'state.instanceName.length' ) ;
387+ var isLoading = $rootScope . isLoading . newContainerSingleRepo || $rootScope . isLoading . creatingDockerCompose ;
388+ var isFormValid = ! keypather . get ( NCC , 'nameForm.$invalid' ) ;
389+ var isTemplate = NCC . state . templateSource ;
390+ var isValidCompose = ! $scope . $root . featureFlags . composeNewService || NCC . validateDockerComposeBuild ( ) ;
391+ return hasInstances &&
392+ isFormValid &&
393+ ! isLoading &&
394+ ( isTemplate || isValidCompose ) ;
389395 } ;
390396
391397 NCC . validateDockerComposeBuild = function ( ) {
392- return ( ( NCC . state . configurationMethod === 'new' || NCC . state . configurationMethod === 'blankDockerfile' ) ||
393- ( NCC . state . configurationMethod === 'dockerfile' && NCC . state . dockerfile ) ||
394- ( NCC . state . configurationMethod === 'dockerComposeFile' &&
395- ( ( NCC . state . types . test ? NCC . state . dockerComposeTestFile && NCC . state . testReporter : NCC . state . types . stage ) &&
396- ( NCC . state . types . stage ? NCC . state . dockerComposeFile : NCC . state . types . test ) ) ) ) ;
398+ var isNewBlankDockerfile = [ 'new' , 'blankDockerfile' ] . includes ( NCC . state . configurationMethod ) ;
399+ var isValidDockerfile = NCC . state . configurationMethod === 'dockerfile' && NCC . state . dockerfile ;
400+ var isValidComposeFile = false ;
401+ if ( NCC . state . configurationMethod === 'dockerComposeFile' ) {
402+ var isValidTestCompose = true , isValidStagingCompose = true ;
403+ var hasTestOrStaging = NCC . state . types . test || NCC . state . types . stage ;
404+ if ( NCC . state . types . test ) {
405+ isValidTestCompose = NCC . state . dockerComposeTestFile && NCC . state . testReporter ;
406+ }
407+ if ( NCC . state . types . stage ) {
408+ isValidStagingCompose = NCC . state . dockerComposeFile ;
409+ }
410+ isValidComposeFile = hasTestOrStaging && isValidTestCompose && isValidStagingCompose ;
411+ }
412+ return isNewBlankDockerfile || isValidDockerfile || isValidComposeFile ;
397413 } ;
398414
399415 NCC . isSaving = function ( ) {
0 commit comments