1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 16:30:59 +01:00

Clean up file browse view a bit

Summary:
  - Use DiffusionCommitQuery
  - Get rid of the "Author" column.
  - Collapse commit + revision together.
  - Better tooltips to cover for the removed information.
  - Colorize only the "line" column.
  - Generally, reduce the amount of visual noise and non-code-stuff going on in this interface.
  - I'd like to make the "<<" thing look nicer too but that might take some actual design.

Test Plan: See screenshots.

Reviewers: btrahan, chad

Reviewed By: chad

CC: chad, aran

Differential Revision: https://secure.phabricator.com/D7457
This commit is contained in:
epriestley 2013-10-30 13:15:26 -07:00
parent d51ae49f61
commit 93d7a1451b
3 changed files with 95 additions and 64 deletions

View file

@ -1154,7 +1154,7 @@ celerity_register_resource_map(array(
),
'diffusion-source-css' =>
array(
'uri' => '/res/f4a2f867/rsrc/css/application/diffusion/diffusion-source.css',
'uri' => '/res/5076c269/rsrc/css/application/diffusion/diffusion-source.css',
'type' => 'css',
'requires' =>
array(

View file

@ -548,35 +548,49 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
++$line_number;
}
$request = $this->getRequest();
$viewer = $request->getUser();
$commits = array_filter(ipull($display, 'commit'));
if ($commits) {
$commits = id(new PhabricatorAuditCommitQuery())
->withIdentifiers($drequest->getRepository()->getID(), $commits)
->needCommitData(true)
$commits = id(new DiffusionCommitQuery())
->setViewer($viewer)
->withRepositoryIDs(array($drequest->getRepository()->getID()))
->withIdentifiers($commits)
->execute();
$commits = mpull($commits, null, 'getCommitIdentifier');
}
$request = $this->getRequest();
$user = $request->getUser();
$revision_ids = id(new DifferentialRevision())
->loadIDsByCommitPHIDs(mpull($commits, 'getPHID'));
$revisions = array();
if ($revision_ids) {
$revisions = id(new DifferentialRevisionQuery())
->setViewer($user)
->setViewer($viewer)
->withIDs($revision_ids)
->execute();
}
$phids = array();
foreach ($commits as $commit) {
if ($commit->getAuthorPHID()) {
$phids[] = $commit->getAuthorPHID();
}
}
foreach ($revisions as $revision) {
if ($revision->getAuthorPHID()) {
$phids[] = $revision->getAuthorPHID();
}
}
$handles = $this->loadViewerHandles($phids);
Javelin::initBehavior('phabricator-oncopy', array());
$engine = null;
$inlines = array();
if ($this->getRequest()->getStr('lint') !== null && $this->lintMessages) {
$engine = new PhabricatorMarkupEngine();
$engine->setViewer($user);
$engine->setViewer($viewer);
foreach ($this->lintMessages as $message) {
$inline = id(new PhabricatorAuditInlineComment())
@ -624,15 +638,15 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
if (idx($line, 'commit')) {
$commit = $line['commit'];
$summary = 'Unknown';
if (idx($commits, $commit)) {
$summary = $commits[$commit]->getCommitData()->getSummary();
$tooltip = $this->renderCommitTooltip(
$commits[$commit],
$handles,
$line['author']);
} else {
$tooltip = null;
}
$tooltip = phabricator_date(
$line['epoch'],
$user)." \xC2\xB7 ".$summary;
Javelin::initBehavior('phabricator-tooltips', array());
require_celerity_resource('aphront-tooltip-css');
@ -660,26 +674,21 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
if ($revision_id) {
$revision = idx($revisions, $revision_id);
if (!$revision) {
$tooltip = pht('(Invalid revision)');
} else {
$tooltip =
phabricator_date($revision->getDateModified(), $user).
" \xC2\xB7 ".
$revision->getTitle();
}
$revision_link = javelin_tag(
'a',
array(
'href' => '/D'.$revision_id,
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $tooltip,
'align' => 'E',
'size' => 600,
if ($revision) {
$tooltip = $this->renderRevisionTooltip($revision, $handles);
$revision_link = javelin_tag(
'a',
array(
'href' => '/D'.$revision->getID(),
'sigil' => 'has-tooltip',
'meta' => array(
'tip' => $tooltip,
'align' => 'E',
'size' => 600,
),
),
),
'D'.$revision_id);
'D'.$revision->getID());
}
}
$uri = $line_href->alter('before', $commit);
@ -701,39 +710,29 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
'th',
array(
'class' => 'diffusion-blame-link',
'style' => $style,
),
$before_link);
$blame[] = phutil_tag(
'th',
array(
'class' => 'diffusion-rev-link',
'style' => $style,
),
$commit_link);
$object_links = array();
$object_links[] = $commit_link;
if ($revision_link) {
$object_links[] = phutil_tag('span', array(), '/');
$object_links[] = $revision_link;
}
$blame[] = phutil_tag(
'th',
array(
'class' => 'diffusion-rev-link',
'style' => $style,
),
$revision_link);
$blame[] = phutil_tag(
'th',
array(
'class' => 'diffusion-author-link',
'style' => $style,
),
idx($line, 'author'));
$object_links);
}
$line_link = phutil_tag(
'a',
array(
'href' => $line_href,
'style' => $style,
),
$line['line']);
@ -977,4 +976,36 @@ final class DiffusionBrowseFileController extends DiffusionBrowseController {
return head($parents);
}
private function renderRevisionTooltip(
DifferentialRevision $revision,
array $handles) {
$viewer = $this->getRequest()->getUser();
$date = phabricator_date($revision->getDateModified(), $viewer);
$id = $revision->getID();
$title = $revision->getTitle();
$header = "D{$id} {$title}";
$author = $handles[$revision->getAuthorPHID()]->getName();
return "{$header}\n{$date} \xC2\xB7 {$author}";
}
private function renderCommitTooltip(
PhabricatorRepositoryCommit $commit,
array $handles,
$author) {
$viewer = $this->getRequest()->getUser();
$date = phabricator_date($commit->getEpoch(), $viewer);
$summary = trim($commit->getSummary());
if ($commit->getAuthorPHID()) {
$author = $handles[$commit->getAuthorPHID()]->getName();
}
return "{$summary}\n{$date} \xC2\xB7 {$author}";
}
}

View file

@ -37,8 +37,7 @@
}
.diffusion-blame-link,
.diffusion-rev-link,
.diffusion-author-link {
.diffusion-rev-link {
white-space: nowrap;
}
@ -46,26 +45,27 @@
min-width: 28px;
}
.diffusion-rev-link {
min-width: 90px;
}
.diffusion-author-link {
min-width: 120px;
.diffusion-source th.diffusion-rev-link {
text-align: left;
min-width: 130px;
}
.diffusion-blame-link a,
.diffusion-rev-link a,
.diffusion-author-link a,
.diffusion-line-link a {
color: {$darkbluetext};
}
.diffusion-rev-link a,
.diffusion-author-link span,
.diffusion-author-link a {
.diffusion-rev-link span {
margin: 2px 8px 0;
display: block;
display: inline-block;
}
.diffusion-rev-link span {
margin-right: -4px;
margin-left: -4px;
color: {$lightgreytext};
}
.diffusion-blame-link a,