Merge "Move canEdit checks to server from client"

This commit is contained in:
jenkins-bot 2018-11-09 22:07:47 +00:00 committed by Gerrit Code Review
commit 90629a0578
2 changed files with 12 additions and 14 deletions

View File

@ -1155,13 +1155,18 @@ class SkinMinerva extends SkinTemplate {
*/ */
protected function createEditPageAction() { protected function createEditPageAction() {
$title = $this->getTitle(); $title = $this->getTitle();
$user = $this->getUser();
$editArgs = [ 'action' => 'edit' ]; $editArgs = [ 'action' => 'edit' ];
if ( $title->isWikitextPage() ) { if ( $title->isWikitextPage() ) {
// If the content model is wikitext we'll default to editing the lead section. // If the content model is wikitext we'll default to editing the lead section.
// Full wikitext editing is hard on mobile devices. // Full wikitext editing is hard on mobile devices.
$editArgs['section'] = self::LEAD_SECTION_NUMBER; $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 [ return [
'id' => 'ca-edit', 'id' => 'ca-edit',
'text' => '', 'text' => '',
@ -1291,10 +1296,6 @@ class SkinMinerva extends SkinTemplate {
'wgMinervaMenuData' => $this->getMenuData(), 'wgMinervaMenuData' => $this->getMenuData(),
]; ];
if ( $this->isAuthenticatedUser() ) {
$vars['wgMinervaUserBlockInfo'] = $user->isBlockedFrom( $title, true );
}
return $vars; return $vars;
} }

View File

@ -2,7 +2,6 @@
var var
toast = M.require( 'mobile.startup/toast' ), toast = M.require( 'mobile.startup/toast' ),
time = M.require( 'mobile.startup/time' ), time = M.require( 'mobile.startup/time' ),
user = M.require( 'mobile.startup/user' ),
skin = M.require( 'mobile.init/skin' ), skin = M.require( 'mobile.init/skin' ),
issues = M.require( 'skins.minerva.scripts/pageIssues' ), issues = M.require( 'skins.minerva.scripts/pageIssues' ),
DownloadIcon = M.require( 'skins.minerva.scripts/DownloadIcon' ), DownloadIcon = M.require( 'skins.minerva.scripts/DownloadIcon' ),
@ -342,15 +341,13 @@
glyphPrefix: 'minerva' glyphPrefix: 'minerva'
} ), } ),
enabledClass = enabledEditIcon.getGlyphClassName(), enabledClass = enabledEditIcon.getGlyphClassName(),
disabledClass = disabledEditIcon.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;
$( '#ca-edit' ) if ( mw.config.get( 'wgMinervaReadOnly' ) ) {
.addClass( canEdit ? enabledClass : disabledClass ) $( '#ca-edit' )
.removeClass( canEdit ? disabledClass : enabledClass ); .removeClass( enabledClass )
.addClass( disabledClass );
}
} }
$( function () { $( function () {