r91925 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91924‎ | r91925 | r91926 >
Date:23:39, 11 July 2011
Author:diebuche
Status:resolved (Comments)
Tags:
Comment:
CodeReview: Add a dropdown to revision list to specify status filter. Bug 29810
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionListView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.i18n.php
@@ -119,7 +119,7 @@
120120 'code-signoff-struckdate' => '$1 (struck $2)',
121121 'code-pathsearch-legend' => 'Search revisions in this repo by path',
122122 'code-pathsearch-path' => 'Path:',
123 - 'code-pathsearch-filter' => 'Filter applied:',
 123+ 'code-pathsearch-filter' => 'Show only:',
124124 'code-revfilter-cr_status' => 'Status = $1',
125125 'code-revfilter-cr_author' => 'Author = $1',
126126 'code-revfilter-ct_tag' => 'Tag = $1',
Index: trunk/extensions/CodeReview/ui/CodeRevisionListView.php
@@ -221,30 +221,40 @@
222222 * @return string
223223 */
224224 function showForm( $pager ) {
225 - global $wgScript;
 225+ global $wgScript, $wgRequest;
226226
 227+ $states = CodeRevision::getPossibleStates();
 228+ $name = $this->mRepo->getName();
 229+
 230+ $title = SpecialPage::getTitleFor( 'Code', $name );
 231+ $options = array(Xml::option('', $title, $wgRequest->getVal('title') == $title ) );
 232+
 233+
 234+ foreach ($states as $key => $state) {
 235+ $title = SpecialPage::getTitleFor( 'Code', $name . "/status/$state" );
 236+ $options[] = Xml::option(
 237+ wfMsgHtml( "code-status-".$state ),
 238+ $title,
 239+ $wgRequest->getVal('title') == $title
 240+ );
 241+ }
 242+
227243 $ret = "<fieldset><legend>" . wfMsgHtml( 'code-pathsearch-legend' ) . "</legend>" .
228244 '<table width="100%"><tr><td>' .
229245 Xml::openElement( 'form', array( 'action' => $wgScript, 'method' => 'get' ) ) .
230246 Xml::inputlabel( wfMsg( "code-pathsearch-path" ), 'path', 'path', 55,
231 - $this->getPathsAsString(), array( 'dir' => 'ltr' ) ) .
 247+ $this->getPathsAsString(), array( 'dir' => 'ltr' ) ) . '&#160;' .
 248+ Xml::label( wfMsg( 'code-pathsearch-filter' ), 'code-status-filter' ) . '&#160;' .
 249+ Xml::openElement( 'select', array( 'id' => 'code-status-filter', 'name' => 'title' ) ) .
 250+ "\n" .
 251+ implode( "\n", $options ) .
 252+ "\n" .
 253+ Xml::closeElement( 'select' ) .
232254 '&#160;' . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
233 - $pager->getHiddenFields( array( 'path' ) ) .
 255+ $pager->getHiddenFields( array( 'path', 'title' ) ) .
234256 Xml::closeElement( 'form' ) .
235 - '</td>';
 257+ '</td></tr></table></fieldset>' ;
236258
237 - if ( strlen( $this->mAppliedFilter ) ) {
238 - $ret .= '<td>' .
239 - Xml::openElement( 'form', array( 'action' => $pager->getTitle()->getLocalURL(), 'method' => 'get' ) ) .
240 - Xml::label( wfMsg( 'code-pathsearch-filter' ), 'revFilter' ) . '&#160;<strong>' .
241 - Xml::span( $this->mAppliedFilter, '' ) . '</strong>&#160;' .
242 - Xml::submitButton( wfMsg( 'code-revfilter-clear' ) ) .
243 - Xml::closeElement( 'form' ) .
244 - '</td>';
245 - }
246 -
247 - $ret .= "</tr></table></fieldset>" ;
248 -
249259 return $ret;
250260 }
251261

Follow-up revisions

RevisionCommit summaryAuthorDate
r92235r91925 : Compare with mStatus per CRdiebuche10:00, 15 July 2011
r92868Followup r91925: minor w/s tweak && don't rely on opaque __toString() magic.demon17:32, 22 July 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   18:10, 12 July 2011

Instead of all these title constructions and comparisons, it's probably simpler and more reliable to just check what $this->mStatus is set to.

#Comment by 😂 (talk | contribs)   12:21, 15 July 2011

I also don't like relying on implicit __toString() conversion in your foreach loop. Code readability is everything.

#Comment by Reedy (talk | contribs)   18:29, 25 July 2011

Seems like this overwrites/ignores possibly any and all other set query params. Will log a bug and then fix it from there

#Comment by Reedy (talk | contribs)   18:33, 25 July 2011
#Comment by Reedy (talk | contribs)   22:37, 25 August 2011

See also bug 30576

Status & tagging log