jenkins-bot has submitted this change and it was merged.
Change subject: Fix flash of wrong Edit tab in non-VE namespaces
......................................................................
Fix flash of wrong Edit tab in non-VE namespaces
Follows-up 6bc797f which added an early return in namespaces
where VE is not enabled. However, just like the init-init JS code
does already, we should still update the Edit tab message to say
"Edit source" regardless of whether VE is enabled.
After 6bc797f this started to cause a flash where the tab first
says "Edit" and then becomes "Edit source" client-side.
And since the Title::isKnown logic is not available client-side,
this actually exposed a bug with regards to MediaWiki-namespage
messages. Currently the client-side considers these "Create source"
when they are in fact "Edit" (or "Edit source").
Change-Id: If88d648b657d8a571beb7991805f8af8bd547975
---
M VisualEditor.hooks.php
1 file changed, 15 insertions(+), 12 deletions(-)
Approvals:
Alex Monk: Looks good to me, approved
jenkins-bot: Verified
diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 6135b65..813ebc6 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -118,10 +118,9 @@
$availableNamespaces = $config->get(
'VisualEditorAvailableNamespaces' );
$title = $skin->getRelevantTitle();
- // Exit if we're not in a VE-enabled namespace
- if ( !$title->inNamespaces( array_keys( array_filter(
$availableNamespaces ) ) ) ) {
- return true;
- }
+ // 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 ) ) );
// HACK: Exit if we're in the Education Program namespace (even
though it's content)
if ( defined( 'EP_NS' ) && $title->inNamespace( EP_NS ) ) {
@@ -169,16 +168,20 @@
if ( $editTabMessage !== null ) {
$editTab['text'] = $skin->msg(
$editTabMessage )->text();
}
-
- // Inject the VE tab before or after the edit
tab
- if ( $config->get( 'VisualEditorTabPosition' )
=== 'before' ) {
- $editTab['class'] .= ' collapsible';
- $newViews['ve-edit'] = $veTab;
- $newViews['edit'] = $editTab;
+ if ( $namespaceEnabled ) {
+ // Inject the VE tab before or after
the edit tab
+ if ( $config->get(
'VisualEditorTabPosition' ) === 'before' ) {
+ $editTab['class'] .= '
collapsible';
+ $newViews['ve-edit'] = $veTab;
+ $newViews['edit'] = $editTab;
+ } else {
+ $veTab['class'] .= '
collapsible';
+ $newViews['edit'] = $editTab;
+ $newViews['ve-edit'] = $veTab;
+ }
} else {
- $veTab['class'] .= ' collapsible';
+ // Don't add ve-edit, but do update the
edit tab (e.g. "Edit source").
$newViews['edit'] = $editTab;
- $newViews['ve-edit'] = $veTab;
}
} else {
// Just pass through
--
To view, visit https://gerrit.wikimedia.org/r/233661
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If88d648b657d8a571beb7991805f8af8bd547975
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits