@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
at recaptime-dev/main 89 lines 2.0 kB view raw
1<?php 2 3final class AlmanacInterfaceTableView extends AphrontView { 4 5 private $interfaces; 6 private $canEdit; 7 8 public function setInterfaces(array $interfaces) { 9 $this->interfaces = $interfaces; 10 return $this; 11 } 12 13 public function getInterfaces() { 14 return $this->interfaces; 15 } 16 17 public function setCanEdit($can_edit) { 18 $this->canEdit = $can_edit; 19 return $this; 20 } 21 22 public function getCanEdit() { 23 return $this->canEdit; 24 } 25 26 public function render() { 27 $interfaces = $this->getInterfaces(); 28 $viewer = $this->getUser(); 29 30 $can_edit = $this->getCanEdit(); 31 32 if ($can_edit) { 33 $button_class = 'small button button-grey'; 34 } else { 35 $button_class = 'small button button-grey disabled'; 36 } 37 38 $handles = $viewer->loadHandles(mpull($interfaces, 'getNetworkPHID')); 39 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'), 53 ), 54 pht('Edit')), 55 javelin_tag( 56 'a', 57 array( 58 'class' => $button_class, 59 'href' => '/almanac/interface/delete/'.$interface->getID().'/', 60 'sigil' => 'workflow', 61 ), 62 pht('Delete')), 63 ); 64 } 65 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, 75 )) 76 ->setColumnClasses( 77 array( 78 '', 79 'wide', 80 '', 81 '', 82 'action', 83 'action', 84 )); 85 86 return $table; 87 } 88 89}