From d87220349536d28c189f3c99ce3157b89908c4e7 Mon Sep 17 00:00:00 2001 From: Dayllan Maza Date: Tue, 9 Apr 2019 12:49:12 -0400 Subject: [PATCH] Add block type filter to Special:BlockList Now that Partial Blocks feature is being enabled on multiple wikis a new filter (Block Type) is added to Special:BlockList to facilitate viewing the different blocks in place. Bug: T191549 Change-Id: I0bc8c6eaff22930c2e3c12ae5e77e03287910db9 --- includes/specials/SpecialBlockList.php | 44 +++++++++++++++---- languages/i18n/en.json | 6 ++- languages/i18n/qqq.json | 4 ++ resources/Resources.php | 4 ++ .../src/mediawiki.special/blocklist.less | 19 ++++++++ 5 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 resources/src/mediawiki.special/blocklist.less diff --git a/includes/specials/SpecialBlockList.php b/includes/specials/SpecialBlockList.php index fd27fdc5fa..4e541c9581 100644 --- a/includes/specials/SpecialBlockList.php +++ b/includes/specials/SpecialBlockList.php @@ -31,6 +31,8 @@ class SpecialBlockList extends SpecialPage { protected $options; + protected $blockType; + function __construct() { parent::__construct( 'BlockList' ); } @@ -43,13 +45,14 @@ class SpecialBlockList extends SpecialPage { $this->outputHeader(); $out = $this->getOutput(); $out->setPageTitle( $this->msg( 'ipblocklist' ) ); - $out->addModuleStyles( [ 'mediawiki.special' ] ); + $out->addModuleStyles( [ 'mediawiki.special', 'mediawiki.special.blocklist' ] ); $request = $this->getRequest(); $par = $request->getVal( 'ip', $par ); $this->target = trim( $request->getVal( 'wpTarget', $par ) ); $this->options = $request->getArray( 'wpOptions', [] ); + $this->blockType = $request->getVal( 'blockType' ); $action = $request->getText( 'action' ); @@ -83,14 +86,33 @@ class SpecialBlockList extends SpecialPage { ], 'flatlist' => true, ], - 'Limit' => [ - 'type' => 'limitselect', - 'label-message' => 'table_pager_limit_label', - 'options' => $pager->getLimitSelectList(), - 'name' => 'limit', - 'default' => $pager->getLimit(), - ], ]; + + if ( $this->getConfig()->get( 'EnablePartialBlocks' ) ) { + $fields['BlockType'] = [ + 'type' => 'select', + 'label-message' => 'blocklist-type', + 'options' => [ + $this->msg( 'blocklist-type-opt-all' )->escaped() => '', + $this->msg( 'blocklist-type-opt-sitewide' )->escaped() => 'sitewide', + $this->msg( 'blocklist-type-opt-partial' )->escaped() => 'partial', + ], + 'name' => 'blockType', + 'cssclass' => 'mw-field-block-type', + ]; + } + + $fields['Limit'] = [ + 'type' => 'limitselect', + 'label-message' => 'table_pager_limit_label', + 'options' => $pager->getLimitSelectList(), + 'name' => 'limit', + 'default' => $pager->getLimit(), + 'cssclass' => $this->getConfig()->get( 'EnablePartialBlocks' ) ? + 'mw-field-limit mw-has-field-block-type' : + 'mw-field-limit', + ]; + $context = new DerivativeContext( $this->getContext() ); $context->setTitle( $this->getPageTitle() ); // Remove subpage $form = HTMLForm::factory( 'ooui', $fields, $context ); @@ -159,6 +181,12 @@ class SpecialBlockList extends SpecialPage { $conds[] = "ipb_range_end = ipb_range_start"; } + if ( $this->blockType === 'sitewide' ) { + $conds[] = 'ipb_sitewide = 1'; + } elseif ( $this->blockType === 'partial' ) { + $conds[] = 'ipb_sitewide = 0'; + } + return new BlockListPager( $this, $conds ); } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 56ff4675b5..36d6ca005c 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2680,6 +2680,10 @@ "blocklist-userblocks": "Hide account blocks", "blocklist-tempblocks": "Hide temporary blocks", "blocklist-addressblocks": "Hide single IP blocks", + "blocklist-type": "Type:", + "blocklist-type-opt-all": "All", + "blocklist-type-opt-sitewide": "Sitewide", + "blocklist-type-opt-partial": "Partial", "blocklist-rangeblocks": "Hide range blocks", "blocklist-timestamp": "Timestamp", "blocklist-target": "Target", @@ -2703,7 +2707,7 @@ "blocklist-editing-page": "pages", "blocklist-editing-ns": "namespaces", "ipblocklist-empty": "The block list is empty.", - "ipblocklist-no-results": "The requested IP address or username is not blocked.", + "ipblocklist-no-results": "No matching blocks found for the requested IP address or username.", "blocklink": "block", "unblocklink": "unblock", "change-blocklink": "change block", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index c7f2733cbd..68368127fc 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2887,6 +2887,10 @@ "blocklist-userblocks": "Used as the label for the multi-select checkbox in the form on [[Special:BlockList]].\n{{Related|Blocklist-blocks}}", "blocklist-tempblocks": "Used as the label for the multi-select checkbox in the form on [[Special:BlockList]].\n{{Related|Blocklist-blocks}}", "blocklist-addressblocks": "Used as the label for the multi-select checkbox in the form on [[Special:BlockList]].\n{{Related|Blocklist-blocks}}", + "blocklist-type": "Used as label for dropdown box in [[Special:BlockList]].", + "blocklist-type-opt-all": "Used as option for dropdown box in [[Special:BlockList]]. This is the default option and indicates that \"all\" blocks will be listed", + "blocklist-type-opt-sitewide": "Used as option for dropdown box in [[Special:BlockList]]. This option indicates that only \"sitewide\" blocks will be listed.", + "blocklist-type-opt-partial": "Used as option for dropdown box in [[Special:BlockList]]. This option indicates that only \"partial\" blocks will be listed.", "blocklist-rangeblocks": "Used as the label for the multi-select checkbox in the form on [[Special:BlockList]].\n\nFor an explanation of \"range blocks\", see [[mw:Help:Range_blocks]]\n{{Related|Blocklist-blocks}}", "blocklist-timestamp": "This is a column header for dates and times in the table on the page [[Special:BlockList]].\n{{Identical|Timestamp}}", "blocklist-target": "The table header for the column containing the block targets, that is user names or IP-addresses linked to their respective user pages, in the table on the page [[Special:BlockList]].\n{{Identical|Target}}", diff --git a/resources/Resources.php b/resources/Resources.php index 174c7d9bf3..87488ebdb4 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -2124,6 +2124,10 @@ return [ ], 'targets' => [ 'desktop', 'mobile' ], ], + 'mediawiki.special.blocklist' => [ + 'styles' => 'resources/src/mediawiki.special/blocklist.less', + 'targets' => [ 'desktop', 'mobile' ], + ], 'mediawiki.special.changecredentials.js' => [ 'scripts' => 'resources/src/mediawiki.special.changecredentials.js', 'dependencies' => [ diff --git a/resources/src/mediawiki.special/blocklist.less b/resources/src/mediawiki.special/blocklist.less new file mode 100644 index 0000000000..80a59b113c --- /dev/null +++ b/resources/src/mediawiki.special/blocklist.less @@ -0,0 +1,19 @@ +.mw-special-BlockList { + .oo-ui-fieldsetLayout-group { + max-width: 50em; + } + + .oo-ui-layout { + &.mw-field-block-type, + &.mw-field-limit.mw-has-field-block-type { + display: inline-block; + width: 50%; + box-sizing: border-box; + margin-top: 0; + } + + &.mw-field-block-type { + padding-right: 1em; + } + } +} -- 2.20.1