1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Use curtain views in Almanac

Summary: Convert Almanac interfaces to Curtain views.

Test Plan: Viewed Services, Bindings, Devices, Namespaces and Networks.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D15415
This commit is contained in:
epriestley 2016-03-06 09:38:29 -08:00
parent 61f82bb97b
commit 11774ef290
5 changed files with 60 additions and 114 deletions

View file

@ -28,7 +28,7 @@ final class AlmanacBindingViewController
$properties = $this->buildPropertyList($binding);
$details = $this->buildPropertySection($binding);
$actions = $this->buildActionList($binding);
$curtain = $this->buildCurtain($binding);
$header = id(new PHUIHeaderView())
->setUser($viewer)
@ -62,14 +62,13 @@ final class AlmanacBindingViewController
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
$issue,
$this->buildAlmanacPropertiesTable($binding),
$timeline,
))
->setPropertyList($properties)
->addPropertySection(pht('DETAILS'), $details)
->setActionList($actions);
->addPropertySection(pht('DETAILS'), $details);
return $this->newPage()
->setTitle($title)
@ -116,23 +115,25 @@ final class AlmanacBindingViewController
return $properties;
}
private function buildActionList(AlmanacBinding $binding) {
private function buildCurtain(AlmanacBinding $binding) {
$viewer = $this->getViewer();
$id = $binding->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$binding,
PhabricatorPolicyCapability::CAN_EDIT);
$actions = id(new PhabricatorActionListView())
->setUser($viewer);
$id = $binding->getID();
$edit_uri = $this->getApplicationURI("binding/edit/{$id}/");
$disable_uri = $this->getApplicationURI("binding/disable/{$id}/");
$actions->addAction(
$curtain = $this->newCurtainView($binding);
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-pencil')
->setName(pht('Edit Binding'))
->setHref($this->getApplicationURI("binding/edit/{$id}/"))
->setHref($edit_uri)
->setWorkflow(!$can_edit)
->setDisabled(!$can_edit));
@ -144,17 +145,15 @@ final class AlmanacBindingViewController
$disable_text = pht('Disable Binding');
}
$disable_href = $this->getApplicationURI("binding/disable/{$id}/");
$actions->addAction(
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon($disable_icon)
->setName($disable_text)
->setHref($disable_href)
->setHref($disable_uri)
->setWorkflow(true)
->setDisabled(!$can_edit));
return $actions;
return $curtain;
}
}

View file

@ -23,8 +23,7 @@ final class AlmanacDeviceViewController
$title = pht('Device %s', $device->getName());
$properties = $this->buildPropertyList($device);
$actions = $this->buildActionList($device);
$curtain = $this->buildCurtain($device);
$header = id(new PHUIHeaderView())
->setUser($viewer)
@ -55,6 +54,7 @@ final class AlmanacDeviceViewController
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
$issue,
$interfaces,
@ -62,9 +62,7 @@ final class AlmanacDeviceViewController
$this->buildSSHKeysTable($device),
$this->buildServicesTable($device),
$timeline,
))
->setPropertyList($properties)
->setActionList($actions);
));
return $this->newPage()
->setTitle($title)
@ -75,37 +73,28 @@ final class AlmanacDeviceViewController
));
}
private function buildPropertyList(AlmanacDevice $device) {
private function buildCurtain(AlmanacDevice $device) {
$viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($device);
return $properties;
}
private function buildActionList(AlmanacDevice $device) {
$viewer = $this->getViewer();
$id = $device->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$device,
PhabricatorPolicyCapability::CAN_EDIT);
$actions = id(new PhabricatorActionListView())
->setUser($viewer);
$id = $device->getID();
$edit_uri = $this->getApplicationURI("device/edit/{$id}/");
$actions->addAction(
$curtain = $this->newCurtainView($device);
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-pencil')
->setName(pht('Edit Device'))
->setHref($this->getApplicationURI("device/edit/{$id}/"))
->setHref($edit_uri)
->setWorkflow(!$can_edit)
->setDisabled(!$can_edit));
return $actions;
return $curtain;
}
private function buildInterfaceList(AlmanacDevice $device) {

View file

@ -21,8 +21,7 @@ final class AlmanacNamespaceViewController
$title = pht('Namespace %s', $namespace->getName());
$properties = $this->buildPropertyList($namespace);
$actions = $this->buildActionList($namespace);
$curtain = $this->buildCurtain($namespace);
$header = id(new PHUIHeaderView())
->setUser($viewer)
@ -41,11 +40,10 @@ final class AlmanacNamespaceViewController
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
$timeline,
))
->setPropertyList($properties)
->setActionList($actions);
));
return $this->newPage()
->setTitle($title)
@ -56,39 +54,28 @@ final class AlmanacNamespaceViewController
));
}
private function buildPropertyList(AlmanacNamespace $namespace) {
private function buildCurtain(AlmanacNamespace $namespace) {
$viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($namespace);
$properties->invokeWillRenderEvent();
return $properties;
}
private function buildActionList(AlmanacNamespace $namespace) {
$viewer = $this->getViewer();
$id = $namespace->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$namespace,
PhabricatorPolicyCapability::CAN_EDIT);
$actions = id(new PhabricatorActionListView())
->setUser($viewer);
$id = $namespace->getID();
$edit_uri = $this->getApplicationURI("namespace/edit/{$id}/");
$actions->addAction(
$curtain = $this->newCurtainView($namespace);
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-pencil')
->setName(pht('Edit Namespace'))
->setHref($this->getApplicationURI("namespace/edit/{$id}/"))
->setHref($edit_uri)
->setWorkflow(!$can_edit)
->setDisabled(!$can_edit));
return $actions;
return $curtain;
}
}

View file

@ -21,8 +21,7 @@ final class AlmanacNetworkViewController
$title = pht('Network %s', $network->getName());
$properties = $this->buildPropertyList($network);
$actions = $this->buildActionList($network);
$curtain = $this->buildCurtain($network);
$header = id(new PHUIHeaderView())
->setUser($viewer)
@ -41,11 +40,10 @@ final class AlmanacNetworkViewController
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
$timeline,
))
->setPropertyList($properties)
->setActionList($actions);
));
return $this->newPage()
->setTitle($title)
@ -56,39 +54,29 @@ final class AlmanacNetworkViewController
));
}
private function buildPropertyList(AlmanacNetwork $network) {
private function buildCurtain(AlmanacNetwork $network) {
$viewer = $this->getViewer();
$properties = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($network);
$properties->invokeWillRenderEvent();
return $properties;
}
private function buildActionList(AlmanacNetwork $network) {
$viewer = $this->getViewer();
$id = $network->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$network,
PhabricatorPolicyCapability::CAN_EDIT);
$actions = id(new PhabricatorActionListView())
->setUser($viewer);
$id = $network->getID();
$edit_uri = $this->getApplicationURI("network/edit/{$id}/");
$actions->addAction(
$curtain = $this->newCurtainView($network);
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-pencil')
->setName(pht('Edit Network'))
->setHref($this->getApplicationURI("network/edit/{$id}/"))
->setHref($edit_uri)
->setWorkflow(!$can_edit)
->setDisabled(!$can_edit));
return $actions;
return $curtain;
}
}

View file

@ -23,8 +23,7 @@ final class AlmanacServiceViewController
$title = pht('Service %s', $service->getName());
$properties = $this->buildPropertyList($service);
$actions = $this->buildActionList($service);
$curtain = $this->buildCurtain($service);
$details = $this->buildPropertySection($service);
$header = id(new PHUIHeaderView())
@ -55,36 +54,19 @@ final class AlmanacServiceViewController
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
$issue,
$details,
$bindings,
$this->buildAlmanacPropertiesTable($service),
$timeline,
))
->setPropertyList($properties)
->setActionList($actions);
));
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild(
array(
$view,
));
}
private function buildPropertyList(
AlmanacService $service) {
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($service);
$view->invokeWillRenderEvent();
return $view;
->appendChild($view);
}
private function buildPropertySection(
@ -104,27 +86,28 @@ final class AlmanacServiceViewController
->appendChild($properties);
}
private function buildActionList(AlmanacService $service) {
private function buildCurtain(AlmanacService $service) {
$viewer = $this->getViewer();
$id = $service->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$service,
PhabricatorPolicyCapability::CAN_EDIT);
$actions = id(new PhabricatorActionListView())
->setUser($viewer);
$id = $service->getID();
$edit_uri = $this->getApplicationURI("service/edit/{$id}/");
$actions->addAction(
$curtain = $this->newCurtainView($service);
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-pencil')
->setName(pht('Edit Service'))
->setHref($this->getApplicationURI("service/edit/{$id}/"))
->setHref($edit_uri)
->setWorkflow(!$can_edit)
->setDisabled(!$can_edit));
return $actions;
return $curtain;
}
private function buildBindingList(AlmanacService $service) {