jenkins-bot has submitted this change and it was merged.

Change subject: Add some error details to bug report
......................................................................


Add some error details to bug report

Bug: T111112
Change-Id: I1c3a31ddaefdfec0d86b80891671316741e53b0c
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M resources/mmv/ui/mmv.ui.canvas.js
M resources/mmv/ui/mmv.ui.metadataPanel.js
5 files changed, 45 insertions(+), 11 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/extension.json b/extension.json
index 0e3fe39..c89d023 100644
--- a/extension.json
+++ b/extension.json
@@ -144,6 +144,8 @@
                                "multimediaviewer-thumbnail-error-description",
                                "multimediaviewer-thumbnail-error-retry",
                                "multimediaviewer-report-issue-url",
+                               "multimediaviewer-thumbnail-error-report",
+                               "multimediaviewer-errorreport-privacywarning",
                                "multimediaviewer-download-link",
                                "multimediaviewer-reuse-link",
                                "multimediaviewer-options-tooltip",
diff --git a/i18n/en.json b/i18n/en.json
index adfe8f4..7377d5d 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -19,9 +19,10 @@
        "multimediaviewer-multiple-authors-combine": "$1 and $2",
        "multimediaviewer-metadata-error": "Could not load image details 
(error: $1)",
        "multimediaviewer-thumbnail-error": "Sorry, the file cannot be 
displayed",
-       "multimediaviewer-thumbnail-error-description": "There seems to be a 
technical issue. You can $1 or [{{int:multimediaviewer-report-issue-url}} 
report the issue] if it persists. Error: $2",
+       "multimediaviewer-thumbnail-error-description": "There seems to be a 
technical issue. You can $1 or $3 if it persists. Error: $2",
        "multimediaviewer-thumbnail-error-retry": "retry",
-       "multimediaviewer-report-issue-url": 
"https://phabricator.wikimedia.org/maniphest/task/create/?projects=PHID-PROJ-cabyqp5sf4hyvauln3sq";,
+       "multimediaviewer-thumbnail-error-report": "report the issue",
+       "multimediaviewer-report-issue-url": 
"https://phabricator.wikimedia.org/maniphest/task/create/?projects=PHID-PROJ-cabyqp5sf4hyvauln3sq&description=$1";,
        "multimediaviewer-license-cc-by-1.0": "CC BY 1.0",
        "multimediaviewer-license-cc-sa-1.0": "CC SA 1.0",
        "multimediaviewer-license-cc-by-sa-1.0": "CC BY-SA 1.0",
@@ -159,5 +160,6 @@
        "multimediaviewer-enable-confirmation-text": "Next time you click on a 
thumbnail on $1, Media Viewer will be used.",
        "multimediaviewer-enable-alert": "Media Viewer is now disabled",
        "multimediaviewer-disable-info-title": "You have disabled Media Viewer",
-       "multimediaviewer-disable-info": "You can still view individual files 
with Media Viewer."
+       "multimediaviewer-disable-info": "You can still view individual files 
with Media Viewer.",
+       "multimediaviewer-errorreport-privacywarning": "Details of the error 
are atteched to the report, which will be publicly viewable. If you are not 
comfortable with that, you can edit the report below and remove all data you 
don't want to share."
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 5e15d34..1026150 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -27,9 +27,10 @@
        "multimediaviewer-multiple-authors-combine": "Combines the author name 
and the message about other authors.\n* $1 - author name, parsed from the file 
page\n* $2 - {{msg-mw|multimediaviewer-multiple-authors}} wrapped in a link.",
        "multimediaviewer-metadata-error": "Text shown when the information on 
the metadata panel could not be loaded. Parameters:\n* $1 - the error message 
(not localized)\nSee also:\n* {{msg-mw|multimediaviewer-thumbnail-error}}",
        "multimediaviewer-thumbnail-error": "Text shown when the image could 
not be loaded. Followed by 
{{msg-mw|multimediaviewer-thumbnail-error-description}}.\nSee also:\n* 
{{msg-mw|multimediaviewer-thumbnail-error-description}}\n* 
{{msg-mw|multimediaviewer-metadata-error}}",
-       "multimediaviewer-thumbnail-error-description": "Text shown when the 
image could not be loaded. Follows {{msg-mw|multimediaviewer-thumbnail-error}}. 
Parameters:\n* $1 - \"retry\" link (see 
{{msg-wm|multimediaviewer-thumbnail-error-retry}})\n* $2 - the error message 
(not localized)\nSee also:\n* {{msg-mw|multimediaviewer-thumbnail-error}}",
+       "multimediaviewer-thumbnail-error-description": "Text shown when the 
image could not be loaded. Follows {{msg-mw|multimediaviewer-thumbnail-error}}. 
Parameters:\n* $1 - \"retry\" link (see 
{{msg-wm|multimediaviewer-thumbnail-error-retry}})\n* $2 - the error message 
(not localized)\n* $3 - report link (creates a Phabricator task; see 
{{msg-mw|multimediaviewer-thumbnail-error-report}})\nSee also:\n* 
{{msg-mw|multimediaviewer-thumbnail-error}}",
        "multimediaviewer-thumbnail-error-retry": "Used as a part of 
{{msg-mw|multimediaviewer-thumbnail-error-description}} (as a link 
text).\n{{Identical|Retry}}",
        "multimediaviewer-report-issue-url": "{{ignored}}URL to the report 
issue website",
+       "multimediaviewer-thumbnail-error-report": "Used as a part of 
{{msg-mw|multimediaviewer-thumbnail-error-description}} (as a link text).",
        "multimediaviewer-license-cc-by-1.0": "Very short label for the 
Creative Commons Attribution license, version 1.0, used in a link to the file 
information page that has more licensing information.\n{{Identical|CC BY}}",
        "multimediaviewer-license-cc-sa-1.0": "Very short label for the 
Creative Commons ShareAlike license, version 1.0, used in a link to the file 
information page that has more licensing information.",
        "multimediaviewer-license-cc-by-sa-1.0": "Very short label for the 
Creative Commons Attribution ShareAlike license, version 1.0, used in a link to 
the file information page that has more licensing information.\n{{Identical|CC 
BY-SA}}",
@@ -167,5 +168,6 @@
        "multimediaviewer-enable-confirmation-text": "Text confirming that the 
user successfully re-enabled the media viewer. $1 is the wiki's name.",
        "multimediaviewer-enable-alert": "Text shown in the enable panel to 
alert the user that the media viewer is currently disabled.",
        "multimediaviewer-disable-info-title": "Used as title for 
{{msg-mw|Multimediaviewer-disable-info}}.",
-       "multimediaviewer-disable-info": "The title for this message is 
{{msg-mw|Multimediaviewer-disable-info-title}}."
+       "multimediaviewer-disable-info": "The title for this message is 
{{msg-mw|Multimediaviewer-disable-info-title}}.",
+       "multimediaviewer-errorreport-privacywarning": "A warning that is 
included in the Phabricator error report that's generated when the user clicks 
on the report link on an error page."
 }
diff --git a/resources/mmv/ui/mmv.ui.canvas.js 
b/resources/mmv/ui/mmv.ui.canvas.js
index fef3c7d..6943acf 100644
--- a/resources/mmv/ui/mmv.ui.canvas.js
+++ b/resources/mmv/ui/mmv.ui.canvas.js
@@ -341,19 +341,45 @@
         * @param {string} error error message
         */
        C.showError = function ( error ) {
+               var errorDetails, description, errorUri, retryLink, reportLink,
+                       canvasDimensions = this.getDimensions(),
+                       thumbnailDimensions = this.getCurrentImageWidths(),
+                       htmlUtils = new mw.mmv.HtmlUtils();
+
+               errorDetails = [
+                       'error: ' + error,
+                       'URL: ' + location.href,
+                       'user agent: ' + navigator.userAgent,
+                       'screen size: ' + screen.width + 'x' + screen.height,
+                       'canvas size: ' + canvasDimensions.width + 'x' + 
canvasDimensions.height,
+                       'image size: ' + this.imageRawMetadata.originalWidth + 
'x' + this.imageRawMetadata.originalHeight,
+                       'thumbnail size: CSS: ' + thumbnailDimensions.cssWidth 
+ 'x' + thumbnailDimensions.cssHeight
+                               + ', screen width: ' + 
thumbnailDimensions.screen + ', real width: ' + thumbnailDimensions.real
+               ];
+               // ** is bolding in Phabricator
+               description = '**' + mw.message( 
'multimediaviewer-errorreport-privacywarning' ).text() + '**\n\n\n'
+                       + 'Error details:\n\n' + errorDetails.join( '\n' );
+               errorUri = mw.msg( 'multimediaviewer-report-issue-url', 
encodeURIComponent( description ) );
+
+               retryLink = $( '<a>' ).addClass( 'mw-mmv-retry-link' ).text(
+                       mw.msg( 'multimediaviewer-thumbnail-error-retry' ) );
+               reportLink = $( '<a>' ).attr( 'href', errorUri ).text(
+                       mw.msg( 'multimediaviewer-thumbnail-error-report' ) );
+
                this.$imageDiv.empty()
                        .addClass( 'error' )
                        .append(
                                $( '<div>' ).addClass( 'error-box' ).append(
                                        $( '<div>' ).addClass( 
'mw-mmv-error-text' ).text(
-                                               mw.message( 
'multimediaviewer-thumbnail-error' ).text()
+                                               mw.msg( 
'multimediaviewer-thumbnail-error' )
                                        )
                                ).append(
                                        $( '<div>' ).addClass( 
'mw-mmv-error-description' ).append(
-                                               mw.message( 
'multimediaviewer-thumbnail-error-description',
-                                                       $( '<a>' ).addClass( 
'mw-mmv-retry-link' ).text(
-                                                               mw.message( 
'multimediaviewer-thumbnail-error-retry' ).text() ),
-                                                       error ).parse()
+                                               mw.msg( 
'multimediaviewer-thumbnail-error-description',
+                                                       htmlUtils.jqueryToHtml( 
retryLink ),
+                                                       error,
+                                                       htmlUtils.jqueryToHtml( 
reportLink )
+                                               )
                                        )
                                )
                        );
diff --git a/resources/mmv/ui/mmv.ui.metadataPanel.js 
b/resources/mmv/ui/mmv.ui.metadataPanel.js
index fc8d001..919ff9d 100644
--- a/resources/mmv/ui/mmv.ui.metadataPanel.js
+++ b/resources/mmv/ui/mmv.ui.metadataPanel.js
@@ -460,7 +460,9 @@
        MPP.setUserPageLink = function ( repoData, username, gender ) {
                var userpage = 'User:' + username,
                        articlePath = repoData.getArticlePath(),
-                       userlink = articlePath.replace( '$1', userpage );
+                       // articlePath is null when the imageinfo API query 
fails
+                       userlink = ( typeof articlePath === 'string' )
+                               ? articlePath.replace( '$1', userpage ) : 
undefined;
 
                this.$username
                        .text(

-- 
To view, visit https://gerrit.wikimedia.org/r/247969
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1c3a31ddaefdfec0d86b80891671316741e53b0c
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Jdlrobson <jrob...@wikimedia.org>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to