Gate option to save RC filters to default false
authorMatthew Flaschen <mflaschen@wikimedia.org>
Thu, 11 May 2017 17:49:23 +0000 (13:49 -0400)
committerMatthew Flaschen <mflaschen@wikimedia.org>
Thu, 11 May 2017 21:14:14 +0000 (17:14 -0400)
Change-Id: I1c9e382c265a097b5eea07b529ec542a60562307

includes/DefaultSettings.php
includes/specials/SpecialRecentchanges.php
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js
resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterWrapperWidget.js

index 09a614c..0d82d35 100644 (file)
@@ -6762,6 +6762,11 @@ $wgRCWatchCategoryMembership = false;
  */
 $wgUseRCPatrol = true;
 
+/**
+ * Whether to allow users to save their RecentChanges filters
+ */
+$wgStructuredChangeFiltersEnableSaving = false;
+
 /**
  * Use new page patrolling to check new pages on Special:Newpages
  */
index 5553218..acfc1c0 100644 (file)
@@ -138,6 +138,8 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
         * @param string $subpage
         */
        public function execute( $subpage ) {
+               global $wgStructuredChangeFiltersEnableSaving;
+
                // Backwards-compatibility: redirect to new feed URLs
                $feedFormat = $this->getRequest()->getVal( 'feed' );
                if ( !$this->including() && $feedFormat ) {
@@ -178,6 +180,10 @@ class SpecialRecentChanges extends ChangesListSpecialPage {
                        );
 
                        $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
+                       $out->addJsConfigVars(
+                               'wgStructuredChangeFiltersEnableSaving',
+                               $wgStructuredChangeFiltersEnableSaving
+                       );
                }
        }
 
index 35541d1..1dd0f83 100644 (file)
                        savedHighlights = {},
                        defaultSavedQueryItem = this.savedQueriesModel.getItemByID( this.savedQueriesModel.getDefault() );
 
-               if ( defaultSavedQueryItem ) {
+               if ( mw.config.get( 'wgStructuredChangeFiltersEnableSaving' ) &&
+                       defaultSavedQueryItem ) {
+
                        data = defaultSavedQueryItem.getData();
 
                        queryHighlights = data.highlights || {};
index cbf8747..78f3a08 100644 (file)
@@ -13,7 +13,9 @@
         * @cfg {jQuery} [$overlay] A jQuery object serving as overlay for popups
         */
        mw.rcfilters.ui.FilterTagMultiselectWidget = function MwRcfiltersUiFilterTagMultiselectWidget( controller, model, savedQueriesModel, config ) {
-               var title = new OO.ui.LabelWidget( {
+               var rcFiltersRow,
+                       areSavedQueriesEnabled = mw.config.get( 'wgStructuredChangeFiltersEnableSaving' ),
+                       title = new OO.ui.LabelWidget( {
                                label: mw.msg( 'rcfilters-activefilters' ),
                                classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-wrapper-content-title' ]
                        } ),
@@ -27,6 +29,7 @@
                this.queriesModel = savedQueriesModel;
                this.$overlay = config.$overlay || this.$element;
                this.matchingQuery = null;
+               this.areSavedQueriesEnabled = areSavedQueriesEnabled;
 
                // Parent
                mw.rcfilters.ui.FilterTagMultiselectWidget.parent.call( this, $.extend( true, {
                        classes: [ 'mw-rcfilters-ui-filterTagMultiselectWidget-resetButton' ]
                } );
 
-               this.saveQueryButton = new mw.rcfilters.ui.SaveFiltersPopupButtonWidget(
-                       this.controller,
-                       this.queriesModel
-               );
+               if ( areSavedQueriesEnabled ) {
+                       this.saveQueryButton = new mw.rcfilters.ui.SaveFiltersPopupButtonWidget(
+                               this.controller,
+                               this.queriesModel
+                       );
+
+                       this.saveQueryButton.$element.on( 'mousedown', function ( e ) { e.stopPropagation(); } );
+
+                       this.saveQueryButton.connect( this, {
+                               click: 'onSaveQueryButtonClick',
+                               saveCurrent: 'setSavedQueryVisibility'
+                       } );
+               }
 
                this.emptyFilterMessage = new OO.ui.LabelWidget( {
                        label: mw.msg( 'rcfilters-empty-filter' ),
                // Stop propagation for mousedown, so that the widget doesn't
                // trigger the focus on the input and scrolls up when we click the reset button
                this.resetButton.$element.on( 'mousedown', function ( e ) { e.stopPropagation(); } );
-               this.saveQueryButton.$element.on( 'mousedown', function ( e ) { e.stopPropagation(); } );
                this.model.connect( this, {
                        initialize: 'onModelInitialize',
                        itemUpdate: 'onModelItemUpdate',
                        highlightChange: 'onModelHighlightChange'
                } );
-               this.saveQueryButton.connect( this, {
-                       click: 'onSaveQueryButtonClick',
-                       saveCurrent: 'setSavedQueryVisibility'
-               } );
                this.queriesModel.connect( this, { itemUpdate: 'onSavedQueriesItemUpdate' } );
 
+               // The filter list and button should appear side by side regardless of how
+               // wide the button is; the button also changes its width depending
+               // on language and its state, so the safest way to present both side
+               // by side is with a table layout
+               rcFiltersRow = $( '<div>' )
+                       .addClass( 'mw-rcfilters-ui-row' )
+                       .append(
+                               this.$content
+                                       .addClass( 'mw-rcfilters-ui-cell' )
+                                       .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-filters' )
+                       );
+
+               if ( areSavedQueriesEnabled ) {
+                       rcFiltersRow.append(
+                               $( '<div>' )
+                                       .addClass( 'mw-rcfilters-ui-cell' )
+                                       .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-save' )
+                                       .append( this.saveQueryButton.$element )
+                       );
+               }
+
+               rcFiltersRow.append(
+                       $( '<div>' )
+                               .addClass( 'mw-rcfilters-ui-cell' )
+                               .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-reset' )
+                               .append( this.resetButton.$element )
+               );
+
                // Build the content
                $contentWrapper.append(
                        title.$element,
                        $( '<div>' )
                                .addClass( 'mw-rcfilters-ui-table' )
                                .append(
-                                       // The filter list and button should appear side by side regardless of how
-                                       // wide the button is; the button also changes its width depending
-                                       // on language and its state, so the safest way to present both side
-                                       // by side is with a table layout
-                                       $( '<div>' )
-                                               .addClass( 'mw-rcfilters-ui-row' )
-                                               .append(
-                                                       this.$content
-                                                               .addClass( 'mw-rcfilters-ui-cell' )
-                                                               .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-filters' ),
-                                                       $( '<div>' )
-                                                               .addClass( 'mw-rcfilters-ui-cell' )
-                                                               .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-save' )
-                                                               .append( this.saveQueryButton.$element ),
-                                                       $( '<div>' )
-                                                               .addClass( 'mw-rcfilters-ui-cell' )
-                                                               .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-reset' )
-                                                               .append( this.resetButton.$element )
-                                               )
+                                       rcFiltersRow
                                )
                );
 
         * Set the visibility of the saved query button
         */
        mw.rcfilters.ui.FilterTagMultiselectWidget.prototype.setSavedQueryVisibility = function () {
-               this.matchingQuery = this.controller.findQueryMatchingCurrentState();
+               if ( this.areSavedQueriesEnabled ) {
+                       this.matchingQuery = this.controller.findQueryMatchingCurrentState();
 
-               this.savedQueryTitle.setLabel(
-                       this.matchingQuery ? this.matchingQuery.getLabel() : ''
-               );
-               this.savedQueryTitle.toggle( !!this.matchingQuery );
-               this.saveQueryButton.toggle(
-                       !this.isEmpty() &&
-                       !this.matchingQuery
-               );
+                       this.savedQueryTitle.setLabel(
+                               this.matchingQuery ? this.matchingQuery.getLabel() : ''
+                       );
+                       this.savedQueryTitle.toggle( !!this.matchingQuery );
+                       this.saveQueryButton.toggle(
+                               !this.isEmpty() &&
+                               !this.matchingQuery
+                       );
+               }
        };
        /**
         * Respond to model itemUpdate event
index 738a981..ebef62f 100644 (file)
                        { $overlay: this.$overlay }
                );
 
-               this.savedLinksListWidget = new mw.rcfilters.ui.SavedLinksListWidget(
-                       this.controller,
-                       this.queriesModel,
-                       { $overlay: this.$overlay }
-               );
-
                // Initialize
                this.$element
-                       .addClass( 'mw-rcfilters-ui-filterWrapperWidget' )
-                       .append(
-                               this.savedLinksListWidget.$element,
-                               this.filterTagWidget.$element
+                       .addClass( 'mw-rcfilters-ui-filterWrapperWidget' );
+
+               if ( mw.config.get( 'wgStructuredChangeFiltersEnableSaving' ) ) {
+                       this.savedLinksListWidget = new mw.rcfilters.ui.SavedLinksListWidget(
+                               this.controller,
+                               this.queriesModel,
+                               { $overlay: this.$overlay }
                        );
+
+                       this.$element.append(
+                               this.savedLinksListWidget.$element
+                       );
+
+               }
+
+               this.$element.append(
+                       this.filterTagWidget.$element
+               );
        };
 
        /* Initialization */