Merge "Disable edit icon in read-only mode"
This commit is contained in:
commit
44e59d625d
|
@ -177,4 +177,20 @@ class MinervaHooks {
|
|||
] );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* ResourceLoaderGetConfigVars hook handler.
|
||||
* Used for setting JS variables which are pulled in dynamically with RL
|
||||
* instead of embedded directly on the page with a script tag.
|
||||
* These vars have a shorter cache-life than those in `getSkinConfigVariables`.
|
||||
*
|
||||
* @param array &$vars Array of variables to be added into the output of the RL startup module.
|
||||
* @return bool
|
||||
*/
|
||||
public static function onResourceLoaderGetConfigVars( &$vars ) {
|
||||
$vars += [
|
||||
'wgMinervaReadOnly' => wfReadOnly()
|
||||
];
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
var
|
||||
// see: https://www.mediawiki.org/wiki/Manual:Interface/JavaScript#Page-specific
|
||||
isEditable = mw.config.get( 'wgIsProbablyEditable' ),
|
||||
isReadOnly = mw.config.get( 'wgMinervaReadOnly' ),
|
||||
isEditable = !isReadOnly && mw.config.get( 'wgIsProbablyEditable' ),
|
||||
blockInfo = mw.config.get( 'wgMinervaUserBlockInfo', false ),
|
||||
router = require( 'mediawiki.router' ),
|
||||
issues = M.require( 'skins.minerva.scripts/cleanuptemplates' ),
|
||||
|
@ -25,6 +26,7 @@
|
|||
name: 'edit-enabled',
|
||||
glyphPrefix: 'minerva'
|
||||
} ),
|
||||
editErrorMessage = isReadOnly ? mw.msg( 'apierror-readonly' ) : mw.msg( 'mobile-frontend-editor-disabled' ),
|
||||
// TODO: move enabledClass, $caEdit, and disabledClass to locals within
|
||||
// updateEditPageButton().
|
||||
enabledClass = enabledEditIcon.getGlyphClassName(),
|
||||
|
@ -347,7 +349,7 @@
|
|||
setupEditor( currentPage );
|
||||
} else {
|
||||
updateEditPageButton( false );
|
||||
showSorryToast( mw.msg( 'mobile-frontend-editor-disabled' ) );
|
||||
showSorryToast( editErrorMessage );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,7 +378,7 @@
|
|||
} );
|
||||
} else {
|
||||
updateEditPageButton( false );
|
||||
showSorryToast( mw.msg( 'mobile-frontend-editor-disabled' ) );
|
||||
showSorryToast( editErrorMessage );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,11 @@
|
|||
],
|
||||
"SpecialPageBeforeExecute": [
|
||||
"MinervaHooks::onSpecialPageBeforeExecute"
|
||||
],
|
||||
"ResourceLoaderGetConfigVars": [
|
||||
"MinervaHooks::onResourceLoaderGetConfigVars"
|
||||
]
|
||||
|
||||
},
|
||||
"MessagesDirs": {
|
||||
"MinervaNeue": [
|
||||
|
@ -529,7 +533,8 @@
|
|||
"mobile-frontend-editor-edit",
|
||||
"mobile-frontend-editor-redlink-create",
|
||||
"mobile-frontend-editor-redlink-leave",
|
||||
"mobile-frontend-editor-redlink-explain"
|
||||
"mobile-frontend-editor-redlink-explain",
|
||||
"apierror-readonly"
|
||||
],
|
||||
"scripts": [
|
||||
"resources/skins.minerva.editor/init.js"
|
||||
|
|
Loading…
Reference in New Issue