DLynch has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/324501

Change subject: Save Dialog: add shortcut for opening to the review panel
......................................................................

Save Dialog: add shortcut for opening to the review panel

Create a new MWSaveDialogAction, which can be hooked up to triggers. Switch
the existing save dialog accesskey to just use the trigger system.
(Maintaining all the accesskey logic, so we don't change the shortcut on
people.)

Bug: T149914
Change-Id: I9b4ef8504148703556f802b266a517dd5098c06b
---
M .jsduck/eg-iframe.html
M extension.json
M lib/ve
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
M modules/ve-mw/init/ve.init.mw.ArticleTarget.js
A modules/ve-mw/ui/actions/ve.ui.MWSaveDialogAction.js
M modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
7 files changed, 126 insertions(+), 24 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/01/324501/1

diff --git a/.jsduck/eg-iframe.html b/.jsduck/eg-iframe.html
index 5c566ba..495c611 100644
--- a/.jsduck/eg-iframe.html
+++ b/.jsduck/eg-iframe.html
@@ -254,8 +254,10 @@
                <script 
src="lib/ve/src/dm/annotations/ve.dm.CodeAnnotation.js"></script>
                <script 
src="lib/ve/src/dm/annotations/ve.dm.DatetimeAnnotation.js"></script>
                <script 
src="lib/ve/src/dm/annotations/ve.dm.DefinitionAnnotation.js"></script>
+               <script 
src="lib/ve/src/dm/annotations/ve.dm.DeleteAnnotation.js"></script>
                <script 
src="lib/ve/src/dm/annotations/ve.dm.FontAnnotation.js"></script>
                <script 
src="lib/ve/src/dm/annotations/ve.dm.HighlightAnnotation.js"></script>
+               <script 
src="lib/ve/src/dm/annotations/ve.dm.InsertAnnotation.js"></script>
                <script 
src="lib/ve/src/dm/annotations/ve.dm.ItalicAnnotation.js"></script>
                <script 
src="lib/ve/src/dm/annotations/ve.dm.QuotationAnnotation.js"></script>
                <script 
src="lib/ve/src/dm/annotations/ve.dm.SmallAnnotation.js"></script>
@@ -344,8 +346,10 @@
                <script 
src="lib/ve/src/ce/annotations/ve.ce.CodeSampleAnnotation.js"></script>
                <script 
src="lib/ve/src/ce/annotations/ve.ce.DatetimeAnnotation.js"></script>
                <script 
src="lib/ve/src/ce/annotations/ve.ce.DefinitionAnnotation.js"></script>
+               <script 
src="lib/ve/src/ce/annotations/ve.ce.DeleteAnnotation.js"></script>
                <script 
src="lib/ve/src/ce/annotations/ve.ce.FontAnnotation.js"></script>
                <script 
src="lib/ve/src/ce/annotations/ve.ce.HighlightAnnotation.js"></script>
+               <script 
src="lib/ve/src/ce/annotations/ve.ce.InsertAnnotation.js"></script>
                <script 
src="lib/ve/src/ce/annotations/ve.ce.ItalicAnnotation.js"></script>
                <script 
src="lib/ve/src/ce/annotations/ve.ce.QuotationAnnotation.js"></script>
                <script 
src="lib/ve/src/ce/annotations/ve.ce.SmallAnnotation.js"></script>
diff --git a/extension.json b/extension.json
index e032504..b59d7d1 100644
--- a/extension.json
+++ b/extension.json
@@ -1180,6 +1180,7 @@
                                
"modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js",
                                
"modules/ve-mw/ui/inspectors/ve.ui.MWLiveExtensionInspector.js",
                                
"modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js",
+                               
"modules/ve-mw/ui/actions/ve.ui.MWSaveDialogAction.js",
                                
"modules/ve-mw/ui/tools/ve.ui.MWEducationPopupTool.js"
                        ],
                        "styles": [
diff --git a/lib/ve b/lib/ve
index f4d2cd2..02cd2b4 160000
--- a/lib/ve
+++ b/lib/ve
@@ -1 +1 @@
-Subproject commit f4d2cd2465aca0f8f166454e797993e8b1331900
+Subproject commit 02cd2b4fbe20e0f18368f2a69139f8c8a5ea08fd
diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js 
b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
index 29c9e80..e185a7f 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
@@ -1046,7 +1046,7 @@
  * @inheritdoc
  */
 ve.init.mw.DesktopArticleTarget.prototype.getSaveDialogOpeningData = function 
() {
-       var data = 
ve.init.mw.DesktopArticleTarget.super.prototype.getSaveDialogOpeningData.call( 
this );
+       var data = 
ve.init.mw.DesktopArticleTarget.super.prototype.getSaveDialogOpeningData.apply( 
this, arguments );
        data.editSummary = this.initialEditSummary;
        return data;
 };
diff --git a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js 
b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js
index ebae4e7..b36d76b 100644
--- a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js
+++ b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js
@@ -1773,19 +1773,24 @@
  * Handle clicks on the save button in the toolbar.
  */
 ve.init.mw.ArticleTarget.prototype.onToolbarSaveButtonClick = function () {
-       if ( this.edited || this.restoring ) {
-               this.showSaveDialog();
-       }
+       this.showSaveDialog();
 };
 
 /**
  * Show a save dialog
  *
+ * @param {string} [action] Window action to trigger after opening
+ * @param {string} [initialPanel] Initial panel to show in the dialog
+ *
  * @fires saveWorkflowBegin
  */
-ve.init.mw.ArticleTarget.prototype.showSaveDialog = function () {
+ve.init.mw.ArticleTarget.prototype.showSaveDialog = function ( action, 
initialPanel ) {
        var target = this,
                windowAction = ve.ui.actionFactory.create( 'window', 
this.getSurface() );
+
+       if ( !( this.edited || this.restoring ) ) {
+               return;
+       }
 
        this.emit( 'saveWorkflowBegin' );
 
@@ -1810,17 +1815,20 @@
        } );
 
        // Open the dialog
-       windowAction.open( 'mwSave', this.getSaveDialogOpeningData() );
+       windowAction.open( 'mwSave', this.getSaveDialogOpeningData( 
initialPanel ), action );
 };
 
 /**
  * Get opening data to pass to the save dialog
+ *
+ * @param {string} [initialPanel] Initial panel to show in the dialog
  */
-ve.init.mw.ArticleTarget.prototype.getSaveDialogOpeningData = function () {
+ve.init.mw.ArticleTarget.prototype.getSaveDialogOpeningData = function ( 
initialPanel ) {
        return {
                saveButtonLabel: this.getSaveButtonLabel(),
                checkboxFields: this.checkboxFields,
-               checkboxesByName: this.checkboxesByName
+               checkboxesByName: this.checkboxesByName,
+               initialPanel: initialPanel
        };
 };
 
@@ -1990,17 +1998,3 @@
                this.welcomeDialogPromise.reject();
        }
 };
-
-// Register save button with command help dialog
-( function () {
-       var accessKeyPrefix = 
$.fn.updateTooltipAccessKeys.getAccessKeyPrefix().toUpperCase().replace( /-/g, 
' + ' ),
-               saveShortcut = ve.msg( 'accesskey-save' );
-
-       if ( saveShortcut !== '-' && saveShortcut !== '' ) {
-               ve.ui.commandHelpRegistry.register( 'other', 'save', {
-                       shortcuts: [ accessKeyPrefix + 
saveShortcut.toUpperCase() ],
-                       label: function () { return 
ve.init.target.getSaveButtonLabel(); },
-                       demote: true
-               } );
-       }
-}() );
diff --git a/modules/ve-mw/ui/actions/ve.ui.MWSaveDialogAction.js 
b/modules/ve-mw/ui/actions/ve.ui.MWSaveDialogAction.js
new file mode 100644
index 0000000..0b7814e
--- /dev/null
+++ b/modules/ve-mw/ui/actions/ve.ui.MWSaveDialogAction.js
@@ -0,0 +1,103 @@
+/*!
+ * VisualEditor UserInterface MWSaveDialogAction class.
+ *
+ * @copyright 2011-2016 VisualEditor Team and others; see 
http://ve.mit-license.org
+ */
+
+// TODO: Can perhaps extract a lot of the dialog lifecycle management code
+// from ArticleTarget and put it here.
+
+/**
+ * Save action.
+ *
+ * @class
+ * @extends ve.ui.Action
+ *
+ * @constructor
+ * @param {ve.ui.Surface} surface Surface to act on
+ */
+ve.ui.MWSaveDialogAction = function VeUiMWSaveDialogAction() {
+       // Parent constructor
+       ve.ui.MWSaveDialogAction.super.apply( this, arguments );
+};
+
+/* Inheritance */
+
+OO.inheritClass( ve.ui.MWSaveDialogAction, ve.ui.Action );
+
+/* Static Properties */
+
+ve.ui.MWSaveDialogAction.static.name = 'mwSaveDialog';
+
+/**
+ * List of allowed methods for the action.
+ *
+ * @static
+ * @property
+ */
+ve.ui.MWSaveDialogAction.static.methods = [ 'save', 'review' ];
+
+/* Methods */
+
+/**
+ * Open the save dialog
+ *
+ * @method
+ * @return {boolean} Action was executed
+ */
+ve.ui.MWSaveDialogAction.prototype.save = function () {
+       ve.init.target.showSaveDialog();
+       return true;
+};
+
+/**
+ * Open the save dialog, and set it to the review panel
+ *
+ * @method
+ * @return {boolean} Action was executed
+ */
+ve.ui.MWSaveDialogAction.prototype.review = function () {
+       ve.init.target.showSaveDialog( 'review', 'review' );
+       return true;
+};
+
+/* Registration */
+
+ve.ui.actionFactory.register( ve.ui.MWSaveDialogAction );
+
+ve.ui.commandRegistry.register(
+       new ve.ui.Command(
+               'showChanges', 'mwSaveDialog', 'review',
+               { supportedSelections: [ 'linear', 'table' ] }
+       )
+);
+ve.ui.triggerRegistry.register(
+       'showChanges', new ve.ui.Trigger( 'alt+shift+v' )
+);
+ve.ui.commandHelpRegistry.register( 'other', 'showChanges', {
+       trigger: 'showChanges',
+       label: OO.ui.deferMsg( 'visualeditor-savedialog-label-review' )
+} );
+ve.ui.MWCommandHelpDialog.static.commandGroups.other.demote.push( 
'showChanges' );
+
+ve.ui.commandRegistry.register(
+       new ve.ui.Command(
+               'showSave', 'mwSaveDialog', 'save',
+               { supportedSelections: [ 'linear', 'table' ] }
+       )
+);
+( function () {
+       var accessKeyPrefix = 
$.fn.updateTooltipAccessKeys.getAccessKeyPrefix().toUpperCase().replace( /-/g, 
' + ' ),
+               saveShortcut = ve.msg( 'accesskey-save' );
+
+       if ( saveShortcut !== '-' && saveShortcut !== '' ) {
+               ve.ui.triggerRegistry.register(
+                       'showSave', new ve.ui.Trigger( accessKeyPrefix + 
saveShortcut )
+               );
+               ve.ui.commandHelpRegistry.register( 'other', 'save', {
+                       trigger: 'showSave',
+                       label: function () { return 
ve.init.target.getSaveButtonLabel(); }
+               } );
+               
ve.ui.MWCommandHelpDialog.static.commandGroups.other.demote.push( 'save' );
+       }
+}() );
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
index 4147338..43d46e3 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
@@ -534,7 +534,7 @@
                        this.checkboxesByName = data.checkboxesByName || {};
                        // Old messages should not persist
                        this.clearAllMessages();
-                       this.swapPanel( 'save' );
+                       this.swapPanel( data.initialPanel || 'save' );
                        // Update save button label
                        if ( data.saveButtonLabel ) {
                                this.actions.forEach( { actions: 'save' }, 
function ( action ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b4ef8504148703556f802b266a517dd5098c06b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <dly...@wikimedia.org>

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

Reply via email to