MediaWiki:Gadget-twinkleblock.js: Difference between revisions
Content deleted Content added
Repo at 04d11bb: add regression test (#2110); fix no-useless-concat (#2100); fix prefer-const (#2099) |
MusikAnimal (talk | contribs) deploy #2180: soft redirect to Special:Block for multi-blocked targets |
||
(One intermediate revision by one other user not shown) | |||
Line 4:
const api = new mw.Api();
let relevantUserName, blockedUserName, blockWindow;
const menuFormattedNamespaces = $.extend({}, mw.config.get('wgFormattedNamespaces'));
menuFormattedNamespaces[0] = '(Article)';
Line 35:
Twinkle.block.field_template_options = {};
// need to be verbose about who we're blocking
// Always added, hidden later if actual user not blocked
const form = new Morebits.QuickForm(Twinkle.block.callback.evaluate);
Line 126:
const result = form.render();
result.root = result;
Line 155:
// Store fetched user data, only relevant if switching IPv6 to a /64
Twinkle.block.fetchedData = {};
// Processes the data from
// Twinkle.block.fetchUserInfo to allow reprocessing of already-fetched data
Twinkle.block.processUserInfo = function twinkleblockProcessUserInfo(data, fn) {
let blockinfo = data.query.blocks[0];
// Soft redirect to Special:Block if the user is multi-blocked (#2178)
if (blockinfo && data.query.blocks.length > 1) {
// Remove submission buttons.
$(blockWindow.content).dialog('widget').find('.morebits-dialog-buttons').empty();
Morebits.Status.init(blockWindow.content.querySelector('form'));
Morebits.Status.warn(
`This target has ${data.query.blocks.length} active blocks`,
`Multiblocks is not supported by Twinkle. Use [[Special:Block/${relevantUserName}]] instead.`
);
return;
}
const userinfo = data.query.users[0];
// If an IP is blocked *and* rangeblocked, the above finds
Line 171 ⟶ 182:
Twinkle.block.isRegistered = !!userinfo.userid;
if (Twinkle.block.isRegistered) {
Twinkle.block.userIsBot = !!userinfo.groupmemberships && userinfo.groupmemberships.map((e) => e.group).
} else {
Twinkle.block.userIsBot = false;
Line 1,549 ⟶ 1,560:
if (!Twinkle.block.seeAlsos.length) {
this.form.reason.value = reason;
} else if (reason.
this.form.reason.value = reason + ' <!-- see also ' + seeAlsoMessage + ' -->';
} else {
Line 1,761 ⟶ 1,772:
if (toBlock) {
if (blockoptions.partial) {
if (blockoptions.disabletalk && !blockoptions.namespacerestrictions.
return alert('Partial blocks cannot prevent talk page access unless also restricting them from editing User talk space!');
}
|