From 1b36252ef39bfa2f58dbc7b1d54a00d34d489fd7 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Tue, 23 May 2017 14:01:32 -0700 Subject: [PATCH] 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 --- resources/celerity/map.php | 2 + src/__phutil_library_map__.php | 2 + .../view/DiffusionHistoryListView.php | 148 ++++++++++++++++++ ...bricatorPeopleProfileCommitsController.php | 11 +- .../diffusion/diffusion-history.css | 12 ++ 5 files changed, 166 insertions(+), 9 deletions(-) create mode 100644 src/applications/diffusion/view/DiffusionHistoryListView.php create mode 100644 webroot/rsrc/css/application/diffusion/diffusion-history.css diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 2415f90ff1..8329159685 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -71,6 +71,7 @@ return array( 'rsrc/css/application/differential/revision-history.css' => '0e8eb855', 'rsrc/css/application/differential/revision-list.css' => 'f3c47d33', 'rsrc/css/application/differential/table-of-contents.css' => 'ae4b7a55', + 'rsrc/css/application/diffusion/diffusion-history.css' => 'b4ac65b3', 'rsrc/css/application/diffusion/diffusion-icons.css' => 'a6a1e2ba', 'rsrc/css/application/diffusion/diffusion-readme.css' => '18bd3910', 'rsrc/css/application/diffusion/diffusion-source.css' => '750add59', @@ -574,6 +575,7 @@ return array( 'differential-revision-history-css' => '0e8eb855', 'differential-revision-list-css' => 'f3c47d33', 'differential-table-of-contents-css' => 'ae4b7a55', + 'diffusion-history-css' => 'b4ac65b3', 'diffusion-icons-css' => 'a6a1e2ba', 'diffusion-readme-css' => '18bd3910', 'diffusion-source-css' => '750add59', diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 21daf85177..ff287cbb01 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -728,6 +728,7 @@ phutil_register_library_map(array( 'DiffusionGitSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitSSHWorkflow.php', 'DiffusionGitUploadPackSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitUploadPackSSHWorkflow.php', 'DiffusionHistoryController' => 'applications/diffusion/controller/DiffusionHistoryController.php', + 'DiffusionHistoryListView' => 'applications/diffusion/view/DiffusionHistoryListView.php', 'DiffusionHistoryQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php', 'DiffusionHistoryTableView' => 'applications/diffusion/view/DiffusionHistoryTableView.php', 'DiffusionHovercardEngineExtension' => 'applications/diffusion/engineextension/DiffusionHovercardEngineExtension.php', @@ -5694,6 +5695,7 @@ phutil_register_library_map(array( ), 'DiffusionGitUploadPackSSHWorkflow' => 'DiffusionGitSSHWorkflow', 'DiffusionHistoryController' => 'DiffusionController', + 'DiffusionHistoryListView' => 'AphrontView', 'DiffusionHistoryQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 'DiffusionHistoryTableView' => 'DiffusionView', 'DiffusionHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension', diff --git a/src/applications/diffusion/view/DiffusionHistoryListView.php b/src/applications/diffusion/view/DiffusionHistoryListView.php new file mode 100644 index 0000000000..d3223f70db --- /dev/null +++ b/src/applications/diffusion/view/DiffusionHistoryListView.php @@ -0,0 +1,148 @@ +noDataString = $no_data_string; + return $this; + } + + public function setHeader($header) { + $this->header = $header; + return $this; + } + + public function setCommits(array $commits) { + assert_instances_of($commits, 'PhabricatorRepositoryCommit'); + $this->commits = mpull($commits, null, 'getPHID'); + return $this; + } + + public function getCommits() { + return $this->commits; + } + + private function getCommitDescription($phid) { + if ($this->commits === null) { + return pht('(Unknown Commit)'); + } + + $commit = idx($this->commits, $phid); + if (!$commit) { + return pht('(Unknown Commit)'); + } + + $summary = $commit->getCommitData()->getSummary(); + if (strlen($summary)) { + return $summary; + } + + // No summary, so either this is still importing or just has an empty + // commit message. + + if (!$commit->isImported()) { + return pht('(Importing Commit...)'); + } else { + return pht('(Untitled Commit)'); + } + } + + public function render() { + require_celerity_resource('diffusion-history-css'); + return $this->buildList(); + } + + public function buildList() { + $viewer = $this->getViewer(); + $rowc = array(); + + $phids = array(); + foreach ($this->getCommits() as $commit) { + $phids[] = $commit->getPHID(); + + $author_phid = $commit->getAuthorPHID(); + if ($author_phid) { + $phids[] = $author_phid; + } + } + + $handles = $viewer->loadHandles($phids); + + $cur_date = 0; + $list = null; + $header = null; + $view = array(); + foreach ($this->commits as $commit) { + $new_date = date('Ymd', $commit->getEpoch()); + if ($cur_date != $new_date) { + if ($list) { + $view[] = id(new PHUIObjectBoxView()) + ->setHeader($header) + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) + ->setObjectList($list); + } + $date = ucfirst( + phabricator_relative_date($commit->getEpoch(), $viewer)); + $header = id(new PHUIHeaderView()) + ->setHeader($date); + $list = id(new PHUIObjectItemListView()) + ->setFlush(true) + ->addClass('diffusion-history-list'); + } + + $commit_phid = $commit->getPHID(); + $commit_handle = $handles[$commit_phid]; + $committed = null; + + $commit_name = $commit_handle->getName(); + $commit_link = $commit_handle->getURI(); + $commit_desc = $this->getCommitDescription($commit_phid); + $committed = phabricator_datetime($commit->getEpoch(), $viewer); + + $author_phid = $commit->getAuthorPHID(); + if ($author_phid) { + $author_name = $handles[$author_phid]->renderLink(); + $author_image_uri = $handles[$author_phid]->getImageURI(); + } else { + $author_name = $commit->getCommitData()->getAuthorName(); + $author_image_uri = + celerity_get_resource_uri('/rsrc/image/people/user0.png'); + } + + $commit_tag = id(new PHUITagView()) + ->setName($commit_name) + ->setType(PHUITagView::TYPE_SHADE) + ->setColor(PHUITagView::COLOR_INDIGO) + ->setSlimShady(true); + + $item = id(new PHUIObjectItemView()) + ->setHeader($commit_desc) + ->setHref($commit_link) + ->setDisabled($commit->isUnreachable()) + ->setImageURI($author_image_uri) + ->addByline(pht('Author: %s', $author_name)) + ->addIcon('none', $committed) + ->addAttribute($commit_tag); + + $list->addItem($item); + $cur_date = $new_date; + } + + if (!$view) { + $list = id(new PHUIObjectItemListView()) + ->setFlush(true) + ->setNoDataString($this->noDataString); + + $view = id(new PHUIObjectBoxView()) + ->setHeaderText(pht('Recent Commits')) + ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) + ->setObjectList($list); + } + + return $view; + } + +} diff --git a/src/applications/people/controller/PhabricatorPeopleProfileCommitsController.php b/src/applications/people/controller/PhabricatorPeopleProfileCommitsController.php index 3e1e6de1ee..81e4fa304e 100644 --- a/src/applications/people/controller/PhabricatorPeopleProfileCommitsController.php +++ b/src/applications/people/controller/PhabricatorPeopleProfileCommitsController.php @@ -56,22 +56,15 @@ final class PhabricatorPeopleProfileCommitsController $commits = id(new DiffusionCommitQuery()) ->setViewer($viewer) ->withAuthorPHIDs(array($user->getPHID())) - ->needAuditRequests(true) ->needCommitData(true) - ->needDrafts(true) ->setLimit(100) ->execute(); - $list = id(new PhabricatorAuditListView()) + $list = id(new DiffusionHistoryListView()) ->setViewer($viewer) ->setCommits($commits) ->setNoDataString(pht('No recent commits.')); - $view = id(new PHUIObjectBoxView()) - ->setHeaderText(pht('Recent Commits')) - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) - ->appendChild($list); - - return $view; + return $list; } } diff --git a/webroot/rsrc/css/application/diffusion/diffusion-history.css b/webroot/rsrc/css/application/diffusion/diffusion-history.css new file mode 100644 index 0000000000..796b4b6059 --- /dev/null +++ b/webroot/rsrc/css/application/diffusion/diffusion-history.css @@ -0,0 +1,12 @@ +/** + * @provides diffusion-history-css + */ + +.diffusion-history-list .phui-oi-link { + color: {$darkbluetext}; + font-size: {$biggerfontsize}; +} + +.diffusion-history-list .phui-oi-attribute .phui-tag-core { + border-color: transparent; +}