mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
Edit check: Simplify "experience" config to "maximumEditcount"
There's no product need for anything other than an upper limit on edit count. If one arises in the future we can adjust accordingly, but better to keep the JSON, and any UI implementation, simple for now. Change-Id: I892847ad78b19695f0f0f664002d3c566f7806de
This commit is contained in:
parent
47dc22d6c0
commit
70c116a17a
|
@ -19,8 +19,7 @@ class ResourceLoaderData {
|
||||||
// TODO: when we have multiple edit checks this will likely be a generic block:
|
// TODO: when we have multiple edit checks this will likely be a generic block:
|
||||||
// account: loggedin, loggedout, anything non-truthy means allow either
|
// account: loggedin, loggedout, anything non-truthy means allow either
|
||||||
'account' => false,
|
'account' => false,
|
||||||
// experience: [ comparison, number ], compared to wgUserEditCount
|
'maximumEditcount' => 100
|
||||||
'experience' => [ '<', 100 ],
|
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -5,23 +5,6 @@ mw.editcheck = {};
|
||||||
|
|
||||||
mw.editcheck.config = require( './config.json' );
|
mw.editcheck.config = require( './config.json' );
|
||||||
|
|
||||||
var compares = function ( matcher, number ) {
|
|
||||||
// config is an array of [ comparison, value ]
|
|
||||||
try {
|
|
||||||
switch ( matcher[ 0 ] ) {
|
|
||||||
case '<': return number < matcher[ 1 ];
|
|
||||||
case '<=': return number <= matcher[ 1 ];
|
|
||||||
case '>': return number > matcher[ 1 ];
|
|
||||||
case '>=': return number >= matcher[ 1 ];
|
|
||||||
case '==': return number === matcher[ 1 ];
|
|
||||||
case '!=': return number !== matcher[ 1 ];
|
|
||||||
default: return false;
|
|
||||||
}
|
|
||||||
} catch ( err ) {
|
|
||||||
// In case something uncomparable was given as the number
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
mw.editcheck.accountShouldSeeEditCheck = function ( config ) {
|
mw.editcheck.accountShouldSeeEditCheck = function ( config ) {
|
||||||
// account status:
|
// account status:
|
||||||
// loggedin, loggedout, or any-other-value meaning 'both'
|
// loggedin, loggedout, or any-other-value meaning 'both'
|
||||||
|
@ -32,7 +15,7 @@ mw.editcheck.accountShouldSeeEditCheck = function ( config ) {
|
||||||
if ( config.account === 'loggedin' && !mw.user.isNamed() ) {
|
if ( config.account === 'loggedin' && !mw.user.isNamed() ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( config.experience && !compares( config.experience, mw.config.get( 'wgUserEditCount', 0 ) ) ) {
|
if ( config.maximumEditcount && mw.config.get( 'wgUserEditCount', 0 ) > config.maximumEditcount ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue