From cce52fae65d734c9192c07c28995b280f88eb4f4 Mon Sep 17 00:00:00 2001 From: Dringsim Date: Sat, 29 Jul 2023 16:59:34 +0800 Subject: [PATCH] Use different tooltips for ca-edit and ca-ve-edit links Bug: T337653 Bug: T341424 Change-Id: I3aa79fec71ca2c40a0ece3ca73dd934cf6c9d5a8 --- extension.json | 10 +++++-- i18n/ve-mw/en.json | 18 ++++++++--- i18n/ve-mw/qqq.json | 18 ++++++++--- includes/Hooks.php | 28 ++++++++++++++--- .../ve.init.mw.DesktopArticleTarget.init.js | 30 +++++++++++++++---- 5 files changed, 84 insertions(+), 20 deletions(-) diff --git a/extension.json b/extension.json index 820d429715..885f41cf2d 100644 --- a/extension.json +++ b/extension.json @@ -370,10 +370,14 @@ "accesskey-ca-editsource", "accesskey-ca-ve-edit", "pipe-separator", - "tooltip-ca-createsource", - "tooltip-ca-edit", + "tooltip-ca-ve-edit", + "tooltip-ca-ve-create", + "tooltip-ca-ve-edit-local", + "tooltip-ca-ve-create-local", "tooltip-ca-editsource", - "tooltip-ca-ve-edit" + "tooltip-ca-createsource", + "tooltip-ca-editsource-local", + "tooltip-ca-createsource-local" ] }, "ext.visualEditor.desktopArticleTarget.noscript": { diff --git a/i18n/ve-mw/en.json b/i18n/ve-mw/en.json index 6a136a2093..26668de098 100644 --- a/i18n/ve-mw/en.json +++ b/i18n/ve-mw/en.json @@ -17,15 +17,25 @@ "Zoranzoki21" ] }, - "accesskey-ca-editsource": "e", "accesskey-ca-ve-edit": "v", + "accesskey-ca-ve-edit-local": "v", + "accesskey-ca-ve-create": "v", + "accesskey-ca-ve-create-local": "v", + "accesskey-ca-editsource": "e", + "accesskey-ca-editsource-local": "e", + "accesskey-ca-createsource": "e", + "accesskey-ca-createsource-local": "e", "collabpad-doctitle": "CollabPad: $1", "collabpad-import-subtitle": "Imported from $1", "collabpad": "CollabPad", - "tooltip-ca-createsource": "Create the source code of this page", - "tooltip-ca-edit": "Edit this page using wikitext", - "tooltip-ca-editsource": "Edit the source code of this page", "tooltip-ca-ve-edit": "Edit this page", + "tooltip-ca-ve-edit-local": "Edit the local description page", + "tooltip-ca-ve-create": "Create this page", + "tooltip-ca-ve-create-local": "Create the local description page", + "tooltip-ca-editsource": "Edit the source code of this page", + "tooltip-ca-editsource-local": "Edit the source code of the local description page", + "tooltip-ca-createsource": "Create the source code of this page", + "tooltip-ca-createsource-local": "Create the source code of the local description page", "visualeditor-advancedsettings-tool": "Advanced settings", "visualeditor-annotations-default-description": "This part of the page is part of an annotation range.", "visualeditor-annotations-default-end": "End of the annotated range", diff --git a/i18n/ve-mw/qqq.json b/i18n/ve-mw/qqq.json index 21572ffb81..197e928001 100644 --- a/i18n/ve-mw/qqq.json +++ b/i18n/ve-mw/qqq.json @@ -38,15 +38,25 @@ "Ата" ] }, - "accesskey-ca-editsource": "{{doc-accesskey}}", "accesskey-ca-ve-edit": "{{doc-accesskey}}", + "accesskey-ca-ve-edit-local": "{{doc-accesskey}}", + "accesskey-ca-ve-create": "{{doc-accesskey}}", + "accesskey-ca-ve-create-local": "{{doc-accesskey}}", + "accesskey-ca-editsource": "{{doc-accesskey}}", + "accesskey-ca-editsource-local": "{{doc-accesskey}}", + "accesskey-ca-createsource": "{{doc-accesskey}}", + "accesskey-ca-createsource-local": "{{doc-accesskey}}", "collabpad-doctitle": "Name of CollabPad special page with a document subtitle", "collabpad-import-subtitle": "Subtitle of CollabPad page, linking to the page the content was imported from", "collabpad": "Name of CollabPad special page", - "tooltip-ca-createsource": "Tooltip of the {{msg-mw|Visualeditor-ca-createsource}} tab, used if the page does not exist.\n\nSee also:\n* {{msg-mw|Tooltip-ca-editsource}} - tooltip of the {{msg-mw|Visualeditor-ca-editsource}} tab, used if the page already exists", - "tooltip-ca-edit": "Over-ridden tooltip of the wikitext \"Edit source\" tab.", - "tooltip-ca-editsource": "Tooltip of the {{msg-mw|Visualeditor-ca-editsource}} tab, used if the page already exists.\n\nSee also:\n* {{msg-mw|Tooltip-ca-createsource}} - tooltip of the {{msg-mw|Visualeditor-ca-createsource}} tab, used if the page does not exist", "tooltip-ca-ve-edit": "Tooltip of the dedicated VisualEditor \"Edit\" tab.\n{{Identical|Edit this page}}", + "tooltip-ca-ve-edit-local": "Tooltip of the dedicated VisualEditor \"Edit local description\" tab.", + "tooltip-ca-ve-create": "Tooltip of the dedicated VisualEditor \"Create\" tab.", + "tooltip-ca-ve-create-local": "Tooltip of the dedicated VisualEditor \"Add local description\" tab.", + "tooltip-ca-editsource": "Tooltip of the {{msg-mw|Visualeditor-ca-editsource}} tab, used if the page already exists.\n\nSee also:\n* {{msg-mw|Tooltip-ca-createsource}} - tooltip of the {{msg-mw|Visualeditor-ca-createsource}} tab, used if the page does not exist", + "tooltip-ca-editsource-local": "Tooltip of the {{msg-mw|Visualeditor-ca-editlocaldescriptionsource}} tab, used if the page already exists.\n\nSee also:\n* {{msg-mw|Tooltip-ca-createsource-local}} - tooltip of the {{msg-mw|Visualeditor-ca-createlocaldescriptionsource}} tab, used if the page does not exist", + "tooltip-ca-createsource": "Tooltip of the {{msg-mw|Visualeditor-ca-createsource}} tab, used if the page does not exist.\n\nSee also:\n* {{msg-mw|Tooltip-ca-editsource}} - tooltip of the {{msg-mw|Visualeditor-ca-editsource}} tab, used if the page already exists", + "tooltip-ca-createsource-local": "Tooltip of the {{msg-mw|Visualeditor-ca-createlocaldescriptionsource}} tab, used if the page does not exist.\n\nSee also:\n* {{msg-mw|Tooltip-ca-editsource-local}} - tooltip of the {{msg-mw|Visualeditor-ca-editlocaldescriptionsource}} tab, used if the page already exists", "visualeditor-advancedsettings-tool": "Tool for opening the advanced settings section of the meta dialog.\n{{Identical|Advanced settings}}", "visualeditor-annotations-default-description": "Default description for annotated ranges", "visualeditor-annotations-default-end": "Label of the context item for a closing annotation tag without message", diff --git a/includes/Hooks.php b/includes/Hooks.php index 952bb94741..5862c9bdfe 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -550,6 +550,8 @@ class Hooks implements TextSlotDiffRendererTablePrefixHook { // us to splice into the middle of an associative array. $newViews = []; $wikiPageFactory = $services->getWikiPageFactory(); + $isRemote = $title->inNamespace( NS_FILE ) && + !$wikiPageFactory->newFromTitle( $title )->isLocal(); foreach ( $links['views'] as $action => $data ) { if ( $action === 'edit' ) { // Build the VisualEditor tab @@ -567,32 +569,50 @@ class Hooks implements TextSlotDiffRendererTablePrefixHook { // @phan-suppress-next-line PhanTypeInvalidDimOffset $veTabText = $veTabMessage === null ? $data['text'] : $skin->msg( $veTabMessage )->text(); + if ( $isRemote ) { + // The following messages can be used here: + // * tooltip-ca-ve-edit-local + // * tooltip-ca-ve-create-local + $veTooltip = 'ca-ve-' . $action . '-local'; + } else { + // The following messages can be used here: + // * tooltip-ca-ve-edit + // * tooltip-ca-ve-create + $veTooltip = 'ca-ve-' . $action; + } $veTab = [ 'href' => $title->getLocalURL( $veParams ), 'text' => $veTabText, + 'single-id' => $veTooltip, 'primary' => true, 'class' => '', ]; // Alter the edit tab $editTab = $data; - if ( - $title->inNamespace( NS_FILE ) && - !$wikiPageFactory->newFromTitle( $title )->isLocal() - ) { + if ( $isRemote ) { // The following messages can be used here: // * visualeditor-ca-editlocaldescriptionsource // * visualeditor-ca-createlocaldescriptionsource $editTabMessage = $tabMessages[$action . 'localdescriptionsource']; + // The following messages can be used here: + // * tooltip-ca-editsource-local + // * tooltip-ca-createsource-local + $editTabTooltip = 'ca-' . $action . 'source-local'; } else { // The following messages can be used here: // * visualeditor-ca-editsource // * visualeditor-ca-createsource $editTabMessage = $tabMessages[$action . 'source']; + // The following messages can be used here: + // * tooltip-ca-editsource + // * tooltip-ca-createsource + $editTabTooltip = 'ca-' . $action . 'source'; } if ( $editTabMessage !== null ) { $editTab['text'] = $skin->msg( $editTabMessage )->text(); + $editTab['single-id'] = $editTabTooltip; } $editor = self::getLastEditor( $user, $skin->getRequest() ); diff --git a/modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js b/modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js index 5cca0b174e..4c58e5ba28 100644 --- a/modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js +++ b/modules/ve-mw/preinit/ve.init.mw.DesktopArticleTarget.init.js @@ -909,14 +909,15 @@ caVeEditNextnode = ( conf.tabPosition === 'before' ) ? $caEdit.get( 0 ) : - $caEdit.next().get( 0 ); + $caEdit.next().get( 0 ), + isRemote = $( '#ca-view-foreign' ).length; if ( !$caVeEdit.length ) { // The below duplicates the functionality of VisualEditorHooks::onSkinTemplateNavigation() // in case we're running on a cached page that doesn't have these tabs yet. // Alter the edit tab (#ca-edit) - if ( $( '#ca-view-foreign' ).length ) { + if ( isRemote ) { if ( tabMessages[ action + 'localdescriptionsource' ] ) { // The following messages can be used here: // * visualeditor-ca-editlocaldescriptionsource @@ -931,6 +932,13 @@ $caEditLink.text( mw.msg( tabMessages[ action + 'source' ] ) ); } } + // The following messages can be used here: + // * tooltip-ca-editsource + // * tooltip-ca-createsource + // * tooltip-ca-editsource-local + // * tooltip-ca-createsource-local + $caEditLink.attr( 'title', mw.msg( 'tooltip-ca-' + action + 'source' + ( isRemote ? '-local' : '' ) ) ); + $caEditLink.updateTooltipAccessKeys(); // If there is no edit tab or a view-source tab, // the user doesn't have permission to edit. @@ -944,9 +952,14 @@ // 2) when onEditTabClick is not bound (!pageCanLoadEditor) it will // just work. veEditUrl, - getTabMessage( action + ( $( '#ca-view-foreign' ).length ? '-local' : '' ) ), + getTabMessage( action + ( isRemote ? '-local' : '' ) ), 'ca-ve-edit', - mw.msg( 'tooltip-ca-ve-edit' ), + // The following messages can be used here: + // * tooltip-ca-ve-edit + // * tooltip-ca-ve-create + // * tooltip-ca-ve-edit-local + // * tooltip-ca-ve-create-local + mw.msg( 'tooltip-ca-ve-' + action + ( isRemote ? '-local' : '' ) ), mw.msg( 'accesskey-ca-ve-edit' ), caVeEditNextnode ); @@ -967,7 +980,14 @@ $caEdit.after( $caVeEdit ); } } - $caVeEditLink.text( getTabMessage( action + ( $( '#ca-view-foreign' ).length ? '-local' : '' ) ) ); + $caVeEditLink.text( getTabMessage( action + ( isRemote ? '-local' : '' ) ) ); + // The following messages can be used here: + // * tooltip-ca-ve-edit + // * tooltip-ca-ve-create + // * tooltip-ca-ve-edit-local + // * tooltip-ca-ve-create-local + $caVeEditLink.attr( 'title', mw.msg( 'tooltip-ca-ve-' + action + ( isRemote ? '-local' : '' ) ) ); + $caVeEditLink.updateTooltipAccessKeys(); } // If the edit tab is hidden, remove it.