mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 16:22:43 +01:00
Unify more build, property, auditor, and status information into "CommitGraphView"
Summary: Ref T13552. In unifying the various Graph/List/Table commit views, some information was dropped -- particularly, audit status. Restore most of it. The result isn't very pretty, but has most of the required information. Test Plan: {F7637411} Maniphest Tasks: T13552 Differential Revision: https://secure.phabricator.com/D21417
This commit is contained in:
parent
36dac46ff2
commit
8aec3f916b
5 changed files with 216 additions and 69 deletions
|
@ -9,7 +9,7 @@ return array(
|
|||
'names' => array(
|
||||
'conpherence.pkg.css' => '0e3cf785',
|
||||
'conpherence.pkg.js' => '020aebcf',
|
||||
'core.pkg.css' => '9b2e2e20',
|
||||
'core.pkg.css' => '9cb7cb3f',
|
||||
'core.pkg.js' => '845355f4',
|
||||
'dark-console.pkg.js' => '187792c2',
|
||||
'differential.pkg.css' => '5c459f92',
|
||||
|
@ -133,7 +133,7 @@ return array(
|
|||
'rsrc/css/phui/object-item/phui-oi-color.css' => 'b517bfa0',
|
||||
'rsrc/css/phui/object-item/phui-oi-drag-ui.css' => 'da15d3dc',
|
||||
'rsrc/css/phui/object-item/phui-oi-flush-ui.css' => '490e2e2e',
|
||||
'rsrc/css/phui/object-item/phui-oi-list-view.css' => 'd7723ecc',
|
||||
'rsrc/css/phui/object-item/phui-oi-list-view.css' => '4b0def39',
|
||||
'rsrc/css/phui/object-item/phui-oi-simple-ui.css' => '6a30fa46',
|
||||
'rsrc/css/phui/phui-action-list.css' => '1b0085b2',
|
||||
'rsrc/css/phui/phui-action-panel.css' => '6c386cbf',
|
||||
|
@ -866,7 +866,7 @@ return array(
|
|||
'phui-oi-color-css' => 'b517bfa0',
|
||||
'phui-oi-drag-ui-css' => 'da15d3dc',
|
||||
'phui-oi-flush-ui-css' => '490e2e2e',
|
||||
'phui-oi-list-view-css' => 'd7723ecc',
|
||||
'phui-oi-list-view-css' => '4b0def39',
|
||||
'phui-oi-simple-ui-css' => '6a30fa46',
|
||||
'phui-pager-css' => 'd022c7ad',
|
||||
'phui-pinboard-view-css' => '1f08f5d8',
|
||||
|
|
|
@ -222,7 +222,8 @@ final class PhabricatorCommitSearchEngine
|
|||
$bucket = $this->getResultBucket($query);
|
||||
|
||||
$template = id(new DiffusionCommitGraphView())
|
||||
->setViewer($viewer);
|
||||
->setViewer($viewer)
|
||||
->setShowAuditors(true);
|
||||
|
||||
$views = array();
|
||||
if ($bucket) {
|
||||
|
|
|
@ -14,6 +14,8 @@ final class DiffusionCommitGraphView
|
|||
private $buildableMap;
|
||||
private $revisionMap;
|
||||
|
||||
private $showAuditors;
|
||||
|
||||
public function setHistory(array $history) {
|
||||
assert_instances_of($history, 'DiffusionPathChange');
|
||||
$this->history = $history;
|
||||
|
@ -34,6 +36,15 @@ final class DiffusionCommitGraphView
|
|||
return $this->commits;
|
||||
}
|
||||
|
||||
public function setShowAuditors($show_auditors) {
|
||||
$this->showAuditors = $show_auditors;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getShowAuditors() {
|
||||
return $this->showAuditors;
|
||||
}
|
||||
|
||||
public function setParents(array $parents) {
|
||||
$this->parents = $parents;
|
||||
return $this;
|
||||
|
@ -92,10 +103,36 @@ final class DiffusionCommitGraphView
|
|||
}
|
||||
|
||||
private function newObjectItemViews() {
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
require_celerity_resource('diffusion-css');
|
||||
|
||||
$show_builds = $this->shouldShowBuilds();
|
||||
$show_revisions = $this->shouldShowRevisions();
|
||||
$show_auditors = $this->shouldShowAuditors();
|
||||
|
||||
$phids = array();
|
||||
|
||||
if ($show_revisions) {
|
||||
$revision_map = $this->getRevisionMap();
|
||||
foreach ($revision_map as $revisions) {
|
||||
foreach ($revisions as $revision) {
|
||||
$phids[] = $revision->getPHID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($show_auditors) {
|
||||
$commits = $this->getCommitMap();
|
||||
foreach ($commits as $commit) {
|
||||
$audits = $commit->getAudits();
|
||||
foreach ($audits as $auditor) {
|
||||
$phids[] = $auditor->getAuditorPHID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$handles = $viewer->loadHandles($phids);
|
||||
|
||||
$views = array();
|
||||
|
||||
|
@ -111,38 +148,52 @@ final class DiffusionCommitGraphView
|
|||
$short_hash = $this->getCommitObjectName($hash);
|
||||
$is_disabled = $this->getCommitIsDisabled($commit);
|
||||
|
||||
$author_view = $this->getCommitAuthorView($commit);
|
||||
|
||||
$item_view = id(new PHUIObjectItemView())
|
||||
->setViewer($viewer)
|
||||
->setHeader($commit_description)
|
||||
->setObjectName($short_hash)
|
||||
->setHref($commit_link)
|
||||
->setDisabled($is_disabled);
|
||||
|
||||
if ($author_view !== null) {
|
||||
$item_view->addAttribute($author_view);
|
||||
}
|
||||
$this->addBrowseAction($item_view, $hash);
|
||||
|
||||
$browse_button = $this->newBrowseButton($hash);
|
||||
|
||||
$build_view = null;
|
||||
if ($show_builds) {
|
||||
$build_view = $this->newBuildView($hash);
|
||||
$this->addBuildAction($item_view, $hash);
|
||||
}
|
||||
|
||||
$item_view->setSideColumn(
|
||||
array(
|
||||
$build_view,
|
||||
$browse_button,
|
||||
));
|
||||
$this->addAuditAction($item_view, $hash);
|
||||
|
||||
if ($show_auditors) {
|
||||
$auditor_list = $item_view->newPropertyList();
|
||||
if ($commit) {
|
||||
$auditors = $this->newAuditorList($commit, $handles);
|
||||
$auditor_list->addProperty(pht('Auditors'), $auditors);
|
||||
}
|
||||
}
|
||||
|
||||
$property_list = $item_view->newPropertyList();
|
||||
|
||||
if ($commit) {
|
||||
$author_view = $this->getCommitAuthorView($commit);
|
||||
if ($author_view) {
|
||||
$property_list->addProperty(
|
||||
pht('Author'),
|
||||
$this->getCommitAuthorView($commit));
|
||||
}
|
||||
}
|
||||
|
||||
$revision_view = null;
|
||||
if ($show_revisions) {
|
||||
$revision_view = $this->newRevisionView($hash);
|
||||
}
|
||||
if ($commit) {
|
||||
$revisions = $this->getRevisions($commit);
|
||||
if ($revisions) {
|
||||
$revision = head($revisions);
|
||||
$handle = $handles[$revision->getPHID()];
|
||||
|
||||
if ($revision_view !== null) {
|
||||
$item_view->addAttribute($revision_view);
|
||||
$property_list->addProperty(
|
||||
pht('Revision'),
|
||||
$handle->renderLink());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$views[$hash] = $item_view;
|
||||
|
@ -172,6 +223,7 @@ final class DiffusionCommitGraphView
|
|||
$item_view = $views[$hash];
|
||||
|
||||
$list_view = id(new PHUIObjectItemListView())
|
||||
->setViewer($viewer)
|
||||
->setFlush(true)
|
||||
->addItem($item_view);
|
||||
|
||||
|
@ -268,6 +320,10 @@ final class DiffusionCommitGraphView
|
|||
return $show_revisions;
|
||||
}
|
||||
|
||||
private function shouldShowAuditors() {
|
||||
return $this->getShowAuditors();
|
||||
}
|
||||
|
||||
private function newHistoryItems() {
|
||||
$items = array();
|
||||
|
||||
|
@ -367,24 +423,6 @@ final class DiffusionCommitGraphView
|
|||
return $commit->newCommitAuthorView($viewer);
|
||||
}
|
||||
|
||||
private function newBrowseButton($hash) {
|
||||
$repository = $this->getRepository();
|
||||
|
||||
if ($repository) {
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
|
||||
return $this->linkBrowse(
|
||||
$drequest->getPath(),
|
||||
array(
|
||||
'commit' => $hash,
|
||||
'branch' => $drequest->getBranch(),
|
||||
),
|
||||
$as_button = true);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function getCommit($hash) {
|
||||
$commit_map = $this->getCommitMap();
|
||||
return idx($commit_map, $hash);
|
||||
|
@ -399,18 +437,84 @@ final class DiffusionCommitGraphView
|
|||
return $this->commitMap;
|
||||
}
|
||||
|
||||
private function newBuildView($hash) {
|
||||
private function addBrowseAction(PHUIObjectItemView $item, $hash) {
|
||||
$repository = $this->getRepository();
|
||||
|
||||
if (!$repository) {
|
||||
return;
|
||||
}
|
||||
|
||||
$drequest = $this->getDiffusionRequest();
|
||||
$path = $drequest->getPath();
|
||||
|
||||
$uri = $drequest->generateURI(
|
||||
array(
|
||||
'action' => 'browse',
|
||||
'path' => $path,
|
||||
));
|
||||
|
||||
$item->newAction()
|
||||
->setIcon('fa-folder-open-o bluegrey')
|
||||
->setName(pht('Browse Repository'))
|
||||
->setHref($uri);
|
||||
}
|
||||
|
||||
private function addBuildAction(PHUIObjectItemView $item, $hash) {
|
||||
$is_disabled = true;
|
||||
|
||||
$buildable = null;
|
||||
|
||||
$commit = $this->getCommit($hash);
|
||||
if (!$commit) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$buildable = $this->getBuildable($commit);
|
||||
if (!$buildable) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $this->renderBuildable($buildable, 'button');
|
||||
if ($buildable) {
|
||||
$icon = $buildable->getStatusIcon();
|
||||
$color = $buildable->getStatusColor();
|
||||
$name = $buildable->getStatusDisplayName();
|
||||
$uri = $buildable->getURI();
|
||||
} else {
|
||||
$icon = 'fa-times';
|
||||
$color = 'grey';
|
||||
$name = pht('No Builds');
|
||||
$uri = null;
|
||||
}
|
||||
|
||||
$item->newAction()
|
||||
->setIcon($icon.' '.$color)
|
||||
->setName($name)
|
||||
->setHref($uri)
|
||||
->setDisabled(($uri === null));
|
||||
}
|
||||
|
||||
private function addAuditAction(PHUIObjectItemView $item_view, $hash) {
|
||||
$commit = $this->getCommit($hash);
|
||||
|
||||
if ($commit) {
|
||||
$status = $commit->getAuditStatusObject();
|
||||
|
||||
$text = $status->getName();
|
||||
$color = $status->getColor();
|
||||
$icon = $status->getIcon();
|
||||
|
||||
$uri = $commit->getURI();
|
||||
|
||||
$is_disabled = $status->isNoAudit();
|
||||
} else {
|
||||
$text = pht('No Audit');
|
||||
$color = 'grey';
|
||||
$icon = 'fa-times';
|
||||
$uri = null;
|
||||
|
||||
$is_disabled = true;
|
||||
}
|
||||
|
||||
$item_view->newAction()
|
||||
->setIcon($icon.' '.$color)
|
||||
->setName($text)
|
||||
->setHref($uri)
|
||||
->setDisabled($is_disabled);
|
||||
}
|
||||
|
||||
private function getBuildable(PhabricatorRepositoryCommit $commit) {
|
||||
|
@ -428,28 +532,6 @@ final class DiffusionCommitGraphView
|
|||
return $this->buildableMap;
|
||||
}
|
||||
|
||||
private function newRevisionView($hash) {
|
||||
$commit = $this->getCommit($hash);
|
||||
if (!$commit) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$revisions = $this->getRevisions($commit);
|
||||
if (!$revisions) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$revision = head($revisions);
|
||||
|
||||
return id(new PHUITagView())
|
||||
->setName($revision->getMonogram())
|
||||
->setType(PHUITagView::TYPE_SHADE)
|
||||
->setColor(PHUITagView::COLOR_BLUE)
|
||||
->setHref($revision->getURI())
|
||||
->setBorder(PHUITagView::BORDER_NONE)
|
||||
->setSlimShady(true);
|
||||
}
|
||||
|
||||
private function getRevisions(PhabricatorRepositoryCommit $commit) {
|
||||
$revision_map = $this->getRevisionMap();
|
||||
return idx($revision_map, $commit->getPHID(), array());
|
||||
|
@ -510,4 +592,21 @@ final class DiffusionCommitGraphView
|
|||
return $commits;
|
||||
}
|
||||
|
||||
private function newAuditorList(
|
||||
PhabricatorRepositoryCommit $commit,
|
||||
$handles) {
|
||||
|
||||
$auditors = $commit->getAudits();
|
||||
if (!$auditors) {
|
||||
return phutil_tag('em', array(), pht('None'));
|
||||
}
|
||||
|
||||
$auditor_phids = mpull($auditors, 'getAuditorPHID');
|
||||
$auditor_list = $handles->newSublist($auditor_phids)
|
||||
->renderList()
|
||||
->setAsInline(true);
|
||||
|
||||
return $auditor_list;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ final class PHUIObjectItemView extends AphrontTagView {
|
|||
private $bylines = array();
|
||||
private $grippable;
|
||||
private $actions = array();
|
||||
private $actionItems = array();
|
||||
private $headIcons = array();
|
||||
private $disabled;
|
||||
private $imageURI;
|
||||
|
@ -29,6 +30,7 @@ final class PHUIObjectItemView extends AphrontTagView {
|
|||
private $coverImage;
|
||||
private $description;
|
||||
private $clickable;
|
||||
private $propertyLists = array();
|
||||
|
||||
private $selectableName;
|
||||
private $selectableValue;
|
||||
|
@ -212,6 +214,18 @@ final class PHUIObjectItemView extends AphrontTagView {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function newAction() {
|
||||
$action = new PhabricatorActionView();
|
||||
$this->actionItems[] = $action;
|
||||
return $action;
|
||||
}
|
||||
|
||||
public function newPropertyList() {
|
||||
$list = new PHUIPropertyListView();
|
||||
$this->propertyLists[] = $list;
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method has been deprecated, use @{method:setImageIcon} instead.
|
||||
*
|
||||
|
@ -598,6 +612,14 @@ final class PHUIObjectItemView extends AphrontTagView {
|
|||
'');
|
||||
}
|
||||
|
||||
$property_lists = null;
|
||||
if ($this->propertyLists) {
|
||||
$property_lists[] = phutil_tag(
|
||||
'div',
|
||||
array(),
|
||||
$this->propertyLists);
|
||||
}
|
||||
|
||||
$content = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
|
@ -606,6 +628,7 @@ final class PHUIObjectItemView extends AphrontTagView {
|
|||
array(
|
||||
$subhead,
|
||||
$attrs,
|
||||
$property_lists,
|
||||
$this->renderChildren(),
|
||||
));
|
||||
|
||||
|
@ -733,6 +756,23 @@ final class PHUIObjectItemView extends AphrontTagView {
|
|||
));
|
||||
}
|
||||
|
||||
$column4 = null;
|
||||
if ($this->actionItems) {
|
||||
$action_list = id(new PhabricatorActionListView())
|
||||
->setViewer($viewer);
|
||||
|
||||
foreach ($this->actionItems as $action_item) {
|
||||
$action_list->addAction($action_item);
|
||||
}
|
||||
|
||||
$column4 = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
'class' => 'phui-oi-col2 phui-oi-action-list',
|
||||
),
|
||||
$action_list);
|
||||
}
|
||||
|
||||
$table = phutil_tag(
|
||||
'div',
|
||||
array(
|
||||
|
@ -745,6 +785,7 @@ final class PHUIObjectItemView extends AphrontTagView {
|
|||
$column1,
|
||||
$column2,
|
||||
$column3,
|
||||
$column4,
|
||||
)));
|
||||
|
||||
$box = phutil_tag(
|
||||
|
|
|
@ -725,3 +725,9 @@ ul.phui-oi-list-view .phui-oi-selectable
|
|||
padding: 8px 0;
|
||||
background: linear-gradient({$lightbluebackground}, #fff 66%, #fff);
|
||||
}
|
||||
|
||||
.phui-oi-action-list {
|
||||
background: {$lightbluebackground};
|
||||
border-left: 1px solid {$thinblueborder};
|
||||
padding: 4px;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue