From 38b5a9c0fe049a4eec13384e843c09d00c0f809b Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 10 Sep 2020 14:52:33 +0100 Subject: [PATCH] Create preference for turning off reply tool once out of beta Bug: T259943 Depends-On: I75d38560a649794effbfc07cab1de0cc2e18f57b Change-Id: Iec472bddd92e821d924a18db1734e8da6188b3dd --- extension.json | 3 ++- i18n/en.json | 4 +++- i18n/qqq.json | 6 ++++-- includes/Hooks.php | 20 ++++++++++++++++++-- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/extension.json b/extension.json index 6dabe2bbd..f44718cb4 100644 --- a/extension.json +++ b/extension.json @@ -302,7 +302,8 @@ "RecentChange_save": "\\MediaWiki\\Extension\\DiscussionTools\\Hooks::onRecentChangeSave" }, "DefaultUserOptions": { - "discussiontools-editmode": "" + "discussiontools-editmode": "", + "discussiontools-replytool": 1 }, "config": { "DiscussionToolsEnable": { diff --git a/i18n/en.json b/i18n/en.json index 27d5a1006..96e401409 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -7,8 +7,10 @@ "discussiontools-desc": "Tools to enhance discussion pages.", "discussiontools-preference-label": "Discussion tools", "discussiontools-preference-description": "Enable a new workflow for [https://www.mediawiki.org/wiki/Talk_pages_project/replying replying to specific comments] on talk pages.\n\nPlease note that over time new tools for interacting with talk pages will be added.\n\nUpdates about these features will be posted on the [https://www.mediawiki.org/wiki/Talk_pages_project/Updates talk pages project's updates page].", - "discussiontools-preference-info-link": "https:\/\/www.mediawiki.org\/wiki\/Special:MyLanguage\/Talk_pages_project", + "discussiontools-preference-info-link": "https:\/\/www.mediawiki.org\/wiki\/Special:MyLanguage\/Talk_pages_project/Feature_summary", "discussiontools-preference-discussion-link": "https:\/\/www.mediawiki.org\/wiki\/Talk:Talk_pages_project", + "discussiontools-preference-replytool": "Enable quick replying", + "discussiontools-preference-replytool-help": "This will show you a link to reply to talk page comments in one click. You can learn more about this feature by reading the [https:\/\/www.mediawiki.org\/wiki\/Special:MyLanguage\/Talk_pages_project\/Feature_summary feature summary].", "discussiontools-replylink": "reply", "discussiontools-replywidget-abandon": "Are you sure you want to discard the comment you are writing?", "discussiontools-replywidget-abandon-discard": "Discard comment", diff --git a/i18n/qqq.json b/i18n/qqq.json index a199cc883..bd8206872 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -11,10 +11,12 @@ "discussiontools": "{{name}}", "discussiontools-defaultsummary-reply": "Default edit summary for a reply.\n\n'''Note that this is a noun (''a reply''), not a verb (''to reply''). Alternatively you can use a past tense verb if that's more natural in your language.'''", "discussiontools-desc": "{{desc\n| name = DiscussionTools\n| url = https://www.mediawiki.org/wiki/Extension:DiscussionTools\n}}", - "discussiontools-preference-label": "Used in [[Special:Preferences]].\n\nUsed as label for checkbox to enable discussion tools.\n\nThe description for this checkbox is: {{msg-mw|discussiontools-preference-description}}", - "discussiontools-preference-description": "Used in [[Special:Preferences]].\n\nUsed as description for the checkbox to enable discussion tools.\n\nThe label for this checkbox is {{msg-mw|discussiontools-preference-label}}.", + "discussiontools-preference-label": "Used in [[Special:Preferences]].\n\nUsed as label for checkbox to enable discussion tools as Beta Feature.\n\nThe description for this checkbox is: {{msg-mw|discussiontools-preference-description}}", + "discussiontools-preference-description": "Used in [[Special:Preferences]].\n\nUsed as description for the checkbox to enable discussion tools as a Beta Feature.\n\nThe label for this checkbox is {{msg-mw|discussiontools-preference-label}}.", "discussiontools-preference-info-link": "{{optional|Used on [[Special:Preferences]] as a link to a page where users can learn about this Beta Feature. Defaults to a page on MediaWiki.org.}}", "discussiontools-preference-discussion-link": "{{optional|Used on [[Special:Preferences]] as a link to a page where users can discuss this Beta Feature. Defaults to a page on MediaWiki.org.}}", + "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}}.", diff --git a/includes/Hooks.php b/includes/Hooks.php index 73def42c1..2812ee388 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -75,9 +75,10 @@ class Hooks { $optionsLookup = $services->getUserOptionsLookup(); $dtConfig = $services->getConfigFactory()->makeConfig( 'discussiontools' ); + $isBeta = $dtConfig->get( 'DiscussionToolsBeta' ); $userEnabled = $dtConfig->get( 'DiscussionToolsEnable' ) && ( - !$dtConfig->get( 'DiscussionToolsBeta' ) || - $optionsLookup->getOption( $user, 'discussiontools-betaenable' ) + ( $isBeta && $optionsLookup->getOption( $user, 'discussiontools-betaenable' ) ) || + ( !$isBeta && $optionsLookup->getOption( $user, 'discussiontools-replytool' ) ) ); // Finally check the user has the tool enabled and that the page @@ -150,6 +151,21 @@ class Hooks { * @param array &$preferences Their preferences object */ public static function onGetPreferences( User $user, array &$preferences ) { + $dtConfig = MediaWikiServices::getInstance()->getConfigFactory() + ->makeConfig( 'discussiontools' ); + + if ( + $dtConfig->get( 'DiscussionToolsEnable' ) && + !$dtConfig->get( 'DiscussionToolsBeta' ) + ) { + $preferences['discussiontools-replytool'] = [ + 'type' => 'toggle', + 'label-message' => 'discussiontools-preference-replytool', + 'help-message' => 'discussiontools-preference-replytool-help', + 'section' => 'editing/discussion', + ]; + } + $api = [ 'type' => 'api' ]; $preferences['discussiontools-editmode'] = [ 'type' => 'api',