mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-14 02:42:40 +01:00
Remove "PhabricatorAuditListView"
Summary: Ref T13552. Remove yet another way to render a list of commits, and unify it with "CommitGraphView". Test Plan: - Viewed commit search results. - Viewed owners package detail page. Maniphest Tasks: T13552 Differential Revision: https://secure.phabricator.com/D21415
This commit is contained in:
parent
2b0632b442
commit
57ee6649aa
4 changed files with 28 additions and 202 deletions
|
@ -2274,7 +2274,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorAuditController' => 'applications/audit/controller/PhabricatorAuditController.php',
|
'PhabricatorAuditController' => 'applications/audit/controller/PhabricatorAuditController.php',
|
||||||
'PhabricatorAuditEditor' => 'applications/audit/editor/PhabricatorAuditEditor.php',
|
'PhabricatorAuditEditor' => 'applications/audit/editor/PhabricatorAuditEditor.php',
|
||||||
'PhabricatorAuditInlineComment' => 'applications/audit/storage/PhabricatorAuditInlineComment.php',
|
'PhabricatorAuditInlineComment' => 'applications/audit/storage/PhabricatorAuditInlineComment.php',
|
||||||
'PhabricatorAuditListView' => 'applications/audit/view/PhabricatorAuditListView.php',
|
|
||||||
'PhabricatorAuditMailReceiver' => 'applications/audit/mail/PhabricatorAuditMailReceiver.php',
|
'PhabricatorAuditMailReceiver' => 'applications/audit/mail/PhabricatorAuditMailReceiver.php',
|
||||||
'PhabricatorAuditManagementDeleteWorkflow' => 'applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php',
|
'PhabricatorAuditManagementDeleteWorkflow' => 'applications/audit/management/PhabricatorAuditManagementDeleteWorkflow.php',
|
||||||
'PhabricatorAuditManagementWorkflow' => 'applications/audit/management/PhabricatorAuditManagementWorkflow.php',
|
'PhabricatorAuditManagementWorkflow' => 'applications/audit/management/PhabricatorAuditManagementWorkflow.php',
|
||||||
|
@ -8586,7 +8585,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorAuditController' => 'PhabricatorController',
|
'PhabricatorAuditController' => 'PhabricatorController',
|
||||||
'PhabricatorAuditEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhabricatorAuditEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhabricatorAuditInlineComment' => 'PhabricatorInlineComment',
|
'PhabricatorAuditInlineComment' => 'PhabricatorInlineComment',
|
||||||
'PhabricatorAuditListView' => 'AphrontView',
|
|
||||||
'PhabricatorAuditMailReceiver' => 'PhabricatorObjectMailReceiver',
|
'PhabricatorAuditMailReceiver' => 'PhabricatorObjectMailReceiver',
|
||||||
'PhabricatorAuditManagementDeleteWorkflow' => 'PhabricatorAuditManagementWorkflow',
|
'PhabricatorAuditManagementDeleteWorkflow' => 'PhabricatorAuditManagementWorkflow',
|
||||||
'PhabricatorAuditManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
'PhabricatorAuditManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
||||||
|
|
|
@ -221,9 +221,8 @@ final class PhabricatorCommitSearchEngine
|
||||||
|
|
||||||
$bucket = $this->getResultBucket($query);
|
$bucket = $this->getResultBucket($query);
|
||||||
|
|
||||||
$template = id(new PhabricatorAuditListView())
|
$template = id(new DiffusionCommitGraphView())
|
||||||
->setViewer($viewer)
|
->setViewer($viewer);
|
||||||
->setShowDrafts(true);
|
|
||||||
|
|
||||||
$views = array();
|
$views = array();
|
||||||
if ($bucket) {
|
if ($bucket) {
|
||||||
|
@ -235,37 +234,31 @@ final class PhabricatorCommitSearchEngine
|
||||||
foreach ($groups as $group) {
|
foreach ($groups as $group) {
|
||||||
// Don't show groups in Dashboard Panels
|
// Don't show groups in Dashboard Panels
|
||||||
if ($group->getObjects() || !$this->isPanelContext()) {
|
if ($group->getObjects() || !$this->isPanelContext()) {
|
||||||
$views[] = id(clone $template)
|
$item_list = id(clone $template)
|
||||||
|
->setCommits($group->getObjects())
|
||||||
|
->newObjectItemListView();
|
||||||
|
|
||||||
|
$views[] = $item_list
|
||||||
->setHeader($group->getName())
|
->setHeader($group->getName())
|
||||||
->setNoDataString($group->getNoDataString())
|
->setNoDataString($group->getNoDataString());
|
||||||
->setCommits($group->getObjects());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
$this->addError($ex->getMessage());
|
$this->addError($ex->getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$views[] = id(clone $template)
|
|
||||||
->setCommits($commits)
|
|
||||||
->setNoDataString(pht('No commits found.'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$views) {
|
if (!$views) {
|
||||||
$views[] = id(new PhabricatorAuditListView())
|
$item_list = id(clone $template)
|
||||||
->setViewer($viewer)
|
->setCommits($commits)
|
||||||
|
->newObjectItemListView();
|
||||||
|
|
||||||
|
$views[] = $item_list
|
||||||
->setNoDataString(pht('No commits found.'));
|
->setNoDataString(pht('No commits found.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($views) == 1) {
|
return id(new PhabricatorApplicationSearchResultView())
|
||||||
$list = head($views)->buildList();
|
->setContent($views);
|
||||||
} else {
|
|
||||||
$list = $views;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = new PhabricatorApplicationSearchResultView();
|
|
||||||
$result->setContent($list);
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getNewUserBody() {
|
protected function getNewUserBody() {
|
||||||
|
|
|
@ -1,171 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhabricatorAuditListView extends AphrontView {
|
|
||||||
|
|
||||||
private $commits = array();
|
|
||||||
private $header;
|
|
||||||
private $showDrafts;
|
|
||||||
private $noDataString;
|
|
||||||
private $highlightedAudits;
|
|
||||||
|
|
||||||
public function setNoDataString($no_data_string) {
|
|
||||||
$this->noDataString = $no_data_string;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNoDataString() {
|
|
||||||
return $this->noDataString;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setHeader($header) {
|
|
||||||
$this->header = $header;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getHeader() {
|
|
||||||
return $this->header;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setShowDrafts($show_drafts) {
|
|
||||||
$this->showDrafts = $show_drafts;
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShowDrafts() {
|
|
||||||
return $this->showDrafts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* These commits should have both commit data and audit requests attached.
|
|
||||||
*/
|
|
||||||
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() {
|
|
||||||
$list = $this->buildList();
|
|
||||||
$list->setFlush(true);
|
|
||||||
return $list->render();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function buildList() {
|
|
||||||
$viewer = $this->getViewer();
|
|
||||||
$rowc = array();
|
|
||||||
|
|
||||||
$phids = array();
|
|
||||||
foreach ($this->getCommits() as $commit) {
|
|
||||||
$phids[] = $commit->getPHID();
|
|
||||||
|
|
||||||
foreach ($commit->getAudits() as $audit) {
|
|
||||||
$phids[] = $audit->getAuditorPHID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$handles = $viewer->loadHandles($phids);
|
|
||||||
|
|
||||||
$show_drafts = $this->getShowDrafts();
|
|
||||||
|
|
||||||
$draft_icon = id(new PHUIIconView())
|
|
||||||
->setIcon('fa-comment yellow')
|
|
||||||
->addSigil('has-tooltip')
|
|
||||||
->setMetadata(
|
|
||||||
array(
|
|
||||||
'tip' => pht('Unsubmitted Comments'),
|
|
||||||
));
|
|
||||||
|
|
||||||
$list = new PHUIObjectItemListView();
|
|
||||||
foreach ($this->commits as $commit) {
|
|
||||||
$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);
|
|
||||||
|
|
||||||
$status = $commit->getAuditStatusObject();
|
|
||||||
|
|
||||||
$status_text = $status->getName();
|
|
||||||
$status_color = $status->getColor();
|
|
||||||
$status_icon = $status->getIcon();
|
|
||||||
|
|
||||||
$item = id(new PHUIObjectItemView())
|
|
||||||
->setObjectName($commit_name)
|
|
||||||
->setHeader($commit_desc)
|
|
||||||
->setHref($commit_link)
|
|
||||||
->setDisabled($commit->isUnreachable())
|
|
||||||
->addIcon('none', $committed);
|
|
||||||
|
|
||||||
$author_name = $commit->newCommitAuthorView($viewer);
|
|
||||||
if ($author_name) {
|
|
||||||
$item->addByline(pht('Author: %s', $author_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($show_drafts) {
|
|
||||||
if ($commit->getHasDraft($viewer)) {
|
|
||||||
$item->addAttribute($draft_icon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$audits = $commit->getAudits();
|
|
||||||
$auditor_phids = mpull($audits, 'getAuditorPHID');
|
|
||||||
if ($auditor_phids) {
|
|
||||||
$auditor_list = $handles->newSublist($auditor_phids)
|
|
||||||
->renderList()
|
|
||||||
->setAsInline(true);
|
|
||||||
} else {
|
|
||||||
$auditor_list = phutil_tag('em', array(), pht('None'));
|
|
||||||
}
|
|
||||||
$item->addAttribute(pht('Auditors: %s', $auditor_list));
|
|
||||||
|
|
||||||
if ($status_color) {
|
|
||||||
$item->setStatusIcon($status_icon.' '.$status_color, $status_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
$list->addItem($item);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->noDataString) {
|
|
||||||
$list->setNoDataString($this->noDataString);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->header) {
|
|
||||||
$list->setHeader($this->header);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $list;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -82,12 +82,15 @@ final class PhabricatorOwnersDetailController
|
||||||
))
|
))
|
||||||
->needCommitData(true)
|
->needCommitData(true)
|
||||||
->needAuditRequests(true)
|
->needAuditRequests(true)
|
||||||
|
->needIdentities(true)
|
||||||
->setLimit(10)
|
->setLimit(10)
|
||||||
->execute();
|
->execute();
|
||||||
$view = id(new PhabricatorAuditListView())
|
$view = id(new DiffusionCommitGraphView())
|
||||||
->setUser($viewer)
|
->setViewer($viewer)
|
||||||
->setNoDataString(pht('This package has no open problem commits.'))
|
->setCommits($attention_commits)
|
||||||
->setCommits($attention_commits);
|
->newObjectItemListView();
|
||||||
|
|
||||||
|
$view->setNoDataString(pht('This package has no open problem commits.'));
|
||||||
|
|
||||||
$commit_views[] = array(
|
$commit_views[] = array(
|
||||||
'view' => $view,
|
'view' => $view,
|
||||||
|
@ -105,13 +108,16 @@ final class PhabricatorOwnersDetailController
|
||||||
->withPackagePHIDs(array($package->getPHID()))
|
->withPackagePHIDs(array($package->getPHID()))
|
||||||
->needCommitData(true)
|
->needCommitData(true)
|
||||||
->needAuditRequests(true)
|
->needAuditRequests(true)
|
||||||
|
->needIdentities(true)
|
||||||
->setLimit(25)
|
->setLimit(25)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
$view = id(new PhabricatorAuditListView())
|
$view = id(new DiffusionCommitGraphView())
|
||||||
->setUser($viewer)
|
->setViewer($viewer)
|
||||||
->setCommits($all_commits)
|
->setCommits($all_commits)
|
||||||
->setNoDataString(pht('No commits in this package.'));
|
->newObjectItemListView();
|
||||||
|
|
||||||
|
$view->setNoDataString(pht('No commits in this package.'));
|
||||||
|
|
||||||
$commit_views[] = array(
|
$commit_views[] = array(
|
||||||
'view' => $view,
|
'view' => $view,
|
||||||
|
|
Loading…
Reference in a new issue