From de2b3f7a593c8eea2e131dd568e643e8aa75fa6e Mon Sep 17 00:00:00 2001 From: MusikAnimal Date: Wed, 28 Aug 2024 22:11:35 -0400 Subject: [PATCH] mediawiki.special.block: make submit destructive and use old messages SpecialBlock calls HTMLForm::setSubmitDestructive(). This patch applies that to the new Vue version of Special:Block. Additionally, since we're not going to enable multiblocks in the initial launch, the submit button message is changed to as it was before. "Save block" is questionable even for multiblocks. It will likely be a while before we iron out the UI for multiblocks, so we might as well remove now-unused 'block-save' message. The "[username] is already blocked" message is now also surfaced, i.e. browsing to [[Special:Block/someblockuser]]. Like the old Special:Block, changes to the block target field won't re-query to see if the user is already blocked (though that would be a fine improvement). However *unlike* the old Special:Block, such changes do make the message disappear. Bug: T373572 Change-Id: Iceaedbb1e3496c52b49a2b96d65445da45261b9f --- includes/specials/SpecialBlock.php | 4 +++ languages/i18n/en.json | 1 - languages/i18n/qqq.json | 1 - resources/Resources.php | 7 +++- .../mediawiki.special.block/SpecialBlock.vue | 27 ++++++++++---- .../components/UserLookup.vue | 9 ++--- tests/jest/jest.setup.js | 7 ++++ .../SpecialBlock.setup.js | 30 ++++++++++++++++ .../SpecialBlock.test.js | 36 +++++++------------ .../UserLookup.test.js | 31 ++++++++++++++++ .../includes/specials/SpecialBlockTest.php | 20 +++++++++++ 11 files changed, 135 insertions(+), 38 deletions(-) create mode 100644 tests/jest/mediawiki.special.block/SpecialBlock.setup.js create mode 100644 tests/jest/mediawiki.special.block/UserLookup.test.js diff --git a/includes/specials/SpecialBlock.php b/includes/specials/SpecialBlock.php index db30aa004a2..ab2c07387a7 100644 --- a/includes/specials/SpecialBlock.php +++ b/includes/specials/SpecialBlock.php @@ -152,6 +152,10 @@ class SpecialBlock extends FormSpecialPage { if ( $this->useCodex ) { $this->getOutput()->addModules( 'mediawiki.special.block.codex' ); + $this->codexFormData[ 'blockAlreadyBlocked' ] = $this->alreadyBlocked; + $this->codexFormData[ 'blockTargetUser' ] = $this->target instanceof UserIdentity ? + $this->target->getName() : + $this->target ?? null; $this->getOutput()->addJsConfigVars( $this->codexFormData ); } } diff --git a/languages/i18n/en.json b/languages/i18n/en.json index e80381565f1..9b49cde9f9a 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2693,7 +2693,6 @@ "block-user-label": "Which user do you want to block?", "block-user-description": "A user can be a username, IP address, or an IP range.", "block-user-placeholder": "Start typing a user...", - "block-save": "Save block", "block-target": "Username, IP address, or IP range:", "block-target-placeholder": "UserName, 1.1.1.42, or 1.1.1.42/16", "unblockip": "Unblock user", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 01ebba4b2e4..4e7a986168e 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2956,7 +2956,6 @@ "block-user-label": "Label for the input for specifying the user of a block on [[Special:Block]]", "block-user-description": "Description for the input for specifying the user of a block on [[Special:Block]]", "block-user-placeholder": "Placeholder text for the input specifying the user of a block on [[Special:Block]]", - "block-save": "Label for submit button on block form [[Special:Block]]", "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]]", "unblockip": "Used as title and legend for the form in [[Special:Unblock]].", diff --git a/resources/Resources.php b/resources/Resources.php index 06d5281fd0c..468d21efeee 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -2279,20 +2279,25 @@ return [ 'block-options-description', 'block-reason', 'block-reason-other', - 'block-save', 'block-user-description', 'block-user-label', 'block-user-placeholder', 'blocklist-type-opt-partial', 'blocklist-type-opt-sitewide', 'colon-separator', + 'block-user-label', + 'block-user-description', + 'block-user-placeholder', + 'ipbsubmit', 'htmlform-optional-flag', 'htmlform-selectorother-other', 'ipb-action-create', 'ipb-action-move', 'ipb-action-upload', + 'ipb-change-block', 'ipb-disableusertalk', 'ipb-hardblock', + 'ipb-needreblock', 'ipb-partial-help', 'ipb-sitewide-help', 'ipbcreateaccount', diff --git a/resources/src/mediawiki.special.block/SpecialBlock.vue b/resources/src/mediawiki.special.block/SpecialBlock.vue index c01c758bb45..2d7fc453e97 100644 --- a/resources/src/mediawiki.special.block/SpecialBlock.vue +++ b/resources/src/mediawiki.special.block/SpecialBlock.vue @@ -1,5 +1,15 @@