Skip to content

Commit b19a894

Browse files
author
Marco Pereirinha
committed
Improve the worklfow to udpate the connection string
1 parent 26bfc29 commit b19a894

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/js/components/wizard.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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 ) {

ui-definitions/components/wizard.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
<input type="text" class="connection-string cld-ui-input regular-text" name="connect[cloudinary_url]" id="connect.cloudinary_url" value="" placeholder="cloudinary://API_KEY:API_SECRET@CLOUD_NAME">
143143
</div>
144144
<button id="update-connection" class="button button-primary hidden"><?php esc_html_e( 'Update the connection string', 'cloudinary' ); ?></button>
145+
<button id="cancel-update-connection" class="button button-secondary hidden"><?php esc_html_e( 'Cancel the update', 'cloudinary' ); ?></button>
145146
<span id="connection-success" class="cld-wizard-connect-status success">
146147
<span class="dashicons dashicons-yes-alt"></span> <?php esc_html_e( 'Connected!', 'cloudinary' ); ?>
147148
</span>

0 commit comments

Comments
 (0)