mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-18 17:58:37 +01:00
Remove some callsites to loadViewerHandles()
Summary: Ref T7689. Use the more modern handle load mechanisms in Almanac. Test Plan: - Viewed Almanac binding detail page. - Viewed Almanac device interface list. - Grepped for other callsites to InterfaceTableView. - Viewed Almanac binding table. - Grepped for other callsites to BindingTableView. - Viewed Alamanc service table. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7689 Differential Revision: https://secure.phabricator.com/D12340
This commit is contained in:
parent
75c03986ad
commit
b717298c9e
5 changed files with 21 additions and 57 deletions
|
@ -73,24 +73,17 @@ final class AlmanacBindingViewController
|
|||
$properties = id(new PHUIPropertyListView())
|
||||
->setUser($viewer);
|
||||
|
||||
$handles = $this->loadViewerHandles(
|
||||
array(
|
||||
$binding->getServicePHID(),
|
||||
$binding->getDevicePHID(),
|
||||
$binding->getInterface()->getNetworkPHID(),
|
||||
));
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Service'),
|
||||
$handles[$binding->getServicePHID()]->renderLink());
|
||||
$viewer->renderHandle($binding->getServicePHID()));
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Device'),
|
||||
$handles[$binding->getDevicePHID()]->renderLink());
|
||||
$viewer->renderHandle($binding->getDevicePHID()));
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Network'),
|
||||
$handles[$binding->getInterface()->getNetworkPHID()]->renderLink());
|
||||
$viewer->renderHandle($binding->getInterface()->getNetworkPHID()));
|
||||
|
||||
$properties->addProperty(
|
||||
pht('Interface'),
|
||||
|
|
|
@ -119,17 +119,9 @@ final class AlmanacDeviceViewController
|
|||
->withDevicePHIDs(array($device->getPHID()))
|
||||
->execute();
|
||||
|
||||
$phids = array();
|
||||
foreach ($interfaces as $interface) {
|
||||
$phids[] = $interface->getNetworkPHID();
|
||||
$phids[] = $interface->getDevicePHID();
|
||||
}
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
|
||||
$table = id(new AlmanacInterfaceTableView())
|
||||
->setUser($viewer)
|
||||
->setInterfaces($interfaces)
|
||||
->setHandles($handles)
|
||||
->setCanEdit($can_edit);
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
|
@ -214,6 +206,7 @@ final class AlmanacDeviceViewController
|
|||
}
|
||||
|
||||
private function buildServicesTable(AlmanacDevice $device) {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
// NOTE: We're loading all services so we can show hidden, locked services.
|
||||
// In general, we let you know about all the things the device is bound to,
|
||||
|
@ -226,19 +219,18 @@ final class AlmanacDeviceViewController
|
|||
->withDevicePHIDs(array($device->getPHID()))
|
||||
->execute();
|
||||
|
||||
$handles = $this->loadViewerHandles(mpull($services, 'getPHID'));
|
||||
$handles = $viewer->loadHandles(mpull($services, 'getPHID'));
|
||||
|
||||
$icon_lock = id(new PHUIIconView())
|
||||
->setIconFont('fa-lock');
|
||||
|
||||
$rows = array();
|
||||
foreach ($services as $service) {
|
||||
$handle = $handles[$service->getPHID()];
|
||||
$rows[] = array(
|
||||
($service->getIsLocked()
|
||||
? $icon_lock
|
||||
: null),
|
||||
$handle->renderLink(),
|
||||
$handles->renderHandle($service->getPHID()),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -120,20 +120,11 @@ final class AlmanacServiceViewController
|
|||
->withServicePHIDs(array($service->getPHID()))
|
||||
->execute();
|
||||
|
||||
$phids = array();
|
||||
foreach ($bindings as $binding) {
|
||||
$phids[] = $binding->getServicePHID();
|
||||
$phids[] = $binding->getDevicePHID();
|
||||
$phids[] = $binding->getInterface()->getNetworkPHID();
|
||||
}
|
||||
$handles = $this->loadViewerHandles($phids);
|
||||
|
||||
$table = id(new AlmanacBindingTableView())
|
||||
->setNoDataString(
|
||||
pht('This service has not been bound to any device interfaces yet.'))
|
||||
->setUser($viewer)
|
||||
->setBindings($bindings)
|
||||
->setHandles($handles);
|
||||
->setBindings($bindings);
|
||||
|
||||
$header = id(new PHUIHeaderView())
|
||||
->setHeader(pht('Service Bindings'))
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
final class AlmanacBindingTableView extends AphrontView {
|
||||
|
||||
private $bindings;
|
||||
private $handles;
|
||||
private $noDataString;
|
||||
|
||||
public function setNoDataString($no_data_string) {
|
||||
|
@ -15,15 +14,6 @@ final class AlmanacBindingTableView extends AphrontView {
|
|||
return $this->noDataString;
|
||||
}
|
||||
|
||||
public function setHandles(array $handles) {
|
||||
$this->handles = $handles;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHandles() {
|
||||
return $this->handles;
|
||||
}
|
||||
|
||||
public function setBindings(array $bindings) {
|
||||
$this->bindings = $bindings;
|
||||
return $this;
|
||||
|
@ -35,9 +25,16 @@ final class AlmanacBindingTableView extends AphrontView {
|
|||
|
||||
public function render() {
|
||||
$bindings = $this->getBindings();
|
||||
$handles = $this->getHandles();
|
||||
$viewer = $this->getUser();
|
||||
|
||||
$phids = array();
|
||||
foreach ($bindings as $binding) {
|
||||
$phids[] = $binding->getServicePHID();
|
||||
$phids[] = $binding->getDevicePHID();
|
||||
$phids[] = $binding->getInterface()->getNetworkPHID();
|
||||
}
|
||||
$handles = $viewer->loadHandles($phids);
|
||||
|
||||
$rows = array();
|
||||
foreach ($bindings as $binding) {
|
||||
$addr = $binding->getInterface()->getAddress();
|
||||
|
@ -45,9 +42,9 @@ final class AlmanacBindingTableView extends AphrontView {
|
|||
|
||||
$rows[] = array(
|
||||
$binding->getID(),
|
||||
$handles[$binding->getServicePHID()]->renderLink(),
|
||||
$handles[$binding->getDevicePHID()]->renderLink(),
|
||||
$handles[$binding->getInterface()->getNetworkPHID()]->renderLink(),
|
||||
$handles->renderHandle($binding->getServicePHID()),
|
||||
$handles->renderHandle($binding->getDevicePHID()),
|
||||
$handles->renderHandle($binding->getInterface()->getNetworkPHID()),
|
||||
$binding->getInterface()->renderDisplayAddress(),
|
||||
phutil_tag(
|
||||
'a',
|
||||
|
|
|
@ -3,18 +3,8 @@
|
|||
final class AlmanacInterfaceTableView extends AphrontView {
|
||||
|
||||
private $interfaces;
|
||||
private $handles;
|
||||
private $canEdit;
|
||||
|
||||
public function setHandles(array $handles) {
|
||||
$this->handles = $handles;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHandles() {
|
||||
return $this->handles;
|
||||
}
|
||||
|
||||
public function setInterfaces(array $interfaces) {
|
||||
$this->interfaces = $interfaces;
|
||||
return $this;
|
||||
|
@ -35,7 +25,6 @@ final class AlmanacInterfaceTableView extends AphrontView {
|
|||
|
||||
public function render() {
|
||||
$interfaces = $this->getInterfaces();
|
||||
$handles = $this->getHandles();
|
||||
$viewer = $this->getUser();
|
||||
|
||||
if ($this->getCanEdit()) {
|
||||
|
@ -44,11 +33,13 @@ final class AlmanacInterfaceTableView extends AphrontView {
|
|||
$button_class = 'small grey button disabled';
|
||||
}
|
||||
|
||||
$handles = $viewer->loadHandles(mpull($interfaces, 'getNetworkPHID'));
|
||||
|
||||
$rows = array();
|
||||
foreach ($interfaces as $interface) {
|
||||
$rows[] = array(
|
||||
$interface->getID(),
|
||||
$handles[$interface->getNetworkPHID()]->renderLink(),
|
||||
$handles->renderHandle($interface->getNetworkPHID()),
|
||||
$interface->getAddress(),
|
||||
$interface->getPort(),
|
||||
phutil_tag(
|
||||
|
|
Loading…
Add table
Reference in a new issue