Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / nuance / controller / NuanceSourceViewController.php
blob93facde3c13d64c535a15344423b603dfc37a132
1 <?php
3 final class NuanceSourceViewController
4 extends NuanceSourceController {
6 public function handleRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
9 $source = id(new NuanceSourceQuery())
10 ->setViewer($viewer)
11 ->withIDs(array($request->getURIData('id')))
12 ->executeOne();
13 if (!$source) {
14 return new Aphront404Response();
17 $source_id = $source->getID();
19 $header = $this->buildHeaderView($source);
20 $curtain = $this->buildCurtain($source);
21 $properties = $this->buildPropertyView($source);
23 $title = $source->getName();
25 $routing_list = id(new PHUIPropertyListView())
26 ->addProperty(
27 pht('Default Queue'),
28 $viewer->renderHandle($source->getDefaultQueuePHID()));
30 $crumbs = $this->buildApplicationCrumbs();
31 $crumbs->addTextCrumb(pht('Sources'), $this->getApplicationURI('source/'));
32 $crumbs->addTextCrumb($title);
33 $crumbs->setBorder(true);
35 $timeline = $this->buildTransactionTimeline(
36 $source,
37 new NuanceSourceTransactionQuery());
38 $timeline->setShouldTerminate(true);
40 $view = id(new PHUITwoColumnView())
41 ->setHeader($header)
42 ->setCurtain($curtain)
43 ->addPropertySection(pht('Details'), $properties)
44 ->addPropertySection(pht('Routing'), $routing_list)
45 ->setMainColumn($timeline);
47 return $this->newPage()
48 ->setTitle($title)
49 ->setCrumbs($crumbs)
50 ->appendChild($view);
53 private function buildHeaderView(NuanceSource $source) {
54 $viewer = $this->getViewer();
56 $header = id(new PHUIHeaderView())
57 ->setUser($viewer)
58 ->setHeader($source->getName())
59 ->setPolicyObject($source);
61 return $header;
64 private function buildCurtain(NuanceSource $source) {
65 $viewer = $this->getViewer();
66 $id = $source->getID();
68 $actions = id(new PhabricatorActionListView())
69 ->setUser($viewer);
71 $can_edit = PhabricatorPolicyFilter::hasCapability(
72 $viewer,
73 $source,
74 PhabricatorPolicyCapability::CAN_EDIT);
76 $curtain = $this->newCurtainView($source);
78 $curtain->addAction(
79 id(new PhabricatorActionView())
80 ->setName(pht('Edit Source'))
81 ->setIcon('fa-pencil')
82 ->setHref($this->getApplicationURI("source/edit/{$id}/"))
83 ->setDisabled(!$can_edit)
84 ->setWorkflow(!$can_edit));
86 $request = $this->getRequest();
87 $definition = $source->getDefinition();
89 $definition
90 ->setViewer($viewer)
91 ->setSource($source);
93 $source_actions = $definition->getSourceViewActions($request);
94 foreach ($source_actions as $source_action) {
95 $curtain->addAction($source_action);
98 return $curtain;
101 private function buildPropertyView(
102 NuanceSource $source) {
103 $viewer = $this->getViewer();
105 $properties = id(new PHUIPropertyListView())
106 ->setViewer($viewer);
108 $definition = $source->getDefinition();
110 $properties->addProperty(
111 pht('Source Type'),
112 $definition->getName());
114 return $properties;