3 final class AlmanacServiceViewController
4 extends AlmanacServiceController
{
6 public function shouldAllowPublic() {
10 public function handleRequest(AphrontRequest
$request) {
11 $viewer = $request->getViewer();
13 $name = $request->getURIData('name');
15 $service = id(new AlmanacServiceQuery())
17 ->withNames(array($name))
18 ->needProperties(true)
21 return new Aphront404Response();
24 $title = pht('Service %s', $service->getName());
26 $curtain = $this->buildCurtain($service);
27 $details = $this->buildPropertySection($service);
29 $header = id(new PHUIHeaderView())
31 ->setHeader($service->getName())
32 ->setPolicyObject($service)
33 ->setHeaderIcon('fa-plug');
36 if ($service->isClusterService()) {
37 $issue = $this->addClusterMessage(
38 pht('This is a cluster service.'),
40 'This service is a cluster service. You do not have permission to '.
41 'edit cluster services, so you can not edit this service.'));
44 $bindings = $this->buildBindingList($service);
46 $crumbs = $this->buildApplicationCrumbs();
47 $crumbs->addTextCrumb($service->getName());
48 $crumbs->setBorder(true);
50 $timeline = $this->buildTransactionTimeline(
52 new AlmanacServiceTransactionQuery());
53 $timeline->setShouldTerminate(true);
55 $view = id(new PHUITwoColumnView())
57 ->setCurtain($curtain)
58 ->setMainColumn(array(
62 $this->buildAlmanacPropertiesTable($service),
66 return $this->newPage()
72 private function buildPropertySection(
73 AlmanacService
$service) {
74 $viewer = $this->getViewer();
76 $properties = id(new PHUIPropertyListView())
79 $properties->addProperty(
81 $service->getServiceImplementation()->getServiceTypeShortName());
83 return id(new PHUIObjectBoxView())
84 ->setHeaderText(pht('Details'))
85 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
86 ->appendChild($properties);
89 private function buildCurtain(AlmanacService
$service) {
90 $viewer = $this->getViewer();
92 $can_edit = PhabricatorPolicyFilter
::hasCapability(
95 PhabricatorPolicyCapability
::CAN_EDIT
);
97 $id = $service->getID();
98 $edit_uri = $this->getApplicationURI("service/edit/{$id}/");
100 $curtain = $this->newCurtainView($service);
103 id(new PhabricatorActionView())
104 ->setIcon('fa-pencil')
105 ->setName(pht('Edit Service'))
107 ->setWorkflow(!$can_edit)
108 ->setDisabled(!$can_edit));
113 private function buildBindingList(AlmanacService
$service) {
114 $viewer = $this->getViewer();
115 $id = $service->getID();
117 $can_edit = PhabricatorPolicyFilter
::hasCapability(
120 PhabricatorPolicyCapability
::CAN_EDIT
);
122 $bindings = id(new AlmanacBindingQuery())
124 ->withServicePHIDs(array($service->getPHID()))
127 $table = id(new AlmanacBindingTableView())
129 pht('This service has not been bound to any device interfaces yet.'))
131 ->setBindings($bindings)
132 ->setHideServiceColumn(true);
134 $header = id(new PHUIHeaderView())
135 ->setHeader(pht('Service Bindings'))
137 id(new PHUIButtonView())
139 ->setHref($this->getApplicationURI("binding/edit/?serviceID={$id}"))
140 ->setWorkflow(!$can_edit)
141 ->setDisabled(!$can_edit)
142 ->setText(pht('Add Binding'))
143 ->setIcon('fa-plus'));
145 return id(new PHUIObjectBoxView())
147 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)