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

Change subject: Show 'view terms' when we can't figure out the license
......................................................................


Show 'view terms' when we can't figure out the license

...since there probably still is one, and our failure to parse it
just makes it more important that we direct the user to the file
page.

Change-Id: Id31f95021f059ccf4bf9893b1146f3807dcabdcb
---
M resources/mmv/ui/mmv.ui.metadataPanel.js
M tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js
2 files changed, 14 insertions(+), 9 deletions(-)

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



diff --git a/resources/mmv/ui/mmv.ui.metadataPanel.js 
b/resources/mmv/ui/mmv.ui.metadataPanel.js
index d13a983..ac41b14 100644
--- a/resources/mmv/ui/mmv.ui.metadataPanel.js
+++ b/resources/mmv/ui/mmv.ui.metadataPanel.js
@@ -548,14 +548,20 @@
        MPP.setLicense = function ( license, filePageUrl ) {
                var message, shortName, url, isCc;
 
-               message = 'multimediaviewer-license-' + ( license.internalName 
|| '' );
-               if ( mw.messages.exists( message ) ) {
-                       shortName = mw.message( message ).text();
+               if ( license ) {
+                       message = 'multimediaviewer-license-' + ( 
license.internalName || '' );
+                       if ( mw.messages.exists( message ) ) {
+                               shortName = mw.message( message ).text();
+                       } else {
+                               shortName = mw.message( 
'multimediaviewer-license-default' ).text();
+                       }
+                       url = license.deedUrl || filePageUrl;
+                       isCc = license.isCc();
                } else {
                        shortName = mw.message( 
'multimediaviewer-license-default' ).text();
+                       url = filePageUrl;
+                       isCc = false;
                }
-               url = license.deedUrl || filePageUrl;
-               isCc = license.isCc();
 
                this.$license
                        .text( shortName )
@@ -691,9 +697,7 @@
                this.description.set( imageData.description, image.caption );
                this.categories.set( repoData.getArticlePath(), 
imageData.categories );
 
-               if ( imageData.license ) {
-                       this.setLicense( imageData.license, 
imageData.descriptionUrl );
-               }
+               this.setLicense( imageData.license, imageData.descriptionUrl );
 
                if ( imageData.permission ) {
                        this.setPermission( imageData.permission );
diff --git a/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js 
b/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js
index dcc72b0..2cc3947 100644
--- a/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js
+++ b/tests/qunit/mmv/ui/mmv.ui.metadataPanel.test.js
@@ -152,7 +152,8 @@
 
                assert.strictEqual( panel.$title.text(), title, 'Title is 
correctly set' );
                assert.ok( panel.$credit.hasClass( 'empty' ), 'Credit is empty' 
);
-               assert.ok( panel.$license.hasClass( 'empty' ), 'License is 
empty' );
+               assert.strictEqual( panel.$license.prop( 'href' ), 
imageData.descriptionUrl,
+                       'User is directed to file page for license information' 
);
                assert.ok( panel.$usernameLi.hasClass( 'empty' ), 'Username is 
empty' );
                assert.ok( panel.$datetimeLi.hasClass( 'empty' ), 'Date/Time is 
empty' );
                assert.ok( panel.$locationLi.hasClass( 'empty' ), 'Location is 
empty' );

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id31f95021f059ccf4bf9893b1146f3807dcabdcb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Gilles <gdu...@wikimedia.org>
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