@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 148 lines 3.9 kB view raw
1<?php 2 3final class HarbormasterStepViewController 4 extends HarbormasterPlanController { 5 6 public function shouldAllowPublic() { 7 return true; 8 } 9 10 public function handleRequest(AphrontRequest $request) { 11 $viewer = $this->getViewer(); 12 $id = $request->getURIData('id'); 13 14 $step = id(new HarbormasterBuildStepQuery()) 15 ->setViewer($viewer) 16 ->withIDs(array($id)) 17 ->executeOne(); 18 if (!$step) { 19 return new Aphront404Response(); 20 } 21 $plan = $step->getBuildPlan(); 22 23 $plan_id = $plan->getID(); 24 $plan_uri = $this->getApplicationURI("plan/{$plan_id}/"); 25 26 $field_list = PhabricatorCustomField::getObjectFields( 27 $step, 28 PhabricatorCustomField::ROLE_VIEW); 29 $field_list 30 ->setViewer($viewer) 31 ->readFieldsFromStorage($step); 32 33 $crumbs = $this->buildApplicationCrumbs(); 34 $crumbs->addTextCrumb(pht('Plan %d', $plan_id), $plan_uri); 35 $crumbs->addTextCrumb(pht('Step %d', $id)); 36 $crumbs->setBorder(true); 37 38 $header = id(new PHUIHeaderView()) 39 ->setHeader(pht('Build Step %d: %s', $id, $step->getName())) 40 ->setHeaderIcon('fa-chevron-circle-right'); 41 42 $properties = $this->buildPropertyList($step, $field_list); 43 $curtain = $this->buildCurtainView($step); 44 45 $timeline = $this->buildTransactionTimeline( 46 $step, 47 new HarbormasterBuildStepTransactionQuery()); 48 $timeline->setShouldTerminate(true); 49 50 $view = id(new PHUITwoColumnView()) 51 ->setHeader($header) 52 ->setCurtain($curtain) 53 ->setMainColumn(array( 54 $properties, 55 $timeline, 56 )); 57 58 return $this->newPage() 59 ->setTitle(pht('Step %d', $id)) 60 ->setCrumbs($crumbs) 61 ->appendChild($view); 62 63 } 64 65 private function buildPropertyList( 66 HarbormasterBuildStep $step, 67 PhabricatorCustomFieldList $field_list) { 68 $viewer = $this->getViewer(); 69 70 $view = id(new PHUIPropertyListView()) 71 ->setUser($viewer); 72 73 try { 74 $implementation = $step->getStepImplementation(); 75 } catch (Exception $ex) { 76 $implementation = null; 77 } 78 79 if ($implementation) { 80 $type = $implementation->getName(); 81 } else { 82 $type = phutil_tag( 83 'em', 84 array(), 85 pht( 86 'Invalid Implementation ("%s")!', 87 $step->getClassName())); 88 } 89 90 $view->addProperty(pht('Step Type'), $type); 91 92 $view->addProperty( 93 pht('Created'), 94 phabricator_datetime($step->getDateCreated(), $viewer)); 95 96 $field_list->appendFieldsToPropertyList( 97 $step, 98 $viewer, 99 $view); 100 101 $description = $step->getDescription(); 102 if (strlen($description)) { 103 $view->addSectionHeader( 104 pht('Description'), 105 PHUIPropertyListView::ICON_SUMMARY); 106 $view->addTextContent( 107 new PHUIRemarkupView($viewer, $description)); 108 } 109 110 return id(new PHUIObjectBoxView()) 111 ->setHeaderText(pht('Properties')) 112 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 113 ->appendChild($view); 114 } 115 116 117 private function buildCurtainView(HarbormasterBuildStep $step) { 118 $viewer = $this->getViewer(); 119 $id = $step->getID(); 120 121 $curtain = $this->newCurtainView($step); 122 123 $can_edit = PhabricatorPolicyFilter::hasCapability( 124 $viewer, 125 $step, 126 PhabricatorPolicyCapability::CAN_EDIT); 127 128 $curtain->addAction( 129 id(new PhabricatorActionView()) 130 ->setName(pht('Edit Step')) 131 ->setHref($this->getApplicationURI("step/edit/{$id}/")) 132 ->setWorkflow(!$can_edit) 133 ->setDisabled(!$can_edit) 134 ->setIcon('fa-pencil')); 135 136 $curtain->addAction( 137 id(new PhabricatorActionView()) 138 ->setName(pht('Delete Step')) 139 ->setHref($this->getApplicationURI("step/delete/{$id}/")) 140 ->setWorkflow(true) 141 ->setDisabled(!$can_edit) 142 ->setIcon('fa-times')); 143 144 return $curtain; 145 } 146 147 148}