@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.

Replace the primary "Disabled/Enabled" Herald Rule filter with "Active/Inactive", considering author status

Summary:
Ref T13216. See PHI947. In Herald, Personal rules do not run if their author's account is disabled.

This isn't communicated very clearly in the UI, and the way the SearchEngine/Query are set up isn't great.

Define "active" as "rule will actually run", which specifically means "rule is enabled, and has a valid (non-disabled) author if it needs one".

Change the meaning of the "Active" default filter from "rule is enabled" to "rule is enabled, and has a valid author if it needs one".

Refine the status badge on the view controller to show this "invalid author" state.

Tweak the language for "Disable/Enable" to be more consistent -- we currently call it "disabled" in some cases and "archived" in others.

Test Plan:
- Disabled a user account and saw their personal rules behave properly with the new filters/options/view controller.
- Disabled/enabled a rule, saw consistent text.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13216

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

+65 -19
+4 -4
src/applications/herald/controller/HeraldDisableController.php
··· 44 44 } 45 45 46 46 if ($is_disable) { 47 - $title = pht('Really archive this rule?'); 47 + $title = pht('Really disable this rule?'); 48 48 $body = pht('This rule will no longer activate.'); 49 - $button = pht('Archive Rule'); 49 + $button = pht('Disable Rule'); 50 50 } else { 51 - $title = pht('Really activate this rule?'); 51 + $title = pht('Really enable this rule?'); 52 52 $body = pht('This rule will become active again.'); 53 - $button = pht('Activate Rule'); 53 + $button = pht('Enable Rule'); 54 54 } 55 55 56 56 $dialog = id(new AphrontDialogView())
+7 -11
src/applications/herald/controller/HeraldRuleViewController.php
··· 14 14 ->setViewer($viewer) 15 15 ->withIDs(array($id)) 16 16 ->needConditionsAndActions(true) 17 + ->needValidateAuthors(true) 17 18 ->executeOne(); 18 19 if (!$rule) { 19 20 return new Aphront404Response(); ··· 26 27 ->setHeaderIcon('fa-bullhorn'); 27 28 28 29 if ($rule->getIsDisabled()) { 29 - $header->setStatus( 30 - 'fa-ban', 31 - 'red', 32 - pht('Archived')); 30 + $header->setStatus('fa-ban', 'red', pht('Disabled')); 31 + } else if (!$rule->hasValidAuthor()) { 32 + $header->setStatus('fa-user', 'red', pht('Author Not Active')); 33 33 } else { 34 - $header->setStatus( 35 - 'fa-check', 36 - 'bluegrey', 37 - pht('Active')); 34 + $header->setStatus('fa-check', 'bluegrey', pht('Active')); 38 35 } 39 36 40 37 $curtain = $this->buildCurtain($rule); ··· 90 87 if ($rule->getIsDisabled()) { 91 88 $disable_uri = "disable/{$id}/enable/"; 92 89 $disable_icon = 'fa-check'; 93 - $disable_name = pht('Activate Rule'); 90 + $disable_name = pht('Enable Rule'); 94 91 } else { 95 92 $disable_uri = "disable/{$id}/disable/"; 96 93 $disable_icon = 'fa-ban'; 97 - $disable_name = pht('Archive Rule'); 94 + $disable_name = pht('Disable Rule'); 98 95 } 99 96 100 97 $curtain->addAction( 101 98 id(new PhabricatorActionView()) 102 - ->setName(pht('Disable Rule')) 103 99 ->setHref($this->getApplicationURI($disable_uri)) 104 100 ->setIcon($disable_icon) 105 101 ->setName($disable_name)
+35 -1
src/applications/herald/query/HeraldRuleQuery.php
··· 8 8 private $ruleTypes; 9 9 private $contentTypes; 10 10 private $disabled; 11 + private $active; 11 12 private $datasourceQuery; 12 13 private $triggerObjectPHIDs; 13 14 ··· 42 43 43 44 public function withDisabled($disabled) { 44 45 $this->disabled = $disabled; 46 + return $this; 47 + } 48 + 49 + public function withActive($active) { 50 + $this->active = $active; 45 51 return $this; 46 52 } 47 53 ··· 92 98 } 93 99 } 94 100 95 - if ($this->needValidateAuthors) { 101 + if ($this->needValidateAuthors || ($this->active !== null)) { 96 102 $this->validateRuleAuthors($rules); 97 103 } 98 104 105 + if ($this->active !== null) { 106 + $need_active = (bool)$this->active; 107 + foreach ($rules as $key => $rule) { 108 + if ($rule->getIsDisabled()) { 109 + $is_active = false; 110 + } else if (!$rule->hasValidAuthor()) { 111 + $is_active = false; 112 + } else { 113 + $is_active = true; 114 + } 115 + 116 + if ($is_active != $need_active) { 117 + unset($rules[$key]); 118 + } 119 + } 120 + } 121 + 122 + if (!$rules) { 123 + return array(); 124 + } 125 + 99 126 if ($this->needConditionsAndActions) { 100 127 $conditions = id(new HeraldCondition())->loadAllWhere( 101 128 'ruleID IN (%Ld)', ··· 211 238 $conn, 212 239 'rule.isDisabled = %d', 213 240 (int)$this->disabled); 241 + } 242 + 243 + if ($this->active !== null) { 244 + $where[] = qsprintf( 245 + $conn, 246 + 'rule.isDisabled = %d', 247 + (int)(!$this->active)); 214 248 } 215 249 216 250 if ($this->datasourceQuery !== null) {
+19 -3
src/applications/herald/query/HeraldRuleSearchEngine.php
··· 11 11 } 12 12 13 13 public function newQuery() { 14 - return new HeraldRuleQuery(); 14 + return id(new HeraldRuleQuery()) 15 + ->needValidateAuthors(true); 15 16 } 16 17 17 18 protected function buildCustomSearchFields() { ··· 41 42 pht('Search for rules affecting given types of content.')) 42 43 ->setOptions($content_types), 43 44 id(new PhabricatorSearchThreeStateField()) 44 - ->setLabel(pht('Rule Status')) 45 + ->setLabel(pht('Active Rules')) 46 + ->setKey('active') 47 + ->setOptions( 48 + pht('(Show All)'), 49 + pht('Show Only Active Rules'), 50 + pht('Show Only Inactive Rules')), 51 + id(new PhabricatorSearchThreeStateField()) 52 + ->setLabel(pht('Disabled Rules')) 45 53 ->setKey('disabled') 46 54 ->setOptions( 47 55 pht('(Show All)'), ··· 67 75 68 76 if ($map['disabled'] !== null) { 69 77 $query->withDisabled($map['disabled']); 78 + } 79 + 80 + if ($map['active'] !== null) { 81 + $query->withActive($map['active']); 70 82 } 71 83 72 84 return $query; ··· 99 111 case 'all': 100 112 return $query; 101 113 case 'active': 102 - return $query->setParameter('disabled', false); 114 + return $query 115 + ->setParameter('active', true); 103 116 case 'authored': 104 117 return $query 105 118 ->setParameter('authorPHIDs', array($viewer_phid)) ··· 145 158 if ($rule->getIsDisabled()) { 146 159 $item->setDisabled(true); 147 160 $item->addIcon('fa-lock grey', pht('Disabled')); 161 + } else if (!$rule->hasValidAuthor()) { 162 + $item->setDisabled(true); 163 + $item->addIcon('fa-user grey', pht('Author Not Active')); 148 164 } 149 165 150 166 $content_type_name = idx($content_type_map, $rule->getContentType());