Skip to content

Commit d17337b

Browse files
author
Marco Pereirinha
committed
Add confirmation dialog for Cloudinary only storage
1 parent 30d00be commit d17337b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

js/src/deactivate.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const Deactivate = {
77
pluginListLinks: document.querySelectorAll(
88
'.cld-deactivate-link, .cld-deactivate'
99
),
10+
// The deactivation links when Cloudinary only is set for storage.
11+
triggers: document.getElementsByClassName( 'cld-deactivate' ),
1012
// The reasons.
1113
options: document.querySelectorAll(
1214
'.cloudinary-deactivation input[type="radio"]'
@@ -53,6 +55,24 @@ const Deactivate = {
5355
} );
5456
} );
5557

58+
// Add it a trigger watch to stop deactivation.
59+
[ ...context.triggers ].forEach( ( trigger ) => {
60+
trigger.addEventListener( 'click', function ( ev ) {
61+
if (
62+
! confirm(
63+
wp.i18n.__(
64+
'Caution: Your storage setting is currently set to "Cloudinary only", disabling the plugin will result in broken links to media assets. Are you sure you want to continue?',
65+
'cloudinary'
66+
)
67+
)
68+
) {
69+
ev.preventDefault();
70+
// Close the feedback form.
71+
document.getElementById( 'TB_closeWindowButton' ).click();
72+
}
73+
} );
74+
} );
75+
5676
// Add event listener to skip feedback.
5777
context.skipButton.addEventListener( 'click', function () {
5878
window.location.href = context.deactivationUrl;

0 commit comments

Comments
 (0)