jenkins-bot has submitted this change and it was merged.
Change subject: Refactor mw.ErrorDialog to use OO.ui.alert()
......................................................................
Refactor mw.ErrorDialog to use OO.ui.alert()
* Simplify mw.ErrorDialog by turning it into a helper function for
OO.ui.alert() with default values
* mw.ErrorDialog is now a function, mw.errorDialog()
Bug: T117079
Change-Id: I05870f28445b751a103325bdfdd2805a8d0d3477
---
M UploadWizardHooks.php
M resources/details/uw.TitleDetailsWidget.js
D resources/mw.ErrorDialog.js
M resources/mw.FlickrChecker.js
M resources/mw.UploadWizardUpload.js
M resources/mw.UploadWizardUploadInterface.js
A resources/mw.errorDialog.js
M resources/ui/steps/uw.ui.Upload.js
8 files changed, 50 insertions(+), 68 deletions(-)
Approvals:
Bartosz Dziewoński: Looks good to me, approved
jenkins-bot: Verified
diff --git a/UploadWizardHooks.php b/UploadWizardHooks.php
index 919ecea..040f15c 100644
--- a/UploadWizardHooks.php
+++ b/UploadWizardHooks.php
@@ -81,7 +81,7 @@
'resources/mw.fileApi.js',
'resources/mw.units.js',
'resources/mw.canvas.js',
- 'resources/mw.ErrorDialog.js',
+ 'resources/mw.errorDialog.js',
// title validity checks
'resources/mw.DestinationChecker.js',
diff --git a/resources/details/uw.TitleDetailsWidget.js
b/resources/details/uw.TitleDetailsWidget.js
index 1d29996..5fc884d 100644
--- a/resources/details/uw.TitleDetailsWidget.js
+++ b/resources/details/uw.TitleDetailsWidget.js
@@ -142,8 +142,7 @@
'mwe-upwiz-blacklisted-details',
titleString,
function () {
- var errorDialog = new mw.ErrorDialog(
result.blacklist.blacklistReason );
- errorDialog.open();
+ mw.errorDialog(
result.blacklist.blacklistReason );
}
];
diff --git a/resources/mw.ErrorDialog.js b/resources/mw.ErrorDialog.js
deleted file mode 100644
index 1b0ce39..0000000
--- a/resources/mw.ErrorDialog.js
+++ /dev/null
@@ -1,32 +0,0 @@
-( function ( mw, $ ) {
-
- /**
- * Displays an error message.
- *
- * @param {string} errorMessage
- * @param {string} [title]
- */
- mw.ErrorDialog = function ( errorMessage, title ) {
- this.errorMessage = errorMessage;
- this.title = title || mw.message( 'mwe-upwiz-errordialog-title'
).text();
- this.windowManager = new OO.ui.WindowManager();
- $( 'body' ).append( this.windowManager.$element );
- this.dialog = new OO.ui.MessageDialog();
- this.windowManager.addWindows( [ this.dialog ] );
- };
-
- mw.ErrorDialog.prototype.open = function () {
- this.windowManager.openWindow( this.dialog, {
- title: this.title,
- message: this.errorMessage,
- verbose: true,
- actions: [
- {
- label: mw.message(
'mwe-upwiz-errordialog-ok' ).text(),
- action: 'accept'
- }
- ]
- } );
- };
-
-}( mediaWiki, jQuery ) );
diff --git a/resources/mw.FlickrChecker.js b/resources/mw.FlickrChecker.js
index bc0c7ac..5abcbb7 100644
--- a/resources/mw.FlickrChecker.js
+++ b/resources/mw.FlickrChecker.js
@@ -109,7 +109,7 @@
}
} else {
// XXX show user the message that the URL
entered was not valid
- this.showErrorDialog( mw.message(
'mwe-upwiz-url-invalid', 'Flickr' ).escaped() );
+ mw.errorDialog( mw.message(
'mwe-upwiz-url-invalid', 'Flickr' ).escaped() );
this.wizard.flickrInterfaceReset();
}
},
@@ -475,7 +475,7 @@
$(
'#mwe-upwiz-flickr-select-list-container' ).show();
}
} ).fail( function ( message ) {
- checker.showErrorDialog( message );
+ mw.errorDialog( message );
checker.wizard.flickrInterfaceReset();
} );
},
@@ -554,7 +554,7 @@
checker.setImageURL( 0, checker );
checker.reserveFileName( fileName );
} ).fail( function ( message ) {
- checker.showErrorDialog( message );
+ mw.errorDialog( message );
checker.wizard.flickrInterfaceReset();
} );
},
@@ -696,7 +696,7 @@
newUpload.fill( upload );
} else {
- checker.showErrorDialog( mw.message(
'mwe-upwiz-error-no-image-retrieved', 'Flickr' ).escaped() );
+ mw.errorDialog( mw.message(
'mwe-upwiz-error-no-image-retrieved', 'Flickr' ).escaped() );
checker.wizard.flickrInterfaceReset();
}
} );
@@ -723,13 +723,7 @@
};
return license;
- },
-
- showErrorDialog: function ( errorMsg ) {
- var errorDialog = new mw.ErrorDialog( errorMsg );
- errorDialog.open();
}
-
};
} )( mediaWiki, jQuery, OO );
diff --git a/resources/mw.UploadWizardUpload.js
b/resources/mw.UploadWizardUpload.js
index da20c4d..f548572 100644
--- a/resources/mw.UploadWizardUpload.js
+++ b/resources/mw.UploadWizardUpload.js
@@ -579,16 +579,14 @@
* @param {number} maxSize Maximum file size
*/
mw.UploadWizardUpload.prototype.showMaxSizeWarning = function ( size,
maxSize ) {
- var ed = new mw.ErrorDialog(
- mw.message(
- 'mwe-upwiz-file-too-large-text',
- mw.units.bytes( maxSize ),
- mw.units.bytes( size )
- ).text(),
- mw.message( 'mwe-upwiz-file-too-large' ).text()
- );
-
- ed.open();
+ mw.errorDialog(
+ mw.message(
+ 'mwe-upwiz-file-too-large-text',
+ mw.units.bytes( maxSize ),
+ mw.units.bytes( size )
+ ).text(),
+ mw.message( 'mwe-upwiz-file-too-large' ).text()
+ );
};
/**
diff --git a/resources/mw.UploadWizardUploadInterface.js
b/resources/mw.UploadWizardUploadInterface.js
index 322474c..37d4e1e 100644
--- a/resources/mw.UploadWizardUploadInterface.js
+++ b/resources/mw.UploadWizardUploadInterface.js
@@ -460,7 +460,7 @@
};
mw.UploadWizardUploadInterface.prototype.showFilenameError = function (
$text ) {
- var msgText, dialog;
+ var msgText;
if ( $text instanceof jQuery ) {
msgText = $text.text();
@@ -469,8 +469,7 @@
}
uw.eventFlowLogger.logError( 'file', { code: 'filename',
message: msgText } );
- dialog = new mw.ErrorDialog( $text );
- dialog.open();
+ mw.errorDialog( $text );
};
/**
diff --git a/resources/mw.errorDialog.js b/resources/mw.errorDialog.js
new file mode 100644
index 0000000..8c179ec
--- /dev/null
+++ b/resources/mw.errorDialog.js
@@ -0,0 +1,26 @@
+( function ( mw ) {
+
+ /**
+ * Displays an error message.
+ *
+ * @param {string} errorMessage
+ * @param {string} [title]
+ */
+ mw.errorDialog = function ( errorMessage, title ) {
+ OO.ui.alert(
+ errorMessage,
+ {
+ title: title || mw.message(
'mwe-upwiz-errordialog-title' ).text(),
+ message: errorMessage,
+ verbose: true,
+ actions: [
+ {
+ label: mw.message(
'mwe-upwiz-errordialog-ok' ).text(),
+ action: 'accept'
+ }
+ ]
+ }
+ );
+ };
+
+}( mediaWiki ) );
diff --git a/resources/ui/steps/uw.ui.Upload.js
b/resources/ui/steps/uw.ui.Upload.js
index 09ac498..c0d6607 100644
--- a/resources/ui/steps/uw.ui.Upload.js
+++ b/resources/ui/steps/uw.ui.Upload.js
@@ -339,16 +339,14 @@
* @param {number} filesUploaded The number of files that have been
attempted to upload
*/
uw.ui.Upload.prototype.showTooManyFilesWarning = function (
filesUploaded ) {
- var dialog = new mw.ErrorDialog(
- mw.message(
- 'mwe-upwiz-too-many-files-text',
- this.config.maxUploads,
- filesUploaded
- ).text(),
- mw.message( 'mwe-upwiz-too-many-files' ).text()
- );
-
- dialog.open();
+ mw.errorDialog(
+ mw.message(
+ 'mwe-upwiz-too-many-files-text',
+ this.config.maxUploads,
+ filesUploaded
+ ).text(),
+ mw.message( 'mwe-upwiz-too-many-files' ).text()
+ );
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/260945
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I05870f28445b751a103325bdfdd2805a8d0d3477
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UploadWizard
Gerrit-Branch: master
Gerrit-Owner: Sn1per <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits