mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-12 09:09:25 +00:00
Fix flash of bad ve-edit tab on non-wikitext page in enabled namespacea
E.g. when viewing User:Example/common.js there was previously both Edit and Edit source (or Create and Create source) and the client-side JavaScript then removed the ve-edit tab after checking the content model for 've.isAvailable'. Change-Id: Ic2daeefa439648ef0602f8606773655cf9ab188a
This commit is contained in:
parent
4e3d3acf65
commit
d97f85019c
|
@ -118,9 +118,14 @@ class VisualEditorHooks {
|
|||
|
||||
$availableNamespaces = $config->get( 'VisualEditorAvailableNamespaces' );
|
||||
$title = $skin->getRelevantTitle();
|
||||
// Don't exit if this namespace isn't VE-enabled, since we should still
|
||||
// change "Edit" to "Edit source" (especially for NS_MEDIAWIKI).
|
||||
$namespaceEnabled = $title->inNamespaces( array_keys( array_filter( $availableNamespaces ) ) );
|
||||
$pageContentModel = $title->getContentModel();
|
||||
// Don't exit if this page isn't VE-enabled, since we should still
|
||||
// change "Edit" to "Edit source".
|
||||
$isAvailable = (
|
||||
$namespaceEnabled &&
|
||||
$pageContentModel === CONTENT_MODEL_WIKITEXT
|
||||
);
|
||||
|
||||
// HACK: Exit if we're in the Education Program namespace (even though it's content)
|
||||
if ( defined( 'EP_NS' ) && $title->inNamespace( EP_NS ) ) {
|
||||
|
@ -168,7 +173,7 @@ class VisualEditorHooks {
|
|||
if ( $editTabMessage !== null ) {
|
||||
$editTab['text'] = $skin->msg( $editTabMessage )->text();
|
||||
}
|
||||
if ( $namespaceEnabled ) {
|
||||
if ( $isAvailable ) {
|
||||
// Inject the VE tab before or after the edit tab
|
||||
if ( $config->get( 'VisualEditorTabPosition' ) === 'before' ) {
|
||||
$editTab['class'] .= ' collapsible';
|
||||
|
|
Loading…
Reference in a new issue