mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-09-24 02:38:16 +00:00
Use OOUI buttons instead of plain links and Html::errorbox for errors
Like we did for other links in /diff and /histories, there are some links that we'd better display as OOUI buttons. Also, use the Html class' specific method to show errorboxes. Bug: T132284 Change-Id: If67035991a0835ec3edc13be4543e6b40c76c3ea
This commit is contained in:
parent
cbabcf1276
commit
2d876d08bd
|
@ -13,6 +13,7 @@ class AbuseFilterViewDiff extends AbuseFilterView {
|
|||
$show = $this->loadData();
|
||||
$out = $this->getOutput();
|
||||
$out->enableOOUI();
|
||||
$out->addModuleStyles( [ 'oojs-ui.styles.icons-movement' ] );
|
||||
|
||||
$links = [];
|
||||
if ( $this->mFilter ) {
|
||||
|
@ -38,36 +39,40 @@ class AbuseFilterViewDiff extends AbuseFilterView {
|
|||
|
||||
if ( $show ) {
|
||||
$out->addHTML( $this->formatDiff() );
|
||||
|
||||
// Next and previous change links
|
||||
$links = [];
|
||||
$buttons = [];
|
||||
if ( AbuseFilter::getFirstFilterChange( $this->mFilter ) !=
|
||||
$this->mOldVersion['meta']['history_id']
|
||||
) {
|
||||
// Create a "previous change" link if this isn't the first change of the given filter
|
||||
$links[] = $this->linkRenderer->makeLink(
|
||||
$this->getTitle(
|
||||
'history/' . $this->mFilter . '/diff/prev/' . $this->mOldVersion['meta']['history_id']
|
||||
),
|
||||
$this->getLanguage()->getArrow( 'backwards' ) .
|
||||
' ' . $this->msg( 'abusefilter-diff-prev' )->text()
|
||||
);
|
||||
$href = $this->getTitle(
|
||||
'history/' . $this->mFilter . '/diff/prev/' . $this->mOldVersion['meta']['history_id']
|
||||
)->getFullURL();
|
||||
$buttons[] = new OOUI\ButtonWidget( [
|
||||
'label' => $this->msg( 'abusefilter-diff-prev' )->text(),
|
||||
'href' => $href,
|
||||
'icon' => 'previous'
|
||||
] );
|
||||
}
|
||||
|
||||
if ( !is_null( $this->mNextHistoryId ) ) {
|
||||
// Create a "next change" link if this isn't the last change of the given filter
|
||||
$links[] = $this->linkRenderer->makeLink(
|
||||
$this->getTitle(
|
||||
'history/' . $this->mFilter . '/diff/prev/' . $this->mNextHistoryId
|
||||
),
|
||||
$this->msg( 'abusefilter-diff-next' )->text() .
|
||||
' ' . $this->getLanguage()->getArrow( 'forwards' )
|
||||
);
|
||||
$href = $this->getTitle(
|
||||
'history/' . $this->mFilter . '/diff/prev/' . $this->mNextHistoryId
|
||||
)->getFullURL();
|
||||
$buttons[] = new OOUI\ButtonWidget( [
|
||||
'label' => $this->msg( 'abusefilter-diff-next' )->text(),
|
||||
'href' => $href,
|
||||
'icon' => 'next'
|
||||
] );
|
||||
}
|
||||
|
||||
if ( count( $links ) > 0 ) {
|
||||
$backlinks = $this->getLanguage()->pipeList( $links );
|
||||
$out->addHTML( Xml::tags( 'p', null, $backlinks ) );
|
||||
if ( count( $buttons ) > 0 ) {
|
||||
$buttons = new OOUI\HorizontalLayout( [
|
||||
'items' => $buttons,
|
||||
'classes' => [ 'mw-abusefilter-history-buttons' ]
|
||||
] );
|
||||
$out->addHTML( $buttons );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -398,9 +398,18 @@ class AbuseFilterViewEdit extends AbuseFilterView {
|
|||
list( $row, $actions ) = $this->loadRequest( $filter, $history_id );
|
||||
|
||||
if ( !$row ) {
|
||||
$out->addWikiMsg( 'abusefilter-edit-badfilter' );
|
||||
$out->addHTML( $this->linkRenderer->makeLink( $this->getTitle(),
|
||||
$this->msg( 'abusefilter-return' )->text() ) );
|
||||
$out->addHTML(
|
||||
Xml::tags(
|
||||
'p',
|
||||
null,
|
||||
Html::errorBox( $this->msg( 'abusefilter-edit-badfilter' )->parse() )
|
||||
)
|
||||
);
|
||||
$href = $this->getTitle()->getFullURL();
|
||||
$btn = new OOUI\ButtonWidget( [
|
||||
'label' => $this->msg( 'abusefilter-return' )->text(),
|
||||
'href' => $href
|
||||
] );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -562,8 +562,13 @@ class SpecialAbuseLog extends SpecialPage {
|
|||
// Make sure it is a valid request
|
||||
$token = $request->getVal( 'wpEditToken' );
|
||||
if ( !$request->wasPosted() || !$this->getUser()->matchEditToken( $token ) ) {
|
||||
$out->wrapWikiMsg( '<div class="errorbox">$1</div>',
|
||||
[ 'abusefilter-invalid-request', $id ] );
|
||||
$out->addHTML(
|
||||
Xml::tags(
|
||||
'p',
|
||||
null,
|
||||
Html::errorBox( $this->msg( 'abusefilter-invalid-request' )->params( $id )->parse() )
|
||||
)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -118,3 +118,7 @@ ul li.mw-abusefilter-changeslist-match {
|
|||
.client-js #mw-abusefilter-export {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.mw-abusefilter-history-buttons {
|
||||
text-align: center;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue