@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<?php
2
3final class HeraldWebhookRequestListView
4 extends AphrontView {
5
6 private $requests;
7 private $highlightID;
8
9 /**
10 * @param array<HeraldWebhookRequest> $requests
11 */
12 public function setRequests(array $requests) {
13 assert_instances_of($requests, HeraldWebhookRequest::class);
14 $this->requests = $requests;
15 return $this;
16 }
17
18 public function setHighlightID($highlight_id) {
19 $this->highlightID = $highlight_id;
20 return $this;
21 }
22
23 public function getHighlightID() {
24 return $this->highlightID;
25 }
26
27 public function render() {
28 $viewer = $this->getViewer();
29 $requests = $this->requests;
30
31 $handle_phids = array();
32 foreach ($requests as $request) {
33 $handle_phids[] = $request->getObjectPHID();
34 }
35 $handles = $viewer->loadHandles($handle_phids);
36
37 $highlight_id = $this->getHighlightID();
38
39 $rows = array();
40 $rowc = array();
41 foreach ($requests as $request) {
42 $icon = $request->newStatusIcon();
43
44 if ($highlight_id == $request->getID()) {
45 $rowc[] = 'highlighted';
46 } else {
47 $rowc[] = null;
48 }
49
50 $last_epoch = $request->getLastRequestEpoch();
51 if ($request->getLastRequestEpoch()) {
52 $last_request = phabricator_datetime($last_epoch, $viewer);
53 } else {
54 $last_request = null;
55 }
56
57 $rows[] = array(
58 $request->getID(),
59 $icon,
60 $handles[$request->getObjectPHID()]->renderLink(),
61 $request->getErrorTypeForDisplay(),
62 $request->getErrorCodeForDisplay(),
63 $last_request,
64 );
65 }
66
67 $table = id(new AphrontTableView($rows))
68 ->setRowClasses($rowc)
69 ->setHeaders(
70 array(
71 pht('ID'),
72 null,
73 pht('Object'),
74 pht('Type'),
75 pht('Code'),
76 pht('Requested At'),
77 ))
78 ->setColumnClasses(
79 array(
80 'n',
81 '',
82 'wide',
83 '',
84 '',
85 '',
86 ));
87
88 return $table;
89 }
90
91}