@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.

Adding paging to transcript pages

Summary:
enable paging by adding a AphrontPagerView to the two
transcript page.

Test Plan:
test the paging on both pages. Also test it with a certain
phid is given.

Reviewed By: epriestley
Reviewers: epriestley, tuomaspelkonen
CC: epriestley, jungejason
Differential Revision: 116

+56 -11
+21 -5
src/applications/herald/controller/transcriptlist/HeraldTranscriptListController.php
··· 22 22 23 23 $request = $this->getRequest(); 24 24 25 + // Get one page of data together with the pager. 25 26 // Pull these objects manually since the serialized fields are gigantic. 26 27 $transcript = new HeraldTranscript(); 27 28 ··· 32 33 $where_clause = qsprintf( 33 34 $conn_r, 34 35 'WHERE objectPHID = %s', 35 - $phid 36 - ); 36 + $phid); 37 37 } 38 38 39 + $offset = $request->getInt('offset', 0); 40 + $page_size = 100; 41 + $limit_clause = qsprintf( 42 + $conn_r, 43 + 'LIMIT %d, %d', 44 + $offset, $page_size + 1); 45 + 39 46 $data = queryfx_all( 40 47 $conn_r, 41 48 'SELECT id, objectPHID, time, duration, dryRun FROM %T 42 49 %Q 43 50 ORDER BY id DESC 44 - LIMIT 100', 51 + %Q', 45 52 $transcript->getTableName(), 46 - $where_clause); 53 + $where_clause, 54 + $limit_clause); 55 + 56 + $pager = new AphrontPagerView(); 57 + $pager->getPageSize($page_size); 58 + $pager->setHasMorePages(count($data) == $page_size + 1); 59 + $pager->setOffset($offset); 60 + $pager->setURI($request->getRequestURI(), 'offset'); 47 61 48 62 /* 49 63 ··· 73 87 $filter); 74 88 */ 75 89 90 + // Render the table. 76 91 $handles = array(); 77 92 if ($data) { 78 93 $phids = ipull($data, 'objectPHID', 'objectPHID'); ··· 118 133 'action', 119 134 )); 120 135 121 - 136 + // Render the whole page. 122 137 $panel = new AphrontPanelView(); 123 138 $panel->setHeader('Herald Transcripts'); 124 139 $panel->appendChild($table); 140 + $panel->appendChild($pager); 125 141 126 142 return $this->buildStandardPageResponse( 127 143 $panel,
+1
src/applications/herald/controller/transcriptlist/__init__.php
··· 11 11 phutil_require_module('phabricator', 'applications/phid/handle/data'); 12 12 phutil_require_module('phabricator', 'storage/qsprintf'); 13 13 phutil_require_module('phabricator', 'storage/queryfx'); 14 + phutil_require_module('phabricator', 'view/control/pager'); 14 15 phutil_require_module('phabricator', 'view/control/table'); 15 16 phutil_require_module('phabricator', 'view/layout/panel'); 16 17
+31 -5
src/applications/metamta/controller/list/PhabricatorMetaMTAListController.php
··· 19 19 class PhabricatorMetaMTAListController extends PhabricatorMetaMTAController { 20 20 21 21 public function processRequest() { 22 - $related_phid = $this->getRequest()->getStr('phid'); 22 + // Get a page of mails together with pager. 23 + $request = $this->getRequest(); 24 + $offset = $request->getInt('offset', 0); 25 + $related_phid = $request->getStr('phid'); 26 + 27 + $pager = new AphrontPagerView(); 28 + $pager->setOffset($offset); 29 + $pager->setURI($request->getRequestURI(), 'offset'); 30 + 31 + $mail = new PhabricatorMetaMTAMail(); 32 + $conn_r = $mail->establishConnection('r'); 23 33 24 34 if ($related_phid) { 25 - $mails = id(new PhabricatorMetaMTAMail())->loadAllWhere( 26 - 'relatedPHID = %s ORDER BY id DESC LIMIT 100', 35 + $where_clause = qsprintf( 36 + $conn_r, 37 + 'WHERE relatedPHID = %s', 27 38 $related_phid); 28 39 } else { 29 - $mails = id(new PhabricatorMetaMTAMail())->loadAllWhere( 30 - '1 = 1 ORDER BY id DESC LIMIT 100'); 40 + $where_clause = 'WHERE 1 = 1'; 31 41 } 32 42 43 + $data = queryfx_all( 44 + $conn_r, 45 + 'SELECT * FROM %T 46 + %Q 47 + ORDER BY id DESC 48 + LIMIT %d, %d', 49 + $mail->getTableName(), 50 + $where_clause, 51 + $pager->getOffset(), $pager->getPageSize() + 1); 52 + $data = $pager->sliceResults($data); 53 + 54 + $mails = $mail->loadAllFromArray($data); 55 + 56 + // Render the details table. 33 57 $rows = array(); 34 58 foreach ($mails as $mail) { 35 59 $rows[] = array( ··· 71 95 'action', 72 96 )); 73 97 98 + // Render the whole page. 74 99 $panel = new AphrontPanelView(); 75 100 $panel->appendChild($table); 76 101 $panel->setHeader('MetaMTA Messages'); 77 102 $panel->setCreateButton('Send New Message', '/mail/send/'); 103 + $panel->appendChild($pager); 78 104 79 105 return $this->buildStandardPageResponse( 80 106 $panel,
+3 -1
src/applications/metamta/controller/list/__init__.php
··· 8 8 9 9 phutil_require_module('phabricator', 'applications/metamta/controller/base'); 10 10 phutil_require_module('phabricator', 'applications/metamta/storage/mail'); 11 + phutil_require_module('phabricator', 'storage/qsprintf'); 12 + phutil_require_module('phabricator', 'storage/queryfx'); 13 + phutil_require_module('phabricator', 'view/control/pager'); 11 14 phutil_require_module('phabricator', 'view/control/table'); 12 15 phutil_require_module('phabricator', 'view/layout/panel'); 13 16 14 17 phutil_require_module('phutil', 'markup'); 15 - phutil_require_module('phutil', 'utils'); 16 18 17 19 18 20 phutil_require_source('PhabricatorMetaMTAListController.php');