3 final class PhabricatorPackagesPackageViewController
4 extends PhabricatorPackagesPackageController
{
6 public function shouldAllowPublic() {
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;
17 $package = id(new PhabricatorPackagesPackageQuery())
19 ->withFullKeys(array($full_key))
22 return new Aphront404Response();
25 $publisher = $package->getPublisher();
27 $crumbs = $this->buildApplicationCrumbs()
28 ->addTextCrumb($publisher->getName(), $publisher->getURI())
29 ->addTextCrumb($package->getName())
32 $header = $this->buildHeaderView($package);
33 $curtain = $this->buildCurtain($package);
35 $versions_view = $this->buildVersionsView($package);
37 $timeline = $this->buildTransactionTimeline(
39 new PhabricatorPackagesPackageTransactionQuery());
40 $timeline->setShouldTerminate(true);
42 $package_view = id(new PHUITwoColumnView())
44 ->setCurtain($curtain)
51 return $this->newPage()
57 ->appendChild($package_view);
61 private function buildHeaderView(PhabricatorPackagesPackage
$package) {
62 $viewer = $this->getViewer();
63 $name = $package->getName();
65 return id(new PHUIHeaderView())
68 ->setPolicyObject($package)
69 ->setHeaderIcon('fa-gift');
72 private function buildCurtain(PhabricatorPackagesPackage
$package) {
73 $viewer = $this->getViewer();
74 $curtain = $this->newCurtainView($package);
76 $can_edit = PhabricatorPolicyFilter
::hasCapability(
79 PhabricatorPolicyCapability
::CAN_EDIT
);
81 $id = $package->getID();
82 $edit_uri = $this->getApplicationURI("package/edit/{$id}/");
85 id(new PhabricatorActionView())
86 ->setName(pht('Edit Package'))
87 ->setIcon('fa-pencil')
88 ->setDisabled(!$can_edit)
89 ->setHref($edit_uri));
94 private function buildVersionsView(PhabricatorPackagesPackage
$package) {
95 $viewer = $this->getViewer();
97 $versions = id(new PhabricatorPackagesVersionQuery())
99 ->withPackagePHIDs(array($package->getPHID()))
103 $versions_list = id(new PhabricatorPackagesVersionListView())
105 ->setVersions($versions);
107 $all_href = urisprintf(
108 'version/?package=%s#R',
109 $package->getPHID());
110 $all_href = $this->getApplicationURI($all_href);
112 $view_all = id(new PHUIButtonView())
114 ->setIcon('fa-search')
115 ->setText(pht('View All'))
116 ->setHref($all_href);
118 $header = id(new PHUIHeaderView())
119 ->setHeader(pht('Versions'))
120 ->addActionLink($view_all);
122 $versions_view = id(new PHUIObjectBoxView())
124 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
125 ->setObjectList($versions_list);
127 return $versions_view;