Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / packages / controller / PhabricatorPackagesPublisherViewController.php
blobf0df21e93f519ccdc70a216437e377857b8da793
1 <?php
3 final class PhabricatorPackagesPublisherViewController
4 extends PhabricatorPackagesPublisherController {
6 public function shouldAllowPublic() {
7 return true;
10 public function handleRequest(AphrontRequest $request) {
11 $viewer = $request->getViewer();
12 $publisher_key = $request->getURIData('publisherKey');
14 $publisher = id(new PhabricatorPackagesPublisherQuery())
15 ->setViewer($viewer)
16 ->withPublisherKeys(array($publisher_key))
17 ->executeOne();
18 if (!$publisher) {
19 return new Aphront404Response();
22 $crumbs = $this->buildApplicationCrumbs()
23 ->addTextCrumb(
24 pht('Publishers'),
25 $this->getApplicationURI('publisher/'))
26 ->addTextCrumb($publisher->getName())
27 ->setBorder(true);
29 $header = $this->buildHeaderView($publisher);
30 $curtain = $this->buildCurtain($publisher);
32 $packages_view = $this->buildPackagesView($publisher);
34 $timeline = $this->buildTransactionTimeline(
35 $publisher,
36 new PhabricatorPackagesPublisherTransactionQuery());
37 $timeline->setShouldTerminate(true);
39 $publisher_view = id(new PHUITwoColumnView())
40 ->setHeader($header)
41 ->setCurtain($curtain)
42 ->setMainColumn(
43 array(
44 $packages_view,
45 $timeline,
46 ));
48 return $this->newPage()
49 ->setCrumbs($crumbs)
50 ->setPageObjectPHIDs(
51 array(
52 $publisher->getPHID(),
54 ->appendChild($publisher_view);
58 private function buildHeaderView(PhabricatorPackagesPublisher $publisher) {
59 $viewer = $this->getViewer();
60 $name = $publisher->getName();
62 return id(new PHUIHeaderView())
63 ->setViewer($viewer)
64 ->setHeader($name)
65 ->setPolicyObject($publisher)
66 ->setHeaderIcon('fa-paw');
69 private function buildCurtain(PhabricatorPackagesPublisher $publisher) {
70 $viewer = $this->getViewer();
71 $curtain = $this->newCurtainView($publisher);
73 $can_edit = PhabricatorPolicyFilter::hasCapability(
74 $viewer,
75 $publisher,
76 PhabricatorPolicyCapability::CAN_EDIT);
78 $id = $publisher->getID();
79 $edit_uri = $this->getApplicationURI("publisher/edit/{$id}/");
81 $curtain->addAction(
82 id(new PhabricatorActionView())
83 ->setName(pht('Edit Publisher'))
84 ->setIcon('fa-pencil')
85 ->setDisabled(!$can_edit)
86 ->setHref($edit_uri));
88 return $curtain;
91 private function buildPackagesView(PhabricatorPackagesPublisher $publisher) {
92 $viewer = $this->getViewer();
94 $packages = id(new PhabricatorPackagesPackageQuery())
95 ->setViewer($viewer)
96 ->withPublisherPHIDs(array($publisher->getPHID()))
97 ->setLimit(25)
98 ->execute();
100 $packages_list = id(new PhabricatorPackagesPackageListView())
101 ->setViewer($viewer)
102 ->setPackages($packages);
104 $all_href = urisprintf(
105 'package/?publisher=%s#R',
106 $publisher->getPHID());
107 $all_href = $this->getApplicationURI($all_href);
109 $view_all = id(new PHUIButtonView())
110 ->setTag('a')
111 ->setIcon('fa-search')
112 ->setText(pht('View All'))
113 ->setHref($all_href);
115 $header = id(new PHUIHeaderView())
116 ->setHeader(pht('Packages'))
117 ->addActionLink($view_all);
119 $packages_view = id(new PHUIObjectBoxView())
120 ->setHeader($header)
121 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
122 ->setObjectList($packages_list);
124 return $packages_view;