jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/358984 )

Change subject: MWTransclusionDialog: fix conditions for "show options" button 
disabling
......................................................................


MWTransclusionDialog: fix conditions for "show options" button disabling

As I understand it, the button should be enabled whenever there's more than
one option in the sidebar, and disabled otherwise. The previously chosen
conditions weren't perfectly proxying this, and the button would be disabled
whenever editing an already-existing transclusion.

Bug: T167710
Change-Id: Id303b680c072642ae7b66066e28ecc9f1dc90fd7
---
M lib/ve
M modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
2 files changed, 27 insertions(+), 7 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/ve b/lib/ve
index a25e5de..19942cc 160000
--- a/lib/ve
+++ b/lib/ve
@@ -1 +1 @@
-Subproject commit a25e5de6740217a0c5f1efedc885815f5af0148f
+Subproject commit 19942cca31c585ec58de8bbdf034fae497bbb760
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
index d742924..7ac6395 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js
@@ -244,7 +244,7 @@
                this.setSize( single ? 'medium' : 'large' );
                this.bookletLayout.toggleOutline( !single );
                this.updateTitle();
-               this.updateModeActionLabel();
+               this.updateModeActionState();
 
                // HACK blur any active input so that its dropdown will be 
hidden and won't end
                // up being mispositioned
@@ -265,10 +265,11 @@
 };
 
 /**
- * Update the label for the 'mode' action
+ * Update the state of the 'mode' action
  */
-ve.ui.MWTransclusionDialog.prototype.updateModeActionLabel = function () {
-       var mode = this.mode;
+ve.ui.MWTransclusionDialog.prototype.updateModeActionState = function () {
+       var parts = this.transclusionModel && this.transclusionModel.getParts(),
+               mode = this.mode;
        this.actions.forEach( { actions: [ 'mode' ] }, function ( action ) {
                action.setLabel(
                        mode === 'single' ?
@@ -276,6 +277,26 @@
                                ve.msg( 
'visualeditor-dialog-transclusion-single-mode' )
                );
        } );
+
+       // Decide whether the button should be enabled or not. It needs to be:
+       // * disabled when we're in the initial add-new-template phase, because 
it's
+       //   meaningless
+       // * disabled if we're in a multi-part transclusion, because the 
sidebar's
+       //   forced open
+       // * enabled if we're in a single-part transclusion, because the 
sidebar's
+       //   closed but can be opened to add more parts
+       if ( parts ) {
+               if ( parts.length === 1 && parts[ 0 ] instanceof 
ve.dm.MWTemplatePlaceholderModel ) {
+                       // Initial new-template phase: button is meaningless
+                       this.actions.setAbilities( { mode: false } );
+               } else if ( !this.isSingleTemplateTransclusion() ) {
+                       // Multi-part transclusion: button disabled because 
sidebar forced-open
+                       this.actions.setAbilities( { mode: false } );
+               } else {
+                       // Single-part transclusion: button enabled because 
sidebar is optional
+                       this.actions.setAbilities( { mode: true } );
+               }
+       }
 };
 
 /**
@@ -358,8 +379,7 @@
        return ve.ui.MWTransclusionDialog.super.prototype.getSetupProcess.call( 
this, data )
                .next( function () {
                        this.setMode( 'single' );
-                       this.updateModeActionLabel();
-                       this.actions.setAbilities( { mode: false } );
+                       this.updateModeActionState();
                }, this );
 };
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Id303b680c072642ae7b66066e28ecc9f1dc90fd7
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <dly...@wikimedia.org>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: DLynch <dly...@wikimedia.org>
Gerrit-Reviewer: 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

Reply via email to