@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 Nuance items to put commands actions into the work UI

Summary:
Ref T12738. This doesn't actually do anything yet, but allows items to define commands that show up in the UI.

Adds a "Throw in Trash" item for complaints.

This construction will allow future changes to add an `EngineExtension` which can provide generic/default commands across item types.

Test Plan: {F4975086}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12738

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

+113 -3
+2
src/__phutil_library_map__.php
··· 1622 1622 'NuanceItemActionController' => 'applications/nuance/controller/NuanceItemActionController.php', 1623 1623 'NuanceItemCommand' => 'applications/nuance/storage/NuanceItemCommand.php', 1624 1624 'NuanceItemCommandQuery' => 'applications/nuance/query/NuanceItemCommandQuery.php', 1625 + 'NuanceItemCommandSpec' => 'applications/nuance/command/NuanceItemCommandSpec.php', 1625 1626 'NuanceItemCommandTransaction' => 'applications/nuance/xaction/NuanceItemCommandTransaction.php', 1626 1627 'NuanceItemController' => 'applications/nuance/controller/NuanceItemController.php', 1627 1628 'NuanceItemEditor' => 'applications/nuance/editor/NuanceItemEditor.php', ··· 6744 6745 'PhabricatorPolicyInterface', 6745 6746 ), 6746 6747 'NuanceItemCommandQuery' => 'NuanceQuery', 6748 + 'NuanceItemCommandSpec' => 'Phobject', 6747 6749 'NuanceItemCommandTransaction' => 'NuanceItemTransactionType', 6748 6750 'NuanceItemController' => 'NuanceController', 6749 6751 'NuanceItemEditor' => 'PhabricatorApplicationTransactionEditor',
+37
src/applications/nuance/command/NuanceItemCommandSpec.php
··· 1 + <?php 2 + 3 + final class NuanceItemCommandSpec 4 + extends Phobject { 5 + 6 + private $commandKey; 7 + private $name; 8 + private $icon; 9 + 10 + public function setCommandKey($command_key) { 11 + $this->commandKey = $command_key; 12 + return $this; 13 + } 14 + 15 + public function getCommandKey() { 16 + return $this->commandKey; 17 + } 18 + 19 + public function setName($name) { 20 + $this->name = $name; 21 + return $this; 22 + } 23 + 24 + public function getName() { 25 + return $this->name; 26 + } 27 + 28 + public function setIcon($icon) { 29 + $this->icon = $icon; 30 + return $this; 31 + } 32 + 33 + public function getIcon() { 34 + return $this->icon; 35 + } 36 + 37 + }
+28 -3
src/applications/nuance/controller/NuanceQueueWorkController.php
··· 54 54 55 55 $item = head($items); 56 56 57 - $curtain = $this->buildCurtain($queue); 57 + $curtain = $this->buildCurtain($queue, $item); 58 58 59 59 $timeline = $this->buildTransactionTimeline( 60 60 $item, 61 61 new NuanceItemTransactionQuery()); 62 62 $timeline->setShouldTerminate(true); 63 63 64 + $impl = $item->getImplementation() 65 + ->setViewer($viewer); 66 + 67 + $work_content = $impl->buildItemWorkView($item); 68 + 64 69 $view = id(new PHUITwoColumnView()) 65 70 ->setCurtain($curtain) 66 - ->setMainColumn($timeline); 71 + ->setMainColumn( 72 + array( 73 + $work_content, 74 + $timeline, 75 + )); 67 76 68 77 return $this->newPage() 69 78 ->setTitle($title) ··· 71 80 ->appendChild($view); 72 81 } 73 82 74 - private function buildCurtain(NuanceQueue $queue) { 83 + private function buildCurtain(NuanceQueue $queue, NuanceItem $item) { 75 84 $viewer = $this->getViewer(); 76 85 $id = $queue->getID(); 77 86 78 87 $curtain = $this->newCurtainView(); 88 + 89 + $impl = $item->getImplementation(); 90 + $commands = $impl->buildWorkCommands($item); 91 + 92 + foreach ($commands as $command) { 93 + $command_key = $command->getCommandKey(); 94 + 95 + $item_id = $item->getID(); 96 + 97 + $curtain->addAction( 98 + id(new PhabricatorActionView()) 99 + ->setName($command->getName()) 100 + ->setIcon($command->getIcon()) 101 + ->setHref("queue/command/{$id}/{$command_key}/{$item_id}/")) 102 + ->setWorkflow(true); 103 + } 79 104 80 105 $curtain->addAction( 81 106 id(new PhabricatorActionView())
+34
src/applications/nuance/item/NuanceFormItemType.php
··· 13 13 return pht('Complaint'); 14 14 } 15 15 16 + protected function newWorkCommands(NuanceItem $item) { 17 + return array( 18 + $this->newCommand('trash') 19 + ->setIcon('fa-trash') 20 + ->setName(pht('Throw In Trash')), 21 + ); 22 + } 23 + 24 + protected function newItemView(NuanceItem $item) { 25 + $viewer = $this->getViewer(); 26 + 27 + $content = $item->getItemProperty('complaint'); 28 + $content_view = id(new PHUIRemarkupView($viewer, $content)) 29 + ->setContextObject($item); 30 + 31 + $content_section = id(new PHUIPropertyListView()) 32 + ->addTextContent( 33 + phutil_tag( 34 + 'div', 35 + array( 36 + 'class' => 'phabricator-remarkup', 37 + ), 38 + $content_view)); 39 + 40 + $content_box = id(new PHUIObjectBoxView()) 41 + ->setHeaderText(pht('Complaint')) 42 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 43 + ->appendChild($content_section); 44 + 45 + return array( 46 + $content_box, 47 + ); 48 + } 49 + 16 50 }
+12
src/applications/nuance/item/NuanceItemType.php
··· 32 32 return $this->newItemView($item); 33 33 } 34 34 35 + final public function buildItemWorkView(NuanceItem $item) { 36 + return $this->newItemView($item); 37 + } 38 + 35 39 protected function newItemView(NuanceItem $item) { 36 40 return null; 37 41 } ··· 104 108 return null; 105 109 } 106 110 111 + final public function buildWorkCommands(NuanceItem $item) { 112 + return $this->newWorkCommands($item); 113 + } 114 + 107 115 final public function applyCommand( 108 116 NuanceItem $item, 109 117 NuanceItemCommand $command) { ··· 159 167 return id(new PhabricatorNuanceApplication())->getPHID(); 160 168 } 161 169 170 + protected function newCommand($command_key) { 171 + return id(new NuanceItemCommandSpec()) 172 + ->setCommandKey($command_key); 173 + } 162 174 }