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

Add a dedicated HistoryListView for Diffusion

Summary: Going to play a bit with this layout (diffusion sans audit) and see how it feels on profile. Uses a user image, moves the commit hash (easily selectible) and separates commits by date.

Test Plan:
Review profiles with and without commits.

{F4973987}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

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

+166 -9
+2
resources/celerity/map.php
··· 71 71 'rsrc/css/application/differential/revision-history.css' => '0e8eb855', 72 72 'rsrc/css/application/differential/revision-list.css' => 'f3c47d33', 73 73 'rsrc/css/application/differential/table-of-contents.css' => 'ae4b7a55', 74 + 'rsrc/css/application/diffusion/diffusion-history.css' => 'b4ac65b3', 74 75 'rsrc/css/application/diffusion/diffusion-icons.css' => 'a6a1e2ba', 75 76 'rsrc/css/application/diffusion/diffusion-readme.css' => '18bd3910', 76 77 'rsrc/css/application/diffusion/diffusion-source.css' => '750add59', ··· 574 575 'differential-revision-history-css' => '0e8eb855', 575 576 'differential-revision-list-css' => 'f3c47d33', 576 577 'differential-table-of-contents-css' => 'ae4b7a55', 578 + 'diffusion-history-css' => 'b4ac65b3', 577 579 'diffusion-icons-css' => 'a6a1e2ba', 578 580 'diffusion-readme-css' => '18bd3910', 579 581 'diffusion-source-css' => '750add59',
+2
src/__phutil_library_map__.php
··· 728 728 'DiffusionGitSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitSSHWorkflow.php', 729 729 'DiffusionGitUploadPackSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitUploadPackSSHWorkflow.php', 730 730 'DiffusionHistoryController' => 'applications/diffusion/controller/DiffusionHistoryController.php', 731 + 'DiffusionHistoryListView' => 'applications/diffusion/view/DiffusionHistoryListView.php', 731 732 'DiffusionHistoryQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php', 732 733 'DiffusionHistoryTableView' => 'applications/diffusion/view/DiffusionHistoryTableView.php', 733 734 'DiffusionHovercardEngineExtension' => 'applications/diffusion/engineextension/DiffusionHovercardEngineExtension.php', ··· 5694 5695 ), 5695 5696 'DiffusionGitUploadPackSSHWorkflow' => 'DiffusionGitSSHWorkflow', 5696 5697 'DiffusionHistoryController' => 'DiffusionController', 5698 + 'DiffusionHistoryListView' => 'AphrontView', 5697 5699 'DiffusionHistoryQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 5698 5700 'DiffusionHistoryTableView' => 'DiffusionView', 5699 5701 'DiffusionHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension',
+148
src/applications/diffusion/view/DiffusionHistoryListView.php
··· 1 + <?php 2 + 3 + final class DiffusionHistoryListView extends AphrontView { 4 + 5 + private $commits = array(); 6 + private $noDataString; 7 + 8 + public function setNoDataString($no_data_string) { 9 + $this->noDataString = $no_data_string; 10 + return $this; 11 + } 12 + 13 + public function setHeader($header) { 14 + $this->header = $header; 15 + return $this; 16 + } 17 + 18 + public function setCommits(array $commits) { 19 + assert_instances_of($commits, 'PhabricatorRepositoryCommit'); 20 + $this->commits = mpull($commits, null, 'getPHID'); 21 + return $this; 22 + } 23 + 24 + public function getCommits() { 25 + return $this->commits; 26 + } 27 + 28 + private function getCommitDescription($phid) { 29 + if ($this->commits === null) { 30 + return pht('(Unknown Commit)'); 31 + } 32 + 33 + $commit = idx($this->commits, $phid); 34 + if (!$commit) { 35 + return pht('(Unknown Commit)'); 36 + } 37 + 38 + $summary = $commit->getCommitData()->getSummary(); 39 + if (strlen($summary)) { 40 + return $summary; 41 + } 42 + 43 + // No summary, so either this is still importing or just has an empty 44 + // commit message. 45 + 46 + if (!$commit->isImported()) { 47 + return pht('(Importing Commit...)'); 48 + } else { 49 + return pht('(Untitled Commit)'); 50 + } 51 + } 52 + 53 + public function render() { 54 + require_celerity_resource('diffusion-history-css'); 55 + return $this->buildList(); 56 + } 57 + 58 + public function buildList() { 59 + $viewer = $this->getViewer(); 60 + $rowc = array(); 61 + 62 + $phids = array(); 63 + foreach ($this->getCommits() as $commit) { 64 + $phids[] = $commit->getPHID(); 65 + 66 + $author_phid = $commit->getAuthorPHID(); 67 + if ($author_phid) { 68 + $phids[] = $author_phid; 69 + } 70 + } 71 + 72 + $handles = $viewer->loadHandles($phids); 73 + 74 + $cur_date = 0; 75 + $list = null; 76 + $header = null; 77 + $view = array(); 78 + foreach ($this->commits as $commit) { 79 + $new_date = date('Ymd', $commit->getEpoch()); 80 + if ($cur_date != $new_date) { 81 + if ($list) { 82 + $view[] = id(new PHUIObjectBoxView()) 83 + ->setHeader($header) 84 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 85 + ->setObjectList($list); 86 + } 87 + $date = ucfirst( 88 + phabricator_relative_date($commit->getEpoch(), $viewer)); 89 + $header = id(new PHUIHeaderView()) 90 + ->setHeader($date); 91 + $list = id(new PHUIObjectItemListView()) 92 + ->setFlush(true) 93 + ->addClass('diffusion-history-list'); 94 + } 95 + 96 + $commit_phid = $commit->getPHID(); 97 + $commit_handle = $handles[$commit_phid]; 98 + $committed = null; 99 + 100 + $commit_name = $commit_handle->getName(); 101 + $commit_link = $commit_handle->getURI(); 102 + $commit_desc = $this->getCommitDescription($commit_phid); 103 + $committed = phabricator_datetime($commit->getEpoch(), $viewer); 104 + 105 + $author_phid = $commit->getAuthorPHID(); 106 + if ($author_phid) { 107 + $author_name = $handles[$author_phid]->renderLink(); 108 + $author_image_uri = $handles[$author_phid]->getImageURI(); 109 + } else { 110 + $author_name = $commit->getCommitData()->getAuthorName(); 111 + $author_image_uri = 112 + celerity_get_resource_uri('/rsrc/image/people/user0.png'); 113 + } 114 + 115 + $commit_tag = id(new PHUITagView()) 116 + ->setName($commit_name) 117 + ->setType(PHUITagView::TYPE_SHADE) 118 + ->setColor(PHUITagView::COLOR_INDIGO) 119 + ->setSlimShady(true); 120 + 121 + $item = id(new PHUIObjectItemView()) 122 + ->setHeader($commit_desc) 123 + ->setHref($commit_link) 124 + ->setDisabled($commit->isUnreachable()) 125 + ->setImageURI($author_image_uri) 126 + ->addByline(pht('Author: %s', $author_name)) 127 + ->addIcon('none', $committed) 128 + ->addAttribute($commit_tag); 129 + 130 + $list->addItem($item); 131 + $cur_date = $new_date; 132 + } 133 + 134 + if (!$view) { 135 + $list = id(new PHUIObjectItemListView()) 136 + ->setFlush(true) 137 + ->setNoDataString($this->noDataString); 138 + 139 + $view = id(new PHUIObjectBoxView()) 140 + ->setHeaderText(pht('Recent Commits')) 141 + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 142 + ->setObjectList($list); 143 + } 144 + 145 + return $view; 146 + } 147 + 148 + }
+2 -9
src/applications/people/controller/PhabricatorPeopleProfileCommitsController.php
··· 56 56 $commits = id(new DiffusionCommitQuery()) 57 57 ->setViewer($viewer) 58 58 ->withAuthorPHIDs(array($user->getPHID())) 59 - ->needAuditRequests(true) 60 59 ->needCommitData(true) 61 - ->needDrafts(true) 62 60 ->setLimit(100) 63 61 ->execute(); 64 62 65 - $list = id(new PhabricatorAuditListView()) 63 + $list = id(new DiffusionHistoryListView()) 66 64 ->setViewer($viewer) 67 65 ->setCommits($commits) 68 66 ->setNoDataString(pht('No recent commits.')); 69 67 70 - $view = id(new PHUIObjectBoxView()) 71 - ->setHeaderText(pht('Recent Commits')) 72 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 73 - ->appendChild($list); 74 - 75 - return $view; 68 + return $list; 76 69 } 77 70 }
+12
webroot/rsrc/css/application/diffusion/diffusion-history.css
··· 1 + /** 2 + * @provides diffusion-history-css 3 + */ 4 + 5 + .diffusion-history-list .phui-oi-link { 6 + color: {$darkbluetext}; 7 + font-size: {$biggerfontsize}; 8 + } 9 + 10 + .diffusion-history-list .phui-oi-attribute .phui-tag-core { 11 + border-color: transparent; 12 + }