Add block type filter to Special:BlockList
authorDayllan Maza <dmaza@wikimedia.org>
Tue, 9 Apr 2019 16:49:12 +0000 (12:49 -0400)
committerEsanders <esanders@wikimedia.org>
Wed, 17 Apr 2019 11:40:26 +0000 (11:40 +0000)
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
languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki.special/blocklist.less [new file with mode: 0644]

index fd27fdc..4e541c9 100644 (file)
@@ -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 );
        }
 
index 56ff467..36d6ca0 100644 (file)
        "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",
        "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",
index c7f2733..6836812 100644 (file)
        "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}}",
index 174c7d9..87488eb 100644 (file)
@@ -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 (file)
index 0000000..80a59b1
--- /dev/null
@@ -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;
+               }
+       }
+}