mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 14:23:53 +00:00
Move canEdit checks to server from client
Bug: T206262 Change-Id: I08bfc56998f4fb42c8ce76cc2ad9fba83106d476
This commit is contained in:
parent
880607b55a
commit
c64a4cf811
|
@ -1155,13 +1155,18 @@ class SkinMinerva extends SkinTemplate {
|
|||
*/
|
||||
protected function createEditPageAction() {
|
||||
$title = $this->getTitle();
|
||||
$user = $this->getUser();
|
||||
$editArgs = [ 'action' => 'edit' ];
|
||||
if ( $title->isWikitextPage() ) {
|
||||
// If the content model is wikitext we'll default to editing the lead section.
|
||||
// Full wikitext editing is hard on mobile devices.
|
||||
$editArgs['section'] = self::LEAD_SECTION_NUMBER;
|
||||
}
|
||||
$userCanEdit = $title->quickUserCan( 'edit', $this->getUser() );
|
||||
$userQuickEditCheck = $title->quickUserCan( 'edit', $user )
|
||||
&& ( $title->exists() || $title->quickUserCan( 'create', $user ) );
|
||||
$userBlockInfo = $user->getId() == 0 ? false : $user->isBlockedFrom( $title, true );
|
||||
$userCanEdit = $userQuickEditCheck && !$userBlockInfo;
|
||||
|
||||
return [
|
||||
'id' => 'ca-edit',
|
||||
'text' => '',
|
||||
|
@ -1291,10 +1296,6 @@ class SkinMinerva extends SkinTemplate {
|
|||
'wgMinervaMenuData' => $this->getMenuData(),
|
||||
];
|
||||
|
||||
if ( $this->isAuthenticatedUser() ) {
|
||||
$vars['wgMinervaUserBlockInfo'] = $user->isBlockedFrom( $title, true );
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
var
|
||||
toast = M.require( 'mobile.startup/toast' ),
|
||||
time = M.require( 'mobile.startup/time' ),
|
||||
user = M.require( 'mobile.startup/user' ),
|
||||
skin = M.require( 'mobile.init/skin' ),
|
||||
issues = M.require( 'skins.minerva.scripts/pageIssues' ),
|
||||
DownloadIcon = M.require( 'skins.minerva.scripts/DownloadIcon' ),
|
||||
|
@ -342,15 +341,13 @@
|
|||
glyphPrefix: 'minerva'
|
||||
} ),
|
||||
enabledClass = enabledEditIcon.getGlyphClassName(),
|
||||
disabledClass = disabledEditIcon.getGlyphClassName(),
|
||||
isReadOnly = mw.config.get( 'wgMinervaReadOnly' ),
|
||||
isEditable = mw.config.get( 'wgIsProbablyEditable' ),
|
||||
blockInfo = user.isAnon() ? false : mw.config.get( 'wgMinervaUserBlockInfo', false ),
|
||||
canEdit = !isReadOnly && isEditable && !blockInfo;
|
||||
disabledClass = disabledEditIcon.getGlyphClassName();
|
||||
|
||||
$( '#ca-edit' )
|
||||
.addClass( canEdit ? enabledClass : disabledClass )
|
||||
.removeClass( canEdit ? disabledClass : enabledClass );
|
||||
if ( mw.config.get( 'wgMinervaReadOnly' ) ) {
|
||||
$( '#ca-edit' )
|
||||
.removeClass( enabledClass )
|
||||
.addClass( disabledClass );
|
||||
}
|
||||
}
|
||||
|
||||
$( function () {
|
||||
|
|
Loading…
Reference in a new issue