1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Show small author portraits in Diffusion blame view

Summary: Depends on D18746. See PHI174. Adds small author portraits next to each blame line (this is similar to GitHub).

Test Plan:
My local test data isn't that great since I don't have commits from a lot of accounts, but looks functional:

{F5251056}

Reviewers: amckinley

Reviewed By: amckinley

Differential Revision: https://secure.phabricator.com/D18747
This commit is contained in:
epriestley 2017-10-31 11:28:31 -07:00
parent 90d0f8ac6c
commit bde71324f8
3 changed files with 62 additions and 3 deletions

View file

@ -73,7 +73,7 @@ return array(
'rsrc/css/application/diffusion/diffusion-icons.css' => '0c15255e',
'rsrc/css/application/diffusion/diffusion-readme.css' => '419dd5b6',
'rsrc/css/application/diffusion/diffusion-repository.css' => 'ee6f20ec',
'rsrc/css/application/diffusion/diffusion-source.css' => '3a1056d8',
'rsrc/css/application/diffusion/diffusion-source.css' => 'd96b3f9f',
'rsrc/css/application/diffusion/diffusion.css' => '45727264',
'rsrc/css/application/feed/feed.css' => 'ecd4ec57',
'rsrc/css/application/files/global-drag-and-drop.css' => 'b556a948',
@ -572,7 +572,7 @@ return array(
'diffusion-icons-css' => '0c15255e',
'diffusion-readme-css' => '419dd5b6',
'diffusion-repository-css' => 'ee6f20ec',
'diffusion-source-css' => '3a1056d8',
'diffusion-source-css' => 'd96b3f9f',
'diviner-shared-css' => '896f1d43',
'font-fontawesome' => 'e838e088',
'font-lato' => 'c7ccd872',

View file

@ -969,6 +969,24 @@ final class DiffusionBrowseController extends DiffusionController {
$handles = $viewer->loadHandles($phids);
$author_phids = array();
$author_map = array();
foreach ($blame_commits as $commit) {
$commit_identifier = $commit->getCommitIdentifier();
$author_phid = '';
if (isset($revision_map[$commit_identifier])) {
$revision_id = $revision_map[$commit_identifier];
$revision = $revisions[$revision_id];
$author_phid = $revision->getAuthorPHID();
} else {
$author_phid = $commit->getAuthorPHID();
}
$author_map[$commit_identifier] = $author_phid;
$author_phids[$author_phid] = $author_phid;
}
$colors = array();
if ($blame_commits) {
$epochs = array();
@ -1113,6 +1131,7 @@ final class DiffusionBrowseController extends DiffusionController {
// blame outputs.
$commit_links = $this->renderCommitLinks($blame_commits, $handles);
$revision_links = $this->renderRevisionLinks($revisions, $handles);
$author_links = $this->renderAuthorLinks($author_map, $handles);
if ($this->coverage) {
require_celerity_resource('differential-changeset-view-css');
@ -1145,6 +1164,7 @@ final class DiffusionBrowseController extends DiffusionController {
$revision_link = null;
$commit_link = null;
$author_link = null;
$before_link = null;
$style = 'background: '.$line['color'].';';
@ -1152,6 +1172,7 @@ final class DiffusionBrowseController extends DiffusionController {
if ($identifier && !$line['duplicate']) {
if (isset($commit_links[$identifier])) {
$commit_link = $commit_links[$identifier];
$author_link = $author_links[$author_map[$identifier]];
}
if (isset($revision_map[$identifier])) {
@ -1185,6 +1206,7 @@ final class DiffusionBrowseController extends DiffusionController {
$before_link);
$object_links = array();
$object_links[] = $author_link;
$object_links[] = $commit_link;
if ($revision_link) {
$object_links[] = phutil_tag('span', array(), '/');
@ -1772,6 +1794,33 @@ final class DiffusionBrowseController extends DiffusionController {
return array($identifiers, $commits);
}
private function renderAuthorLinks(array $authors, $handles) {
$links = array();
foreach ($authors as $phid) {
if (!strlen($phid)) {
// This means we couldn't identify an author for the commit or the
// revision. We just render a blank for alignment.
$style = null;
$href = null;
} else {
$src = $handles[$phid]->getImageURI();
$style = 'background-image: url('.$src.');';
$href = $handles[$phid]->getURI();
}
$links[$phid] = javelin_tag(
$href ? 'a' : 'span',
array(
'class' => 'diffusion-author-link',
'style' => $style,
'href' => $href,
));
}
return $links;
}
private function renderCommitLinks(array $commits, $handles) {
$links = array();
foreach ($commits as $identifier => $commit) {

View file

@ -66,7 +66,7 @@
.diffusion-rev-link a,
.diffusion-rev-link span {
margin: 2px 8px 0;
margin: 0 8px 0 0;
display: inline-block;
}
@ -90,3 +90,13 @@
-ms-user-select: none;
user-select: none;
}
.diffusion-rev-link .diffusion-author-link {
display: inline-block;
padding: 0;
margin: 2px 4px -4px 4px;
width: 16px;
height: 16px;
background-size: 100% 100%;
background-repeat: no-repeat;
}