Merge "RCFilters: Set up conditional views for RCLinked"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 7 Dec 2017 14:02:29 +0000 (14:02 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 7 Dec 2017 14:02:29 +0000 (14:02 +0000)
resources/src/mediawiki.rcfilters/mw.rcfilters.Controller.js
resources/src/mediawiki.rcfilters/mw.rcfilters.init.js

index eec4f4b..7b5e115 100644 (file)
         * @param {Array} filterStructure Filter definition and structure for the model
         * @param {Object} [namespaceStructure] Namespace definition
         * @param {Object} [tagList] Tag definition
+        * @param {Object} [conditionalViews] Conditional view definition
         */
-       mw.rcfilters.Controller.prototype.initialize = function ( filterStructure, namespaceStructure, tagList ) {
+       mw.rcfilters.Controller.prototype.initialize = function ( filterStructure, namespaceStructure, tagList, conditionalViews ) {
                var parsedSavedQueries, pieces,
                        displayConfig = mw.config.get( 'StructuredChangeFiltersDisplayConfig' ),
                        defaultSavedQueryExists = mw.config.get( 'wgStructuredChangeFiltersDefaultSavedQueryExists' ),
                        controller = this,
-                       views = {},
+                       views = $.extend( true, {}, conditionalViews ),
                        items = [],
                        uri = new mw.Uri();
 
                        ]
                };
 
-               views.recentChangesLinked = {
-                       groups: [
-                               {
-                                       name: 'page',
-                                       type: 'any_value',
-                                       title: '',
-                                       hidden: true,
-                                       sticky: true,
-                                       filters: [
-                                               {
-                                                       name: 'target',
-                                                       'default': ''
-                                               }
-                                       ]
-                               },
-                               {
-                                       name: 'toOrFrom',
-                                       type: 'boolean',
-                                       title: '',
-                                       hidden: true,
-                                       sticky: true,
-                                       filters: [
-                                               {
-                                                       name: 'showlinkedto',
-                                                       'default': false
-                                               }
-                                       ]
-                               }
-                       ]
-               };
-
                // Before we do anything, we need to see if we require additional items in the
                // groups that have 'AllowArbitrary'. For the moment, those are only single_option
                // groups; if we ever expand it, this might need further generalization:
index 2744b8b..40b8bd2 100644 (file)
@@ -12,6 +12,7 @@
                                topSection,
                                $watchlistDetails,
                                namespaces,
+                               conditionalViews = {},
                                savedQueriesPreferenceName = mw.config.get( 'wgStructuredChangeFiltersSavedQueriesPreferenceName' ),
                                daysPreferenceName = mw.config.get( 'wgStructuredChangeFiltersDaysPreferenceName' ),
                                limitPreferenceName = mw.config.get( 'wgStructuredChangeFiltersLimitPreferenceName' ),
                                        '.mw-changeslist-notargetpage'
                                ].join( ', ' ) );
 
+                       if ( specialPage === 'Recentchangeslinked' ) {
+                               conditionalViews.recentChangesLinked = {
+                                       groups: [
+                                               {
+                                                       name: 'page',
+                                                       type: 'any_value',
+                                                       title: '',
+                                                       hidden: true,
+                                                       isSticky: false,
+                                                       filters: [
+                                                               {
+                                                                       name: 'target',
+                                                                       'default': ''
+                                                               }
+                                                       ]
+                                               },
+                                               {
+                                                       name: 'toOrFrom',
+                                                       type: 'boolean',
+                                                       title: '',
+                                                       hidden: true,
+                                                       isSticky: false,
+                                                       filters: [
+                                                               {
+                                                                       name: 'showlinkedto',
+                                                                       'default': false
+                                                               }
+                                                       ]
+                                               }
+                                       ]
+                               };
+
+                       }
+
                        // TODO: The changesListWrapperWidget should be able to initialize
                        // after the model is ready.
 
@@ -60,7 +95,8 @@
                        controller.initialize(
                                mw.config.get( 'wgStructuredChangeFilters' ),
                                namespaces,
-                               mw.config.get( 'wgRCFiltersChangeTags' )
+                               mw.config.get( 'wgRCFiltersChangeTags' ),
+                               conditionalViews
                        );
 
                        // eslint-disable-next-line no-new