3 final class AlmanacBindingViewController
4 extends AlmanacServiceController
{
6 public function shouldAllowPublic() {
10 public function handleRequest(AphrontRequest
$request) {
11 $viewer = $request->getViewer();
13 $id = $request->getURIData('id');
15 $binding = id(new AlmanacBindingQuery())
18 ->needProperties(true)
21 return new Aphront404Response();
24 $service = $binding->getService();
25 $service_uri = $service->getURI();
27 $title = pht('Binding %s', $binding->getID());
29 $properties = $this->buildPropertyList($binding);
30 $details = $this->buildPropertySection($binding);
31 $curtain = $this->buildCurtain($binding);
33 $header = id(new PHUIHeaderView())
36 ->setPolicyObject($binding)
37 ->setHeaderIcon('fa-object-group');
39 if ($binding->getIsDisabled()) {
40 $header->setStatus('fa-ban', 'red', pht('Disabled'));
44 if ($binding->getService()->isClusterService()) {
45 $issue = $this->addClusterMessage(
46 pht('The service for this binding is a cluster service.'),
48 'The service for this binding is a cluster service. You do not '.
49 'have permission to manage cluster services, so this binding can '.
53 $crumbs = $this->buildApplicationCrumbs();
54 $crumbs->addTextCrumb($service->getName(), $service_uri);
55 $crumbs->addTextCrumb($title);
56 $crumbs->setBorder(true);
58 $timeline = $this->buildTransactionTimeline(
60 new AlmanacBindingTransactionQuery());
61 $timeline->setShouldTerminate(true);
63 $view = id(new PHUITwoColumnView())
65 ->setCurtain($curtain)
66 ->setMainColumn(array(
68 $this->buildAlmanacPropertiesTable($binding),
71 ->addPropertySection(pht('Details'), $details);
73 return $this->newPage()
82 private function buildPropertySection(AlmanacBinding
$binding) {
83 $viewer = $this->getViewer();
85 $properties = id(new PHUIPropertyListView())
88 $properties->addProperty(
90 $viewer->renderHandle($binding->getServicePHID()));
92 $properties->addProperty(
94 $viewer->renderHandle($binding->getDevicePHID()));
96 $properties->addProperty(
98 $viewer->renderHandle($binding->getInterface()->getNetworkPHID()));
100 $properties->addProperty(
102 $binding->getInterface()->renderDisplayAddress());
107 private function buildPropertyList(AlmanacBinding
$binding) {
108 $viewer = $this->getViewer();
110 $properties = id(new PHUIPropertyListView())
112 ->setObject($binding);
113 $properties->invokeWillRenderEvent();
118 private function buildCurtain(AlmanacBinding
$binding) {
119 $viewer = $this->getViewer();
121 $can_edit = PhabricatorPolicyFilter
::hasCapability(
124 PhabricatorPolicyCapability
::CAN_EDIT
);
126 $id = $binding->getID();
127 $edit_uri = $this->getApplicationURI("binding/edit/{$id}/");
128 $disable_uri = $this->getApplicationURI("binding/disable/{$id}/");
130 $curtain = $this->newCurtainView($binding);
133 id(new PhabricatorActionView())
134 ->setIcon('fa-pencil')
135 ->setName(pht('Edit Binding'))
137 ->setWorkflow(!$can_edit)
138 ->setDisabled(!$can_edit));
140 if ($binding->getIsDisabled()) {
141 $disable_icon = 'fa-check';
142 $disable_text = pht('Enable Binding');
144 $disable_icon = 'fa-ban';
145 $disable_text = pht('Disable Binding');
149 id(new PhabricatorActionView())
150 ->setIcon($disable_icon)
151 ->setName($disable_text)
152 ->setHref($disable_uri)
154 ->setDisabled(!$can_edit));