Merge "Use different tooltips for ca-edit and ca-ve-edit links"

This commit is contained in:
jenkins-bot 2023-08-03 15:53:21 +00:00 committed by Gerrit Code Review
commit e2efe5079a
5 changed files with 84 additions and 20 deletions

View file

@ -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": {

View file

@ -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",

View file

@ -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",

View file

@ -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() );

View file

@ -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.