@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 upstream/main 83 lines 2.1 kB view raw
1<?php 2 3final class PhluxViewController extends PhluxController { 4 5 public function handleRequest(AphrontRequest $request) { 6 $viewer = $this->getViewer(); 7 $key = $request->getURIData('key'); 8 9 $var = id(new PhluxVariableQuery()) 10 ->setViewer($viewer) 11 ->withKeys(array($key)) 12 ->executeOne(); 13 14 if (!$var) { 15 return new Aphront404Response(); 16 } 17 18 $title = $var->getVariableKey(); 19 20 $crumbs = $this->buildApplicationCrumbs(); 21 $crumbs->addTextCrumb($title, $request->getRequestURI()); 22 $crumbs->setBorder(true); 23 24 $curtain = $this->buildCurtainView($var); 25 26 $header = id(new PHUIHeaderView()) 27 ->setHeader($title) 28 ->setUser($viewer) 29 ->setPolicyObject($var) 30 ->setHeaderIcon('fa-copy'); 31 32 $display_value = json_encode($var->getVariableValue()); 33 34 $properties = id(new PHUIPropertyListView()) 35 ->setUser($viewer) 36 ->addProperty(pht('Value'), $display_value); 37 38 $timeline = $this->buildTransactionTimeline( 39 $var, 40 new PhluxTransactionQuery()); 41 $timeline->setShouldTerminate(true); 42 43 $object_box = id(new PHUIObjectBoxView()) 44 ->setHeaderText(pht('Details')) 45 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 46 ->addPropertyList($properties); 47 48 $view = id(new PHUITwoColumnView()) 49 ->setHeader($header) 50 ->setCurtain($curtain) 51 ->setMainColumn(array( 52 $object_box, 53 $timeline, 54 )); 55 56 return $this->newPage() 57 ->setTitle($title) 58 ->setCrumbs($crumbs) 59 ->appendChild($view); 60 } 61 62 private function buildCurtainView(PhluxVariable $var) { 63 $viewer = $this->getViewer(); 64 65 $curtain = $this->newCurtainView($var); 66 67 $can_edit = PhabricatorPolicyFilter::hasCapability( 68 $viewer, 69 $var, 70 PhabricatorPolicyCapability::CAN_EDIT); 71 72 $curtain->addAction( 73 id(new PhabricatorActionView()) 74 ->setIcon('fa-pencil') 75 ->setName(pht('Edit Variable')) 76 ->setHref($this->getApplicationURI('/edit/'.$var->getVariableKey().'/')) 77 ->setDisabled(!$can_edit) 78 ->setWorkflow(!$can_edit)); 79 80 return $curtain; 81 } 82 83}