Changeset View
Changeset View
Standalone View
Standalone View
src/applications/nuance/controller/NuanceQueueWorkController.php
| Show First 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| $timeline = $this->buildTransactionTimeline( | $timeline = $this->buildTransactionTimeline( | ||||
| $item, | $item, | ||||
| new NuanceItemTransactionQuery()); | new NuanceItemTransactionQuery()); | ||||
| $timeline->setShouldTerminate(true); | $timeline->setShouldTerminate(true); | ||||
| $impl = $item->getImplementation() | $impl = $item->getImplementation() | ||||
| ->setViewer($viewer); | ->setViewer($viewer); | ||||
| $commands = $this->buildCommands($item); | |||||
| $work_content = $impl->buildItemWorkView($item); | $work_content = $impl->buildItemWorkView($item); | ||||
| $view = id(new PHUITwoColumnView()) | $view = id(new PHUITwoColumnView()) | ||||
| ->setCurtain($curtain) | ->setCurtain($curtain) | ||||
| ->setMainColumn( | ->setMainColumn( | ||||
| array( | array( | ||||
| $commands, | |||||
| $work_content, | $work_content, | ||||
| $timeline, | $timeline, | ||||
| )); | )); | ||||
| return $this->newPage() | return $this->newPage() | ||||
| ->setTitle($title) | ->setTitle($title) | ||||
| ->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
| ->appendChild($view); | ->appendChild($view); | ||||
| } | } | ||||
| private function buildCurtain(NuanceQueue $queue, NuanceItem $item) { | private function buildCurtain(NuanceQueue $queue, NuanceItem $item) { | ||||
| $viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
| $id = $queue->getID(); | $id = $queue->getID(); | ||||
| $curtain = $this->newCurtainView(); | $curtain = $this->newCurtainView(); | ||||
| $impl = $item->getImplementation(); | $impl = $item->getImplementation(); | ||||
| $commands = $impl->buildWorkCommands($item); | $commands = $impl->buildWorkCommands($item); | ||||
| foreach ($commands as $command) { | foreach ($commands as $command) { | ||||
| $command_key = $command->getCommandKey(); | $command_key = $command->getCommandKey(); | ||||
| $item_id = $item->getID(); | $item_id = $item->getID(); | ||||
| $action_uri = "queue/action/{$id}/{$command_key}/{$item_id}/"; | |||||
| $action_uri = $this->getApplicationURI($action_uri); | |||||
| $curtain->addAction( | $curtain->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setName($command->getName()) | ->setName($command->getName()) | ||||
| ->setIcon($command->getIcon()) | ->setIcon($command->getIcon()) | ||||
| ->setHref("queue/command/{$id}/{$command_key}/{$item_id}/")) | ->setHref($action_uri) | ||||
| ->setWorkflow(true); | ->setWorkflow(true)); | ||||
| } | } | ||||
| $curtain->addAction( | $curtain->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setType(PhabricatorActionView::TYPE_DIVIDER)); | ->setType(PhabricatorActionView::TYPE_DIVIDER)); | ||||
| $curtain->addAction( | $curtain->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setType(PhabricatorActionView::TYPE_LABEL) | ->setType(PhabricatorActionView::TYPE_LABEL) | ||||
| ->setName(pht('Queue Actions'))); | ->setName(pht('Queue Actions'))); | ||||
| $curtain->addAction( | $curtain->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setName(pht('Manage Queue')) | ->setName(pht('Manage Queue')) | ||||
| ->setIcon('fa-cog') | ->setIcon('fa-cog') | ||||
| ->setHref($this->getApplicationURI("queue/view/{$id}/"))); | ->setHref($this->getApplicationURI("queue/view/{$id}/"))); | ||||
| return $curtain; | return $curtain; | ||||
| } | } | ||||
| private function buildCommands(NuanceItem $item) { | |||||
| $viewer = $this->getViewer(); | |||||
| $commands = id(new NuanceItemCommandQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withItemPHIDs(array($item->getPHID())) | |||||
| ->withStatuses( | |||||
| array( | |||||
| NuanceItemCommand::STATUS_ISSUED, | |||||
| NuanceItemCommand::STATUS_EXECUTING, | |||||
| NuanceItemCommand::STATUS_FAILED, | |||||
| )) | |||||
| ->execute(); | |||||
| $commands = msort($commands, 'getID'); | |||||
| if (!$commands) { | |||||
| return null; | |||||
| } | |||||
| $rows = array(); | |||||
| foreach ($commands as $command) { | |||||
| $icon = $command->getStatusIcon(); | |||||
| $color = $command->getStatusColor(); | |||||
| $rows[] = array( | |||||
| $command->getID(), | |||||
| id(new PHUIIconView()) | |||||
| ->setIcon($icon, $color), | |||||
| $viewer->renderHandle($command->getAuthorPHID()), | |||||
| $command->getCommand(), | |||||
| phabricator_datetime($command->getDateCreated(), $viewer), | |||||
| ); | |||||
| } | |||||
| $table = id(new AphrontTableView($rows)) | |||||
| ->setHeaders( | |||||
| array( | |||||
| pht('ID'), | |||||
| null, | |||||
| pht('Actor'), | |||||
| pht('Command'), | |||||
| pht('Date'), | |||||
| )) | |||||
| ->setColumnClasses( | |||||
| array( | |||||
| null, | |||||
| 'icon', | |||||
| null, | |||||
| 'pri', | |||||
| 'wide right', | |||||
| )); | |||||
| return id(new PHUIObjectBoxView()) | |||||
| ->setHeaderText(pht('Pending Commands')) | |||||
| ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
| ->setTable($table); | |||||
| } | |||||
| } | } | ||||