Create preference for turning off reply tool once out of beta

Bug: T259943
Depends-On: I75d38560a649794effbfc07cab1de0cc2e18f57b
Change-Id: Iec472bddd92e821d924a18db1734e8da6188b3dd
This commit is contained in:
Ed Sanders 2020-09-10 14:52:33 +01:00 committed by Esanders
parent f96678d562
commit 38b5a9c0fe
4 changed files with 27 additions and 6 deletions

View file

@ -302,7 +302,8 @@
"RecentChange_save": "\\MediaWiki\\Extension\\DiscussionTools\\Hooks::onRecentChangeSave"
},
"DefaultUserOptions": {
"discussiontools-editmode": ""
"discussiontools-editmode": "",
"discussiontools-replytool": 1
},
"config": {
"DiscussionToolsEnable": {

View file

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

View file

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

View file

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