mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-09-23 18:38:18 +00:00
Merge "Show a hint on the new topic tool to explain that it's new"
This commit is contained in:
commit
e568c62f85
|
@ -109,6 +109,8 @@
|
|||
"discussiontools-error-noswitchtove-table",
|
||||
"discussiontools-error-noswitchtove-template",
|
||||
"discussiontools-error-noswitchtove-title",
|
||||
"discussiontools-newtopic-legacy-hint",
|
||||
"discussiontools-newtopic-legacy-hint-close",
|
||||
"discussiontools-newtopic-placeholder-title",
|
||||
"discussiontools-newtopic-missing-title",
|
||||
"discussiontools-replylink",
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
"discussiontools-limitreport-errorreqid": "DiscussionTools error request ID",
|
||||
"discussiontools-limitreport-timeusage": "DiscussionTools time usage",
|
||||
"discussiontools-limitreport-timeusage-value": "$1 {{PLURAL:$1|second|seconds}}",
|
||||
"discussiontools-newtopic-legacy-hint": "<strong>A new way to start topics is here.</strong> This update enables you to add topics using an inline form and to ping others with a new shortcut. You can also [$1 switch back to the legacy experience].",
|
||||
"discussiontools-newtopic-legacy-hint-close": "Close message and do not show again",
|
||||
"discussiontools-newtopic-missing-title": "Please provide a title for your discussion topic. If you click \"{{int:discussiontools-replywidget-newtopic}}\", your topic will be added without a title.",
|
||||
"discussiontools-newtopic-placeholder-title": "Title",
|
||||
"discussiontools-notification-subscribed-new-comment-header": "$1 {{GENDER:$2|replied}} in \"<strong>$4</strong>\".",
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
"discussiontools-limitreport-errorreqid": "Label for the ID of the web request in which a DiscussionTools error has occurred.",
|
||||
"discussiontools-limitreport-timeusage": "Label for the time usage (duration) of DiscussionTools in the parser limit report. Followed by {{msg-mw|discussiontools-limitreport-timeusage-value}}.\n\nSimilar to:\n* {{msg-mw|limitreport-cputime}}\n* {{msg-mw|limitreport-walltime}}\n* {{msg-mw|scribunto-limitreport-timeusage}}",
|
||||
"discussiontools-limitreport-timeusage-value": "Follows {{msg-mw|discussiontools-limitreport-timeusage}}.\n\nParameters:\n* $1 - the usage in seconds\n{{Identical|Second}}",
|
||||
"discussiontools-newtopic-legacy-hint": "Dismissable message explaining the new topic tool and how to return to the legacy section adding tool",
|
||||
"discussiontools-newtopic-legacy-hint-close": "Tooltip for the close button that closes an info message so it's never shown again.",
|
||||
"discussiontools-newtopic-missing-title": "Warning message shown when leaving the title field empty while adding a new topic to the page.",
|
||||
"discussiontools-newtopic-placeholder-title": "Placeholder describing the heading field of a new topic\n{{identical|Title}}",
|
||||
"discussiontools-notification-subscribed-new-comment-header": "Notification header text for when there is a reply on a topic. Parameters:\n* $1 - the formatted username of the user who replied to the topic\n* $2 - the username for gender purposes\n* $3 - title of the page\n* $4 - title of the topic.",
|
||||
|
|
|
@ -111,6 +111,9 @@ class PreferenceHooks implements
|
|||
$preferences['discussiontools-newtopictool-opened'] = [
|
||||
'type' => 'api',
|
||||
];
|
||||
$preferences['discussiontools-newtopictool-hint-shown'] = [
|
||||
'type' => 'api',
|
||||
];
|
||||
$preferences['discussiontools-seenautotopicsubpopup'] = [
|
||||
'type' => 'api',
|
||||
];
|
||||
|
|
|
@ -76,7 +76,17 @@ NewTopicController.prototype.setup = function ( mode ) {
|
|||
rootScrollable.scrollTop = rootScrollable.scrollHeight;
|
||||
this.focus();
|
||||
|
||||
if ( !mw.user.options.get( 'discussiontools-newtopictool-opened' ) ) {
|
||||
var firstUse = !mw.user.options.get( 'discussiontools-newtopictool-opened' );
|
||||
if (
|
||||
( firstUse || mw.user.options.get( 'discussiontools-newtopictool-hint-shown' ) ) &&
|
||||
mw.config.get( 'wgUserId' ) && mw.config.get( 'wgUserEditCount', 0 ) >= 500
|
||||
) {
|
||||
// Topic hint should be shown to logged in users who have more than
|
||||
// 500 edits on their first use of the tool, and should persist until
|
||||
// they deliberately close it.
|
||||
this.setupTopicHint();
|
||||
}
|
||||
if ( firstUse ) {
|
||||
controller.getApi().saveOption( 'discussiontools-newtopictool-opened', '1' ).then( function () {
|
||||
mw.user.options.set( 'discussiontools-newtopictool-opened', '1' );
|
||||
} );
|
||||
|
@ -118,6 +128,52 @@ NewTopicController.prototype.setupReplyWidget = function ( replyWidget, data ) {
|
|||
} );
|
||||
};
|
||||
|
||||
/**
|
||||
* Create and display a hint dialog that redirects users to the non-DT version of this tool
|
||||
*/
|
||||
NewTopicController.prototype.setupTopicHint = function () {
|
||||
var legacyURI;
|
||||
try {
|
||||
legacyURI = new mw.Uri();
|
||||
} catch ( err ) {
|
||||
// T106244: URL encoded values using fallback 8-bit encoding (invalid UTF-8) cause mediawiki.Uri to crash
|
||||
return;
|
||||
}
|
||||
legacyURI.query.action = 'edit';
|
||||
legacyURI.query.section = 'new';
|
||||
legacyURI.query.dtenable = '0';
|
||||
this.topicHint = new OO.ui.MessageWidget( {
|
||||
label: mw.message( 'discussiontools-newtopic-legacy-hint', legacyURI.toString() ).parseDom(),
|
||||
icon: 'article'
|
||||
} );
|
||||
this.topicHint.$element.addClass( 'ext-discussiontools-ui-newTopic-hint' );
|
||||
// TODO: Once showClose lands in OOUI's MessageWidget this can be replaced:
|
||||
var dismissButton = new OO.ui.ButtonWidget( {
|
||||
icon: 'close',
|
||||
framed: false,
|
||||
title: mw.msg( 'discussiontools-newtopic-legacy-hint-close' )
|
||||
} ).connect( this, { click: 'onTopicHintCloseClick' } );
|
||||
this.topicHint.$element.prepend( dismissButton.$element );
|
||||
this.container.$element.before( this.topicHint.$element );
|
||||
|
||||
this.topicHint.toggle( true );
|
||||
|
||||
// This needs to persist once it's shown
|
||||
controller.getApi().saveOption( 'discussiontools-newtopictool-hint-shown', 1 ).then( function () {
|
||||
mw.user.options.set( 'discussiontools-newtopictool-hint-shown', 1 );
|
||||
} );
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle clicks on the close button for the hint dialog
|
||||
*/
|
||||
NewTopicController.prototype.onTopicHintCloseClick = function () {
|
||||
this.toggle( false );
|
||||
controller.getApi().saveOption( 'discussiontools-newtopictool-hint-shown', null ).then( function () {
|
||||
mw.user.options.set( 'discussiontools-newtopictool-hint-shown', null );
|
||||
} );
|
||||
};
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
|
@ -151,6 +207,9 @@ NewTopicController.prototype.teardown = function ( abandoned ) {
|
|||
NewTopicController.super.prototype.teardown.call( this, abandoned );
|
||||
|
||||
this.container.$element.detach();
|
||||
if ( this.topicHint ) {
|
||||
this.topicHint.$element.detach();
|
||||
}
|
||||
|
||||
if ( mw.config.get( 'wgDiscussionToolsStartNewTopicTool' ) ) {
|
||||
var uri;
|
||||
|
|
|
@ -103,7 +103,8 @@ ReplyLinksController.prototype.onAnyLinkClick = function ( e ) {
|
|||
} else if (
|
||||
// ?title=...&action=edit§ion=new
|
||||
// ?title=...&veaction=editsource§ion=new
|
||||
( uri.query.action === 'edit' || uri.query.veaction === 'editsource' ) && uri.query.section === 'new'
|
||||
( uri.query.action === 'edit' || uri.query.veaction === 'editsource' ) && uri.query.section === 'new' &&
|
||||
uri.query.dtenable !== '0'
|
||||
) {
|
||||
// Do nothing
|
||||
|
||||
|
|
|
@ -31,3 +31,17 @@
|
|||
max-width: none;
|
||||
}
|
||||
}
|
||||
|
||||
.ext-discussiontools-ui-newTopic-hint.oo-ui-messageWidget-block {
|
||||
margin-top: 2em;
|
||||
margin-bottom: -1.5em;
|
||||
padding-right: 48px;
|
||||
|
||||
.oo-ui-buttonElement {
|
||||
margin-right: 0;
|
||||
/* Position relative to the surrounding .oo-ui-messageWidget */
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
top: 8px;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue