Separate dialog for abandoning a new topic

Bug: T269190
Change-Id: Ie4f486b0641edea369702631556d8ea31f991370
This commit is contained in:
Bartosz Dziewoński 2021-01-18 19:18:32 +01:00
parent 8c01d67c03
commit 37b574f165
6 changed files with 57 additions and 27 deletions

View file

@ -113,7 +113,9 @@
},
"ext.discussionTools.ReplyWidget": {
"packageFiles": [
"dt.ui.ReplyWidget.js"
"dt.ui.ReplyWidget.js",
"AbandonCommentDialog.js",
"AbandonTopicDialog.js"
],
"styles": [
"dt.ui.ReplyWidget.less"
@ -122,6 +124,9 @@
"discussiontools-replywidget-abandon",
"discussiontools-replywidget-abandon-discard",
"discussiontools-replywidget-abandon-keep",
"discussiontools-replywidget-abandontopic",
"discussiontools-replywidget-abandontopic-discard",
"discussiontools-replywidget-abandontopic-keep",
"discussiontools-replywidget-advanced",
"discussiontools-replywidget-anon-warning",
"discussiontools-replywidget-cancel",

View file

@ -17,6 +17,9 @@
"discussiontools-replywidget-abandon": "Are you sure you want to discard the comment you are writing?",
"discussiontools-replywidget-abandon-discard": "Discard comment",
"discussiontools-replywidget-abandon-keep": "Continue writing",
"discussiontools-replywidget-abandontopic": "Are you sure you want to discard the topic you are writing?",
"discussiontools-replywidget-abandontopic-discard": "Discard topic",
"discussiontools-replywidget-abandontopic-keep": "Continue writing",
"discussiontools-replywidget-advanced": "Advanced",
"discussiontools-replywidget-anon-warning": "<strong>You are not logged in.</strong> To receive attribution with your name instead of your IP address, you can [$1 log in] or [$2 create an account].",
"discussiontools-replywidget-cancel": "Cancel",

View file

@ -22,9 +22,12 @@
"discussiontools-preference-replytool": "Used in [[Special:Preferences]].\n\nUsed as label for checkbox to enable the reply tool.\n\nThe help text for this checkbox is: {{msg-mw|discussiontools-preference-replytool-help}}",
"discussiontools-preference-replytool-help": "Used in [[Special:Preferences]].\n\nUsed as help text for the checkbox {{msg-mw|discussiontools-preference-replytool}}",
"discussiontools-replylink": "Label for the reply link added after each comment. Use the same casing as section edit links.\n* {{Related|editsection}}.",
"discussiontools-replywidget-abandon": "Message shown when abandoning a comment\n\nSee also {{msg-mw|mw-widgets-abandonedit}}.",
"discussiontools-replywidget-abandon-discard": "Label for button to abandon a comment\n\nThis button follows {{msg-mw|discussiontools-replywidget-abandon}}.",
"discussiontools-replywidget-abandon-keep": "Label for button to cancel abandoning a comment\n\nThis button follows {{msg-mw|discussiontools-replywidget-abandon}}.",
"discussiontools-replywidget-abandon": "Message shown when abandoning a comment\n\nSimilar to {{msg-mw|mw-widgets-abandonedit}}, {{msg-mw|discussiontools-replywidget-abandontopic}}.",
"discussiontools-replywidget-abandon-discard": "Label for button to abandon a comment\n\nThis button follows {{msg-mw|discussiontools-replywidget-abandon}}.\n\nSimilar to {{msg-mw|discussiontools-replywidget-abandontopic-discard}}.",
"discussiontools-replywidget-abandon-keep": "Label for button to cancel abandoning a comment\n\nThis button follows {{msg-mw|discussiontools-replywidget-abandon}}.\n\nSimilar to {{msg-mw|discussiontools-replywidget-abandontopic-keep}}.",
"discussiontools-replywidget-abandontopic": "Message shown when abandoning a new topic\n\nSimilar to {{msg-mw|mw-widgets-abandonedit}}, {{msg-mw|discussiontools-replywidget-abandon}}.",
"discussiontools-replywidget-abandontopic-discard": "Label for button to abandon a new topic\n\nThis button follows {{msg-mw|discussiontools-replywidget-abandontopic}}.\n\nSimilar to {{msg-mw|discussiontools-replywidget-abandon-discard}}.",
"discussiontools-replywidget-abandontopic-keep": "Label for button to cancel abandoning a new topic\n\nThis button follows {{msg-mw|discussiontools-replywidget-abandontopic}}.\n\nSimilar to {{msg-mw|discussiontools-replywidget-abandon-keep}}.",
"discussiontools-replywidget-advanced": "Label for button to toggle the advanced options for the reply tool, which shows an edit summary input and watchlist checkbox.",
"discussiontools-replywidget-anon-warning": "Warning message to be displayed when anonymous user starts writing a new topic or reply.\n* $1 is a URL to log in.\n* $2 is a URL to register an account.",
"discussiontools-replywidget-cancel": "Label for the cancel button in the reply widget",

View file

@ -0,0 +1,19 @@
function AbandonCommentDialog() {
// Parent constructor
AbandonCommentDialog.super.apply( this, arguments );
}
/* Inheritance */
OO.inheritClass( AbandonCommentDialog, mw.widgets.AbandonEditDialog );
AbandonCommentDialog.static.name = 'abandoncomment';
AbandonCommentDialog.static.message = OO.ui.deferMsg( 'discussiontools-replywidget-abandon' );
AbandonCommentDialog.static.actions = OO.copy( AbandonCommentDialog.static.actions );
AbandonCommentDialog.static.actions[ 0 ].label =
OO.ui.deferMsg( 'discussiontools-replywidget-abandon-discard' );
AbandonCommentDialog.static.actions[ 1 ].label =
OO.ui.deferMsg( 'discussiontools-replywidget-abandon-keep' );
OO.ui.getWindowManager().addWindows( [ new AbandonCommentDialog() ] );

View file

@ -0,0 +1,19 @@
function AbandonTopicDialog() {
// Parent constructor
AbandonTopicDialog.super.apply( this, arguments );
}
/* Inheritance */
OO.inheritClass( AbandonTopicDialog, mw.widgets.AbandonEditDialog );
AbandonTopicDialog.static.name = 'abandontopic';
AbandonTopicDialog.static.message = OO.ui.deferMsg( 'discussiontools-replywidget-abandontopic' );
AbandonTopicDialog.static.actions = OO.copy( AbandonTopicDialog.static.actions );
AbandonTopicDialog.static.actions[ 0 ].label =
OO.ui.deferMsg( 'discussiontools-replywidget-abandontopic-discard' );
AbandonTopicDialog.static.actions[ 1 ].label =
OO.ui.deferMsg( 'discussiontools-replywidget-abandontopic-keep' );
OO.ui.getWindowManager().addWindows( [ new AbandonTopicDialog() ] );

View file

@ -3,6 +3,9 @@ var controller = require( 'ext.discussionTools.init' ).controller,
utils = require( 'ext.discussionTools.init' ).utils,
logger = require( 'ext.discussionTools.init' ).logger;
require( './AbandonCommentDialog.js' );
require( './AbandonTopicDialog.js' );
/**
* @external CommentController
* @external CommentItem
@ -476,7 +479,7 @@ ReplyWidget.prototype.tryTeardown = function () {
widget = this;
if ( !this.isEmpty() || ( this.isNewTopic && this.commentController.sectionTitle.getValue() ) ) {
promise = OO.ui.getWindowManager().openWindow( 'abandoncomment' )
promise = OO.ui.getWindowManager().openWindow( this.isNewTopic ? 'abandontopic' : 'abandoncomment' )
.closed.then( function ( data ) {
if ( !( data && data.action === 'discard' ) ) {
return $.Deferred().reject().promise();
@ -768,26 +771,4 @@ ReplyWidget.prototype.onReplyClick = function () {
} );
};
/* Window registration */
function AbandonCommentDialog() {
// Parent constructor
AbandonCommentDialog.super.apply( this, arguments );
}
/* Inheritance */
OO.inheritClass( AbandonCommentDialog, mw.widgets.AbandonEditDialog );
AbandonCommentDialog.static.name = 'abandoncomment';
AbandonCommentDialog.static.message = OO.ui.deferMsg( 'discussiontools-replywidget-abandon' );
AbandonCommentDialog.static.actions = OO.copy( AbandonCommentDialog.static.actions );
AbandonCommentDialog.static.actions[ 0 ].label =
OO.ui.deferMsg( 'discussiontools-replywidget-abandon-discard' );
AbandonCommentDialog.static.actions[ 1 ].label =
OO.ui.deferMsg( 'discussiontools-replywidget-abandon-keep' );
OO.ui.getWindowManager().addWindows( [ new AbandonCommentDialog() ] );
module.exports = ReplyWidget;