Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / almanac / controller / AlmanacNamespaceViewController.php
bloba673bdf648b042dcc75da2b1ac961a0dbf305bf5
1 <?php
3 final class AlmanacNamespaceViewController
4 extends AlmanacNamespaceController {
6 public function shouldAllowPublic() {
7 return true;
10 public function handleRequest(AphrontRequest $request) {
11 $viewer = $request->getViewer();
13 $id = $request->getURIData('id');
14 $namespace = id(new AlmanacNamespaceQuery())
15 ->setViewer($viewer)
16 ->withIDs(array($id))
17 ->executeOne();
18 if (!$namespace) {
19 return new Aphront404Response();
22 $title = pht('Namespace %s', $namespace->getName());
24 $curtain = $this->buildCurtain($namespace);
26 $header = id(new PHUIHeaderView())
27 ->setUser($viewer)
28 ->setHeader($namespace->getName())
29 ->setPolicyObject($namespace)
30 ->setHeaderIcon('fa-asterisk');
32 $crumbs = $this->buildApplicationCrumbs();
33 $crumbs->addTextCrumb($namespace->getName());
34 $crumbs->setBorder(true);
36 $timeline = $this->buildTransactionTimeline(
37 $namespace,
38 new AlmanacNamespaceTransactionQuery());
39 $timeline->setShouldTerminate(true);
41 $view = id(new PHUITwoColumnView())
42 ->setHeader($header)
43 ->setCurtain($curtain)
44 ->setMainColumn(array(
45 $timeline,
46 ));
48 return $this->newPage()
49 ->setTitle($title)
50 ->setCrumbs($crumbs)
51 ->appendChild(
52 array(
53 $view,
54 ));
57 private function buildCurtain(AlmanacNamespace $namespace) {
58 $viewer = $this->getViewer();
60 $can_edit = PhabricatorPolicyFilter::hasCapability(
61 $viewer,
62 $namespace,
63 PhabricatorPolicyCapability::CAN_EDIT);
65 $id = $namespace->getID();
66 $edit_uri = $this->getApplicationURI("namespace/edit/{$id}/");
68 $curtain = $this->newCurtainView($namespace);
70 $curtain->addAction(
71 id(new PhabricatorActionView())
72 ->setIcon('fa-pencil')
73 ->setName(pht('Edit Namespace'))
74 ->setHref($edit_uri)
75 ->setWorkflow(!$can_edit)
76 ->setDisabled(!$can_edit));
78 return $curtain;