Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / almanac / view / AlmanacInterfaceTableView.php
blob1fdcd0bf356122686673b63c156024d7d3c80073
1 <?php
3 final class AlmanacInterfaceTableView extends AphrontView {
5 private $interfaces;
6 private $canEdit;
8 public function setInterfaces(array $interfaces) {
9 $this->interfaces = $interfaces;
10 return $this;
13 public function getInterfaces() {
14 return $this->interfaces;
17 public function setCanEdit($can_edit) {
18 $this->canEdit = $can_edit;
19 return $this;
22 public function getCanEdit() {
23 return $this->canEdit;
26 public function render() {
27 $interfaces = $this->getInterfaces();
28 $viewer = $this->getUser();
30 $can_edit = $this->getCanEdit();
32 if ($can_edit) {
33 $button_class = 'small button button-grey';
34 } else {
35 $button_class = 'small button button-grey disabled';
38 $handles = $viewer->loadHandles(mpull($interfaces, 'getNetworkPHID'));
40 $rows = array();
41 foreach ($interfaces as $interface) {
42 $rows[] = array(
43 $interface->getID(),
44 $handles->renderHandle($interface->getNetworkPHID()),
45 $interface->getAddress(),
46 $interface->getPort(),
47 javelin_tag(
48 'a',
49 array(
50 'class' => $button_class,
51 'href' => '/almanac/interface/edit/'.$interface->getID().'/',
52 'sigil' => ($can_edit ? null : 'workflow'),
54 pht('Edit')),
55 javelin_tag(
56 'a',
57 array(
58 'class' => $button_class,
59 'href' => '/almanac/interface/delete/'.$interface->getID().'/',
60 'sigil' => 'workflow',
62 pht('Delete')),
66 $table = id(new AphrontTableView($rows))
67 ->setHeaders(
68 array(
69 pht('ID'),
70 pht('Network'),
71 pht('Address'),
72 pht('Port'),
73 null,
74 null,
76 ->setColumnClasses(
77 array(
78 '',
79 'wide',
80 '',
81 '',
82 'action',
83 'action',
84 ));
86 return $table;