1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-05 12:21:02 +01:00

Use a list view for DiffusionHistory

Summary: This moves Diffusion History to use an easier to parse list view for commits and their (diff, audit, build) status. I left TableView around, which is used on a repositories home, and we can maybe add a "graph view" history back as another controller. Not sure what the real use is for that kind of feature though. I don't have Harbormaster set up locally so I could use another install to give this a run. I also expect to maybe not live with this UI as final, I like the UX, but the icons for indicating status don't really feel great to me, just OK.

Test Plan:
pull various repositories, check various history displays.

{F4980356}

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D18039
This commit is contained in:
Chad Little 2017-05-27 17:55:44 -07:00
parent 87c59c0867
commit c5bb69fd7d
11 changed files with 425 additions and 188 deletions

View file

@ -9,7 +9,7 @@ return array(
'names' => array( 'names' => array(
'conpherence.pkg.css' => 'ff161f2d', 'conpherence.pkg.css' => 'ff161f2d',
'conpherence.pkg.js' => 'b5b51108', 'conpherence.pkg.js' => 'b5b51108',
'core.pkg.css' => '19f6f61f', 'core.pkg.css' => '525ecd1c',
'core.pkg.js' => '1475bd91', 'core.pkg.js' => '1475bd91',
'darkconsole.pkg.js' => '1f9a31bc', 'darkconsole.pkg.js' => '1f9a31bc',
'differential.pkg.css' => '7d4cfa59', 'differential.pkg.css' => '7d4cfa59',
@ -71,7 +71,7 @@ return array(
'rsrc/css/application/differential/revision-history.css' => '0e8eb855', 'rsrc/css/application/differential/revision-history.css' => '0e8eb855',
'rsrc/css/application/differential/revision-list.css' => 'f3c47d33', 'rsrc/css/application/differential/revision-list.css' => 'f3c47d33',
'rsrc/css/application/differential/table-of-contents.css' => 'ae4b7a55', 'rsrc/css/application/differential/table-of-contents.css' => 'ae4b7a55',
'rsrc/css/application/diffusion/diffusion-history.css' => '0c596546', 'rsrc/css/application/diffusion/diffusion-history.css' => '4faf40cd',
'rsrc/css/application/diffusion/diffusion-icons.css' => 'a6a1e2ba', 'rsrc/css/application/diffusion/diffusion-icons.css' => 'a6a1e2ba',
'rsrc/css/application/diffusion/diffusion-readme.css' => '18bd3910', 'rsrc/css/application/diffusion/diffusion-readme.css' => '18bd3910',
'rsrc/css/application/diffusion/diffusion-source.css' => '750add59', 'rsrc/css/application/diffusion/diffusion-source.css' => '750add59',
@ -132,7 +132,7 @@ return array(
'rsrc/css/phui/object-item/phui-oi-color.css' => 'cd2b9b77', 'rsrc/css/phui/object-item/phui-oi-color.css' => 'cd2b9b77',
'rsrc/css/phui/object-item/phui-oi-drag-ui.css' => '08f4ccc3', 'rsrc/css/phui/object-item/phui-oi-drag-ui.css' => '08f4ccc3',
'rsrc/css/phui/object-item/phui-oi-flush-ui.css' => '9d9685d6', 'rsrc/css/phui/object-item/phui-oi-flush-ui.css' => '9d9685d6',
'rsrc/css/phui/object-item/phui-oi-list-view.css' => 'ed19241b', 'rsrc/css/phui/object-item/phui-oi-list-view.css' => '43752968',
'rsrc/css/phui/object-item/phui-oi-simple-ui.css' => 'a8beebea', 'rsrc/css/phui/object-item/phui-oi-simple-ui.css' => 'a8beebea',
'rsrc/css/phui/phui-action-list.css' => 'c01858f4', 'rsrc/css/phui/phui-action-list.css' => 'c01858f4',
'rsrc/css/phui/phui-action-panel.css' => '91c7b835', 'rsrc/css/phui/phui-action-panel.css' => '91c7b835',
@ -158,7 +158,7 @@ return array(
'rsrc/css/phui/phui-header-view.css' => 'a3d1aecd', 'rsrc/css/phui/phui-header-view.css' => 'a3d1aecd',
'rsrc/css/phui/phui-hovercard.css' => 'f0592bcf', 'rsrc/css/phui/phui-hovercard.css' => 'f0592bcf',
'rsrc/css/phui/phui-icon-set-selector.css' => '87db8fee', 'rsrc/css/phui/phui-icon-set-selector.css' => '87db8fee',
'rsrc/css/phui/phui-icon.css' => '4c6d624c', 'rsrc/css/phui/phui-icon.css' => '4c46b6ba',
'rsrc/css/phui/phui-image-mask.css' => 'a8498f9c', 'rsrc/css/phui/phui-image-mask.css' => 'a8498f9c',
'rsrc/css/phui/phui-info-panel.css' => '27ea50a1', 'rsrc/css/phui/phui-info-panel.css' => '27ea50a1',
'rsrc/css/phui/phui-info-view.css' => '6e217679', 'rsrc/css/phui/phui-info-view.css' => '6e217679',
@ -575,7 +575,7 @@ return array(
'differential-revision-history-css' => '0e8eb855', 'differential-revision-history-css' => '0e8eb855',
'differential-revision-list-css' => 'f3c47d33', 'differential-revision-list-css' => 'f3c47d33',
'differential-table-of-contents-css' => 'ae4b7a55', 'differential-table-of-contents-css' => 'ae4b7a55',
'diffusion-history-css' => '0c596546', 'diffusion-history-css' => '4faf40cd',
'diffusion-icons-css' => 'a6a1e2ba', 'diffusion-icons-css' => 'a6a1e2ba',
'diffusion-readme-css' => '18bd3910', 'diffusion-readme-css' => '18bd3910',
'diffusion-source-css' => '750add59', 'diffusion-source-css' => '750add59',
@ -862,7 +862,7 @@ return array(
'phui-hovercard' => '1bd28176', 'phui-hovercard' => '1bd28176',
'phui-hovercard-view-css' => 'f0592bcf', 'phui-hovercard-view-css' => 'f0592bcf',
'phui-icon-set-selector-css' => '87db8fee', 'phui-icon-set-selector-css' => '87db8fee',
'phui-icon-view-css' => '4c6d624c', 'phui-icon-view-css' => '4c46b6ba',
'phui-image-mask-css' => 'a8498f9c', 'phui-image-mask-css' => 'a8498f9c',
'phui-info-panel-css' => '27ea50a1', 'phui-info-panel-css' => '27ea50a1',
'phui-info-view-css' => '6e217679', 'phui-info-view-css' => '6e217679',
@ -875,7 +875,7 @@ return array(
'phui-oi-color-css' => 'cd2b9b77', 'phui-oi-color-css' => 'cd2b9b77',
'phui-oi-drag-ui-css' => '08f4ccc3', 'phui-oi-drag-ui-css' => '08f4ccc3',
'phui-oi-flush-ui-css' => '9d9685d6', 'phui-oi-flush-ui-css' => '9d9685d6',
'phui-oi-list-view-css' => 'ed19241b', 'phui-oi-list-view-css' => '43752968',
'phui-oi-simple-ui-css' => 'a8beebea', 'phui-oi-simple-ui-css' => 'a8beebea',
'phui-pager-css' => '77d8a794', 'phui-pager-css' => '77d8a794',
'phui-pinboard-view-css' => '2495140e', 'phui-pinboard-view-css' => '2495140e',

View file

@ -728,8 +728,10 @@ phutil_register_library_map(array(
'DiffusionGitSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitSSHWorkflow.php', 'DiffusionGitSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitSSHWorkflow.php',
'DiffusionGitUploadPackSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitUploadPackSSHWorkflow.php', 'DiffusionGitUploadPackSSHWorkflow' => 'applications/diffusion/ssh/DiffusionGitUploadPackSSHWorkflow.php',
'DiffusionHistoryController' => 'applications/diffusion/controller/DiffusionHistoryController.php', 'DiffusionHistoryController' => 'applications/diffusion/controller/DiffusionHistoryController.php',
'DiffusionHistoryListView' => 'applications/diffusion/view/DiffusionHistoryListView.php',
'DiffusionHistoryQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php', 'DiffusionHistoryQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionHistoryQueryConduitAPIMethod.php',
'DiffusionHistoryTableView' => 'applications/diffusion/view/DiffusionHistoryTableView.php', 'DiffusionHistoryTableView' => 'applications/diffusion/view/DiffusionHistoryTableView.php',
'DiffusionHistoryView' => 'applications/diffusion/view/DiffusionHistoryView.php',
'DiffusionHovercardEngineExtension' => 'applications/diffusion/engineextension/DiffusionHovercardEngineExtension.php', 'DiffusionHovercardEngineExtension' => 'applications/diffusion/engineextension/DiffusionHovercardEngineExtension.php',
'DiffusionInlineCommentController' => 'applications/diffusion/controller/DiffusionInlineCommentController.php', 'DiffusionInlineCommentController' => 'applications/diffusion/controller/DiffusionInlineCommentController.php',
'DiffusionInlineCommentPreviewController' => 'applications/diffusion/controller/DiffusionInlineCommentPreviewController.php', 'DiffusionInlineCommentPreviewController' => 'applications/diffusion/controller/DiffusionInlineCommentPreviewController.php',
@ -5705,8 +5707,10 @@ phutil_register_library_map(array(
), ),
'DiffusionGitUploadPackSSHWorkflow' => 'DiffusionGitSSHWorkflow', 'DiffusionGitUploadPackSSHWorkflow' => 'DiffusionGitSSHWorkflow',
'DiffusionHistoryController' => 'DiffusionController', 'DiffusionHistoryController' => 'DiffusionController',
'DiffusionHistoryListView' => 'DiffusionHistoryView',
'DiffusionHistoryQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 'DiffusionHistoryQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
'DiffusionHistoryTableView' => 'DiffusionView', 'DiffusionHistoryTableView' => 'DiffusionHistoryView',
'DiffusionHistoryView' => 'DiffusionView',
'DiffusionHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension', 'DiffusionHovercardEngineExtension' => 'PhabricatorHovercardEngineExtension',
'DiffusionInlineCommentController' => 'PhabricatorInlineCommentController', 'DiffusionInlineCommentController' => 'PhabricatorInlineCommentController',
'DiffusionInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController', 'DiffusionInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController',

View file

@ -26,11 +26,6 @@ final class DiffusionHistoryController extends DiffusionController {
'limit' => $pager->getPageSize() + 1, 'limit' => $pager->getPageSize() + 1,
); );
if (!$request->getBool('copies')) {
$params['needDirectChanges'] = true;
$params['needChildChanges'] = true;
}
$history_results = $this->callConduitWithDiffusionRequest( $history_results = $this->callConduitWithDiffusionRequest(
'diffusion.historyquery', 'diffusion.historyquery',
$params); $params);
@ -39,27 +34,12 @@ final class DiffusionHistoryController extends DiffusionController {
$history = $pager->sliceResults($history); $history = $pager->sliceResults($history);
$show_graph = !strlen($drequest->getPath()); $history_list = id(new DiffusionHistoryListView())
$history_table = id(new DiffusionHistoryTableView()) ->setViewer($viewer)
->setUser($request->getUser())
->setDiffusionRequest($drequest) ->setDiffusionRequest($drequest)
->setHistory($history); ->setHistory($history);
$history_table->loadRevisions(); $history_list->loadRevisions();
if ($show_graph) {
$history_table->setParents($history_results['parents']);
$history_table->setIsHead(!$pager->getOffset());
$history_table->setIsTail(!$pager->getHasMorePages());
}
$history_header = $this->buildHistoryHeader($drequest);
$history_panel = id(new PHUIObjectBoxView())
->setHeader($history_header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setTable($history_table)
->setPager($pager);
$header = $this->buildHeader($drequest); $header = $this->buildHeader($drequest);
$crumbs = $this->buildCrumbs( $crumbs = $this->buildCrumbs(
@ -70,44 +50,32 @@ final class DiffusionHistoryController extends DiffusionController {
)); ));
$crumbs->setBorder(true); $crumbs->setBorder(true);
$title = array(
pht('History'),
$repository->getDisplayName(),
);
$pager = id(new PHUIBoxView())
->addClass('mlb')
->appendChild($pager);
$view = id(new PHUITwoColumnView()) $view = id(new PHUITwoColumnView())
->setHeader($header) ->setHeader($header)
->setFooter(array( ->setFooter(array(
$history_panel, $history_list,
$pager,
)); ));
return $this->newPage() return $this->newPage()
->setTitle( ->setTitle($title)
array(
pht('History'),
$repository->getDisplayName(),
))
->setCrumbs($crumbs) ->setCrumbs($crumbs)
->appendChild( ->appendChild($view);
array(
$view,
));
} }
private function buildHeader(DiffusionRequest $drequest) { private function buildHeader(DiffusionRequest $drequest) {
$viewer = $this->getViewer(); $viewer = $this->getViewer();
$tag = $this->renderCommitHashTag($drequest); $tag = $this->renderCommitHashTag($drequest);
$header = id(new PHUIHeaderView())
->setUser($viewer)
->setPolicyObject($drequest->getRepository())
->addTag($tag)
->setHeader($this->renderPathLinks($drequest, $mode = 'history'))
->setHeaderIcon('fa-clock-o');
return $header;
}
private function buildHistoryHeader(DiffusionRequest $drequest) {
$viewer = $this->getViewer();
$browse_uri = $drequest->generateURI( $browse_uri = $drequest->generateURI(
array( array(
'action' => 'browse', 'action' => 'browse',
@ -117,36 +85,18 @@ final class DiffusionHistoryController extends DiffusionController {
->setTag('a') ->setTag('a')
->setText(pht('Browse')) ->setText(pht('Browse'))
->setHref($browse_uri) ->setHref($browse_uri)
->setIcon('fa-files-o'); ->setIcon('fa-code');
// TODO: Sometimes we do have a change view, we need to look at the most
// recent history entry to figure it out.
$request = $this->getRequest();
if ($request->getBool('copies')) {
$branch_name = pht('Hide Copies/Branches');
$branch_uri = $request->getRequestURI()
->alter('offset', null)
->alter('copies', null);
} else {
$branch_name = pht('Show Copies/Branches');
$branch_uri = $request->getRequestURI()
->alter('offset', null)
->alter('copies', true);
}
$branch_button = id(new PHUIButtonView())
->setTag('a')
->setText($branch_name)
->setIcon('fa-code-fork')
->setHref($branch_uri);
$header = id(new PHUIHeaderView()) $header = id(new PHUIHeaderView())
->setHeader(pht('History')) ->setUser($viewer)
->addActionLink($browse_button) ->setPolicyObject($drequest->getRepository())
->addActionLink($branch_button); ->addTag($tag)
->setHeader($this->renderPathLinks($drequest, $mode = 'history'))
->setHeaderIcon('fa-clock-o')
->addActionLink($browse_button);
return $header; return $header;
} }
} }

View file

@ -25,6 +25,28 @@ final class DiffusionCommitListView extends AphrontView {
return $this->commits; return $this->commits;
} }
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
private function getRequiredHandlePHIDs() {
$phids = array();
foreach ($this->history as $item) {
$data = $item->getCommitData();
if ($data) {
if ($data->getCommitDetail('authorPHID')) {
$phids[$data->getCommitDetail('authorPHID')] = true;
}
if ($data->getCommitDetail('committerPHID')) {
$phids[$data->getCommitDetail('committerPHID')] = true;
}
}
}
return array_keys($phids);
}
private function getCommitDescription($phid) { private function getCommitDescription($phid) {
if ($this->commits === null) { if ($this->commits === null) {
return pht('(Unknown Commit)'); return pht('(Unknown Commit)');
@ -114,12 +136,10 @@ final class DiffusionCommitListView extends AphrontView {
if ($author_phid) { if ($author_phid) {
$author_name = $handles[$author_phid]->renderLink(); $author_name = $handles[$author_phid]->renderLink();
$author_image_uri = $handles[$author_phid]->getImageURI(); $author_image_uri = $handles[$author_phid]->getImageURI();
$author_image_href = $handles[$author_phid]->getURI();
} else { } else {
$author_name = $commit->getCommitData()->getAuthorName(); $author_name = $commit->getCommitData()->getAuthorName();
$author_image_uri = $author_image_uri =
celerity_get_resource_uri('/rsrc/image/people/user0.png'); celerity_get_resource_uri('/rsrc/image/people/user0.png');
$author_image_href = null;
} }
$commit_tag = id(new PHUITagView()) $commit_tag = id(new PHUITagView())
@ -134,7 +154,6 @@ final class DiffusionCommitListView extends AphrontView {
->setDisabled($commit->isUnreachable()) ->setDisabled($commit->isUnreachable())
->setDescription($message) ->setDescription($message)
->setImageURI($author_image_uri) ->setImageURI($author_image_uri)
->setImageHref($author_image_href)
->addByline(pht('Author: %s', $author_name)) ->addByline(pht('Author: %s', $author_name))
->addIcon('none', $committed) ->addIcon('none', $committed)
->addAttribute($commit_tag); ->addAttribute($commit_tag);

View file

@ -0,0 +1,225 @@
<?php
final class DiffusionHistoryListView extends DiffusionHistoryView {
public function render() {
$drequest = $this->getDiffusionRequest();
$viewer = $this->getUser();
$repository = $drequest->getRepository();
require_celerity_resource('diffusion-history-css');
Javelin::initBehavior('phabricator-tooltips');
$buildables = $this->loadBuildables(
mpull($this->getHistory(), 'getCommit'));
$show_revisions = PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorDifferentialApplication',
$viewer);
$handles = $viewer->loadHandles($this->getRequiredHandlePHIDs());
$show_builds = PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorHarbormasterApplication',
$this->getUser());
$rows = array();
$ii = 0;
$cur_date = 0;
$list = null;
$header = null;
$view = array();
foreach ($this->getHistory() as $history) {
$epoch = $history->getEpoch();
$new_date = date('Ymd', $history->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($history->getEpoch(), $viewer));
$header = id(new PHUIHeaderView())
->setHeader($date);
$list = id(new PHUIObjectItemListView())
->setFlush(true)
->addClass('diffusion-history-list');
}
if ($epoch) {
$committed = $viewer->formatShortDateTime($epoch);
} else {
$committed = null;
}
$data = $history->getCommitData();
$author_phid = $committer = $committer_phid = null;
if ($data) {
$author_phid = $data->getCommitDetail('authorPHID');
$committer_phid = $data->getCommitDetail('committerPHID');
$committer = $data->getCommitDetail('committer');
}
if ($author_phid && isset($handles[$author_phid])) {
$author_name = $handles[$author_phid]->renderLink();
$author_image = $handles[$author_phid]->getImageURI();
} else {
$author_name = self::renderName($history->getAuthorName());
$author_image =
celerity_get_resource_uri('/rsrc/image/people/user0.png');
}
$different_committer = false;
if ($committer_phid) {
$different_committer = ($committer_phid != $author_phid);
} else if ($committer != '') {
$different_committer = ($committer != $history->getAuthorName());
}
if ($different_committer) {
if ($committer_phid && isset($handles[$committer_phid])) {
$committer = $handles[$committer_phid]->renderLink();
} else {
$committer = self::renderName($committer);
}
$author_name = hsprintf('%s / %s', $author_name, $committer);
}
// We can show details once the message and change have been imported.
$partial_import = PhabricatorRepositoryCommit::IMPORTED_MESSAGE |
PhabricatorRepositoryCommit::IMPORTED_CHANGE;
$commit = $history->getCommit();
if ($commit && $commit->isPartiallyImported($partial_import) && $data) {
$commit_desc = $history->getSummary();
} else {
$commit_desc = phutil_tag('em', array(), pht("Importing\xE2\x80\xA6"));
}
$build_view = null;
if ($show_builds) {
$buildable = idx($buildables, $commit->getPHID());
if ($buildable !== null) {
$build_view = $this->renderBuildable($buildable);
}
}
$browse = $this->linkBrowse(
$history->getPath(),
array(
'commit' => $history->getCommitIdentifier(),
'branch' => $drequest->getBranch(),
'type' => $history->getFileType(),
));
$differential_view = null;
if ($show_revisions && $commit) {
$d_id = idx($this->getRevisions(), $commit->getPHID());
if ($d_id) {
$differential_view = id(new PHUIIconCircleView())
->setIcon('fa-gear')
->setColor('green')
->setState(PHUIIconCircleView::STATE_SUCCESS)
->addSigil('has-tooltip')
->setSize(PHUIIconCircleView::SMALL)
->setHref('/D'.$d_id)
->addClass('mmr')
->setMetadata(
array(
'tip' => 'Revision D'.$d_id,
));
}
}
$status = $commit->getAuditStatus();
$icon = PhabricatorAuditCommitStatusConstants::getStatusIcon($status);
$color = PhabricatorAuditCommitStatusConstants::getStatusColor($status);
$name = PhabricatorAuditCommitStatusConstants::getStatusName($status);
$audit_view = id(new PHUIIconCircleView())
->setIcon('fa-code')
->setColor($color)
->setState($icon)
->addSigil('has-tooltip')
->setSize(PHUIIconCircleView::SMALL)
->addClass('mmr')
->setMetadata(
array(
'tip' => $name,
));
if ($show_builds) {
$buildable = idx($buildables, $commit->getPHID());
if ($buildable !== null) {
$status = $buildable->getBuildableStatus();
$icon = HarbormasterBuildable::getBuildableStatusIcon($status);
$color = HarbormasterBuildable::getBuildableStatusColor($status);
$name = HarbormasterBuildable::getBuildableStatusName($status);
$build_view = id(new PHUIIconCircleView())
->setIcon('fa-recycle')
->setColor($color)
->setState($icon)
->addSigil('has-tooltip')
->setSize(PHUIIconCircleView::SMALL)
->setHref('/'.$buildable->getMonogram())
->addClass('mmr')
->setMetadata(
array(
'tip' => $name,
));
}
}
$message = null;
$commit_link = $repository->getCommitURI(
$history->getCommitIdentifier());
$commit_name = $repository->formatCommitName(
$history->getCommitIdentifier(), $local = true);
$committed = phabricator_datetime($commit->getEpoch(), $viewer);
$author_name = phutil_tag(
'strong',
array(
'class' => 'diffusion-history-author-name',
),
$author_name);
$authored = pht('%s on %s.', $author_name, $committed);
$commit_tag = id(new PHUITagView())
->setName($commit_name)
->setType(PHUITagView::TYPE_SHADE)
->setColor(PHUITagView::COLOR_INDIGO)
->setSlimShady(true);
$browse_button = id(new PHUIButtonView())
->setText(pht('Browse'))
->setIcon('fa-code')
->setTag('a')
->setColor(PHUIButtonView::SIMPLE)
->appendChild($audit_view);
$item = id(new PHUIObjectItemView())
->setHeader($commit_desc)
->setHref($commit_link)
->setDisabled($commit->isUnreachable())
->setDescription($message)
->setImageURI($author_image)
->addAttribute($commit_tag)
->addAttribute($authored)
->setSideColumn(array(
$differential_view,
$audit_view,
$build_view,
$browse_button,
));
$list->addItem($item);
$cur_date = $new_date;
}
return $view;
}
}

View file

@ -1,87 +1,14 @@
<?php <?php
final class DiffusionHistoryTableView extends DiffusionView { final class DiffusionHistoryTableView extends DiffusionHistoryView {
private $history;
private $revisions = array();
private $handles = array();
private $isHead;
private $isTail;
private $parents;
private $filterParents;
public function setHistory(array $history) {
assert_instances_of($history, 'DiffusionPathChange');
$this->history = $history;
return $this;
}
public function loadRevisions() {
$commit_phids = array();
foreach ($this->history as $item) {
if ($item->getCommit()) {
$commit_phids[] = $item->getCommit()->getPHID();
}
}
// TODO: Get rid of this.
$this->revisions = id(new DifferentialRevision())
->loadIDsByCommitPHIDs($commit_phids);
return $this;
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
private function getRequiredHandlePHIDs() {
$phids = array();
foreach ($this->history as $item) {
$data = $item->getCommitData();
if ($data) {
if ($data->getCommitDetail('authorPHID')) {
$phids[$data->getCommitDetail('authorPHID')] = true;
}
if ($data->getCommitDetail('committerPHID')) {
$phids[$data->getCommitDetail('committerPHID')] = true;
}
}
}
return array_keys($phids);
}
public function setParents(array $parents) {
$this->parents = $parents;
return $this;
}
public function setIsHead($is_head) {
$this->isHead = $is_head;
return $this;
}
public function setIsTail($is_tail) {
$this->isTail = $is_tail;
return $this;
}
public function setFilterParents($filter_parents) {
$this->filterParents = $filter_parents;
return $this;
}
public function getFilterParents() {
return $this->filterParents;
}
public function render() { public function render() {
$drequest = $this->getDiffusionRequest(); $drequest = $this->getDiffusionRequest();
$viewer = $this->getUser(); $viewer = $this->getUser();
$buildables = $this->loadBuildables(mpull($this->history, 'getCommit')); $buildables = $this->loadBuildables(
mpull($this->getHistory(), 'getCommit'));
$has_any_build = false; $has_any_build = false;
$show_revisions = PhabricatorApplication::isClassInstalledForViewer( $show_revisions = PhabricatorApplication::isClassInstalledForViewer(
@ -91,14 +18,14 @@ final class DiffusionHistoryTableView extends DiffusionView {
$handles = $viewer->loadHandles($this->getRequiredHandlePHIDs()); $handles = $viewer->loadHandles($this->getRequiredHandlePHIDs());
$graph = null; $graph = null;
if ($this->parents) { if ($this->getParents()) {
$parents = $this->parents; $parents = $this->getParents();
// If we're filtering parents, remove relationships which point to // If we're filtering parents, remove relationships which point to
// commits that are not part of the visible graph. Otherwise, we get // commits that are not part of the visible graph. Otherwise, we get
// a big tree of nonsense when viewing release branches like "stable" // a big tree of nonsense when viewing release branches like "stable"
// versus "master". // versus "master".
if ($this->filterParents) { if ($this->getFilterParents()) {
foreach ($parents as $key => $nodes) { foreach ($parents as $key => $nodes) {
foreach ($nodes as $nkey => $node) { foreach ($nodes as $nkey => $node) {
if (empty($parents[$node])) { if (empty($parents[$node])) {
@ -109,8 +36,8 @@ final class DiffusionHistoryTableView extends DiffusionView {
} }
$graph = id(new PHUIDiffGraphView()) $graph = id(new PHUIDiffGraphView())
->setIsHead($this->isHead) ->setIsHead($this->getIsHead())
->setIsTail($this->isTail) ->setIsTail($this->getIsTail())
->renderGraph($parents); ->renderGraph($parents);
} }
@ -120,7 +47,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
$rows = array(); $rows = array();
$ii = 0; $ii = 0;
foreach ($this->history as $history) { foreach ($this->getHistory() as $history) {
$epoch = $history->getEpoch(); $epoch = $history->getEpoch();
if ($epoch) { if ($epoch) {
@ -209,7 +136,7 @@ final class DiffusionHistoryTableView extends DiffusionView {
$build, $build,
$audit_view, $audit_view,
($commit ? ($commit ?
self::linkRevision(idx($this->revisions, $commit->getPHID())) : self::linkRevision(idx($this->getRevisions(), $commit->getPHID())) :
null), null),
$author, $author,
$summary, $summary,

View file

@ -0,0 +1,101 @@
<?php
abstract class DiffusionHistoryView extends DiffusionView {
private $history;
private $revisions = array();
private $handles = array();
private $isHead;
private $isTail;
private $parents;
private $filterParents;
public function setHistory(array $history) {
assert_instances_of($history, 'DiffusionPathChange');
$this->history = $history;
return $this;
}
public function getHistory() {
return $this->history;
}
public function loadRevisions() {
$commit_phids = array();
foreach ($this->history as $item) {
if ($item->getCommit()) {
$commit_phids[] = $item->getCommit()->getPHID();
}
}
// TODO: Get rid of this.
$this->revisions = id(new DifferentialRevision())
->loadIDsByCommitPHIDs($commit_phids);
return $this;
}
public function getRevisions() {
return $this->revisions;
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}
public function getRequiredHandlePHIDs() {
$phids = array();
foreach ($this->history as $item) {
$data = $item->getCommitData();
if ($data) {
if ($data->getCommitDetail('authorPHID')) {
$phids[$data->getCommitDetail('authorPHID')] = true;
}
if ($data->getCommitDetail('committerPHID')) {
$phids[$data->getCommitDetail('committerPHID')] = true;
}
}
}
return array_keys($phids);
}
public function setParents(array $parents) {
$this->parents = $parents;
return $this;
}
public function getParents() {
return $this->parents;
}
public function setIsHead($is_head) {
$this->isHead = $is_head;
return $this;
}
public function getIsHead() {
return $this->isHead;
}
public function setIsTail($is_tail) {
$this->isTail = $is_tail;
return $this;
}
public function getIsTail() {
return $this->isTail;
}
public function setFilterParents($filter_parents) {
$this->filterParents = $filter_parents;
return $this;
}
public function getFilterParents() {
return $this->filterParents;
}
public function render() {}
}

View file

@ -168,7 +168,7 @@ abstract class DiffusionView extends AphrontView {
'sigil' => 'has-tooltip', 'sigil' => 'has-tooltip',
'meta' => array( 'meta' => array(
'tip' => $email->getAddress(), 'tip' => $email->getAddress(),
'align' => 'E', 'align' => 'S',
'size' => 'auto', 'size' => 'auto',
), ),
), ),
@ -177,30 +177,24 @@ abstract class DiffusionView extends AphrontView {
return hsprintf('%s', $name); return hsprintf('%s', $name);
} }
final protected function renderBuildable(HarbormasterBuildable $buildable) { final protected function renderBuildable(
HarbormasterBuildable $buildable) {
$status = $buildable->getBuildableStatus(); $status = $buildable->getBuildableStatus();
Javelin::initBehavior('phabricator-tooltips');
$icon = HarbormasterBuildable::getBuildableStatusIcon($status); $icon = HarbormasterBuildable::getBuildableStatusIcon($status);
$color = HarbormasterBuildable::getBuildableStatusColor($status); $color = HarbormasterBuildable::getBuildableStatusColor($status);
$name = HarbormasterBuildable::getBuildableStatusName($status); $name = HarbormasterBuildable::getBuildableStatusName($status);
$icon_view = id(new PHUIIconView()) return id(new PHUIIconView())
->setIcon($icon.' '.$color); ->setIcon($icon.' '.$color)
->addSigil('has-tooltip')
$tooltip_view = javelin_tag( ->setHref('/'.$buildable->getMonogram())
'span', ->setMetadata(
array( array(
'sigil' => 'has-tooltip', 'tip' => $name,
'meta' => array('tip' => $name), ));
),
$icon_view);
Javelin::initBehavior('phabricator-tooltips');
return phutil_tag(
'a',
array('href' => '/'.$buildable->getMonogram()),
$tooltip_view);
} }
final protected function loadBuildables(array $commits) { final protected function loadBuildables(array $commits) {

View file

@ -3,7 +3,7 @@
*/ */
.diffusion-history-list .phui-oi-link { .diffusion-history-list .phui-oi-link {
color: {$darkbluetext}; color: #000;
font-size: {$biggerfontsize}; font-size: {$biggerfontsize};
} }
@ -11,6 +11,10 @@
border-color: transparent; border-color: transparent;
} }
.diffusion-history-list .phui-oi-attribute .phui-tag-indigo a {
color: {$indigo};
}
.diffusion-history-message { .diffusion-history-message {
background-color: {$bluebackground}; background-color: {$bluebackground};
padding: 16px; padding: 16px;
@ -18,3 +22,12 @@
border-radius: 5px; border-radius: 5px;
color: {$darkbluetext}; color: {$darkbluetext};
} }
.diffusion-history-list .phui-oi-attribute {
font-size: {$smallerfontsize};
letter-spacing: 0.01em;
}
.diffusion-history-author-name a {
color: {$darkbluetext};
}

View file

@ -182,6 +182,10 @@ ul.phui-oi-list-view {
vertical-align: top; vertical-align: top;
} }
.phui-oi-col2.phui-oi-side-column {
width: 200px;
}
.device-phone .phui-oi-col1, .device-phone .phui-oi-col1,
.device-phone .phui-oi-col2 { .device-phone .phui-oi-col2 {
display: block; display: block;

View file

@ -144,7 +144,7 @@ a.phui-icon-circle.hover-red:hover .phui-icon-view {
color: {$red}; color: {$red};
} }
a.phui-icon-circle .phui-icon-view.phui-icon-circle-state-icon { .phui-icon-circle .phui-icon-view.phui-icon-circle-state-icon {
position: absolute; position: absolute;
width: 14px; width: 14px;
height: 14px; height: 14px;