@@ -31,52 +31,62 @@ export class RegistrySettingsModalComponent implements OnInit {
31
31
32
32
public confirm ( ) {
33
33
this . loading = true ;
34
+ this . dialogRef . disableClose = true ;
35
+
34
36
this . registryFormGroup . disable ( ) ;
35
- let obs : Observable < any > ;
37
+ let obs : Observable < any > = of ( null ) ;
36
38
37
- const registrySettings = this . registryFormGroup . getRawValue ( ) as DockerRegistrySettings ;
39
+ const credentialsNeedTesting = this . registryFormGroup . get ( 'username' ) . dirty
40
+ || this . registryFormGroup . get ( 'url' ) . dirty
41
+ || this . registryFormGroup . get ( 'password' ) . dirty ;
38
42
39
- if ( registrySettings . isDockerHub ) {
40
- const username = registrySettings . username ;
41
- const password = registrySettings . password ;
42
- if ( username ) {
43
- obs = this . dockerHub . logIn ( username , password )
43
+ if ( ! credentialsNeedTesting ) {
44
+ // If username/password did not change, do not revalidate them
45
+ this . registryFormGroup . enable ( ) ;
46
+ this . dialogRef . close ( this . registryFormGroup ) ;
47
+ } else {
48
+ const registrySettings = this . registryFormGroup . getRawValue ( ) as DockerRegistrySettings ;
49
+ if ( registrySettings . isDockerHub ) {
50
+ const username = registrySettings . username ;
51
+ const password = registrySettings . password ;
52
+ if ( username ) {
53
+ obs = this . dockerHub . logIn ( username , password )
54
+ . pipe ( catchError ( ( error : HttpErrorResponse ) => {
55
+ this . notification . open ( error . error . detail || error . message , null , {
56
+ panelClass : 'tim-bg-warn'
57
+ } ) ;
58
+ return throwError ( error ) ;
59
+ } ) ) ;
60
+ } else {
61
+ obs = of ( null ) ;
62
+ }
63
+ } else {
64
+ obs = this . registry . testRegistrySettings ( registrySettings )
44
65
. pipe ( catchError ( ( error : HttpErrorResponse ) => {
45
- this . notification . open ( error . error . detail || error . message , null , {
66
+ this . notification . open ( error . error || error . message , null , {
46
67
panelClass : 'tim-bg-warn'
47
68
} ) ;
48
69
return throwError ( error ) ;
49
70
} ) ) ;
50
- } else {
51
- obs = of ( null ) ;
52
71
}
53
- } else {
54
- obs = this . registry . testRegistrySettings ( registrySettings )
55
- . pipe ( catchError ( ( error : HttpErrorResponse ) => {
56
- this . notification . open ( error . error || error . message , null , {
57
- panelClass : 'tim-bg-warn'
72
+ obs
73
+ . pipe ( take ( 1 ) )
74
+ . subscribe ( ( ) => {
75
+ this . registryFormGroup . enable ( ) ;
76
+ this . dialogRef . close ( this . registryFormGroup ) ;
77
+ this . notification . open ( 'Login succeded' , null , {
78
+ panelClass : 'tim-bg-primary'
58
79
} ) ;
59
- return throwError ( error ) ;
60
- } ) ) ;
61
- }
62
-
63
- obs
64
- . pipe ( take ( 1 ) )
65
- . subscribe ( ( ) => {
66
- this . registryFormGroup . enable ( ) ;
67
- this . dialogRef . close ( this . registryFormGroup ) ;
68
- this . notification . open ( 'Login succeded' , null , {
69
- panelClass : 'tim-bg-primary'
70
- } ) ;
71
- } , error => {
72
- this . loading = false ;
73
- this . registryFormGroup . enable ( ) ;
80
+ } , error => {
81
+ this . loading = false ;
82
+ this . registryFormGroup . enable ( ) ;
74
83
75
- if ( this . registryFormGroup . value . isDockerHub ) {
76
- this . registryFormGroup . get ( 'url' ) . disable ( ) ;
77
- }
84
+ if ( this . registryFormGroup . value . isDockerHub ) {
85
+ this . registryFormGroup . get ( 'url' ) . disable ( ) ;
86
+ }
78
87
79
- console . error ( error ) ;
80
- } ) ;
88
+ console . error ( error ) ;
89
+ } ) ;
90
+ }
81
91
}
82
92
}
0 commit comments