@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 editing a subtyped object, use edit forms of the same subtype

Summary:
Ref T12314. When we pick an "Edit" form for a subtyped object, only consider forms with the same subtype.

For example, editing an "Animal" uses the forms with subtype "animal" which are marked as edit forms.

This also makes "Create Subtask" carry the parent task's type.

Test Plan:
- Edited an Animal, got an animal edit form.
- Edited a normal task, got a normal task form.
- Edited a paste, got the normal workflow.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12314

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

+44 -11
+1 -1
src/applications/maniphest/controller/ManiphestTaskDetailController.php
··· 267 267 ->setDisabled(!$can_edit) 268 268 ->setWorkflow(!$can_edit)); 269 269 270 - $edit_config = $edit_engine->loadDefaultEditConfiguration(); 270 + $edit_config = $edit_engine->loadDefaultEditConfiguration($task); 271 271 $can_create = (bool)$edit_config; 272 272 273 273 $can_reassign = $edit_engine->hasEditAccessToTransaction(
+1 -1
src/applications/project/controller/PhabricatorProjectBoardViewController.php
··· 910 910 // for each column or board? 911 911 $edit_config = id(new ManiphestEditEngine()) 912 912 ->setViewer($viewer) 913 - ->loadDefaultEditConfiguration(); 913 + ->loadDefaultEditConfiguration(new ManiphestTask()); 914 914 if ($edit_config) { 915 915 $form_key = $edit_config->getIdentifier(); 916 916 $create_uri = "/maniphest/task/edit/form/{$form_key}/";
+18 -9
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 408 408 'getCreateSortKey'); 409 409 } 410 410 411 - public function loadDefaultEditConfiguration() { 411 + public function loadDefaultEditConfiguration($object) { 412 412 $query = $this->newConfigurationQuery() 413 413 ->withIsEdit(true) 414 414 ->withIsDisabled(false); 415 415 416 + // If this object supports subtyping, we edit it with a form of the same 417 + // subtype: so "bug" tasks get edited with "bug" forms. 418 + if ($object instanceof PhabricatorEditEngineSubtypeInterface) { 419 + $query->withSubtypes( 420 + array( 421 + $object->getEditEngineSubtype(), 422 + )); 423 + } 424 + 416 425 return $this->loadEditEngineConfigurationWithQuery( 417 426 $query, 418 427 'getEditSortKey'); ··· 891 900 } 892 901 } else { 893 902 if ($id) { 894 - $config = $this->loadDefaultEditConfiguration(); 903 + $config = $this->loadDefaultEditConfiguration($object); 895 904 if (!$config) { 896 905 return $this->buildNoEditResponse($object); 897 906 } ··· 1370 1379 final public function hasEditAccessToTransaction($xaction_type) { 1371 1380 $viewer = $this->getViewer(); 1372 1381 1373 - $config = $this->loadDefaultEditConfiguration(); 1374 - if (!$config) { 1375 - return false; 1376 - } 1377 - 1378 1382 $object = $this->getTargetObject(); 1379 1383 if (!$object) { 1380 1384 $object = $this->newEditableObject(); 1385 + } 1386 + 1387 + $config = $this->loadDefaultEditConfiguration($object); 1388 + if (!$config) { 1389 + return false; 1381 1390 } 1382 1391 1383 1392 $fields = $this->buildEditFields($object); ··· 1535 1544 } 1536 1545 1537 1546 final public function buildEditEngineCommentView($object) { 1538 - $config = $this->loadDefaultEditConfiguration(); 1547 + $config = $this->loadDefaultEditConfiguration($object); 1539 1548 1540 1549 if (!$config) { 1541 1550 // TODO: This just nukes the entire comment form if you don't have access ··· 1755 1764 return new Aphront400Response(); 1756 1765 } 1757 1766 1758 - $config = $this->loadDefaultEditConfiguration(); 1767 + $config = $this->loadDefaultEditConfiguration($object); 1759 1768 if (!$config) { 1760 1769 return new Aphront404Response(); 1761 1770 }
+24
src/applications/transactions/query/PhabricatorEditEngineConfigurationQuery.php
··· 12 12 private $isEdit; 13 13 private $disabled; 14 14 private $ignoreDatabaseConfigurations; 15 + private $subtypes; 15 16 16 17 public function withIDs(array $ids) { 17 18 $this->ids = $ids; ··· 55 56 56 57 public function withIgnoreDatabaseConfigurations($ignore) { 57 58 $this->ignoreDatabaseConfigurations = $ignore; 59 + return $this; 60 + } 61 + 62 + public function withSubtypes(array $subtypes) { 63 + $this->subtypes = $subtypes; 58 64 return $this; 59 65 } 60 66 ··· 183 189 } 184 190 } 185 191 192 + if ($this->subtypes !== null) { 193 + $subtypes = array_fuse($this->subtypes); 194 + foreach ($page as $key => $config) { 195 + if (isset($subtypes[$config->getSubtype()])) { 196 + continue; 197 + } 198 + 199 + unset($page[$key]); 200 + } 201 + } 202 + 186 203 return $page; 187 204 } 188 205 ··· 248 265 '(id IN (%Ls) OR builtinKey IN (%Ls))', 249 266 $this->identifiers, 250 267 $this->identifiers); 268 + } 269 + 270 + if ($this->subtypes !== null) { 271 + $where[] = qsprintf( 272 + $conn, 273 + 'subtype IN (%Ls)', 274 + $this->subtypes); 251 275 } 252 276 253 277 return $where;