Page MenuHomePhabricator

Support comments in Herald Actions
Closed, DuplicatePublic

Assigned To
None
Authored By
devd
Nov 25 2015, 8:10 PM
Tags
  • Restricted Project
Referenced Files
F1009049: every.png
Dec 1 2015, 2:29 AM
F1003233: Screen Shot 2015-11-25 at 12.55.44 PM.png
Nov 25 2015, 9:02 PM
F1003231: Screen Shot 2015-11-25 at 12.57.27 PM.png
Nov 25 2015, 9:02 PM
F1003232: Screen Shot 2015-11-25 at 12.55.48 PM.png
Nov 25 2015, 9:02 PM
F1003230: Screen Shot 2015-11-25 at 12.58.42 PM.png
Nov 25 2015, 9:02 PM
F1003238: Screen Shot 2015-11-25 at 1.01.53 PM.png
Nov 25 2015, 9:02 PM

Description

It would be nice if the list of actions herald supported could include comments.

Adding blocking reviewers, sending emails, and all these actions are often a blackbox to new team members or engineers who haven't seen the herald reviewer. A comment explaining what happened, and what are the next steps would make things a bit more pleasant. Adding that as a supported action for differential revisions would be great!

Event Timeline

devd updated the task description. (Show Details)
devd added a project: Restricted Project.
devd added subscribers: jhurwitz, angie, devd.

@chad I figured this would be a simpler and less disruptive task, so filed it separately. The other task still doesn't have any consensus on whether we want to do something and if then what. I was hoping this could get faster consensus.

It's not simpler to build, and then replace, a system. We don't build software in that manner.

You can also speak to the powers that be and formally prioritize T7617 also.

This might be an easier thing to prioritze and pay for (even as an extension). Is there a way to get an estimate?

Monsieur @epriestley can go over that, if you're interested.

I am interested in getting an estimate

I can give you an extension for this in about 15 minutes (at consulting rates).

This is totally unsupported, use at your own risk, etc, etc.

Drop this in src/extensions/:

1<?php
2
3final class AddCommentHeraldAction
4 extends HeraldAction {
5
6 const ACTIONCONST = 'custom.transactions.comment';
7
8 const DO_COMMENT = 'do.comment';
9
10 public function getHeraldActionName() {
11 return pht('Add comment');
12 }
13
14 public function getActionGroupKey() {
15 return HeraldUtilityActionGroup::ACTIONGROUPKEY;
16 }
17
18 public function supportsObject($object) {
19 if (!($object instanceof PhabricatorApplicationTransactionInterface)) {
20 return false;
21 }
22
23 $xaction = $object->getApplicationTransactionTemplate();
24 try {
25 $comment = $xaction->getApplicationTransactionCommentObject();
26 if (!$comment) {
27 return false;
28 }
29 } catch (Exception $ex) {
30 return false;
31 }
32
33 return true;
34 }
35
36 public function supportsRuleType($rule_type) {
37 return true;
38 }
39
40 public function applyEffect($object, HeraldEffect $effect) {
41 $adapter = $this->getAdapter();
42
43 $comment_text = $effect->getTarget();
44
45 $comment = $adapter->newTransaction()
46 ->getApplicationTransactionCommentObject()
47 ->setContent($comment_text);
48
49 $xaction = $adapter->newTransaction()
50 ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT)
51 ->attachComment($comment);
52
53 $adapter->queueTransaction($xaction);
54
55 $this->logEffect(self::DO_COMMENT);
56 }
57
58 public function getHeraldActionStandardType() {
59 return self::STANDARD_TEXT;
60 }
61
62 public function renderActionDescription($value) {
63 return pht('Add comment: %s', $value);
64 }
65
66 protected function getActionEffectMap() {
67 return array(
68 self::DO_COMMENT => array(
69 'icon' => 'fa-comment',
70 'color' => 'blue',
71 'name' => pht('Added comment.'),
72 ),
73 );
74 }
75
76 protected function renderActionEffectDescription($type, $data) {
77 switch ($type) {
78 case self::DO_COMMENT:
79 return pht('Added comment.');
80 }
81 }
82}

This adds a new Herald action for all rules affecting objects which support comments. Here are some examples of what it looks like in the UI in Maniphest and Differential:

Screen Shot 2015-11-25 at 12.55.44 PM.png (1×2 px, 384 KB)

Screen Shot 2015-11-25 at 12.55.48 PM.png (1×2 px, 364 KB)

Screen Shot 2015-11-25 at 12.57.27 PM.png (538×1 px, 100 KB)

Screen Shot 2015-11-25 at 12.58.42 PM.png (616×1 px, 104 KB)

Screen Shot 2015-11-25 at 1.01.53 PM.png (392×904 px, 52 KB)

awesome! thanks! you weren't kidding about 15mins :)

I am also talking internally re consulting rates and paying for this.

Ah, okay, I wasn't sure if "cool!" meant "approved" or "I'll look into it".

Just, uh, don't use the extension if you don't have any luck getting it approved, I guess. ¯\_(ツ)_/¯

aargh.. ok. shouldn't be a big deal though; I am pretty sure we will pay. The hard part is not the budget.

also, sorry. I should have been more clear.

Haha, no problem. Definitely not a big deal either way.

btw, it seems the extension comments every time there is an update to the diff instead of just the first time. That is a bit annoying: was this expected? is there a quick fix to it?

(don't worry .. the budget is approved. its just being processed ;)

That's expected if you've written an "every time" rule.

You should be able to change your rule from this:

Take these actions [every time] this rule matches:

...to this:

Take these actions [only the first time] this rule matches:

...if you only want the actions to be taken the first time.

every.png (389×488 px, 29 KB)

angie moved this task from Restricted Project Column to Restricted Project Column on the Restricted Project board.Dec 5 2015, 5:07 AM