From: Matthew Flaschen Date: Thu, 11 May 2017 17:49:23 +0000 (-0400) Subject: Gate option to save RC filters to default false X-Git-Tag: 1.31.0-rc.0~3270^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=5b9f2c8d002ea91c73480a3f8c1390feae2a4c49;p=lhc%2Fweb%2Fwiklou.git Gate option to save RC filters to default false Change-Id: I1c9e382c265a097b5eea07b529ec542a60562307 --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 09a614cd7a..0d82d35c98 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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 */ diff --git a/includes/specials/SpecialRecentchanges.php b/includes/specials/SpecialRecentchanges.php index 5553218665..acfc1c0e7b 100644 --- a/includes/specials/SpecialRecentchanges.php +++ b/includes/specials/SpecialRecentchanges.php @@ -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 + ); } } diff --git a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js index 35541d136f..1dd0f83e42 100644 --- a/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js +++ b/resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js @@ -503,7 +503,9 @@ savedHighlights = {}, defaultSavedQueryItem = this.savedQueriesModel.getItemByID( this.savedQueriesModel.getDefault() ); - if ( defaultSavedQueryItem ) { + if ( mw.config.get( 'wgStructuredChangeFiltersEnableSaving' ) && + defaultSavedQueryItem ) { + data = defaultSavedQueryItem.getData(); queryHighlights = data.highlights || {}; diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js index cbf8747664..78f3a083d3 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterTagMultiselectWidget.js @@ -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, { @@ -68,10 +71,19 @@ 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' ), @@ -84,18 +96,41 @@ // 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 = $( '
' ) + .addClass( 'mw-rcfilters-ui-row' ) + .append( + this.$content + .addClass( 'mw-rcfilters-ui-cell' ) + .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-filters' ) + ); + + if ( areSavedQueriesEnabled ) { + rcFiltersRow.append( + $( '
' ) + .addClass( 'mw-rcfilters-ui-cell' ) + .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-save' ) + .append( this.saveQueryButton.$element ) + ); + } + + rcFiltersRow.append( + $( '
' ) + .addClass( 'mw-rcfilters-ui-cell' ) + .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-reset' ) + .append( this.resetButton.$element ) + ); + // Build the content $contentWrapper.append( title.$element, @@ -103,25 +138,7 @@ $( '
' ) .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 - $( '
' ) - .addClass( 'mw-rcfilters-ui-row' ) - .append( - this.$content - .addClass( 'mw-rcfilters-ui-cell' ) - .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-filters' ), - $( '
' ) - .addClass( 'mw-rcfilters-ui-cell' ) - .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-save' ) - .append( this.saveQueryButton.$element ), - $( '
' ) - .addClass( 'mw-rcfilters-ui-cell' ) - .addClass( 'mw-rcfilters-ui-filterTagMultiselectWidget-cell-reset' ) - .append( this.resetButton.$element ) - ) + rcFiltersRow ) ); @@ -221,16 +238,18 @@ * 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 diff --git a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterWrapperWidget.js b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterWrapperWidget.js index 738a981d08..ebef62fb53 100644 --- a/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterWrapperWidget.js +++ b/resources/src/mediawiki.rcfilters/ui/mw.rcfilters.ui.FilterWrapperWidget.js @@ -33,19 +33,26 @@ { $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 */