*/
$wgStructuredChangeFiltersEnableLiveUpdate = false;
+/**
+ * Whether to enable RCFilters app on Special:Watchlist
+ */
+$wgStructuredChangeFiltersOnWatchlist = false;
+
/**
* Use new page patrolling to check new pages on Special:Newpages
*/
$defaultPreferences['rcfilters-saved-queries'] = [
'type' => 'api',
];
+ $defaultPreferences['rcfilters-wl-saved-queries'] = [
+ 'type' => 'api',
+ ];
$defaultPreferences['rcfilters-rclimit'] = [
'type' => 'api',
];
LoggerFactory::getInstance( 'objectcache' )
) );
}
+
+ $this->includeRcFiltersApp();
+ }
+
+ /**
+ * Include the modules and configuration for the RCFilters app.
+ * Conditional on the user having the feature enabled.
+ */
+ protected function includeRcFiltersApp() {
+ if ( $this->isStructuredFilterUiEnabled() ) {
+ $out = $this->getOutput();
+ $jsData = $this->getStructuredFilterJsData();
+
+ $messages = [];
+ foreach ( $jsData['messageKeys'] as $key ) {
+ $messages[$key] = $this->msg( $key )->plain();
+ }
+
+ $out->addHTML(
+ ResourceLoader::makeInlineScript(
+ ResourceLoader::makeMessageSetScript( $messages )
+ )
+ );
+
+ $experimentalStructuredChangeFilters =
+ $this->getConfig()->get( 'StructuredChangeFiltersEnableExperimentalViews' );
+
+ $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
+ $out->addJsConfigVars(
+ 'wgStructuredChangeFiltersEnableExperimentalViews',
+ $experimentalStructuredChangeFilters
+ );
+ $out->addJsConfigVars(
+ 'wgStructuredChangeFiltersEnableLiveUpdate',
+ $this->getConfig()->get( 'StructuredChangeFiltersEnableLiveUpdate' )
+ );
+ $out->addJsConfigVars(
+ 'wgRCFiltersChangeTags',
+ $this->buildChangeTagList()
+ );
+ $out->addJsConfigVars(
+ 'StructuredChangeFiltersDisplayConfig',
+ [
+ 'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
+ 'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
+ 'daysArray' => $this->getConfig()->get( 'RCLinkDays' ),
+ ]
+ );
+ }
+ }
+
+ /**
+ * Fetch the change tags list for the front end
+ *
+ * @return Array Tag data
+ */
+ protected function buildChangeTagList() {
+ $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
+ $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
+
+ // Hit counts disabled for perf reasons, see T169997
+ /*
+ $tagStats = ChangeTags::tagUsageStatistics();
+ $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
+
+ // Sort by hits
+ arsort( $tagHitCounts );
+ */
+ $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags );
+
+ // Build the list and data
+ $result = [];
+ foreach ( $tagHitCounts as $tagName => $hits ) {
+ if (
+ // Only get active tags
+ isset( $explicitlyDefinedTags[ $tagName ] ) ||
+ isset( $softwareActivatedTags[ $tagName ] )
+ ) {
+ // Parse description
+ $desc = ChangeTags::tagLongDescriptionMessage( $tagName, $this->getContext() );
+
+ $result[] = [
+ 'name' => $tagName,
+ 'label' => Sanitizer::stripAllTags(
+ ChangeTags::tagDescription( $tagName, $this->getContext() )
+ ),
+ 'description' => $desc ? Sanitizer::stripAllTags( $desc->parse() ) : '',
+ 'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
+ 'hits' => $hits,
+ ];
+ }
+ }
+
+ // Instead of sorting by hit count (disabled, see above), sort by display name
+ usort( $result, function ( $a, $b ) {
+ return strcasecmp( $a['label'], $b['label'] );
+ } );
+
+ return $result;
}
/**
* @return FormOptions
*/
public function getDefaultOptions() {
- $config = $this->getConfig();
$opts = new FormOptions();
- $structuredUI = $this->getUser()->getOption( 'rcenhancedfilters' );
+ $structuredUI = $this->isStructuredFilterUiEnabled();
// If urlversion=2 is set, ignore the filter defaults and set them all to false/empty
$useDefaults = $this->getRequest()->getInt( 'urlversion' ) !== 2;
// Add all filters
+ /** @var ChangesListFilterGroup $filterGroup */
foreach ( $this->filterGroups as $filterGroup ) {
// URL parameters can be per-group, like 'userExpLevel',
// or per-filter, like 'hideminor'.
if ( $filterGroup->isPerGroupRequestParameter() ) {
$opts->add( $filterGroup->getName(), $useDefaults ? $filterGroup->getDefault() : '' );
} else {
+ /** @var ChangesListBooleanFilter $filter */
foreach ( $filterGroup->getFilters() as $filter ) {
$opts->add( $filter->getName(), $useDefaults ? $filter->getDefault( $structuredUI ) : false );
}
'messageKeys' => [],
];
- $context = $this->getContext();
-
usort( $this->filterGroups, function ( $a, $b ) {
return $b->getPriority() - $a->getPriority();
} );
&$join_conds, FormOptions $opts
) {
$dbr = $this->getDB();
- $user = $this->getUser();
- $context = $this->getContext();
foreach ( $this->filterGroups as $filterGroup ) {
// URL parameters can be per-group, like 'userExpLevel',
// or per-filter, like 'hideminor'.
) . "\n";
$legend .= Html::closeElement( 'dl' ) . "\n";
- # Collapsibility
- $legendHeading = $this->getUser()->getOption(
- 'rcenhancedfilters'
- ) ?
+ $legendHeading = $this->isStructuredFilterUiEnabled() ?
$context->msg( 'rcfilters-legend-heading' )->parse() :
$context->msg( 'recentchanges-legend-heading' )->parse();
+
+ # Collapsible
$legend =
'<div class="mw-changeslist-legend">' .
$legendHeading .
'mediawiki.special.changeslist',
] );
$out->addModules( 'mediawiki.special.changeslist.legend.js' );
+
+ if ( $this->isStructuredFilterUiEnabled() ) {
+ $out->addModules( 'mediawiki.rcfilters.filters.ui' );
+ $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
+ }
}
protected function getGroupName() {
$conds[] = reset( $conditions );
}
}
+
+ /**
+ * Check whether the structured filter UI is enabled
+ *
+ * @return bool
+ */
+ protected function isStructuredFilterUiEnabled() {
+ return $this->getUser()->getOption( 'rcenhancedfilters' );
+ }
}
parent::execute( $subpage );
if ( $this->isStructuredFilterUiEnabled() ) {
- $jsData = $this->getStructuredFilterJsData();
-
- $messages = [];
- foreach ( $jsData['messageKeys'] as $key ) {
- $messages[$key] = $this->msg( $key )->plain();
- }
-
- $out->addHTML(
- ResourceLoader::makeInlineScript(
- ResourceLoader::makeMessageSetScript( $messages )
- )
- );
-
- $experimentalStructuredChangeFilters =
- $this->getConfig()->get( 'StructuredChangeFiltersEnableExperimentalViews' );
-
- $out->addJsConfigVars( 'wgStructuredChangeFilters', $jsData['groups'] );
+ $out->addJsConfigVars( 'wgStructuredChangeFiltersLiveUpdateSupported', true );
$out->addJsConfigVars(
- 'wgStructuredChangeFiltersEnableExperimentalViews',
- $experimentalStructuredChangeFilters
+ 'wgStructuredChangeFiltersSavedQueriesPreferenceName',
+ 'rcfilters-saved-queries'
);
- $out->addJsConfigVars(
- 'wgStructuredChangeFiltersEnableLiveUpdate',
- $this->getConfig()->get( 'StructuredChangeFiltersEnableLiveUpdate' )
- );
- $out->addJsConfigVars(
- 'wgRCFiltersChangeTags',
- $this->buildChangeTagList()
- );
- $out->addJsConfigVars(
- 'StructuredChangeFiltersDisplayConfig',
- [
- 'maxDays' => (int)$this->getConfig()->get( 'RCMaxAge' ) / ( 24 * 3600 ), // Translate to days
- 'limitArray' => $this->getConfig()->get( 'RCLinkLimits' ),
- 'daysArray' => $this->getConfig()->get( 'RCLinkDays' ),
- ]
- );
- }
- }
-
- /**
- * Fetch the change tags list for the front end
- *
- * @return Array Tag data
- */
- protected function buildChangeTagList() {
- $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
- $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
-
- // Hit counts disabled for perf reasons, see T169997
- /*
- $tagStats = ChangeTags::tagUsageStatistics();
- $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags, $tagStats );
-
- // Sort by hits
- arsort( $tagHitCounts );
- */
- $tagHitCounts = array_merge( $explicitlyDefinedTags, $softwareActivatedTags );
-
- // Build the list and data
- $result = [];
- foreach ( $tagHitCounts as $tagName => $hits ) {
- if (
- // Only get active tags
- isset( $explicitlyDefinedTags[ $tagName ] ) ||
- isset( $softwareActivatedTags[ $tagName ] )
- ) {
- // Parse description
- $desc = ChangeTags::tagLongDescriptionMessage( $tagName, $this->getContext() );
-
- $result[] = [
- 'name' => $tagName,
- 'label' => Sanitizer::stripAllTags(
- ChangeTags::tagDescription( $tagName, $this->getContext() )
- ),
- 'description' => $desc ? Sanitizer::stripAllTags( $desc->parse() ) : '',
- 'cssClass' => Sanitizer::escapeClass( 'mw-tag-' . $tagName ),
- 'hits' => $hits,
- ];
- }
}
-
- // Instead of sorting by hit count (disabled, see above), sort by display name
- usort( $result, function ( $a, $b ) {
- return strcasecmp( $a['label'], $b['label'] );
- } );
-
- return $result;
}
/**
&& $this->getUser()->getOption( 'shownumberswatching' );
$watcherCache = [];
- $dbr = $this->getDB();
-
$counter = 1;
$list = ChangesList::newFromContext( $this->getContext(), $this->filterGroups );
$list->initChangesListRows( $rows );
++$count;
$addSubmit = ( $count === $extraOptsCount ) ? $submit : '';
- $out .= Xml::openElement( 'tr' );
+ $out .= Xml::openElement( 'tr', [ 'class' => $name . 'Form' ] );
if ( is_array( $optionRow ) ) {
$out .= Xml::tags(
'td',
$rcoptions = Xml::fieldset(
$this->msg( 'recentchanges-legend' )->text(),
$panelString,
- [ 'class' => 'rcoptions' ]
+ [ 'class' => 'rcoptions cloptions' ]
);
// Insert a placeholder for RCFilters
- if ( $this->getUser()->getOption( 'rcenhancedfilters' ) ) {
+ if ( $this->isStructuredFilterUiEnabled() ) {
$rcfilterContainer = Html::element(
'div',
[ 'class' => 'rcfilters-container' ]
$topLinksAttributes = [ 'class' => 'mw-recentchanges-toplinks' ];
- if ( $this->getUser()->getOption( 'rcenhancedfilters' ) ) {
+ if ( $this->isStructuredFilterUiEnabled() ) {
$contentTitle = Html::rawElement( 'div',
[ 'class' => 'mw-recentchanges-toplinks-title' ],
$this->msg( 'rcfilters-other-review-tools' )->parse()
return $extraOpts;
}
- /**
- * Check whether the structured filter UI is enabled
- *
- * @return bool
- */
- protected function isStructuredFilterUiEnabled() {
- return $this->getUser()->getOption(
- 'rcenhancedfilters'
- );
- }
-
/**
* Add page-specific modules.
*/
parent::addModules();
$out = $this->getOutput();
$out->addModules( 'mediawiki.special.recentchanges' );
- if ( $this->isStructuredFilterUiEnabled() ) {
- $out->addModules( 'mediawiki.rcfilters.filters.ui' );
- $out->addModuleStyles( 'mediawiki.rcfilters.filters.base.styles' );
- }
}
/**
$filterGroups = $this->getFilterGroups();
- $context = $this->getContext();
foreach ( $filterGroups as $groupName => $group ) {
if ( !$group->isPerGroupRequestParameter() ) {
foreach ( $group->getFilters() as $key => $filter ) {
[ $key => 1 - $options[$key] ], $nondefaults );
$attribs = [
- 'class' => "$msg rcshowhideoption",
+ 'class' => "$msg rcshowhideoption clshowhideoption",
'data-filter-name' => $filter->getName(),
];
* @ingroup SpecialPage
*/
class SpecialWatchlist extends ChangesListSpecialPage {
+ private $maxDays;
+
public function __construct( $page = 'Watchlist', $restriction = 'viewmywatchlist' ) {
parent::__construct( $page, $restriction );
}
parent::execute( $subpage );
+
+ if ( $this->isStructuredFilterUiEnabled() ) {
+ $output->addJsConfigVars( 'wgStructuredChangeFiltersLiveUpdateSupported', false );
+ $output->addJsConfigVars(
+ 'wgStructuredChangeFiltersSavedQueriesPreferenceName',
+ 'rcfilters-wl-saved-queries'
+ );
+ }
+ }
+
+ protected function isStructuredFilterUiEnabled() {
+ return parent::isStructuredFilterUiEnabled()
+ && ( $this->getConfig()->get( 'StructuredChangeFiltersOnWatchlist' )
+ || $this->getRequest()->getBool( 'rcfilters' ) );
}
/**
$opts->add( 'days', $user->getOption( 'watchlistdays' ), FormOptions::FLOAT );
$opts->add( 'extended', $user->getBoolOption( 'extendwatchlist' ) );
+ $opts->add( 'limit', $user->getIntOption( 'wllimit' ), FormOptions::INT );
return $opts;
}
public function validateOptions( FormOptions $opts ) {
$opts->validateBounds( 'days', 0, $this->maxDays );
+ $opts->validateIntBounds( 'limit', 0, 5000 );
parent::validateOptions( $opts );
}
$query_options = array_merge( [
'ORDER BY' => 'rc_timestamp DESC',
- 'LIMIT' => $user->getIntOption( 'wllimit' )
+ 'LIMIT' => $opts['limit']
], $query_options );
$join_conds = array_merge(
[
}
$s = $list->beginRecentChangesList();
+
+ if ( $this->isStructuredFilterUiEnabled() ) {
+ $s .= $this->makeLegend();
+ }
+
$userShowHiddenCats = $this->getUser()->getBoolOption( 'showhiddencats' );
$counter = 1;
foreach ( $rows as $obj ) {
$this->setTopText( $opts );
+ $form = '';
+
+ $form .= Xml::openElement( 'form', [
+ 'method' => 'get',
+ 'action' => wfScript(),
+ 'id' => 'mw-watchlist-form'
+ ] );
+ $form .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
+ $form .= Xml::fieldset(
+ $this->msg( 'watchlist-options' )->text(),
+ false,
+ [ 'id' => 'mw-watchlist-options', 'class' => 'cloptions' ]
+ );
+
+ if ( !$this->isStructuredFilterUiEnabled() ) {
+ $form .= $this->makeLegend();
+ }
+
$lang = $this->getLanguage();
if ( $opts['days'] > 0 ) {
$days = $opts['days'];
$days = $this->maxDays;
}
$timestamp = wfTimestampNow();
- $wlInfo = $this->msg( 'wlnote' )->numParams( $numRows, round( $days * 24 ) )->params(
- $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
- )->parse() . "<br />\n";
+ $wlInfo = Html::rawElement(
+ 'span',
+ [ 'class' => 'wlinfo' ],
+ $this->msg( 'wlnote' )->numParams( $numRows, round( $days * 24 ) )->params(
+ $lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user )
+ )->parse()
+ ) . "<br />\n";
$nondefaults = $opts->getChangedValues();
- $cutofflinks = $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts );
+ $cutofflinks = Html::rawElement(
+ 'span',
+ [ 'class' => 'cldays cloption' ],
+ $this->msg( 'wlshowtime' ) . ' ' . $this->cutoffselector( $opts )
+ );
# Spit out some control panel links
$links = [];
- $context = $this->getContext();
$namesOfDisplayedFilters = [];
foreach ( $this->getFilterGroups() as $groupName => $group ) {
if ( !$group->isPerGroupRequestParameter() ) {
$nondefaults,
$filter->getShowHide(),
$filterName,
- $opts[$filterName]
+ $opts[$filterName],
+ $filter->isFeatureAvailableOnStructuredUi( $this )
);
}
}
unset( $hiddenFields[$filterName] );
}
- # Create output
- $form = '';
-
# Namespace filter and put the whole form together.
$form .= $wlInfo;
$form .= $cutofflinks;
- $form .= $this->msg( 'watchlist-hide' ) .
+ $form .= Html::rawElement(
+ 'span',
+ [ 'class' => 'clshowhide' ],
+ $this->msg( 'watchlist-hide' ) .
$this->msg( 'colon-separator' )->escaped() .
- implode( ' ', $links );
+ implode( ' ', $links )
+ );
$form .= "\n<br />\n";
- $form .= Html::namespaceSelector(
+
+ $namespaceForm = Html::namespaceSelector(
[
'selected' => $opts['namespace'],
'all' => '',
'class' => 'namespaceselector',
]
) . "\n";
- $form .= '<span class="mw-input-with-label">' . Xml::checkLabel(
+ $namespaceForm .= '<span class="mw-input-with-label">' . Xml::checkLabel(
$this->msg( 'invert' )->text(),
'invert',
'nsinvert',
$opts['invert'],
[ 'title' => $this->msg( 'tooltip-invert' )->text() ]
) . "</span>\n";
- $form .= '<span class="mw-input-with-label">' . Xml::checkLabel(
+ $namespaceForm .= '<span class="mw-input-with-label">' . Xml::checkLabel(
$this->msg( 'namespace_association' )->text(),
'associated',
'nsassociated',
$opts['associated'],
[ 'title' => $this->msg( 'tooltip-namespace_association' )->text() ]
) . "</span>\n";
- $form .= Xml::submitButton( $this->msg( 'watchlist-submit' )->text() ) . "\n";
+ $form .= Html::rawElement(
+ 'span',
+ [ 'class' => 'namespaceForm cloption' ],
+ $namespaceForm
+ );
+
+ $form .= Xml::submitButton(
+ $this->msg( 'watchlist-submit' )->text(),
+ [ 'class' => 'cloption-submit' ]
+ ) . "\n";
foreach ( $hiddenFields as $key => $value ) {
$form .= Html::hidden( $key, $value ) . "\n";
}
$form .= Xml::closeElement( 'fieldset' ) . "\n";
$form .= Xml::closeElement( 'form' ) . "\n";
- $this->getOutput()->addHTML( $form );
+
+ // Insert a placeholder for RCFilters
+ if ( $this->isStructuredFilterUiEnabled() ) {
+ $rcfilterContainer = Html::element(
+ 'div',
+ [ 'class' => 'rcfilters-container' ]
+ );
+
+ $loadingContainer = Html::rawElement(
+ 'div',
+ [ 'class' => 'rcfilters-spinner' ],
+ Html::element(
+ 'div',
+ [ 'class' => 'rcfilters-spinner-bounce' ]
+ )
+ );
+
+ // Wrap both with rcfilters-head
+ $this->getOutput()->addHTML(
+ Html::rawElement(
+ 'div',
+ [ 'class' => 'rcfilters-head' ],
+ $rcfilterContainer . $form
+ )
+ );
+
+ // Add spinner
+ $this->getOutput()->addHTML( $loadingContainer );
+ } else {
+ $this->getOutput()->addHTML( $form );
+ }
$this->setBottomText( $opts );
}
function setTopText( FormOptions $opts ) {
$nondefaults = $opts->getChangedValues();
- $form = "";
+ $form = '';
$user = $this->getUser();
$numItems = $this->countItems();
$form .= Xml::closeElement( 'form' ) . "\n";
}
- $form .= Xml::openElement( 'form', [
- 'method' => 'get',
- 'action' => wfScript(),
- 'id' => 'mw-watchlist-form'
- ] );
- $form .= Html::hidden( 'title', $this->getPageTitle()->getPrefixedText() );
- $form .= Xml::fieldset(
- $this->msg( 'watchlist-options' )->text(),
- false,
- [ 'id' => 'mw-watchlist-options' ]
- );
-
- $form .= $this->makeLegend();
-
$this->getOutput()->addHTML( $form );
}
- protected function showHideCheck( $options, $message, $name, $value ) {
+ protected function showHideCheck( $options, $message, $name, $value, $inStructuredUi ) {
$options[$name] = 1 - (int)$value;
- return '<span class="mw-input-with-label">' . Xml::checkLabel(
- $this->msg( $message, '' )->text(),
- $name,
- $name,
- (int)$value
- ) . '</span>';
+ $attribs = [ 'class' => 'mw-input-with-label clshowhideoption cloption' ];
+ if ( $inStructuredUi ) {
+ $attribs[ 'data-feature-in-structured-ui' ] = true;
+ }
+
+ return Html::rawElement(
+ 'span',
+ $attribs,
+ Xml::checkLabel(
+ $this->msg( $message, '' )->text(),
+ $name,
+ $name,
+ (int)$value
+ )
+ );
}
/**
mw.rcfilters.dm.ChangesListViewModel.prototype.update = function ( changesListContent, $fieldset, isInitialDOM, separateOldAndNew ) {
var from = this.nextFrom;
this.valid = true;
- this.extractNextFrom( $fieldset );
+ if ( mw.rcfilters.featureFlags.liveUpdate ) {
+ this.extractNextFrom( $fieldset );
+ }
this.emit( 'update', changesListContent, $fieldset, isInitialDOM, separateOldAndNew ? from : null );
};
* @param {mw.rcfilters.dm.FiltersViewModel} filtersModel Filters view model
* @param {mw.rcfilters.dm.ChangesListViewModel} changesListModel Changes list view model
* @param {mw.rcfilters.dm.SavedQueriesModel} savedQueriesModel Saved queries model
+ * @param {Object} config Additional configuration
+ * @cfg {string} savedQueriesPreferenceName Where to save the saved queries
*/
- mw.rcfilters.Controller = function MwRcfiltersController( filtersModel, changesListModel, savedQueriesModel ) {
+ mw.rcfilters.Controller = function MwRcfiltersController( filtersModel, changesListModel, savedQueriesModel, config ) {
this.filtersModel = filtersModel;
this.changesListModel = changesListModel;
this.savedQueriesModel = savedQueriesModel;
+ this.savedQueriesPreferenceName = config.savedQueriesPreferenceName;
+
this.requestCounter = {};
this.baseFilterState = {};
this.uriProcessor = null;
);
try {
- parsedSavedQueries = JSON.parse( mw.user.options.get( 'rcfilters-saved-queries' ) || '{}' );
+ parsedSavedQueries = JSON.parse( mw.user.options.get( this.savedQueriesPreferenceName ) || '{}' );
} catch ( err ) {
parsedSavedQueries = {};
}
// so it gets processed
this.changesListModel.update(
$changesList.length ? $changesList : 'NO_RESULTS',
- $( 'fieldset.rcoptions' ).first(),
+ $( 'fieldset.cloptions' ).first(),
true // We're using existing DOM elements
);
}
}
// Save the preference
- new mw.Api().saveOption( 'rcfilters-saved-queries', stringified );
+ new mw.Api().saveOption( this.savedQueriesPreferenceName, stringified );
// Update the preference for this session
- mw.user.options.set( 'rcfilters-saved-queries', stringified );
+ mw.user.options.set( this.savedQueriesPreferenceName, stringified );
};
/**
return $.ajax( uri.toString(), { contentType: 'html' } )
.then(
- // Success
function ( html ) {
- var $parsed;
+ var $parsed,
+ pieces;
+
if ( !latestRequest() ) {
return $.Deferred().reject();
}
$parsed = $( $.parseHTML( html ) );
- return {
+ pieces = {
// Changes list
changes: $parsed.find( '.mw-changeslist' ).first().contents(),
// Fieldset
- fieldset: $parsed.find( 'fieldset.rcoptions' ).first()
+ fieldset: $parsed.find( 'fieldset.cloptions' ).first()
};
+
+ // Watchlist returns 200 when there is no results
+ if ( pieces.changes.length === 0 ) {
+ pieces.changes = 'NO_RESULTS';
+ }
+
+ return pieces;
},
- // Failure
+ // RC returns 404 when there is no results
function ( responseObj ) {
var $parsed;
// Force a resolve state to this promise
return $.Deferred().resolve( {
changes: 'NO_RESULTS',
- fieldset: $parsed.find( 'fieldset.rcoptions' ).first()
+ fieldset: $parsed.find( 'fieldset.cloptions' ).first()
} ).promise();
}
);
topLinksCookieName = 'rcfilters-toplinks-collapsed-state',
topLinksCookie = mw.cookie.get( topLinksCookieName ),
topLinksCookieValue = topLinksCookie || 'collapsed',
+ savedQueriesPreferenceName = mw.config.get( 'wgStructuredChangeFiltersSavedQueriesPreferenceName' ),
filtersModel = new mw.rcfilters.dm.FiltersViewModel(),
changesListModel = new mw.rcfilters.dm.ChangesListViewModel(),
savedQueriesModel = new mw.rcfilters.dm.SavedQueriesModel(),
- controller = new mw.rcfilters.Controller( filtersModel, changesListModel, savedQueriesModel ),
+ controller = new mw.rcfilters.Controller(
+ filtersModel, changesListModel, savedQueriesModel,
+ {
+ savedQueriesPreferenceName: savedQueriesPreferenceName
+ }
+ ),
$overlay = $( '<div>' )
.addClass( 'mw-rcfilters-ui-overlay' ),
filtersWidget = new mw.rcfilters.ui.FilterWrapperWidget(
// eslint-disable-next-line no-new
new mw.rcfilters.ui.FormWrapperWidget(
- filtersModel, changesListModel, controller, $( 'fieldset.rcoptions' ) );
+ filtersModel, changesListModel, controller, $( 'fieldset.cloptions' ) );
$( '.rcfilters-container' ).append( filtersWidget.$element );
$( 'body' ).append( $overlay );
}
},
featureFlags: {
- liveUpdate: mw.config.get( 'wgStructuredChangeFiltersEnableLiveUpdate' ) || new mw.Uri().query.liveupdate
+ liveUpdate: mw.config.get( 'wgStructuredChangeFiltersLiveUpdateSupported' ) &&
+ ( mw.config.get( 'wgStructuredChangeFiltersEnableLiveUpdate' ) || new mw.Uri().query.liveupdate )
}
};
}( mediaWiki ) );
// Corrections for the standard special page
.client-js {
- .rcoptions {
+ .cloptions {
border: 0;
}
opacity: 0.5;
pointer-events: none;
- .rcoptions {
+ .cloptions {
display: none;
}
}
// Set up highlight containers
this.setupHighlightContainers( this.$element );
- this.setupNewChangesButtonContainer( this.$element );
+ if ( mw.rcfilters.featureFlags.liveUpdate ) {
+ this.setupNewChangesButtonContainer( this.$element );
+ }
};
/* Initialization */
* Clean up the old-style show/hide that we have implemented in the filter list
*/
mw.rcfilters.ui.FormWrapperWidget.prototype.cleanUpFieldset = function () {
- var $namespaceSelect = this.$element.find( '#namespace' );
-
- this.$element.find( '.rcshowhideoption[data-feature-in-structured-ui=1]' ).each( function () {
+ this.$element.find( '.clshowhideoption[data-feature-in-structured-ui=1]' ).each( function () {
// HACK: Remove the text node after the span.
// If there isn't one, we're at the end, so remove the text node before the span.
// This would be unnecessary if we added separators with CSS.
} );
// Hide namespaces and tags
- $namespaceSelect.closest( 'tr' ).detach();
+ this.$element.find( '.namespaceForm' ).detach();
this.$element.find( '.mw-tagfilter-label' ).closest( 'tr' ).detach();
- // Hide limit and days
- this.$element.find( '.rclinks' ).detach();
+ // misc: limit, days, watchlist info msg
+ this.$element.find( '.rclinks, .cldays, .wlinfo' ).detach();
if ( !this.$element.find( '.mw-recentchanges-table tr' ).length ) {
this.$element.find( '.mw-recentchanges-table' ).detach();
this.$element.find( 'br' ).detach();
}
+ if ( this.$element.find( '.cloption' ).text().trim() === '' ) {
+ this.$element.find( '.cloption-submit' ).detach();
+ }
+
if ( mw.rcfilters.featureFlags.liveUpdate ) {
this.$element.find(
- 'legend, .rclistfrom, .rcnotefrom, .rcoptions-listfromreset'
+ '.rclistfrom, .rcnotefrom, .rcoptions-listfromreset'
).detach();
}
- if ( this.$element.text().trim() === '' ) {
+ if ( this.$element.text().trim() === this.$element.find( 'legend' ).text() ) {
this.$element.detach();
}
};