@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Render Drydock logs in text from "bin/drydock lease"; in HTML in web views

Summary: Ref T13073. The new log output from `bin/drydock lease` currently uses HTML handle rendering, but should render to text.

Test Plan: Ran `bin/drydock lease` and saw normal text in log output. Viewed the same logs from the web UI and saw HTML.

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13073

Differential Revision: https://secure.phabricator.com/D19101

+41 -14
+1 -2
src/applications/drydock/logtype/DrydockLeaseNoAuthorizationsLogType.php
··· 13 13 } 14 14 15 15 public function renderLog(array $data) { 16 - $viewer = $this->getViewer(); 17 16 $authorizing_phid = idx($data, 'authorizingPHID'); 18 17 19 18 return pht( 20 19 'The object which authorized this lease (%s) is not authorized to use '. 21 20 'any of the blueprints the lease lists. Approve the authorizations '. 22 21 'before using the lease.', 23 - $viewer->renderHandle($authorizing_phid)->render()); 22 + $this->renderHandle($authorizing_phid)); 24 23 } 25 24 26 25 }
+1 -3
src/applications/drydock/logtype/DrydockLeaseReclaimLogType.php
··· 13 13 } 14 14 15 15 public function renderLog(array $data) { 16 - $viewer = $this->getViewer(); 17 - 18 16 $resource_phids = idx($data, 'resourcePHIDs', array()); 19 17 20 18 return pht( 21 19 'Reclaimed resource %s.', 22 - $viewer->renderHandleList($resource_phids)->render()); 20 + $this->renderHandleList($resource_phids)); 23 21 } 24 22 25 23 }
+1 -3
src/applications/drydock/logtype/DrydockLeaseWaitingForResourcesLogType.php
··· 13 13 } 14 14 15 15 public function renderLog(array $data) { 16 - $viewer = $this->getViewer(); 17 - 18 16 $blueprint_phids = idx($data, 'blueprintPHIDs', array()); 19 17 20 18 return pht( 21 19 'Waiting for available resources from: %s.', 22 - $viewer->renderHandleList($blueprint_phids)->render()); 20 + $this->renderHandleList($blueprint_phids)); 23 21 } 24 22 25 23 }
+35 -2
src/applications/drydock/logtype/DrydockLogType.php
··· 4 4 5 5 private $viewer; 6 6 private $log; 7 + private $renderingMode = 'text'; 7 8 8 9 abstract public function getLogTypeName(); 9 10 abstract public function getLogTypeIcon(array $data); 10 11 abstract public function renderLog(array $data); 11 12 12 - public function setViewer(PhabricatorUser $viewer) { 13 + final public function setViewer(PhabricatorUser $viewer) { 13 14 $this->viewer = $viewer; 14 15 return $this; 15 16 } 16 17 17 - public function getViewer() { 18 + final public function getViewer() { 18 19 return $this->viewer; 19 20 } 20 21 ··· 36 37 ->setAncestorClass(__CLASS__) 37 38 ->setUniqueMethod('getLogTypeConstant') 38 39 ->execute(); 40 + } 41 + 42 + final public function renderLogForText($data) { 43 + $this->renderingMode = 'text'; 44 + return $this->renderLog($data); 45 + } 46 + 47 + final public function renderLogForHTML($data) { 48 + $this->renderingMode = 'html'; 49 + return $this->renderLog($data); 50 + } 51 + 52 + final protected function renderHandle($phid) { 53 + $viewer = $this->getViewer(); 54 + $handle = $viewer->renderHandle($phid); 55 + 56 + if ($this->renderingMode == 'html') { 57 + return $handle->render(); 58 + } else { 59 + return $handle->setAsText(true)->render(); 60 + } 61 + } 62 + 63 + final protected function renderHandleList(array $phids) { 64 + $viewer = $this->getViewer(); 65 + $handle_list = $viewer->renderHandleList($phids); 66 + 67 + if ($this->renderingMode == 'html') { 68 + return $handle_list->render(); 69 + } else { 70 + return $handle_list->setAsText(true)->render(); 71 + } 39 72 } 40 73 41 74 }
+1 -2
src/applications/drydock/logtype/DrydockResourceReclaimLogType.php
··· 13 13 } 14 14 15 15 public function renderLog(array $data) { 16 - $viewer = $this->getViewer(); 17 16 $reclaimer_phid = idx($data, 'reclaimerPHID'); 18 17 19 18 return pht( 20 19 'Resource reclaimed by %s.', 21 - $viewer->renderHandle($reclaimer_phid)->render()); 20 + $this->renderHandle($reclaimer_phid)); 22 21 } 23 22 24 23 }
+1 -1
src/applications/drydock/management/DrydockManagementLeaseWorkflow.php
··· 163 163 $log_data = $log->getData(); 164 164 165 165 $type = $type_object->getLogTypeName(); 166 - $data = $type_object->renderLog($log_data); 166 + $data = $type_object->renderLogForText($log_data); 167 167 } else { 168 168 $type = pht('Unknown ("%s")', $type_key); 169 169 $data = null;
+1 -1
src/applications/drydock/view/DrydockLogListView.php
··· 52 52 53 53 $type = $type_object->getLogTypeName(); 54 54 $icon = $type_object->getLogTypeIcon($log_data); 55 - $data = $type_object->renderLog($log_data); 55 + $data = $type_object->renderLogForHTML($log_data); 56 56 $data = phutil_escape_html_newlines($data); 57 57 } else { 58 58 $type = pht('<Unknown: %s>', $type_key);