From 6869112aadd398ed1c85d5d8026454f383af19bb Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 3 Feb 2022 16:43:45 +0000 Subject: [PATCH] Use MessageWidget's showClose option Change-Id: I81292bd84ce6feefdb852f6a636109f68e55291d --- extension.json | 1 - i18n/en.json | 1 - i18n/qqq.json | 1 - modules/NewTopicController.js | 16 ++++------------ modules/dt.ui.NewTopicController.less | 8 -------- 5 files changed, 4 insertions(+), 23 deletions(-) diff --git a/extension.json b/extension.json index 72d165b6b..7e62a8d53 100644 --- a/extension.json +++ b/extension.json @@ -116,7 +116,6 @@ "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", diff --git a/i18n/en.json b/i18n/en.json index e24278e1f..df9d2bf06 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -39,7 +39,6 @@ "discussiontools-limitreport-timeusage": "DiscussionTools time usage", "discussiontools-limitreport-timeusage-value": "$1 {{PLURAL:$1|second|seconds}}", "discussiontools-newtopic-legacy-hint": "A new way to start topics is here. 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-legacy-hint-return": "You are now viewing the legacy experience. You can [$1 return to the new experience] or visit preferences to [$2 set the legacy experience as your default].", "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", diff --git a/i18n/qqq.json b/i18n/qqq.json index b365403df..795de7fe0 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -50,7 +50,6 @@ "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-legacy-hint-return": "Message shown on the legacy section adding tool", "discussiontools-newtopic-missing-title": "Warning message shown when leaving the title field empty while adding a new topic to the page.\n\nCopy {{int:discussiontools-replywidget-newtopic}} into your translation. It will be shown as {{msg-mw|discussiontools-replywidget-newtopic}}", "discussiontools-newtopic-placeholder-title": "Placeholder describing the heading field of a new topic\n{{identical|Title}}", diff --git a/modules/NewTopicController.js b/modules/NewTopicController.js index e98406a66..6beef4824 100644 --- a/modules/NewTopicController.js +++ b/modules/NewTopicController.js @@ -164,16 +164,11 @@ NewTopicController.prototype.setupTopicHint = function () { this.topicHint = new OO.ui.MessageWidget( { label: mw.message( 'discussiontools-newtopic-legacy-hint', legacyURI.toString() + fragment ).parseDom(), + showClose: true, icon: 'article' - } ); + } ) + .connect( this, { close: 'onTopicHintClose' } ); 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.topicHint.$element.find( 'a' ).on( 'click', function () { // Clicking to follow this link should immediately discard the // autosave. We can do this before the onBeforeUnload handler asks @@ -184,8 +179,6 @@ NewTopicController.prototype.setupTopicHint = function () { } ); 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 ); @@ -195,8 +188,7 @@ NewTopicController.prototype.setupTopicHint = function () { /** * Handle clicks on the close button for the hint dialog */ -NewTopicController.prototype.onTopicHintCloseClick = function () { - this.topicHint.toggle( false ); +NewTopicController.prototype.onTopicHintClose = function () { controller.getApi().saveOption( 'discussiontools-newtopictool-hint-shown', null ).then( function () { mw.user.options.set( 'discussiontools-newtopictool-hint-shown', null ); } ); diff --git a/modules/dt.ui.NewTopicController.less b/modules/dt.ui.NewTopicController.less index 99f7c52fb..47cdccd00 100644 --- a/modules/dt.ui.NewTopicController.less +++ b/modules/dt.ui.NewTopicController.less @@ -36,12 +36,4 @@ 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; - } }