Victorbarbu has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/325049

Change subject: Convert Special:RecentChanges to OOUI [WIP]
......................................................................

Convert Special:RecentChanges to OOUI [WIP]

Bug: T117740
Change-Id: I731ea2b24d44301d1470d6ce06f43a52b092e5fd
---
M includes/specials/SpecialRecentchanges.php
M languages/i18n/en.json
2 files changed, 191 insertions(+), 81 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/49/325049/1

diff --git a/includes/specials/SpecialRecentchanges.php 
b/includes/specials/SpecialRecentchanges.php
index cd3299c..5ce4d1a 100644
--- a/includes/specials/SpecialRecentchanges.php
+++ b/includes/specials/SpecialRecentchanges.php
@@ -401,65 +401,7 @@
                $defaults = $opts->getAllValues();
                $nondefaults = $opts->getChangedValues();
 
-               $panel = [];
-               $panel[] = $this->makeLegend();
-               $panel[] = $this->optionsPanel( $defaults, $nondefaults, 
$numRows );
-               $panel[] = '<hr />';
-
-               $extraOpts = $this->getExtraOptions( $opts );
-               $extraOptsCount = count( $extraOpts );
-               $count = 0;
-               $submit = ' ' . Xml::submitButton( $this->msg( 
'recentchanges-submit' )->text() );
-
-               $out = Xml::openElement( 'table', [ 'class' => 
'mw-recentchanges-table' ] );
-               foreach ( $extraOpts as $name => $optionRow ) {
-                       # Add submit button to the last row only
-                       ++$count;
-                       $addSubmit = ( $count === $extraOptsCount ) ? $submit : 
'';
-
-                       $out .= Xml::openElement( 'tr' );
-                       if ( is_array( $optionRow ) ) {
-                               $out .= Xml::tags(
-                                       'td',
-                                       [ 'class' => 'mw-label mw-' . $name . 
'-label' ],
-                                       $optionRow[0]
-                               );
-                               $out .= Xml::tags(
-                                       'td',
-                                       [ 'class' => 'mw-input' ],
-                                       $optionRow[1] . $addSubmit
-                               );
-                       } else {
-                               $out .= Xml::tags(
-                                       'td',
-                                       [ 'class' => 'mw-input', 'colspan' => 2 
],
-                                       $optionRow . $addSubmit
-                               );
-                       }
-                       $out .= Xml::closeElement( 'tr' );
-               }
-               $out .= Xml::closeElement( 'table' );
-
-               $unconsumed = $opts->getUnconsumedValues();
-               foreach ( $unconsumed as $key => $value ) {
-                       $out .= Html::hidden( $key, $value );
-               }
-
-               $t = $this->getPageTitle();
-               $out .= Html::hidden( 'title', $t->getPrefixedText() );
-               $form = Xml::tags( 'form', [ 'action' => wfScript() ], $out );
-               $panel[] = $form;
-               $panelString = implode( "\n", $panel );
-
-               $this->getOutput()->addHTML(
-                       Xml::fieldset(
-                               $this->msg( 'recentchanges-legend' )->text(),
-                               $panelString,
-                               [ 'class' => 'rcoptions' ]
-                       )
-               );
-
-               $this->setBottomText( $opts );
+               $this->renderForm();
        }
 
        /**
@@ -794,6 +736,185 @@
                return "{$note}$rclinks<br />$rclistfrom";
        }
 
+       /**
+        * Render the OOUI form for filtering changes.
+        */
+       private function renderForm() {
+               $output = $this->getOutput();
+               $form = new OOUI\FormLayout( [
+                       'method' => 'GET',
+                       'action' => wfScript(),
+               ] );
+
+               $this->populateForm( $form );
+
+               $form->addItems( [
+                       new OOUI\FieldLayout(
+                               new OOUI\ButtonInputWidget( [
+                                       'name' => 'submit',
+                                       'label' => $this->msg( 
'recentchanges-submit' )->text(),
+                                       'type' => 'submit',
+                                       'flags' => [ 'primary', 'progressive' ],
+                               ] ),
+                               [
+                                       'label' => null,
+                                       'align' => 'top',
+                               ]
+                       ),
+               ] );
+
+               $output->enableOOUI();
+               $output->addModuleStyles( 'mediawiki.htmlform.ooui.styles' );
+
+               $layout = new OOUI\PanelLayout( [
+                       'expanded' => false,
+                       'padded' => true,
+                       'framed' => true,
+                       'infusable' => false,
+               ] );
+               $layout->appendContent( $form );
+
+               $output->addHTML( $layout );
+       }
+
+       /**
+        * Populate the OOUI form.
+        *
+        * @param \OOUI\FormLayout $form
+        */
+       private function populateForm( OOUI\FormLayout &$form ) {
+               $namespaceFieldset = new OOUI\FieldsetLayout( [
+                       'label' => $this->msg( 'recentchanges-fieldset-filter' 
)->text(),
+                       'items' => [
+                               new OOUI\FieldLayout(
+                                       new 
MediaWiki\Widget\NamespaceInputWidget( [
+                                               'includeAllValue' => '',
+                                               'name' => 'rc-filter-namespace',
+                                       ] ),
+                                       [
+                                               'label' => $this->msg( 
'namespace' )->text(),
+                                               'align' => 'top',
+                                       ]
+                               ),
+                               new OOUI\HorizontalLayout( [
+                                       'items' => [
+                                               new OOUI\FieldLayout(
+                                                       new 
OOUI\CheckboxInputWidget( [
+                                                               'name' => 
'invert',
+                                                               'id' => 
'nsinvert',
+                                                               'selected' => 
false, // @TODO Set to defaults.
+                                                       ] ),
+                                                       [
+                                                               'label' => 
$this->msg( 'invert' )->text(),
+                                                               'align' => 
'inline',
+                                                       ]
+                                               ),
+                                               new OOUI\FieldLayout(
+                                                       new 
OOUI\CheckboxInputWidget( [
+                                                               'name' => 
'associated',
+                                                               'id' => 
'nsassociated',
+                                                               'selected' => 
false, // @TODO Set to defaults.
+                                                               'title' => 
$this->msg( 'tooltip-namespace_association' )->text(),
+                                                       ] ),
+                                                       [
+                                                               'label' => 
$this->msg( 'namespace_association' )->text(),
+                                                               'align' => 
'inline',
+                                                               'title' => 
$this->msg( 'tooltip-namespace_association' )->text(),
+                                                       ]
+                                               ),
+                                       ]
+                               ] ),
+                       ],
+               ] );
+               $changesTypeFieldset = new OOUI\FieldsetLayout( [
+                       'label' => 'Types of changes',
+                       'items' => $this->makeHideCheckboxesList(),
+               ] );
+               $displayOptionsFieldset = new OOUI\FieldsetLayout( [
+                       'label' => $this->msg( 
'recentchanges-fieldset-displayopts' )->text(),
+                       'items' => [
+                               new \OOUI\FieldLayout(
+                                       new \OOUI\TextInputWidget( [
+                                               'name' => 'changes-count',
+                                               'type' => 'number',
+                                       ] ),
+                                       [
+                                               'label' => $this->msg( 
'recentchanges-changescount-label' )->text(),
+                                               'align' => 'top',
+                                       ]
+                               ),
+                               new \OOUI\FieldLayout(
+                                       new \OOUI\DropdownInputWidget( [
+                                               'name' => 'changeage-unit',
+                                               'options' => [
+                                                       [ 'data' => '1h', 
'label' => '1 hour' ],
+                                                       [ 'data' => '2h', 
'label' => '2 hours' ],
+                                                       [ 'data' => '6h', 
'label' => '6 hours' ],
+                                                       [ 'data' => '12h', 
'label' => '12 hours' ],
+                                                       [ 'data' => '1d', 
'label' => '1 day' ],
+                                                       [ 'data' => '3d', 
'label' => '3 days' ],
+                                                       [ 'data' => '7d', 
'label' => '7 days' ],
+                                                       [ 'data' => '90d', 
'label' => '90 days' ],
+                                               ]
+                                       ] ),
+                                       [
+                                               'label' => 'Maximum age of the 
changes',
+                                               'align' => 'top',
+                                       ]
+                               ),
+                       ],
+               ] );
+
+               $form->addItems( [ $namespaceFieldset, $changesTypeFieldset, 
$displayOptionsFieldset ] );
+       }
+
+       /**
+        * Create the hide/show-checkboxes list.
+        *
+        * @return array
+        */
+       private function makeHideCheckboxesList() {
+               $config = $this->getConfig();
+               $user = $this->getUser();
+
+               $filters = [
+                       'hideminor' => 'rchideminor',
+                       'hidebots' => 'rcshowbots',
+                       'hideanons' => 'rchideanons',
+                       'hideliu' => 'rchideregistered',
+                       'hidepatrolled' => 'rchidepatr',
+                       'hidemyself' => 'rchidemine'
+               ];
+
+               if ( $config->get( 'RCWatchCategoryMembership' ) ) {
+                       $filters['hidecategorization'] = 
'rcshowhidecategorization';
+               }
+
+               foreach ( $this->getCustomFilters() as $key => $params ) {
+                       $filters[$key] = $params['msg'];
+               }
+               // Disable some if needed
+               if ( !$user->useRCPatrol() ) {
+                       unset( $filters['hidepatrolled'] );
+               }
+
+               $checkboxes = [];
+               foreach ( $filters as $key => $msg ) {
+                       $checkboxes[] = new OOUI\FieldLayout(
+                               new OOUI\CheckboxInputWidget( [
+                                       'name' => $key,
+                                       'selected' => false // @TODO Set to 
default
+                               ] ),
+                               [
+                                       'label' => $this->msg( $msg )->text(),
+                                       'align' => 'inline',
+                               ]
+                       );
+               }
+
+               return $checkboxes;
+       }
+
        public function isIncludable() {
                return true;
        }
diff --git a/languages/i18n/en.json b/languages/i18n/en.json
index afd13f0..7252982 100644
--- a/languages/i18n/en.json
+++ b/languages/i18n/en.json
@@ -1353,30 +1353,19 @@
        "recentchanges-legend-bot": "{{int:recentchanges-label-bot}}",
        "recentchanges-legend-unpatrolled": 
"{{int:recentchanges-label-unpatrolled}}",
        "recentchanges-legend-plusminus": "(<em>±123</em>)",
-       "recentchanges-submit": "Show",
+       "recentchanges-fieldset-filter": "Filter",
+       "recentchanges-fieldset-displayopts": "Display options",
+       "recentchanges-changescount-label": "Maximum number of changes to 
show:",
+       "recentchanges-submit": "Filter",
        "rcnotefrom": "Below {{PLURAL:$5|is the change|are the changes}} since 
<strong>$3, $4</strong> (up to <strong>$1</strong> shown).",
        "rclistfrom": "Show new changes starting from $2, $3",
-       "rcshowhideminor": "$1 minor edits",
-       "rcshowhideminor-show": "Show",
-       "rcshowhideminor-hide": "Hide",
-       "rcshowhidebots": "$1 bots",
-       "rcshowhidebots-show": "Show",
-       "rcshowhidebots-hide": "Hide",
-       "rcshowhideliu": "$1 registered users",
-       "rcshowhideliu-show": "Show",
-       "rcshowhideliu-hide": "Hide",
-       "rcshowhideanons": "$1 anonymous users",
-       "rcshowhideanons-show": "Show",
-       "rcshowhideanons-hide": "Hide",
-       "rcshowhidepatr": "$1 patrolled edits",
-       "rcshowhidepatr-show": "Show",
-       "rcshowhidepatr-hide": "Hide",
-       "rcshowhidemine": "$1 my edits",
-       "rcshowhidemine-show": "Show",
-       "rcshowhidemine-hide": "Hide",
-       "rcshowhidecategorization": "$1 page categorization",
-       "rcshowhidecategorization-show": "Show",
-       "rcshowhidecategorization-hide": "Hide",
+       "rchideminor": "Hide minor edits",
+       "rcshowbots": "Show bots",
+       "rchideregistered": "Hide registered users",
+       "rchideanons": "Hide anonymous users",
+       "rchidepatr": "Hide patrolled edits",
+       "rchidemine": "Hide my edits",
+       "rcshowcategorization": "Show page categorization",
        "rclinks": "Show last $1 changes in last $2 days<br />$3",
        "diff": "diff",
        "hist": "hist",

-- 
To view, visit https://gerrit.wikimedia.org/r/325049
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I731ea2b24d44301d1470d6ce06f43a52b092e5fd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Victorbarbu <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to