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

at upstream/main 186 lines 4.8 kB view raw
1<?php 2 3final class NuanceQueueWorkController 4 extends NuanceQueueController { 5 6 public function handleRequest(AphrontRequest $request) { 7 $viewer = $this->getViewer(); 8 9 $queue = id(new NuanceQueueQuery()) 10 ->setViewer($viewer) 11 ->withIDs(array($request->getURIData('id'))) 12 ->executeOne(); 13 if (!$queue) { 14 return new Aphront404Response(); 15 } 16 17 $title = $queue->getName(); 18 19 $crumbs = $this->buildApplicationCrumbs(); 20 $crumbs->addTextCrumb(pht('Queues'), $this->getApplicationURI('queue/')); 21 $crumbs->addTextCrumb($queue->getName(), $queue->getURI()); 22 $crumbs->addTextCrumb(pht('Work')); 23 $crumbs->setBorder(true); 24 25 // For now, just pick the first open item. 26 27 $items = id(new NuanceItemQuery()) 28 ->setViewer($viewer) 29 ->withQueuePHIDs( 30 array( 31 $queue->getPHID(), 32 )) 33 ->withStatuses( 34 array( 35 NuanceItem::STATUS_OPEN, 36 )) 37 ->requireCapabilities( 38 array( 39 PhabricatorPolicyCapability::CAN_VIEW, 40 PhabricatorPolicyCapability::CAN_EDIT, 41 )) 42 ->setLimit(5) 43 ->execute(); 44 45 if (!$items) { 46 return $this->newDialog() 47 ->setTitle(pht('Queue Empty')) 48 ->appendParagraph( 49 pht( 50 'This queue has no open items which you have permission to '. 51 'work on.')) 52 ->addCancelButton($queue->getURI()); 53 } 54 55 $item = head($items); 56 57 $curtain = $this->buildCurtain($queue, $item); 58 59 $timeline = $this->buildTransactionTimeline( 60 $item, 61 new NuanceItemTransactionQuery()); 62 $timeline->setShouldTerminate(true); 63 64 $impl = $item->getImplementation() 65 ->setViewer($viewer); 66 67 $commands = $this->buildCommands($item); 68 $work_content = $impl->buildItemWorkView($item); 69 70 $view = id(new PHUITwoColumnView()) 71 ->setCurtain($curtain) 72 ->setMainColumn( 73 array( 74 $commands, 75 $work_content, 76 $timeline, 77 )); 78 79 return $this->newPage() 80 ->setTitle($title) 81 ->setCrumbs($crumbs) 82 ->appendChild($view); 83 } 84 85 private function buildCurtain(NuanceQueue $queue, NuanceItem $item) { 86 $viewer = $this->getViewer(); 87 $id = $queue->getID(); 88 89 $curtain = $this->newCurtainView(); 90 91 $impl = $item->getImplementation(); 92 $commands = $impl->buildWorkCommands($item); 93 94 foreach ($commands as $command) { 95 $command_key = $command->getCommandKey(); 96 97 $item_id = $item->getID(); 98 99 $action_uri = "queue/action/{$id}/{$command_key}/{$item_id}/"; 100 $action_uri = $this->getApplicationURI($action_uri); 101 102 $curtain->addAction( 103 id(new PhabricatorActionView()) 104 ->setName($command->getName()) 105 ->setIcon($command->getIcon()) 106 ->setHref($action_uri) 107 ->setWorkflow(true)); 108 } 109 110 $curtain->addAction( 111 id(new PhabricatorActionView()) 112 ->setType(PhabricatorActionView::TYPE_DIVIDER)); 113 114 $curtain->addAction( 115 id(new PhabricatorActionView()) 116 ->setType(PhabricatorActionView::TYPE_LABEL) 117 ->setName(pht('Queue Actions'))); 118 119 $curtain->addAction( 120 id(new PhabricatorActionView()) 121 ->setName(pht('Manage Queue')) 122 ->setIcon('fa-cog') 123 ->setHref($this->getApplicationURI("queue/view/{$id}/"))); 124 125 return $curtain; 126 } 127 128 private function buildCommands(NuanceItem $item) { 129 $viewer = $this->getViewer(); 130 131 $commands = id(new NuanceItemCommandQuery()) 132 ->setViewer($viewer) 133 ->withItemPHIDs(array($item->getPHID())) 134 ->withStatuses( 135 array( 136 NuanceItemCommand::STATUS_ISSUED, 137 NuanceItemCommand::STATUS_EXECUTING, 138 NuanceItemCommand::STATUS_FAILED, 139 )) 140 ->execute(); 141 $commands = msort($commands, 'getID'); 142 143 if (!$commands) { 144 return null; 145 } 146 147 $rows = array(); 148 foreach ($commands as $command) { 149 $icon = $command->getStatusIcon(); 150 $color = $command->getStatusColor(); 151 152 $rows[] = array( 153 $command->getID(), 154 id(new PHUIIconView()) 155 ->setIcon($icon, $color), 156 $viewer->renderHandle($command->getAuthorPHID()), 157 $command->getCommand(), 158 phabricator_datetime($command->getDateCreated(), $viewer), 159 ); 160 } 161 162 $table = id(new AphrontTableView($rows)) 163 ->setHeaders( 164 array( 165 pht('ID'), 166 null, 167 pht('Actor'), 168 pht('Command'), 169 pht('Date'), 170 )) 171 ->setColumnClasses( 172 array( 173 null, 174 'icon', 175 null, 176 'pri', 177 'wide right', 178 )); 179 180 return id(new PHUIObjectBoxView()) 181 ->setHeaderText(pht('Pending Commands')) 182 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 183 ->setTable($table); 184 } 185 186}