AbuseLog: Use a radio button not checkbox for suppressing entries

Add a radio to select between "hide" and "show" instead of a single,
cryptic checkbox which doesn't really explain what it does.
Also wrap the list in a form which will later be used to mass-delete
entries.

Depends-On: I1bb45e47c3b42c01388b99778ce833e4e44419e1
Change-Id: Ie2d019fad5af7c626d722dc348f40eb0db21e527
This commit is contained in:
Daimona Eaytoy 2019-01-23 12:01:06 +01:00 committed by Jforrester
parent cc10f76bfa
commit b5ae7360bc
3 changed files with 35 additions and 19 deletions

View file

@ -104,10 +104,12 @@
"abusefilter-log-private-not-included": "One or more of the filter IDs you specified are private. Because you are not allowed to view details of private filters, these filters have not been searched for.",
"abusefilter-log-hide-legend": "Hide log entry",
"abusefilter-log-hide-id": "Log entry ID:",
"abusefilter-log-hide-hidden": "Hide this entry from public view",
"abusefilter-log-hide-set-visibility": "Set visibility for the selected entries:",
"abusefilter-log-hide-reason": "Reason:",
"abusefilter-log-hide-reason-other": "Other/additional reason:",
"abusefilter-log-hide-forbidden": "You do not have permission to hide abuse log entries.",
"abusefilter-log-hide-show": "Show",
"abusefilter-log-hide-hide": "Hide",
"abusefilter-log-entry-suppress": "$1 {{GENDER:$2|hid}} $3",
"abusefilter-log-entry-unsuppress": "$1 {{GENDER:$2|unhid}} $3",
"logentry-abusefilter-hit": "$1 {{GENDER:$2|triggered}} $4, {{GENDER:$2|performing}} the action \"$5\" on $3. Actions taken: $6 ($7)",

View file

@ -142,10 +142,12 @@
"abusefilter-log-private-not-included": "Message shown when an unauthorized user searches by ID for private filters.",
"abusefilter-log-hide-legend": "Legend for form to hide a log entry.",
"abusefilter-log-hide-id": "Field label in form to hide a log entry.",
"abusefilter-log-hide-hidden": "Checkbox label in form to hide a log entry.",
"abusefilter-log-hide-set-visibility": "Description of a form field where users can specify how to change the visibility of selected AbuseLog entries",
"abusefilter-log-hide-reason": "{{Identical|Reason}}",
"abusefilter-log-hide-reason-other": "{{Identical|Other/additional reason}}",
"abusefilter-log-hide-forbidden": "Message shown instead of a \"hide log entry\" form when not having the correct user rights.",
"abusefilter-log-hide-show": "Option allowing to show the selected AbuseLog entries",
"abusefilter-log-hide-hide": "Option allowing to hide the selected AbuseLog entries",
"abusefilter-log-entry-suppress": "Log entry when hiding an abuse filter log entry. Parameters:\n* $1 - a link to a user page with a user name as link text, followed by a series of related links\n* $2 - raw username, for GENDER support\n* $3 a link to the log ID.",
"abusefilter-log-entry-unsuppress": "Log entry when unhiding an abuse filter log entry. Parameters:\n* $1 - a link to a user page with a user name as link text, followed by a series of related links\n* $2 - raw username, for GENDER support\n* $3 a link to the log ID.",
"logentry-abusefilter-hit": "This message is for a log entry. Parameters:\n* $1 - user who performed the action\n* $2 - user who performed the action (to be used with GENDER)\n* $3 - link to the page, that the action that triggered the filter was made on\n* $4 - link to filter\n* $5 - action by user, like 'edit', 'move', 'create' etc.\n* $6 - actions taken by the filter\n* $7 - action details link",

View file

@ -153,13 +153,11 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
} else {
$this->showDetails( $args[0] );
}
} elseif ( $hideid ) {
$this->showHideForm( $hideid );
} else {
if ( $hideid ) {
$this->showHideForm( $hideid );
} else {
$this->searchForm();
$this->showList();
}
$this->searchForm();
$this->showList();
}
}
@ -377,6 +375,16 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
$hideReasons = Xml::listDropDownOptions( $hideReasons, [ 'other' => $hideReasonsOther ] );
$formInfo = [
'showorhide' => [
'type' => 'radio',
'label-message' => 'abusefilter-log-hide-set-visibility',
'options-messages' => [
'abusefilter-log-hide-show' => 'show',
'abusefilter-log-hide-hide' => 'hide'
],
'default' => (int)$deleted === 0 ? 'show' : 'hide',
'flatlist' => true
],
'logid' => [
'type' => 'info',
'default' => (string)$id,
@ -391,11 +399,6 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
'type' => 'text',
'label-message' => 'abusefilter-log-hide-reason-other',
],
'hidden' => [
'type' => 'toggle',
'default' => $deleted,
'label-message' => 'abusefilter-log-hide-hidden',
],
];
HTMLForm::factory( 'ooui', $formInfo, $this->getContext() )
@ -418,11 +421,12 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
public function saveHideForm( $fields ) {
$logid = $this->getRequest()->getVal( 'hide' );
$newValue = $fields['showorhide'] === 'hide' ? 1 : 0;
$dbw = wfGetDB( DB_MASTER );
$dbw->update(
'abuse_filter_log',
[ 'afl_deleted' => $fields['hidden'] ],
[ 'afl_deleted' => $newValue ],
[ 'afl_id' => $logid ],
__METHOD__
);
@ -435,7 +439,7 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
$this->msg( 'colon-separator' )->inContentLanguage()->text() . $fields['reason'];
}
$action = $fields['hidden'] ? 'hide-afl' : 'unhide-afl';
$action = $fields['showorhide'] === 'hide' ? 'hide-afl' : 'unhide-afl';
$logEntry = new ManualLogEntry( 'suppress', $action );
$logEntry->setPerformer( $this->getUser() );
$logEntry->setTarget( $this->getPageTitle( $logid ) );
@ -622,10 +626,18 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
);
$pager->doQuery();
$result = $pager->getResult();
$form = Xml::tags(
'form',
[
'method' => 'GET',
'action' => $this->getPageTitle()->getLocalURL()
],
Xml::tags( 'ul', [ 'class' => 'plainlinks' ], $pager->getBody() )
);
if ( $result && $result->numRows() !== 0 ) {
$out->addHTML( $pager->getNavigationBar() .
Xml::tags( 'ul', [ 'class' => 'plainlinks' ], $pager->getBody() ) .
$pager->getNavigationBar() );
$out->addHTML( $pager->getNavigationBar() . $form . $pager->getNavigationBar() );
} else {
$out->addWikiMsg( 'abusefilter-log-noresults' );
}
@ -815,7 +827,7 @@ class SpecialAbuseLog extends AbuseFilterSpecialPage {
$row = $dbr->selectRow(
[ 'abuse_filter_log', 'abuse_filter' ],
[ 'afl_id', 'afl_filter', 'afl_user_text', 'afl_timestamp', 'afl_ip', 'af_id',
'af_public_comments', 'af_hidden' ],
'af_public_comments', 'af_hidden' ],
[ 'afl_id' => $id ],
__METHOD__,
[],