@@ -30,7 +30,12 @@ const Wizard = {
3030 working : document . getElementById ( 'connection-working' ) ,
3131 } ,
3232 debounceConnect : null ,
33+ updateConnection : document . getElementById ( 'update-connection' ) ,
34+ cancelUpdateConnection : document . getElementById (
35+ 'cancel-update-connection'
36+ ) ,
3337 config : { } ,
38+ didSave : false ,
3439 init ( ) {
3540 if ( ! cldData . wizard ) {
3641 return ;
@@ -55,12 +60,23 @@ const Wizard = {
5560 const connectionInput = document . getElementById (
5661 'connect.cloudinary_url'
5762 ) ;
58- const updateConnection = document . getElementById ( 'update-connection' ) ;
59- const didSave = false ;
6063
61- updateConnection . addEventListener ( 'click' , ( ) => {
64+ this . updateConnection . addEventListener ( 'click' , ( ) => {
65+ this . lockNext ( ) ;
6266 connectionInput . parentNode . classList . remove ( 'hidden' ) ;
63- updateConnection . classList . add ( 'hidden' ) ;
67+ this . cancelUpdateConnection . classList . remove ( 'hidden' ) ;
68+ this . updateConnection . classList . add ( 'hidden' ) ;
69+ } ) ;
70+
71+ this . cancelUpdateConnection . addEventListener ( 'click' , ( ) => {
72+ this . unlockNext ( ) ;
73+ connectionInput . parentNode . classList . add ( 'hidden' ) ;
74+ this . cancelUpdateConnection . classList . add ( 'hidden' ) ;
75+ this . updateConnection . classList . remove ( 'hidden' ) ;
76+ this . config . cldString = true ;
77+ connectionInput . value = '' ;
78+ this . connection . error . classList . remove ( 'active' ) ;
79+ this . connection . success . classList . add ( 'active' ) ;
6480 } ) ;
6581
6682 [ ...navs ] . forEach ( ( button ) => {
@@ -104,7 +120,7 @@ const Wizard = {
104120
105121 if ( this . config . cldString ) {
106122 connectionInput . parentNode . classList . add ( 'hidden' ) ;
107- updateConnection . classList . remove ( 'hidden' ) ;
123+ this . updateConnection . classList . remove ( 'hidden' ) ;
108124 }
109125
110126 this . getTab ( this . config . tab ) ;
@@ -202,6 +218,9 @@ const Wizard = {
202218 } else {
203219 this . showSuccess ( ) ;
204220 }
221+ if ( this . updateConnection . classList . contains ( 'hidden' ) ) {
222+ this . lockNext ( ) ;
223+ }
205224 break ;
206225 case 3 :
207226 if ( ! this . config . cldString ) {
0 commit comments