Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 119x 360x 1018x 360x 360x 119x 119x 119x 119x 119x 119x 119x 119x 319x 119x 119x 119x 119x 119x 119x 119x 119x 345x 119x 119x 119x 119x 119x 119x 119x 119x 332x 119x 119x 119x 119x 119x 119x 119x 119x 338x 338x 119x 119x 119x 119x 119x 119x 119x 119x 23x 1x 23x 23x 119x 119x | /*!
* WikiLambda Vue editor: Pinia store for frontend user rights and privileges
*
* @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
* @license MIT
*/
'use strict';
module.exports = {
state: {
/**
* Array of user rights or null if not initialized
*/
userRights: null
},
getters: {
/**
* Returns whether the current user has the given
* right, or undefined if state is not yet initialized.
*
* @param {Object} state
* @return {Function}
*/
userHasRight: function ( state ) {
const findUserHasRight = ( right ) => state.userRights !== null ?
state.userRights.includes( right ) :
undefined;
return findUserHasRight;
},
/**
* Returns whether the user is logged in
*
* @return {boolean}
*/
isUserLoggedIn: function () {
return !!mw.config.values.wgUserName;
},
/**
* Returns whether the user can execute functions
*
* @return {boolean}
*/
userCanRunFunction: function () {
return this.userHasRight( 'wikilambda-execute' );
},
/**
* Returns whether the user can execute unsaved code
*
* @return {boolean}
*/
userCanRunUnsavedCode: function () {
return this.userHasRight( 'wikilambda-execute-unsaved-code' );
},
/**
* Returns whether the user can edit type
*
* @return {boolean}
*/
userCanEditTypes: function () {
return this.userHasRight( 'wikilambda-edit-type' );
}
},
actions: {
/**
* Fetch the user rights from mw.user.getRights and
* store them in the state
*/
fetchUserRights: function () {
mw.user.getRights().then( ( rights ) => {
this.userRights = rights;
} );
}
}
};
|