@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

When a task changes status, update blocked tasks

Summary:
Ref T5008. Three notes:

- I'm not hiding these even if the status change is open -> open or closed -> closed. I think these are OK, but might be a little spammy.
- These show in feed, but shouldn't, since they're very redundant with stories which will almost always appear adjacently. Probably a bit spammy, see TODO. We can't hide them from feed without also squelching the notifications right now, which I //don't// want to do.
- You get a notification even if you're on the original task which changed status. This is definitely spammy, see other TODO.

Test Plan: {F156217}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T5008

Differential Revision: https://secure.phabricator.com/D9166

+128 -1
+59
src/applications/maniphest/editor/ManiphestTransactionEditor.php
··· 19 19 $types[] = ManiphestTransaction::TYPE_EDGE; 20 20 $types[] = ManiphestTransaction::TYPE_SUBPRIORITY; 21 21 $types[] = ManiphestTransaction::TYPE_PROJECT_COLUMN; 22 + $types[] = ManiphestTransaction::TYPE_UNBLOCK; 22 23 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 23 24 $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; 24 25 ··· 84 85 case ManiphestTransaction::TYPE_EDGE: 85 86 case ManiphestTransaction::TYPE_SUBPRIORITY: 86 87 case ManiphestTransaction::TYPE_PROJECT_COLUMN: 88 + case ManiphestTransaction::TYPE_UNBLOCK: 87 89 return $xaction->getNewValue(); 88 90 } 89 91 } ··· 243 245 break; 244 246 } 245 247 } 248 + 249 + protected function applyFinalEffects( 250 + PhabricatorLiskDAO $object, 251 + array $xactions) { 252 + 253 + // When we change the status of a task, update tasks this tasks blocks 254 + // with a message to the effect of "alincoln resolved blocking task Txxx." 255 + $unblock_xaction = null; 256 + foreach ($xactions as $xaction) { 257 + switch ($xaction->getTransactionType()) { 258 + case ManiphestTransaction::TYPE_STATUS: 259 + $unblock_xaction = $xaction; 260 + break; 261 + } 262 + } 263 + 264 + if ($unblock_xaction !== null) { 265 + $blocked_phids = PhabricatorEdgeQuery::loadDestinationPHIDs( 266 + $object->getPHID(), 267 + PhabricatorEdgeConfig::TYPE_TASK_DEPENDED_ON_BY_TASK); 268 + if ($blocked_phids) { 269 + // In theory we could apply these through policies, but that seems a 270 + // little bit surprising. For now, use the actor's vision. 271 + $blocked_tasks = id(new ManiphestTaskQuery()) 272 + ->setViewer($this->getActor()) 273 + ->withPHIDs($blocked_phids) 274 + ->execute(); 275 + 276 + $old = $unblock_xaction->getOldValue(); 277 + $new = $unblock_xaction->getNewValue(); 278 + 279 + foreach ($blocked_tasks as $blocked_task) { 280 + $xactions = array(); 281 + 282 + $xactions[] = id(new ManiphestTransaction()) 283 + ->setTransactionType(ManiphestTransaction::TYPE_UNBLOCK) 284 + ->setOldValue(array($object->getPHID() => $old)) 285 + ->setNewValue(array($object->getPHID() => $new)); 286 + 287 + // TODO: We should avoid notifiying users about these indirect 288 + // changes if they are getting a notification about the current 289 + // change, so you don't get a pile of extra notifications if you are 290 + // subscribed to this task. 291 + 292 + id(new ManiphestTransactionEditor()) 293 + ->setActor($this->getActor()) 294 + ->setContentSource($this->getContentSource()) 295 + ->setContinueOnNoEffect(true) 296 + ->setContinueOnMissingFields(true) 297 + ->applyTransactions($blocked_task, $xactions); 298 + } 299 + } 300 + } 301 + 302 + return $xactions; 303 + } 304 + 246 305 247 306 protected function shouldSendMail( 248 307 PhabricatorLiskDAO $object,
+69 -1
src/applications/maniphest/storage/ManiphestTransaction.php
··· 14 14 const TYPE_SUBPRIORITY = 'subpriority'; 15 15 const TYPE_PROJECT_COLUMN = 'projectcolumn'; 16 16 17 + const TYPE_UNBLOCK = 'unblock'; 18 + 17 19 // NOTE: this type is deprecated. Keep it around for legacy installs 18 20 // so any transactions render correctly. 19 21 const TYPE_ATTACH = 'attach'; ··· 34 36 switch ($this->getTransactionType()) { 35 37 case self::TYPE_PROJECT_COLUMN: 36 38 case self::TYPE_EDGE: 39 + case self::TYPE_UNBLOCK: 37 40 return false; 38 41 } 39 42 ··· 87 90 array_keys(idx($old, 'FILE', array())), 88 91 )); 89 92 break; 90 - 93 + case self::TYPE_UNBLOCK: 94 + foreach (array_keys($new) as $phid) { 95 + $phids[] = $phid; 96 + } 97 + break; 91 98 } 92 99 93 100 return $phids; ··· 233 240 case self::TYPE_EDGE: 234 241 case self::TYPE_ATTACH: 235 242 return pht('Attached'); 243 + 244 + case self::TYPE_UNBLOCK: 245 + $old_status = head($old); 246 + $new_status = head($new); 247 + 248 + $old_closed = ManiphestTaskStatus::isClosedStatus($old_status); 249 + $new_closed = ManiphestTaskStatus::isClosedStatus($new_status); 250 + 251 + if ($old_closed && !$new_closed) { 252 + return pht('Block'); 253 + } else if (!$old_closed && $new_closed) { 254 + return pht('Unblock'); 255 + } else { 256 + return pht('Blocker'); 257 + } 258 + 236 259 } 237 260 238 261 return parent::getActionName(); ··· 290 313 case self::TYPE_ATTACH: 291 314 return 'fa-thumb-tack'; 292 315 316 + case self::TYPE_UNBLOCK: 317 + return 'fa-shield'; 318 + 293 319 } 294 320 295 321 return parent::getIcon(); ··· 352 378 $new_name); 353 379 } 354 380 381 + case self::TYPE_UNBLOCK: 382 + $blocker_phid = key($new); 383 + $old_status = head($old); 384 + $new_status = head($new); 385 + 386 + $old_closed = ManiphestTaskStatus::isClosedStatus($old_status); 387 + $new_closed = ManiphestTaskStatus::isClosedStatus($new_status); 388 + 389 + $old_name = ManiphestTaskStatus::getTaskStatusName($old_status); 390 + $new_name = ManiphestTaskStatus::getTaskStatusName($new_status); 391 + 392 + if ($old_closed && !$new_closed) { 393 + return pht( 394 + '%s reopened blocking task %s as "%s".', 395 + $this->renderHandleLink($author_phid), 396 + $this->renderHandleLink($blocker_phid), 397 + $new_name); 398 + } else if (!$old_closed && $new_closed) { 399 + return pht( 400 + '%s closed blocking task %s as "%s".', 401 + $this->renderHandleLink($author_phid), 402 + $this->renderHandleLink($blocker_phid), 403 + $new_name); 404 + } else { 405 + return pht( 406 + '%s changed the status of blocking task %s from "%s" to "%s".', 407 + $this->renderHandleLink($author_phid), 408 + $this->renderHandleLink($blocker_phid), 409 + $old_name, 410 + $new_name); 411 + } 412 + 355 413 case self::TYPE_OWNER: 356 414 if ($author_phid == $new) { 357 415 return pht( ··· 550 608 $old_name, 551 609 $new_name); 552 610 } 611 + 612 + case self::TYPE_UNBLOCK: 613 + 614 + // TODO: We should probably not show these in feed; they're highly 615 + // redundant. For now, just use the normal titles. Right now, we can't 616 + // publish something to noficiations without also publishing it to feed. 617 + // Fix that, then stop these from rendering in feed only. 618 + 619 + break; 620 + 553 621 554 622 case self::TYPE_OWNER: 555 623 if ($author_phid == $new) {