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

Move Nuance Queues to EditEngine

Summary: Ref T10537. Update queue editing to use EditEngine.

Test Plan:
- Created a new queue.
- Edited an existing queue.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10537

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

+96 -143
+2
src/__phutil_library_map__.php
··· 1436 1436 'NuanceQueueController' => 'applications/nuance/controller/NuanceQueueController.php', 1437 1437 'NuanceQueueDatasource' => 'applications/nuance/typeahead/NuanceQueueDatasource.php', 1438 1438 'NuanceQueueEditController' => 'applications/nuance/controller/NuanceQueueEditController.php', 1439 + 'NuanceQueueEditEngine' => 'applications/nuance/editor/NuanceQueueEditEngine.php', 1439 1440 'NuanceQueueEditor' => 'applications/nuance/editor/NuanceQueueEditor.php', 1440 1441 'NuanceQueueListController' => 'applications/nuance/controller/NuanceQueueListController.php', 1441 1442 'NuanceQueuePHIDType' => 'applications/nuance/phid/NuanceQueuePHIDType.php', ··· 5683 5684 'NuanceQueueController' => 'NuanceController', 5684 5685 'NuanceQueueDatasource' => 'PhabricatorTypeaheadDatasource', 5685 5686 'NuanceQueueEditController' => 'NuanceQueueController', 5687 + 'NuanceQueueEditEngine' => 'PhabricatorEditEngine', 5686 5688 'NuanceQueueEditor' => 'PhabricatorApplicationTransactionEditor', 5687 5689 'NuanceQueueListController' => 'NuanceQueueController', 5688 5690 'NuanceQueuePHIDType' => 'PhabricatorPHIDType',
+3 -3
src/applications/nuance/application/PhabricatorNuanceApplication.php
··· 45 45 'new/' => 'NuanceItemEditController', 46 46 ), 47 47 'source/' => array( 48 - '(?:query/(?P<queryKey>[^/]+)/)?' => 'NuanceSourceListController', 48 + $this->getQueryRoutePattern() => 'NuanceSourceListController', 49 49 'view/(?P<id>[1-9]\d*)/' => 'NuanceSourceViewController', 50 50 'edit/(?P<id>[1-9]\d*)/' => 'NuanceSourceEditController', 51 51 'new/(?P<type>[^/]+)/' => 'NuanceSourceEditController', 52 52 'create/' => 'NuanceSourceCreateController', 53 53 ), 54 54 'queue/' => array( 55 - '(?:query/(?P<queryKey>[^/]+)/)?' => 'NuanceQueueListController', 55 + $this->getQueryRoutePattern() => 'NuanceQueueListController', 56 + $this->getEditRoutePattern('edit/') => 'NuanceQueueEditController', 56 57 'view/(?P<id>[1-9]\d*)/' => 'NuanceQueueViewController', 57 - 'edit/(?P<id>[1-9]\d*)/' => 'NuanceQueueEditController', 58 58 'new/' => 'NuanceQueueEditController', 59 59 ), 60 60 'requestor/' => array(
+3 -127
src/applications/nuance/controller/NuanceQueueEditController.php
··· 4 4 extends NuanceQueueController { 5 5 6 6 public function handleRequest(AphrontRequest $request) { 7 - $viewer = $this->getViewer(); 8 - $queues_uri = $this->getApplicationURI('queue/'); 9 - 10 - $queue_id = $request->getURIData('id'); 11 - $is_new = !$queue_id; 12 - if ($is_new) { 13 - $queue = NuanceQueue::initializeNewQueue(); 14 - $cancel_uri = $queues_uri; 15 - } else { 16 - $queue = id(new NuanceQueueQuery()) 17 - ->setViewer($viewer) 18 - ->withIDs(array($queue_id)) 19 - ->executeOne(); 20 - if (!$queue) { 21 - return new Aphront404Response(); 22 - } 23 - $cancel_uri = $queue->getURI(); 24 - } 25 - 26 - $v_name = $queue->getName(); 27 - $e_name = true; 28 - $v_edit = $queue->getEditPolicy(); 29 - $v_view = $queue->getViewPolicy(); 30 - 31 - $validation_exception = null; 32 - if ($request->isFormPost()) { 33 - $e_name = null; 34 - 35 - $v_name = $request->getStr('name'); 36 - $v_edit = $request->getStr('editPolicy'); 37 - $v_view = $request->getStr('viewPolicy'); 38 - 39 - $type_name = NuanceQueueTransaction::TYPE_NAME; 40 - $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; 41 - $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; 42 - 43 - $xactions = array(); 44 - 45 - $xactions[] = id(new NuanceQueueTransaction()) 46 - ->setTransactionType($type_name) 47 - ->setNewValue($v_name); 48 - 49 - $xactions[] = id(new NuanceQueueTransaction()) 50 - ->setTransactionType($type_view) 51 - ->setNewValue($v_view); 52 - 53 - $xactions[] = id(new NuanceQueueTransaction()) 54 - ->setTransactionType($type_edit) 55 - ->setNewValue($v_edit); 56 - 57 - $editor = id(new NuanceQueueEditor()) 58 - ->setActor($viewer) 59 - ->setContentSourceFromRequest($request) 60 - ->setContinueOnNoEffect(true); 61 - 62 - try { 63 - 64 - $editor->applyTransactions($queue, $xactions); 65 - 66 - $uri = $queue->getURI(); 67 - return id(new AphrontRedirectResponse())->setURI($uri); 68 - } catch (PhabricatorApplicationTransactionValidationException $ex) { 69 - $validation_exception = $ex; 70 - 71 - $e_name = $ex->getShortMessage($type_name); 72 - } 73 - } 74 - 75 - $crumbs = $this->buildApplicationCrumbs(); 76 - $crumbs->addTextCrumb(pht('Queues'), $queues_uri); 77 - 78 - if ($is_new) { 79 - $title = pht('Create Queue'); 80 - $crumbs->addTextCrumb(pht('Create')); 81 - } else { 82 - $title = pht('Edit %s', $queue->getName()); 83 - $crumbs->addTextCrumb($queue->getName(), $queue->getURI()); 84 - $crumbs->addTextCrumb(pht('Edit')); 85 - } 86 - 87 - $policies = id(new PhabricatorPolicyQuery()) 88 - ->setViewer($viewer) 89 - ->setObject($queue) 90 - ->execute(); 91 - 92 - $form = id(new AphrontFormView()) 93 - ->setUser($viewer) 94 - ->appendChild( 95 - id(new AphrontFormTextControl()) 96 - ->setLabel(pht('Name')) 97 - ->setName('name') 98 - ->setError($e_name) 99 - ->setValue($v_name)) 100 - ->appendChild( 101 - id(new AphrontFormPolicyControl()) 102 - ->setUser($viewer) 103 - ->setCapability(PhabricatorPolicyCapability::CAN_VIEW) 104 - ->setPolicyObject($queue) 105 - ->setPolicies($policies) 106 - ->setValue($v_view) 107 - ->setName('viewPolicy')) 108 - ->appendChild( 109 - id(new AphrontFormPolicyControl()) 110 - ->setUser($viewer) 111 - ->setCapability(PhabricatorPolicyCapability::CAN_EDIT) 112 - ->setPolicyObject($queue) 113 - ->setPolicies($policies) 114 - ->setValue($v_edit) 115 - ->setName('editPolicy')) 116 - ->appendChild( 117 - id(new AphrontFormSubmitControl()) 118 - ->addCancelButton($cancel_uri) 119 - ->setValue(pht('Save'))); 120 - 121 - $box = id(new PHUIObjectBoxView()) 122 - ->setHeaderText($title) 123 - ->setValidationException($validation_exception) 124 - ->appendChild($form); 125 - 126 - return $this->buildApplicationPage( 127 - array( 128 - $crumbs, 129 - $box, 130 - ), 131 - array( 132 - 'title' => $title, 133 - )); 7 + return id(new NuanceQueueEditEngine()) 8 + ->setController($this) 9 + ->buildResponse(); 134 10 } 135 11 136 12 }
+80
src/applications/nuance/editor/NuanceQueueEditEngine.php
··· 1 + <?php 2 + 3 + final class NuanceQueueEditEngine 4 + extends PhabricatorEditEngine { 5 + 6 + const ENGINECONST = 'nuance.queue'; 7 + 8 + public function isEngineConfigurable() { 9 + return false; 10 + } 11 + 12 + public function getEngineName() { 13 + return pht('Nuance Queues'); 14 + } 15 + 16 + public function getSummaryHeader() { 17 + return pht('Edit Nuance Queue Configurations'); 18 + } 19 + 20 + public function getSummaryText() { 21 + return pht('This engine is used to edit Nuance queues.'); 22 + } 23 + 24 + public function getEngineApplicationClass() { 25 + return 'PhabricatorNuanceApplication'; 26 + } 27 + 28 + protected function newEditableObject() { 29 + return NuanceQueue::initializeNewQueue(); 30 + } 31 + 32 + protected function newObjectQuery() { 33 + return new NuanceQueueQuery(); 34 + } 35 + 36 + protected function getObjectCreateTitleText($object) { 37 + return pht('Create Queue'); 38 + } 39 + 40 + protected function getObjectCreateButtonText($object) { 41 + return pht('Create Queue'); 42 + } 43 + 44 + protected function getObjectEditTitleText($object) { 45 + return pht('Edit Queue: %s', $object->getName()); 46 + } 47 + 48 + protected function getObjectEditShortText($object) { 49 + return pht('Edit Queue'); 50 + } 51 + 52 + protected function getObjectCreateShortText() { 53 + return pht('Create Queue'); 54 + } 55 + 56 + protected function getEditorURI() { 57 + return '/nuance/queue/edit/'; 58 + } 59 + 60 + protected function getObjectCreateCancelURI($object) { 61 + return '/nuance/queue/'; 62 + } 63 + 64 + protected function getObjectViewURI($object) { 65 + return $object->getURI(); 66 + } 67 + 68 + protected function buildCustomEditFields($object) { 69 + return array( 70 + id(new PhabricatorTextEditField()) 71 + ->setKey('name') 72 + ->setLabel(pht('Name')) 73 + ->setDescription(pht('Name of the queue.')) 74 + ->setTransactionType(NuanceQueueTransaction::TYPE_NAME) 75 + ->setIsRequired(true) 76 + ->setValue($object->getName()), 77 + ); 78 + } 79 + 80 + }
+1
src/applications/nuance/editor/NuanceQueueEditor.php
··· 68 68 69 69 return parent::applyCustomExternalTransaction($object, $xaction); 70 70 } 71 + 71 72 protected function validateTransaction( 72 73 PhabricatorLiskDAO $object, 73 74 $type,
+3 -1
src/applications/nuance/storage/NuanceQueue.php
··· 27 27 } 28 28 29 29 public static function initializeNewQueue() { 30 - return new NuanceQueue(); 30 + return id(new self()) 31 + ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 32 + ->setEditPolicy(PhabricatorPolicies::POLICY_USER); 31 33 } 32 34 33 35 public function save() {
+4 -12
src/applications/nuance/storage/NuanceQueueTransaction.php
··· 12 12 return new NuanceQueueTransactionComment(); 13 13 } 14 14 15 - public function shouldHide() { 16 - $old = $this->getOldValue(); 17 - $type = $this->getTransactionType(); 18 - 19 - switch ($type) { 20 - case self::TYPE_NAME: 21 - return ($old === null); 22 - } 23 - 24 - return parent::shouldHide(); 25 - } 26 - 27 15 public function getTitle() { 28 16 $old = $this->getOldValue(); 29 17 $new = $this->getNewValue(); ··· 32 20 $author_phid = $this->getAuthorPHID(); 33 21 34 22 switch ($type) { 23 + case PhabricatorTransactions::TYPE_CREATE: 24 + return pht( 25 + '%s created this queue.', 26 + $this->renderHandleLink($author_phid)); 35 27 case self::TYPE_NAME: 36 28 return pht( 37 29 '%s renamed this queue from "%s" to "%s".',