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

Change subject: Remember preferred diff viewer
......................................................................


Remember preferred diff viewer

Separate the preference by surface mode, so you can
use a different preference for NWE.

Bug: T178691
Change-Id: Ib8494a4562ce766a7c8ef7ec1447d06f5d0f17c5
---
M VisualEditor.hooks.php
M modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
2 files changed, 25 insertions(+), 3 deletions(-)

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



diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index ebd7463..cfd8ce6 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -669,6 +669,10 @@
 
                $api = [ 'type' => 'api' ];
                $preferences['visualeditor-autodisable'] = $api;
+               // The diff mode is persisted for each editor mode separately,
+               // e.g. use visual diffs for visual mode only.
+               $preferences['visualeditor-diffmode-source'] = $api;
+               $preferences['visualeditor-diffmode-visual'] = $api;
                $preferences['visualeditor-editor'] = $api;
                $preferences['visualeditor-hidebetawelcome'] = $api;
                $preferences['visualeditor-hidetabdialog'] = $api;
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
index f2649c4..ac8d20a 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js
@@ -593,8 +593,6 @@
                ],
                classes: [ 've-ui-mwSaveDialog-reviewMode' ]
        } );
-       // TODO: Make 'visual' the default
-       this.reviewModeButtonSelect.selectItemByData( 'source' );
        this.reviewModeButtonSelect.connect( this, { select: 'updateReviewMode' 
} );
 
        this.$reviewEditSummary = $( '<span>' ).addClass( 
've-ui-mwSaveDialog-summaryPreview' ).addClass( 'comment' );
@@ -649,7 +647,18 @@
 
 ve.ui.MWSaveDialog.prototype.updateReviewMode = function () {
        var dialog = this,
-               isVisual = 
this.reviewModeButtonSelect.getSelectedItem().getData() === 'visual';
+               diffMode = 
this.reviewModeButtonSelect.findSelectedItem().getData(),
+               surfaceMode = ve.init.target.getSurface().getMode(),
+               isVisual = diffMode === 'visual';
+
+       if ( !this.hasDiff ) {
+               return;
+       }
+
+       // Config values used here:
+       // * visualeditor-diffmode-visual
+       // * visualeditor-diffmode-source
+       ve.userConfig( 'visualeditor-diffmode-' + surfaceMode, diffMode );
 
        // Hack: cache report action so it is getable even when hidden (see 
T174497)
        if ( !this.report ) {
@@ -721,6 +730,7 @@
 ve.ui.MWSaveDialog.prototype.getSetupProcess = function ( data ) {
        return ve.ui.MWSaveDialog.super.prototype.getSetupProcess.call( this, 
data )
                .next( function () {
+                       var surfaceMode = ve.init.target.getSurface().getMode();
                        this.canReview = !!data.canReview;
                        this.canPreview = !!data.canPreview;
                        this.setupCheckboxes( data.checkboxFields || [] );
@@ -736,6 +746,14 @@
                                }
                        }
 
+                       // Config values used here:
+                       // * visualeditor-diffmode-visual
+                       // * visualeditor-diffmode-source
+                       // TODO: Make 'visual' the default for visual mode 
(T178248)
+                       this.reviewModeButtonSelect.selectItemByData(
+                               ve.userConfig( 'visualeditor-diffmode-' + 
surfaceMode ) || 'source'
+                       );
+
                        // Old messages should not persist
                        this.clearAllMessages();
                        // Don't focus during setup to prevent scroll jumping 
(T153010)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib8494a4562ce766a7c8ef7ec1447d06f5d0f17c5
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Bartosz DziewoƄski <[email protected]>
Gerrit-Reviewer: DLynch <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to