jenkins-bot has submitted this change and it was merged.
Change subject: Add unwatch topic/board dynamic action for Flow notifications
......................................................................
Add unwatch topic/board dynamic action for Flow notifications
Add an 'unwatch topc' and 'unwatch board' dynamic action to Flow
notifications:
Unwatch board
[x] flow-new-topic
[x] flowboard-description-edited (not if in the user's talk page)
Unwatch topic
[x] flow-post-reply
[x] flow-post-edited
[x] flow-topic-renamed
[x] Flow-summary-edit (not if in the user's talk page)
[x] Flow-topic-resolved (not if in the user's talk page)
Bug: T132975
Depends-On: Ib16d57c3f1a11a974
Change-Id: I75d0098e7718ec44bfb3a4d43e4e7e5a03c47331
---
M i18n/en.json
M i18n/qqq.json
M includes/Notifications/FlowPresentationModel.php
M includes/Notifications/HeaderEditedPresentationModel.php
M includes/Notifications/NewTopicPresentationModel.php
M includes/Notifications/PostEditedPresentationModel.php
M includes/Notifications/PostReplyPresentationModel.php
M includes/Notifications/SummaryEditedPresentationModel.php
M includes/Notifications/TopicRenamedPresentationModel.php
M includes/Notifications/TopicResolvedPresentationModel.php
10 files changed, 117 insertions(+), 14 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/i18n/en.json b/i18n/en.json
index fbafbb9..9b11510 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -14,6 +14,12 @@
]
},
"enableflow": "Enable Flow",
+ "notification-dynamic-actions-flow-board-unwatch": "Stop watching new
activity on \"$1\"",
+ "notification-dynamic-actions-flow-board-unwatch-confirmation": "You
are no longer watching the page \"$1\"",
+
"notification-dynamic-actions-flow-board-unwatch-confirmation-description":
"This will not affect individual topics you are watching. You can watch [$2
this page] anytime.",
+ "notification-dynamic-actions-flow-topic-unwatch": "Stop watching this
topic",
+ "notification-dynamic-actions-flow-topic-unwatch-confirmation": "You
are no longer watching \"$1\"",
+
"notification-dynamic-actions-flow-topic-unwatch-confirmation-description":
"You can watch [$2 this page] anytime.",
"flow-desc": "Workflow management system",
"flow-talk-taken-over-comment": "/* This page has been converted into a
Flow discussion board */",
"log-name-flow": "Flow activity log",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index e427050..ad72447 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -25,6 +25,12 @@
]
},
"enableflow": "{{doc-special|EnableFlow}}",
+ "notification-dynamic-actions-flow-board-unwatch": "Text for the action
offering the user to unwatch a board from within a
notification.\n\nParameters:\n* $1 - Board name\n* $2 - Board URL",
+ "notification-dynamic-actions-flow-board-unwatch-confirmation": "Title
for the confirmation text for unwatching a board from within a
notification.\n\nParameters:\n* $1 - Board name\n* $2 - Board URL",
+
"notification-dynamic-actions-flow-board-unwatch-confirmation-description":
"Description for the confirmation text for unwatching a board from within a
notification.\n\nParameters:\n* $1 - Board name\n* $2 - Board URL",
+ "notification-dynamic-actions-flow-topic-unwatch": "Text for the action
offering the user to unwatch a topic from within a
notification.\n\nParameters:\n* $1 - Topic name\n* $2 - Topic URL",
+ "notification-dynamic-actions-flow-topic-unwatch-confirmation": "Title
for the confirmation text for unwatching a topic from within a
notification.\n\nParameters:\n* $1 - Topic name\n* $2 - Topic URL",
+
"notification-dynamic-actions-flow-topic-unwatch-confirmation-description":
"Description for the confirmation text for unwatching a topic from within a
notification.\n\nParameters:\n* $1 - Topic name\n* $2 - Topic URL",
"flow-desc":
"{{desc|name=Flow|url=https://www.mediawiki.org/wiki/Extension:Flow}}",
"flow-talk-taken-over-comment": "Comment of the new revision that is
created when a page turns into a Flow discussion board.",
"log-name-flow": "{{doc-logpage}}\nName of the Flow log filter on the
[[Special:Log]] page.",
diff --git a/includes/Notifications/FlowPresentationModel.php
b/includes/Notifications/FlowPresentationModel.php
index 9af56cb..ade342e 100644
--- a/includes/Notifications/FlowPresentationModel.php
+++ b/includes/Notifications/FlowPresentationModel.php
@@ -47,9 +47,7 @@
$anchorPostId = $firstChronologicallyPostId;
}
- $title = Title::makeTitleSafe(
- NS_TOPIC,
- $workflowId->getAlphadecimal(),
+ $title = $this->getTopicTitle(
'flow-post-' . $anchorPostId->getAlphadecimal()
);
@@ -72,10 +70,23 @@
/** @var UUID $workflowId */
$workflowId = $this->event->getExtraParam( 'topic-workflow' );
- $title = Title::makeTitleSafe( NS_TOPIC,
$workflowId->getAlphadecimal() );
- $url = $title->getFullURL( array( 'fromnotif' => 1 ) );
+ $url = $this->getTopicTitle()->getFullURL( array( 'fromnotif'
=> 1 ) );
return $url;
+ }
+
+ /**
+ * Get the topic title Title
+ *
+ * @param string $fragment Optional fragment
+ * @return Title Topic title
+ */
+ protected function getTopicTitleObj( $fragment = '' ) {
+ return Title::makeTitleSafe(
+ NS_TOPIC,
+ $workflowId->getAlphadecimal(),
+ $fragment
+ );
}
/**
@@ -143,4 +154,65 @@
return $this->event->getTitle()->getNamespace() ===
NS_USER_TALK &&
$this->event->getTitle()->getText() === $username;
}
+
+ /**
+ * Get a flow-specific watch/unwatch dynamic action link
+ *
+ * @param bool $isTopic Unwatching a topic. If set to false, the
+ * action is unwatching a board
+ * @return array|null Array representing the dynamic action secondary
link.
+ * Returns null if either
+ * * The notification came from the user's talk page, as that
+ * page cannot be unwatched.
+ * * The page is not currently watched.
+ */
+ protected function getFlowUnwatchDynamicActionLink( $isTopic = false ) {
+ $title = $isTopic ? $this->getTopicTitleObj() :
$this->event->getTitle();
+ $query = array( 'action' => 'unwatch' );
+ $link = $this->getWatchActionLink( $title );
+ $type = $isTopic ? 'topic' : 'board';
+
+ if ( $this->isUserTalkPage() || !$this->getUser()->isWatched(
$title ) ) {
+ return null;
+ }
+
+ $messageKeys = array(
+ 'item' => array(
+ //
notification-dynamic-actions-flow-board-unwatch
+ //
notification-dynamic-actions-flow-topic-unwatch
+ 'title' => $this
+ ->msg(
'notification-dynamic-actions-flow-' . $type . '-unwatch' )
+ ->params(
+ $title->getPrefixedText(),
+ $title->getFullURL( $query )
+ )
+ ->parse(),
+ ),
+ 'confirmation' => array(
+ //
notification-dynamic-actions-flow-board-unwatch-confirmation
+ //
notification-dynamic-actions-flow-topic-unwatch-confirmation
+ 'title' => $this
+ ->msg(
'notification-dynamic-actions-flow-' . $type . '-unwatch-confirmation' )
+ ->params(
+ $title->getPrefixedText(),
+ $title->getFullURL( $query )
+ )
+ ->parse(),
+ //
notification-dynamic-actions-flow-board-unwatch-confirmation-description
+ //
notification-dynamic-actions-flow-topic-unwatch-confirmation-description
+ 'description' => $this
+ ->msg(
'notification-dynamic-actions-flow-' . $type .
'-unwatch-confirmation-description' )
+ ->params(
+ $title->getPrefixedText(),
+ $title->getFullURL( $query )
+ )
+ ->parse(),
+ ),
+ );
+
+ // Override messages with flow-specific messages
+ $link[ 'data' ][ 'messages' ] = array_replace( $link[ 'data' ][
'messages' ], $messageKeys );
+
+ return $link;
+ }
}
diff --git a/includes/Notifications/HeaderEditedPresentationModel.php
b/includes/Notifications/HeaderEditedPresentationModel.php
index 7ca3c5f..2fd6755 100644
--- a/includes/Notifications/HeaderEditedPresentationModel.php
+++ b/includes/Notifications/HeaderEditedPresentationModel.php
@@ -23,6 +23,7 @@
return array(
$this->getAgentLink(),
$this->getDiffLink(),
+ $this->getFlowUnwatchDynamicActionLink()
);
}
diff --git a/includes/Notifications/NewTopicPresentationModel.php
b/includes/Notifications/NewTopicPresentationModel.php
index ee31046..d6f27b4 100644
--- a/includes/Notifications/NewTopicPresentationModel.php
+++ b/includes/Notifications/NewTopicPresentationModel.php
@@ -28,6 +28,7 @@
return array(
$this->getAgentLink(),
$this->getBoardByNewestLink(),
+ $this->getFlowUnwatchDynamicActionLink()
);
}
}
diff --git a/includes/Notifications/PostEditedPresentationModel.php
b/includes/Notifications/PostEditedPresentationModel.php
index 581d51d..9a5722b 100644
--- a/includes/Notifications/PostEditedPresentationModel.php
+++ b/includes/Notifications/PostEditedPresentationModel.php
@@ -25,21 +25,25 @@
public function getSecondaryLinks() {
if ( $this->isBundled() ) {
- return array( $this->getBoardLink() );
+ $links = array( $this->getBoardLink() );
} else {
if ( $this->isUserTalkPage() ) {
- return array(
+ $links = array(
$this->getAgentLink(),
$this->getDiffLink(),
);
} else {
- return array(
+ $links = array(
$this->getAgentLink(),
$this->getBoardLink(),
$this->getDiffLink( false ),
);
}
}
+
+ $links[] = $this->getFlowUnwatchDynamicActionLink( true );
+
+ return $links;
}
protected function getHeaderMessageKey() {
diff --git a/includes/Notifications/PostReplyPresentationModel.php
b/includes/Notifications/PostReplyPresentationModel.php
index bfd28b5..378a1f4 100644
--- a/includes/Notifications/PostReplyPresentationModel.php
+++ b/includes/Notifications/PostReplyPresentationModel.php
@@ -42,10 +42,14 @@
public function getSecondaryLinks() {
if ( $this->isBundled() ) {
- return array( $this->getBoardLink() );
+ $links = array( $this->getBoardLink() );
} else {
- return array( $this->getAgentLink(),
$this->getBoardLink() );
+ $links = array( $this->getAgentLink(),
$this->getBoardLink() );
}
+
+ $links[] = $this->getFlowUnwatchDynamicActionLink( true );
+
+ return $links;
}
protected function getHeaderMessageKey() {
diff --git a/includes/Notifications/SummaryEditedPresentationModel.php
b/includes/Notifications/SummaryEditedPresentationModel.php
index fa05459..ef93677 100644
--- a/includes/Notifications/SummaryEditedPresentationModel.php
+++ b/includes/Notifications/SummaryEditedPresentationModel.php
@@ -21,14 +21,17 @@
public function getSecondaryLinks() {
if ( $this->isBundled() ) {
- return array( $this->getBoardLink() );
+ $links = array( $this->getBoardLink() );
} else {
$links = array( $this->getAgentLink(),
$this->getBoardLink() );
if ( !$this->isFirstRevision() ) {
$links[] = $this->getDiffLink( false );
}
- return $links;
}
+
+ $links[] = $this->getFlowUnwatchDynamicActionLink( true );
+
+ return $links;
}
protected function getHeaderMessageKey() {
diff --git a/includes/Notifications/TopicRenamedPresentationModel.php
b/includes/Notifications/TopicRenamedPresentationModel.php
index c1b400e..cc309ca 100644
--- a/includes/Notifications/TopicRenamedPresentationModel.php
+++ b/includes/Notifications/TopicRenamedPresentationModel.php
@@ -21,17 +21,22 @@
public function getSecondaryLinks() {
if ( $this->isUserTalkPage() ) {
- return array(
+ $links = array(
$this->getAgentLink(),
$this->getDiffLink(),
);
} else {
- return array(
+ $links = array(
$this->getAgentLink(),
$this->getBoardByNewestLink(),
$this->getDiffLink( false ),
);
}
+
+ $links[] = $this->getFlowUnwatchDynamicActionLink( true );
+
+ return $links;
+
}
protected function getHeaderMessageKey() {
diff --git a/includes/Notifications/TopicResolvedPresentationModel.php
b/includes/Notifications/TopicResolvedPresentationModel.php
index ca2f982..275b9fb 100644
--- a/includes/Notifications/TopicResolvedPresentationModel.php
+++ b/includes/Notifications/TopicResolvedPresentationModel.php
@@ -24,6 +24,7 @@
return array(
$this->getAgentLink(),
$this->getBoardLink(),
+ $this->getFlowUnwatchDynamicActionLink( true ),
);
}
--
To view, visit https://gerrit.wikimedia.org/r/303315
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I75d0098e7718ec44bfb3a4d43e4e7e5a03c47331
Gerrit-PatchSet: 15
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Mattflaschen <[email protected]>
Gerrit-Reviewer: Mooeypoo <[email protected]>
Gerrit-Reviewer: Sbisson <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits