3 final class NuanceQueueWorkController
4 extends NuanceQueueController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $viewer = $this->getViewer();
9 $queue = id(new NuanceQueueQuery())
11 ->withIDs(array($request->getURIData('id')))
14 return new Aphront404Response();
17 $title = $queue->getName();
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);
25 // For now, just pick the first open item.
27 $items = id(new NuanceItemQuery())
35 NuanceItem
::STATUS_OPEN
,
37 ->requireCapabilities(
39 PhabricatorPolicyCapability
::CAN_VIEW
,
40 PhabricatorPolicyCapability
::CAN_EDIT
,
46 return $this->newDialog()
47 ->setTitle(pht('Queue Empty'))
50 'This queue has no open items which you have permission to '.
52 ->addCancelButton($queue->getURI());
57 $curtain = $this->buildCurtain($queue, $item);
59 $timeline = $this->buildTransactionTimeline(
61 new NuanceItemTransactionQuery());
62 $timeline->setShouldTerminate(true);
64 $impl = $item->getImplementation()
67 $commands = $this->buildCommands($item);
68 $work_content = $impl->buildItemWorkView($item);
70 $view = id(new PHUITwoColumnView())
71 ->setCurtain($curtain)
79 return $this->newPage()
85 private function buildCurtain(NuanceQueue
$queue, NuanceItem
$item) {
86 $viewer = $this->getViewer();
87 $id = $queue->getID();
89 $curtain = $this->newCurtainView();
91 $impl = $item->getImplementation();
92 $commands = $impl->buildWorkCommands($item);
94 foreach ($commands as $command) {
95 $command_key = $command->getCommandKey();
97 $item_id = $item->getID();
99 $action_uri = "queue/action/{$id}/{$command_key}/{$item_id}/";
100 $action_uri = $this->getApplicationURI($action_uri);
103 id(new PhabricatorActionView())
104 ->setName($command->getName())
105 ->setIcon($command->getIcon())
106 ->setHref($action_uri)
107 ->setWorkflow(true));
111 id(new PhabricatorActionView())
112 ->setType(PhabricatorActionView
::TYPE_DIVIDER
));
115 id(new PhabricatorActionView())
116 ->setType(PhabricatorActionView
::TYPE_LABEL
)
117 ->setName(pht('Queue Actions')));
120 id(new PhabricatorActionView())
121 ->setName(pht('Manage Queue'))
123 ->setHref($this->getApplicationURI("queue/view/{$id}/")));
128 private function buildCommands(NuanceItem
$item) {
129 $viewer = $this->getViewer();
131 $commands = id(new NuanceItemCommandQuery())
133 ->withItemPHIDs(array($item->getPHID()))
136 NuanceItemCommand
::STATUS_ISSUED
,
137 NuanceItemCommand
::STATUS_EXECUTING
,
138 NuanceItemCommand
::STATUS_FAILED
,
141 $commands = msort($commands, 'getID');
148 foreach ($commands as $command) {
149 $icon = $command->getStatusIcon();
150 $color = $command->getStatusColor();
154 id(new PHUIIconView())
155 ->setIcon($icon, $color),
156 $viewer->renderHandle($command->getAuthorPHID()),
157 $command->getCommand(),
158 phabricator_datetime($command->getDateCreated(), $viewer),
162 $table = id(new AphrontTableView($rows))
180 return id(new PHUIObjectBoxView())
181 ->setHeaderText(pht('Pending Commands'))
182 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)