1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-19 03:50:54 +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); $properties = $this->buildPropertyList($binding);
$details = $this->buildPropertySection($binding); $details = $this->buildPropertySection($binding);
$actions = $this->buildActionList($binding); $curtain = $this->buildCurtain($binding);
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setUser($viewer) ->setUser($viewer)
@ -62,14 +62,13 @@ final class AlmanacBindingViewController
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array( ->setMainColumn(array(
$issue, $issue,
$this->buildAlmanacPropertiesTable($binding), $this->buildAlmanacPropertiesTable($binding),
$timeline, $timeline,
)) ))
->setPropertyList($properties) ->addPropertySection(pht('DETAILS'), $details);
->addPropertySection(pht('DETAILS'), $details)
->setActionList($actions);
return $this->newPage() return $this->newPage()
->setTitle($title) ->setTitle($title)
@ -116,23 +115,25 @@ final class AlmanacBindingViewController
return $properties; return $properties;
} }
private function buildActionList(AlmanacBinding $binding) { private function buildCurtain(AlmanacBinding $binding) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$id = $binding->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability( $can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer, $viewer,
$binding, $binding,
PhabricatorPolicyCapability::CAN_EDIT); PhabricatorPolicyCapability::CAN_EDIT);
$actions = id(new PhabricatorActionListView()) $id = $binding->getID();
->setUser($viewer); $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()) id(new PhabricatorActionView())
->setIcon('fa-pencil') ->setIcon('fa-pencil')
->setName(pht('Edit Binding')) ->setName(pht('Edit Binding'))
->setHref($this->getApplicationURI("binding/edit/{$id}/")) ->setHref($edit_uri)
->setWorkflow(!$can_edit) ->setWorkflow(!$can_edit)
->setDisabled(!$can_edit)); ->setDisabled(!$can_edit));
@ -144,17 +145,15 @@ final class AlmanacBindingViewController
$disable_text = pht('Disable Binding'); $disable_text = pht('Disable Binding');
} }
$disable_href = $this->getApplicationURI("binding/disable/{$id}/"); $curtain->addAction(
$actions->addAction(
id(new PhabricatorActionView()) id(new PhabricatorActionView())
->setIcon($disable_icon) ->setIcon($disable_icon)
->setName($disable_text) ->setName($disable_text)
->setHref($disable_href) ->setHref($disable_uri)
->setWorkflow(true) ->setWorkflow(true)
->setDisabled(!$can_edit)); ->setDisabled(!$can_edit));
return $actions; return $curtain;
} }
} }

View file

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

View file

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

View file

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

View file

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