jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/342949 )
Change subject: VisualDiff: Add custom messages for change descriptions ...................................................................... VisualDiff: Add custom messages for change descriptions Bug: T151403 Change-Id: I469a3c7897f2417c1850364f65da51c0deca2386 --- M extension.json M modules/ve-mw/dm/annotations/ve.dm.MWExternalLinkAnnotation.js M modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js M modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js M modules/ve-mw/dm/nodes/ve.dm.MWImageNode.js M modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js M modules/ve-mw/i18n/en.json M modules/ve-mw/i18n/qqq.json 8 files changed, 96 insertions(+), 1 deletion(-) Approvals: jenkins-bot: Verified Jforrester: Looks good to me, approved diff --git a/extension.json b/extension.json index fc0df1c..6985359 100644 --- a/extension.json +++ b/extension.json @@ -1323,7 +1323,7 @@ "ext.visualEditor.mwtransclusion", "ext.visualEditor.mwgallery", "ext.visualEditor.mwalienextension", - "ext.visualEditor.diffing", + "ext.visualEditor.mwdiffing", "ext.visualEditor.language", "ext.visualEditor.icons" ], @@ -1756,6 +1756,18 @@ "mobile" ] }, + "ext.visualEditor.mwdiffing": { + "dependencies": [ + "ext.visualEditor.diffing" + ], + "messages": [ + "visualeditor-changedesc-mwtransclusion" + ], + "targets": [ + "desktop", + "mobile" + ] + }, "ext.visualEditor.diffing": { "debugScripts": [ "lib/ve/src/ve.DiffTreeNode.js", diff --git a/modules/ve-mw/dm/annotations/ve.dm.MWExternalLinkAnnotation.js b/modules/ve-mw/dm/annotations/ve.dm.MWExternalLinkAnnotation.js index 5790ea2..8c2fc69 100644 --- a/modules/ve-mw/dm/annotations/ve.dm.MWExternalLinkAnnotation.js +++ b/modules/ve-mw/dm/annotations/ve.dm.MWExternalLinkAnnotation.js @@ -64,6 +64,13 @@ return domElements; }; +ve.dm.MWExternalLinkAnnotation.static.describeChange = function ( key, change ) { + if ( key === 'href' ) { + return ve.msg( 'visualeditor-changedesc-link-href', change.from, change.to ); + } + return null; +}; + /* Methods */ /** diff --git a/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js b/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js index e364816..90a7021 100644 --- a/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js +++ b/modules/ve-mw/dm/annotations/ve.dm.MWInternalLinkAnnotation.js @@ -193,6 +193,13 @@ return title.getPrefixedText(); }; +ve.dm.MWInternalLinkAnnotation.static.describeChange = function ( key, change ) { + if ( key === 'title' ) { + return ve.msg( 'visualeditor-changedesc-link-href', change.from, change.to ); + } + return null; +}; + /* Methods */ /** diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js index 395c671..b8b28ff 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWExtensionNode.js @@ -141,6 +141,19 @@ return this.extensionName; }; +ve.dm.MWExtensionNode.static.describeChanges = function ( attributeChanges, change, element ) { + // HACK: Try to generate an '<Extension> has changed' message using associated tool's title + // Extensions should provide more detailed change descriptions + var tools = ve.ui.toolFactory.getRelatedItems( [ ve.dm.nodeFactory.createFromElement( element ) ] ); + if ( tools.length ) { + return [ ve.msg( 'visualeditor-changedesc-unknown', + OO.ui.resolveMsg( ve.ui.toolFactory.lookup( tools[ 0 ].name ).static.title ) + ) ]; + } + // Parent method + ve.dm.MWExtensionNode.super.static.describeChange.apply( this, arguments ); +}; + /* Methods */ /** diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWImageNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWImageNode.js index 31fc0a2..1314bde 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWImageNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWImageNode.js @@ -60,6 +60,55 @@ }; }; +ve.dm.MWImageNode.static.describeChanges = function ( attributeChanges, attributes ) { + var key, sizeFrom, sizeTo, change, + customKeys = [ 'width', 'height', 'defaultSize', 'src', 'href' ], + descriptions = []; + + function describeSize( width, height ) { + return width + ve.msg( 'visualeditor-dimensionswidget-times' ) + height + ve.msg( 'visualeditor-dimensionswidget-px' ); + } + + if ( 'width' in attributeChanges || 'height' in attributeChanges ) { + if ( attributeChanges.defaultSize && attributeChanges.defaultSize.from === true ) { + sizeFrom = ve.msg( 'visualeditor-mediasizewidget-sizeoptions-default' ); + } else { + sizeFrom = describeSize( + 'width' in attributeChanges ? attributeChanges.width.from : attributes.width, + 'height' in attributeChanges ? attributeChanges.height.from : attributes.height + ); + } + if ( attributeChanges.defaultSize && attributeChanges.defaultSize.to === true ) { + sizeTo = ve.msg( 'visualeditor-mediasizewidget-sizeoptions-default' ); + } else { + sizeTo = describeSize( + 'width' in attributeChanges ? attributeChanges.width.to : attributes.width, + 'height' in attributeChanges ? attributeChanges.height.to : attributes.height + ); + } + + descriptions.push( ve.msg( 'visualeditor-changedesc-image-size', sizeFrom, sizeTo ) ); + } + for ( key in attributeChanges ) { + if ( customKeys.indexOf( key ) === -1 ) { + change = this.describeChange( key, attributeChanges[ key ] ); + descriptions.push( change ); + } + } + return descriptions; +}; + +ve.dm.MWImageNode.static.describeChange = function ( key, change ) { + if ( key === 'align' ) { + return ve.msg( 'visualeditor-changedesc-align', + ve.msg( 'visualeditor-align-widget-' + change.from ), + ve.msg( 'visualeditor-align-widget-' + change.to ) + ); + } + // Parent method + return ve.dm.Node.static.describeChange.apply( this, arguments ); +}; + /** * Take the given dimensions and scale them to thumbnail size. * diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js index b8dee0c..353846f 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWTransclusionNode.js @@ -192,6 +192,11 @@ return els; }; +ve.dm.MWTransclusionNode.static.describeChanges = function () { + // TODO: Provide a more detailed description of template changes + return [ ve.msg( 'visualeditor-changedesc-mwtransclusion' ) ]; +}; + /** */ ve.dm.MWTransclusionNode.static.cloneElement = function () { // Parent method diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json index bfaad6c..e4ddb5e 100644 --- a/modules/ve-mw/i18n/en.json +++ b/modules/ve-mw/i18n/en.json @@ -76,6 +76,7 @@ "visualeditor-ca-ve-edit": "VisualEditor", "visualeditor-ca-ve-edit-section": "VisualEditor", "visualeditor-categories-tool": "Categories", + "visualeditor-changedesc-mwtransclusion": "Template parameters changed", "visualeditor-desc": "Visual editor for MediaWiki", "visualeditor-descriptionpagelink": "Project:VisualEditor", "visualeditor-dialog-media-alttext-section": "Alternative text", diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json index 467e684..29b4bc7 100644 --- a/modules/ve-mw/i18n/qqq.json +++ b/modules/ve-mw/i18n/qqq.json @@ -89,6 +89,7 @@ "visualeditor-ca-ve-edit": "Link text of the dedicated VisualEditor {{msg-mw|Edit}} tab.\n{{Identical|VisualEditor}}", "visualeditor-ca-ve-edit-section": "{{Identical|VisualEditor}}", "visualeditor-categories-tool": "Tool for opening the categories section of the meta dialog.\n{{Identical|Category}}", + "visualeditor-changedesc-mwtransclusion": "Generic description of a template that has had some parameters changed", "visualeditor-desc": "{{desc|name=VisualEditor|url=https://www.mediawiki.org/wiki/Extension:VisualEditor}}", "visualeditor-descriptionpagelink": "{{doc-important|Do not translate \"Project\"; it is automatically converted to the wiki's project namespace.}}\nName of a page describing the use of VisualEditor in this project.\n\nUsed in:\n* {{msg-mw|Tag-visualeditor}}\n* {{msg-mw|Tag-visualeditor-description}}\n* {{msg-mw|Tag-visualeditor-needcheck}}\n* {{msg-mw|Tag-visualeditor-needcheck-description}}", "visualeditor-dialog-media-alttext-section": "Label for the image alternative text sub-section.", -- To view, visit https://gerrit.wikimedia.org/r/342949 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I469a3c7897f2417c1850364f65da51c0deca2386 Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Esanders <esand...@wikimedia.org> Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits