diff --git a/resources/mmv/ui/mmv.ui.metadataPanel.js b/resources/mmv/ui/mmv.ui.metadataPanel.js index d13a9830d..ac41b14a3 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 dcc72b0d9..2cc3947b9 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' );