Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / nuance / controller / NuanceItemManageController.php
blob2b6b4c89b83e024009f8a0ae6ecec582b72b476d
1 <?php
3 final class NuanceItemManageController extends NuanceController {
5 public function handleRequest(AphrontRequest $request) {
6 $viewer = $this->getViewer();
7 $id = $request->getURIData('id');
9 $item = id(new NuanceItemQuery())
10 ->setViewer($viewer)
11 ->withIDs(array($id))
12 ->executeOne();
13 if (!$item) {
14 return new Aphront404Response();
17 $title = pht('Item %d', $item->getID());
19 $crumbs = $this->buildApplicationCrumbs();
20 $crumbs->addTextCrumb(
21 pht('Items'),
22 $this->getApplicationURI('item/'));
23 $crumbs->addTextCrumb(
24 $title,
25 $item->getURI());
26 $crumbs->addTextCrumb(pht('Manage'));
27 $crumbs->setBorder(true);
29 $properties = $this->buildPropertyView($item);
30 $curtain = $this->buildCurtain($item);
32 $header = id(new PHUIHeaderView())
33 ->setHeader($title);
35 $timeline = $this->buildTransactionTimeline(
36 $item,
37 new NuanceItemTransactionQuery());
38 $timeline->setShouldTerminate(true);
40 $view = id(new PHUITwoColumnView())
41 ->setHeader($header)
42 ->setCurtain($curtain)
43 ->addPropertySection(pht('Details'), $properties)
44 ->setMainColumn($timeline);
46 return $this->newPage()
47 ->setTitle($title)
48 ->setCrumbs($crumbs)
49 ->appendChild($view);
52 private function buildPropertyView(NuanceItem $item) {
53 $viewer = $this->getViewer();
55 $properties = id(new PHUIPropertyListView())
56 ->setUser($viewer);
58 $properties->addProperty(
59 pht('Date Created'),
60 phabricator_datetime($item->getDateCreated(), $viewer));
62 $requestor_phid = $item->getRequestorPHID();
63 if ($requestor_phid) {
64 $requestor_view = $viewer->renderHandle($requestor_phid);
65 } else {
66 $requestor_view = phutil_tag('em', array(), pht('None'));
68 $properties->addProperty(pht('Requestor'), $requestor_view);
70 $properties->addProperty(
71 pht('Source'),
72 $viewer->renderHandle($item->getSourcePHID()));
74 $queue_phid = $item->getQueuePHID();
75 if ($queue_phid) {
76 $queue_view = $viewer->renderHandle($queue_phid);
77 } else {
78 $queue_view = phutil_tag('em', array(), pht('None'));
80 $properties->addProperty(pht('Queue'), $queue_view);
82 $source = $item->getSource();
83 $definition = $source->getDefinition();
85 $definition->renderItemEditProperties(
86 $viewer,
87 $item,
88 $properties);
90 return $properties;
93 private function buildCurtain(NuanceItem $item) {
94 $viewer = $this->getViewer();
95 $id = $item->getID();
97 $curtain = $this->newCurtainView($item);
99 $curtain->addAction(
100 id(new PhabricatorActionView())
101 ->setName(pht('View Item'))
102 ->setIcon('fa-eye')
103 ->setHref($item->getURI()));
105 return $curtain;