Merge "Update Special:Block UI"

This commit is contained in:
jenkins-bot 2021-09-16 16:36:53 +00:00 committed by Gerrit Code Review
commit ed13eb01c4
5 changed files with 51 additions and 72 deletions

View file

@ -247,13 +247,6 @@ class SpecialBlock extends FormSpecialPage {
'section' => 'target',
];
$a['Editing'] = [
'type' => 'check',
'label-message' => 'block-prevent-edit',
'default' => true,
'section' => 'actions',
];
$a['EditingRestriction'] = [
'type' => 'radio',
'cssclass' => 'mw-block-editing-restriction',
@ -262,7 +255,7 @@ class SpecialBlock extends FormSpecialPage {
$this->msg( 'ipb-sitewide' )->escaped() .
new \OOUI\LabelWidget( [
'classes' => [ 'oo-ui-inline-help' ],
'label' => $this->msg( 'ipb-sitewide-help' )->text(),
'label' => new \OOUI\HtmlSnippet( $this->msg( 'ipb-sitewide-help' )->parse() ),
] ) => 'sitewide',
$this->msg( 'ipb-partial' )->escaped() .
new \OOUI\LabelWidget( [
@ -278,7 +271,7 @@ class SpecialBlock extends FormSpecialPage {
'label' => $this->msg( 'ipb-pages-label' )->text(),
'exists' => true,
'max' => 10,
'cssclass' => 'mw-block-restriction',
'cssclass' => 'mw-block-partial-restriction',
'showMissing' => false,
'excludeDynamicNamespaces' => true,
'input' => [
@ -291,18 +284,34 @@ class SpecialBlock extends FormSpecialPage {
'type' => 'namespacesmultiselect',
'label' => $this->msg( 'ipb-namespaces-label' )->text(),
'exists' => true,
'cssclass' => 'mw-block-restriction',
'cssclass' => 'mw-block-partial-restriction',
'input' => [
'autocomplete' => false
],
'section' => 'actions',
];
if ( $conf->get( 'EnablePartialActionBlocks' ) ) {
$blockActions = $this->blockActionInfo->getAllBlockActions();
$a['ActionRestrictions'] = [
'type' => 'multiselect',
'cssclass' => 'mw-block-partial-restriction mw-block-action-restriction',
'options-messages' => array_combine(
array_map( static function ( $action ) {
return "ipb-action-$action";
}, array_keys( $blockActions ) ),
$blockActions
),
'section' => 'actions',
];
}
$a['CreateAccount'] = [
'type' => 'check',
'cssclass' => 'mw-block-restriction',
'label-message' => 'ipbcreateaccount',
'default' => true,
'section' => 'actions',
'section' => 'details',
];
if ( $this->blockPermissionCheckerFactory
@ -311,32 +320,19 @@ class SpecialBlock extends FormSpecialPage {
) {
$a['DisableEmail'] = [
'type' => 'check',
'cssclass' => 'mw-block-restriction',
'label-message' => 'ipbemailban',
'section' => 'actions',
'section' => 'details',
];
}
if ( $blockAllowsUTEdit ) {
$a['DisableUTEdit'] = [
'type' => 'check',
'cssclass' => 'mw-block-restriction',
'label-message' => 'ipb-disableusertalk',
'default' => false,
'section' => 'actions',
];
}
if ( $conf->get( 'EnablePartialActionBlocks' ) ) {
$blockActions = $this->blockActionInfo->getAllBlockActions();
$a['ActionRestrictions'] = [
'type' => 'multiselect',
'cssclass' => 'mw-block-action-restriction',
'options-messages' => array_combine(
array_map( static function ( $action ) {
return "ipb-action-$action";
}, array_keys( $blockActions ) ),
$blockActions
),
'section' => 'actions',
'section' => 'details',
];
}
@ -513,13 +509,6 @@ class SpecialBlock extends FormSpecialPage {
sort( $namespaceRestrictions );
$fields['NamespaceRestrictions']['default'] = implode( "\n", $namespaceRestrictions );
if (
empty( $pageRestrictions ) &&
empty( $namespaceRestrictions )
) {
$fields['Editing']['default'] = false;
}
if ( $this->getConfig()->get( 'EnablePartialActionBlocks' ) ) {
$actionRestrictions = [];
foreach ( $block->getRestrictions() as $restriction ) {
@ -1027,13 +1016,6 @@ class SpecialBlock extends FormSpecialPage {
* @return bool|string|array|Status As documented for HTMLForm::trySubmit.
*/
public function onSubmit( array $data, HTMLForm $form = null ) {
// If "Editing" checkbox is unchecked, the block must be a partial block affecting
// actions other than editing, and there must be no restrictions.
if ( isset( $data['Editing'] ) && $data['Editing'] === false ) {
$data['EditingRestriction'] = 'partial';
$data['PageRestrictions'] = '';
$data['NamespaceRestrictions'] = '';
}
return self::processFormInternal(
$data,
$this->getAuthority(),

View file

@ -2730,8 +2730,8 @@
"ipb-confirm": "Confirm block",
"ipb-sitewide": "Sitewide",
"ipb-partial": "Partial",
"ipb-sitewide-help": "Every page on the wiki and all other contribution actions.",
"ipb-partial-help": "Specific pages or namespaces.",
"ipb-sitewide-help": "Blocks editing on all pages and namespaces. Also blocks default actions ([https://www.mediawiki.org/wiki/Help:Blocking_users See help])",
"ipb-partial-help": "Allows you to select pages and namespaces to block. Doesnt block default actions but lets you block certain specific actions.",
"ipb-action-create": "Creating new pages",
"ipb-action-move": "Renaming pages",
"ipb-action-upload": "Uploading files",
@ -2752,9 +2752,9 @@
"ipb-blocklist-contribs": "Contributions for {{GENDER:$1|$1}}",
"ipb-blocklist-duration-left": "$1 left",
"block-actions": "Actions to block:",
"block-details": "Block details:",
"block-expiry": "Expiration:",
"block-options": "Additional options:",
"block-prevent-edit": "Editing",
"block-reason": "Reason:",
"block-target": "Username, IP address, or IP range:",
"block-target-placeholder": "UserName, 1.1.1.42, or 1.1.1.42/16",

View file

@ -2957,7 +2957,7 @@
"ipb-sitewide": "A type of block the user can select from on [[Special:Block]].",
"ipb-partial": "A type of block the user can select from on [[Special:Block]].",
"ipb-sitewide-help": "Help text describing the effects of a sitewide block on [[Special:Block]]",
"ipb-partial-help": "Help text describing the effects of a partial block on [[Special:Block]]",
"ipb-partial-help": "Help text describing the effects of a partial block on [[Special:Block]]",
"ipb-action-create": "The label for a select option to specify an action to block a user from on [[Special:Block]].",
"ipb-action-move": "The label for a select option to specify an action to block a user from on [[Special:Block]].",
"ipb-action-upload": "The label for a select option to specify an action to block a user from on [[Special:Block]].",
@ -2978,9 +2978,9 @@
"ipb-blocklist-contribs": "Used in [[Special:Block]].\n* $1 - target username",
"ipb-blocklist-duration-left": "Used on [[Special:BlockList]] to show the remaining time (years, months, days, hours, minutes) until the block expires.\n$1 - The duration left",
"block-actions": "Label for the checkboxes for specifying the actions that a block affects on [[Special:Block]]",
"block-details": "Label for the checkboxes for specifying the sitewide block details on [[Special:Block]]",
"block-expiry": "Label for the input for specifying the expiry time of a block on [[Special:Block]]",
"block-options": "Label for the checkboxes for specifying additional options for a block on [[Special:Block]]",
"block-prevent-edit": "Label for the checkbox for specifying an editing block in [[Special:Block]].",
"block-reason": "Label for the input for specifying the reason for a block on [[Special:Block]]\n{{Identical|Reason}}",
"block-target": "Label for the input for specifying the target of a block on [[Special:Block]]",
"block-target-placeholder": "Placeholder text for the input specifying the target of a block on [[Special:Block]]",

View file

@ -12,8 +12,8 @@
$( function () {
var blockTargetWidget, anonOnlyWidget, enableAutoblockWidget, hideUserWidget, watchUserWidget,
expiryWidget, editingWidget, editingRestrictionWidget, preventTalkPageEditWidget,
pageRestrictionsWidget, namespaceRestrictionsWidget, actionRestrictionsWidget, createAccountWidget,
expiryWidget, editingRestrictionWidget, partialActionsRestrictionsWidget, preventTalkPageEditWidget,
pageRestrictionsWidget, namespaceRestrictionsWidget, createAccountWidget,
data, blockAllowsUTEdit, userChangedCreateAccount, updatingBlockOptions;
function preserveSelectedStateOnDisable( widget ) {
@ -52,8 +52,7 @@
infinityValues = [ 'infinite', 'indefinite', 'infinity', 'never' ],
isIndefinite = infinityValues.indexOf( expiryValue ) !== -1,
editingRestrictionValue = editingRestrictionWidget.getValue(),
editingIsSelected = editingWidget.isSelected(),
isSitewide = editingIsSelected && editingRestrictionValue === 'sitewide';
isSitewide = editingRestrictionValue === 'sitewide';
enableAutoblockWidget.setDisabled( isNonEmptyIp );
@ -67,14 +66,11 @@
watchUserWidget.setDisabled( isIpRange && !isEmpty );
}
editingRestrictionWidget.setDisabled( !editingIsSelected );
pageRestrictionsWidget.setDisabled( !editingIsSelected || isSitewide );
namespaceRestrictionsWidget.setDisabled( !editingIsSelected || isSitewide );
pageRestrictionsWidget.setDisabled( isSitewide );
namespaceRestrictionsWidget.setDisabled( isSitewide );
if ( blockAllowsUTEdit ) {
// Disable for partial blocks, unless the block is against the User_talk namespace
preventTalkPageEditWidget.setDisabled(
// Partial block that doesn't block editing
!editingIsSelected ||
// Partial block that blocks editing and doesn't block the User_talk namespace
(
editingRestrictionValue === 'partial' &&
@ -92,13 +88,8 @@
}
if ( mw.config.get( 'wgEnablePartialActionBlocks' ) ) {
if ( editingIsSelected && isSitewide ) {
actionRestrictionsWidget.setDisabled( true );
} else {
actionRestrictionsWidget.setDisabled( false );
}
partialActionsRestrictionsWidget.setDisabled( isSitewide );
}
}
// This code is also loaded on the "block succeeded" page where there is no form,
@ -112,13 +103,11 @@
updatingBlockOptions = false;
// Always present if blockTargetWidget is present
editingWidget = OO.ui.infuse( $( '#mw-input-wpEditing' ) );
expiryWidget = OO.ui.infuse( $( '#mw-input-wpExpiry' ) );
createAccountWidget = OO.ui.infuse( $( '#mw-input-wpCreateAccount' ) );
enableAutoblockWidget = OO.ui.infuse( $( '#mw-input-wpAutoBlock' ) );
anonOnlyWidget = OO.ui.infuse( $( '#mw-input-wpHardBlock' ) );
blockTargetWidget.on( 'change', updateBlockOptions );
editingWidget.on( 'change', updateBlockOptions );
expiryWidget.on( 'change', updateBlockOptions );
createAccountWidget.on( 'change', function () {
if ( !updatingBlockOptions ) {
@ -130,7 +119,7 @@
namespaceRestrictionsWidget = OO.ui.infuse( $( '#mw-input-wpNamespaceRestrictions' ) );
if ( mw.config.get( 'wgEnablePartialActionBlocks' ) ) {
// TODO: Use an ID after T280837 is fixed
actionRestrictionsWidget = OO.ui.infuse( $( '.mw-block-action-restriction.oo-ui-checkboxMultiselectInputWidget' ) );
partialActionsRestrictionsWidget = OO.ui.infuse( '.mw-block-action-restriction.oo-ui-checkboxMultiselectInputWidget' );
}
editingRestrictionWidget.on( 'change', updateBlockOptions );
namespaceRestrictionsWidget.on( 'change', updateBlockOptions );

View file

@ -8,21 +8,29 @@
@ooui-spacing-radio-label: 26 / @ooui-font-size-browser / @ooui-font-size-base; // Equals `1.85714286em`≈`26px`.
.mw-block-editing-restriction.oo-ui-fieldLayout {
margin-left: @ooui-spacing-radio-label;
margin-top: 8px;
// Affects sitewide/partial radio, partial action checkboxes, and block detail checkboxes
.mw-block-editing-restriction.oo-ui-fieldLayout,
.mw-block-action-restriction .oo-ui-checkboxMultioptionWidget,
.mw-block-restriction.oo-ui-labelElement {
margin-top: 12px;
}
.mw-block-restriction.oo-ui-fieldLayout.oo-ui-labelElement {
margin-left: 2 * @ooui-spacing-radio-label;
margin-top: 8px;
.mw-block-restriction.oo-ui-fieldLayout {
.oo-ui-tagMultiselectWidget,
.oo-ui-textInputWidget {
max-width: 50em - 2 * @ooui-spacing-radio-label;
}
}
.mw-block-partial-restriction.oo-ui-fieldLayout {
margin-left: @ooui-spacing-radio-label;
// Match spacing of partial action checkboxes to block detail checkboxes
.oo-ui-checkboxMultioptionWidget {
padding: 0;
}
}
.mw-special-Block .mw-htmlform {
> .oo-ui-panelLayout-framed {
border: 0;