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

Allow Maniphest statuses and priorities to be disabled

Summary: Fixes T9496. If you have some statuses or priorities you don't need, allow users to disable them to stop the bleeding.

Test Plan:
- Set task to status X and priority Y.
- Disabled X and Y using config.
- Verified task still had old status/priority.
- Verified new task could not be created/edited into those settings.
- Verified task/priority appeared in typeahead, but were marked as disabled.
- Viewed email command docs.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9496

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

+113 -11
+7
src/applications/maniphest/command/ManiphestPriorityEmailCommand.php
··· 23 23 $table[] = '| '.pht('Priority').' | '.pht('Keywords'); 24 24 $table[] = '|---|---|'; 25 25 foreach ($keywords as $priority => $words) { 26 + if (ManiphestTaskPriority::isDisabledPriority($priority)) { 27 + continue; 28 + } 26 29 $words = implode(', ', $words); 27 30 $table[] = '| '.$names[$priority].' | '.$words; 28 31 } ··· 60 63 } 61 64 62 65 if ($priority === null) { 66 + return array(); 67 + } 68 + 69 + if (ManiphestTaskPriority::isDisabledPriority($priority)) { 63 70 return array(); 64 71 } 65 72
+8
src/applications/maniphest/command/ManiphestStatusEmailCommand.php
··· 23 23 $table[] = '| '.pht('Status').' | '.pht('Keywords'); 24 24 $table[] = '|---|---|'; 25 25 foreach ($keywords as $status => $words) { 26 + if (ManiphestTaskStatus::isDisabledStatus($status)) { 27 + continue; 28 + } 29 + 26 30 $words = implode(', ', $words); 27 31 $table[] = '| '.$names[$status].' | '.$words; 28 32 } ··· 59 63 } 60 64 61 65 if ($status === null) { 66 + return array(); 67 + } 68 + 69 + if (ManiphestTaskStatus::isDisabledStatus($status)) { 62 70 return array(); 63 71 } 64 72
+9 -1
src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
··· 198 198 - `keywords` //Optional list<string>.// Allows you to specify a list 199 199 of keywords which can be used with `!status` commands in email to select 200 200 this status. 201 + - `disabled` //Optional bool.// Marks this status as no longer in use so 202 + tasks can not be created or edited to have this status. Existing tasks with 203 + this status will not be affected, but you can batch edit them or let them 204 + die out on their own. 201 205 202 206 Statuses will appear in the UI in the order specified. Note the status marked 203 207 `special` as `duplicate` is not settable directly and will not appear in UI ··· 280 284 ' - `color` A color for this priority, like "red" or "blue".'. 281 285 ' - `keywords` An optional list of keywords which can '. 282 286 ' be used to select this priority when using `!priority` '. 283 - ' commands in email.'. 287 + ' commands in email.'."\n". 288 + ' - `disabled` Optional boolean to prevent users from choosing '. 289 + ' this priority when creating or editing tasks. Existing '. 290 + ' tasks will be unaffected, and can be batch edited to a '. 291 + ' different priority or left to eventually die out.'. 284 292 "\n\n". 285 293 'You can choose which priority is the default for newly created '. 286 294 'tasks with `%s`.',
+5
src/applications/maniphest/constants/ManiphestTaskPriority.php
··· 105 105 return 'fa-arrow-right'; 106 106 } 107 107 108 + public static function isDisabledPriority($priority) { 109 + $config = idx(self::getConfig(), $priority, array()); 110 + return idx($config, 'disabled', false); 111 + } 112 + 108 113 private static function getConfig() { 109 114 $config = PhabricatorEnv::getEnvConfig('maniphest.priorities'); 110 115 krsort($config);
+5
src/applications/maniphest/constants/ManiphestTaskStatus.php
··· 167 167 return self::getStatusAttribute($status, 'transaction.color'); 168 168 } 169 169 170 + public static function isDisabledStatus($status) { 171 + return self::getStatusAttribute($status, 'disabled'); 172 + } 173 + 170 174 public static function getStatusIcon($status) { 171 175 $icon = self::getStatusAttribute($status, 'transaction.icon'); 172 176 if ($icon) { ··· 274 278 'prefixes' => 'optional list<string>', 275 279 'suffixes' => 'optional list<string>', 276 280 'keywords' => 'optional list<string>', 281 + 'disabled' => 'optional bool', 277 282 )); 278 283 } 279 284
+65 -8
src/applications/maniphest/editor/ManiphestEditEngine.php
··· 51 51 } 52 52 53 53 protected function buildCustomEditFields($object) { 54 - // See T4819. 55 - $status_map = ManiphestTaskStatus::getTaskStatusMap(); 56 - $dup_status = ManiphestTaskStatus::getDuplicateStatus(); 57 - if ($object->getStatus() != $dup_status) { 58 - unset($status_map[$dup_status]); 59 - } 60 - 61 - $priority_map = ManiphestTaskPriority::getTaskPriorityMap(); 54 + $status_map = $this->getTaskStatusMap($object); 55 + $priority_map = $this->getTaskPriorityMap($object); 62 56 63 57 if ($object->isClosed()) { 64 58 $priority_label = null; ··· 122 116 protected function getEditorURI() { 123 117 // TODO: Remove when cutting over. 124 118 return $this->getApplication()->getApplicationURI('editpro/'); 119 + } 120 + 121 + private function getTaskStatusMap(ManiphestTask $task) { 122 + $status_map = ManiphestTaskStatus::getTaskStatusMap(); 123 + 124 + $current_status = $task->getStatus(); 125 + 126 + // If the current status is something we don't recognize (maybe an older 127 + // status which was deleted), put a dummy entry in the status map so that 128 + // saving the form doesn't destroy any data by accident. 129 + if (idx($status_map, $current_status) === null) { 130 + $status_map[$current_status] = pht('<Unknown: %s>', $current_status); 131 + } 132 + 133 + $dup_status = ManiphestTaskStatus::getDuplicateStatus(); 134 + foreach ($status_map as $status => $status_name) { 135 + // Always keep the task's current status. 136 + if ($status == $current_status) { 137 + continue; 138 + } 139 + 140 + // Don't allow tasks to be changed directly into "Closed, Duplicate" 141 + // status. Instead, you have to merge them. See T4819. 142 + if ($status == $dup_status) { 143 + unset($status_map[$status]); 144 + continue; 145 + } 146 + 147 + // Don't let new or existing tasks be moved into a disabled status. 148 + if (ManiphestTaskStatus::isDisabledStatus($status)) { 149 + unset($status_map[$status]); 150 + continue; 151 + } 152 + } 153 + 154 + return $status_map; 155 + } 156 + 157 + private function getTaskPriorityMap(ManiphestTask $task) { 158 + $priority_map = ManiphestTaskPriority::getTaskPriorityMap(); 159 + $current_priority = $task->getPriority(); 160 + 161 + // If the current value isn't a legitimate one, put it in the dropdown 162 + // anyway so saving the form doesn't cause a side effects. 163 + if (idx($priority_map, $current_priority) === null) { 164 + $priority_map[$current_priority] = pht( 165 + '<Unknown: %s>', 166 + $current_priority); 167 + } 168 + 169 + foreach ($priority_map as $priority => $priority_name) { 170 + // Always keep the current priority. 171 + if ($priority == $current_priority) { 172 + continue; 173 + } 174 + 175 + if (ManiphestTaskPriority::isDisabledPriority($priority)) { 176 + unset($priority_map[$priority]); 177 + continue; 178 + } 179 + } 180 + 181 + return $priority_map; 125 182 } 126 183 127 184 }
+7 -1
src/applications/maniphest/typeahead/ManiphestTaskPriorityDatasource.php
··· 29 29 30 30 $priority_map = ManiphestTaskPriority::getTaskPriorityMap(); 31 31 foreach ($priority_map as $value => $name) { 32 - $results[$value] = id(new PhabricatorTypeaheadResult()) 32 + $result = id(new PhabricatorTypeaheadResult()) 33 33 ->setIcon(ManiphestTaskPriority::getTaskPriorityIcon($value)) 34 34 ->setPHID($value) 35 35 ->setName($name); 36 + 37 + if (ManiphestTaskPriority::isDisabledPriority($value)) { 38 + $result->setClosed(pht('Disabled')); 39 + } 40 + 41 + $results[$value] = $result; 36 42 } 37 43 38 44 return $results;
+7 -1
src/applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php
··· 30 30 31 31 $status_map = ManiphestTaskStatus::getTaskStatusMap(); 32 32 foreach ($status_map as $value => $name) { 33 - $results[$value] = id(new PhabricatorTypeaheadResult()) 33 + $result = id(new PhabricatorTypeaheadResult()) 34 34 ->setIcon(ManiphestTaskStatus::getStatusIcon($value)) 35 35 ->setPHID($value) 36 36 ->setName($name); 37 + 38 + if (ManiphestTaskStatus::isDisabledStatus($value)) { 39 + $result->setClosed(pht('Disabled')); 40 + } 41 + 42 + $results[$value] = $result; 37 43 } 38 44 39 45 return $results;