Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / packages / controller / PhabricatorPackagesVersionViewController.php
blobf2aacea057128fe3109358d9b6b0c81d8e555e8e
1 <?php
3 final class PhabricatorPackagesVersionViewController
4 extends PhabricatorPackagesVersionController {
6 public function shouldAllowPublic() {
7 return true;
10 public function handleRequest(AphrontRequest $request) {
11 $viewer = $request->getViewer();
13 $publisher_key = $request->getURIData('publisherKey');
14 $package_key = $request->getURIData('packageKey');
15 $full_key = $publisher_key.'/'.$package_key;
16 $version_key = $request->getURIData('versionKey');
18 $version = id(new PhabricatorPackagesVersionQuery())
19 ->setViewer($viewer)
20 ->withFullKeys(array($full_key))
21 ->withNames(array($version_key))
22 ->executeOne();
23 if (!$version) {
24 return new Aphront404Response();
27 $package = $version->getPackage();
28 $publisher = $package->getPublisher();
30 $crumbs = $this->buildApplicationCrumbs()
31 ->addTextCrumb($publisher->getName(), $publisher->getURI())
32 ->addTextCrumb($package->getName(), $package->getURI())
33 ->addTextCrumb($version->getName())
34 ->setBorder(true);
36 $header = $this->buildHeaderView($version);
37 $curtain = $this->buildCurtain($version);
39 $timeline = $this->buildTransactionTimeline(
40 $version,
41 new PhabricatorPackagesVersionTransactionQuery());
42 $timeline->setShouldTerminate(true);
44 $version_view = id(new PHUITwoColumnView())
45 ->setHeader($header)
46 ->setCurtain($curtain)
47 ->setMainColumn($timeline);
49 return $this->newPage()
50 ->setCrumbs($crumbs)
51 ->setPageObjectPHIDs(
52 array(
53 $version->getPHID(),
55 ->appendChild($version_view);
59 private function buildHeaderView(PhabricatorPackagesVersion $version) {
60 $viewer = $this->getViewer();
61 $name = $version->getName();
63 return id(new PHUIHeaderView())
64 ->setViewer($viewer)
65 ->setHeader($name)
66 ->setPolicyObject($version)
67 ->setHeaderIcon('fa-tag');
70 private function buildCurtain(PhabricatorPackagesVersion $version) {
71 $viewer = $this->getViewer();
72 $curtain = $this->newCurtainView($version);
74 $can_edit = PhabricatorPolicyFilter::hasCapability(
75 $viewer,
76 $version,
77 PhabricatorPolicyCapability::CAN_EDIT);
79 $id = $version->getID();
80 $edit_uri = $this->getApplicationURI("version/edit/{$id}/");
82 $curtain->addAction(
83 id(new PhabricatorActionView())
84 ->setName(pht('Edit Version'))
85 ->setIcon('fa-pencil')
86 ->setDisabled(!$can_edit)
87 ->setHref($edit_uri));
89 return $curtain;