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

added repository filter view to Audit

Test Plan: created some audit requests, browsed around. displayed fine

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2582

Differential Revision: https://secure.phabricator.com/D5135
This commit is contained in:
Anh Nhan Nguyen 2013-02-27 08:31:05 -08:00 committed by epriestley
parent fe78944c9d
commit ff1a679709
3 changed files with 63 additions and 4 deletions

View file

@ -52,6 +52,10 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$title = pht('Choose A Project');
$message = pht('Choose a project to view audits for.');
break;
case 'repository':
$title = pht('Choose A Repository');
$message = pht('Choose a repository to view audits for.');
break;
case 'package':
case 'packagecommits':
$title = pht('Choose a Package');
@ -88,6 +92,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$nav->addFilter('user', pht('By User'));
$nav->addFilter('project', pht('By Project'));
$nav->addFilter('package', pht('By Package'));
$nav->addFilter('repository', pht('By Repository'));
$nav->addLabel(pht('Commits'));
$nav->addFilter('commits', pht('All'));
@ -110,6 +115,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$show_user = false;
$show_project = false;
$show_package = false;
$show_repository = false;
switch ($this->filter) {
case 'audits':
@ -128,6 +134,10 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$show_project = true;
$show_status = true;
break;
case 'repository':
$show_repository = true;
$show_status = true;
break;
case 'package':
case 'packagecommits':
$show_package = true;
@ -135,7 +145,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
break;
}
if ($show_user || $show_project || $show_package) {
if ($show_user || $show_project || $show_package || $show_repository) {
if ($show_user) {
$uri = '/typeahead/common/users/';
$label = pht('User');
@ -145,6 +155,9 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
} else if ($show_package) {
$uri = '/typeahead/common/packages/';
$label = pht('Package');
} else if ($show_repository) {
$uri = '/typeahead/common/repositories/';
$label = pht('Repository');
}
$tok_value = null;
@ -239,6 +252,11 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
throw new Exception("PHID must be a project PHID!");
}
break;
case 'repository':
if ($handle->getType() !== PhabricatorPHIDConstants::PHID_TYPE_REPO) {
throw new Exception("PHID must be a repository PHID!");
}
break;
case 'audits':
case 'commits':
break;
@ -258,6 +276,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
case 'user':
case 'package':
case 'project':
case 'repository':
$views[] = $this->buildAuditView($handle);
break;
case 'commits':
@ -288,6 +307,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$awaiting = null;
$phids = null;
$repository_phids = null;
switch ($this->filter) {
case 'user':
case 'active':
@ -304,6 +324,9 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
case 'package':
$phids = array($handle->getPHID());
break;
case 'repository':
$repository_phids = array($handle->getPHID());
break;
case 'audits';
break;
default:
@ -314,6 +337,10 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$query->withAuditorPHIDs($phids);
}
if ($repository_phids) {
$query->withRepositoryPHIDs($repository_phids);
}
if ($awaiting) {
$query->withAwaitingUser($awaiting);
}
@ -323,6 +350,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
case 'user':
case 'project':
case 'package':
case 'repository':
switch ($this->filterStatus) {
case 'open':
$query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
@ -335,7 +363,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
}
if ($handle) {
$handle_name = $handle->getName();
$handle_name = $handle->getFullName();
} else {
$handle_name = null;
}
@ -361,6 +389,10 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
$header = pht("Audits for Package %s", $handle_name);
$nodata = pht("No matching audits in package %s.", $handle_name);
break;
case 'repository':
$header = pht("Audits in Repository %s", $handle_name);
$nodata = pht("No matching audits in repository %s.", $handle_name);
break;
}
$query->needCommitData(true);

View file

@ -8,6 +8,8 @@ final class PhabricatorAuditQuery {
private $auditorPHIDs;
private $commitPHIDs;
private $repositoryPHIDs;
private $needCommits;
private $needCommitData;
@ -29,6 +31,11 @@ final class PhabricatorAuditQuery {
return $this;
}
public function withRepositoryPHIDs(array $repository_phids) {
$this->repositoryPHIDs = $repository_phids;
return $this;
}
public function withAwaitingUser(PhabricatorUser $user) {
$this->awaitingUser = $user;
return $this;
@ -119,15 +126,25 @@ final class PhabricatorAuditQuery {
awaiting.auditorPHID = %s',
id(new PhabricatorRepositoryAuditRequest())->getTableName(),
$this->awaitingUser->getPHID());
}
// Join the commit table so we can get the commit author into the result
// row and filter by it later.
if ($this->awaitingUser || $this->repositoryPHIDs) {
// Join the commit table so we can get the commit author or repository id
// into the result row and filter by it later.
$joins[] = qsprintf(
$conn_r,
'JOIN %T commit ON req.commitPHID = commit.phid',
id(new PhabricatorRepositoryCommit())->getTableName());
}
if ($this->repositoryPHIDs) {
// Join in the repository table so we can filter by repository PHID
$joins[] = qsprintf(
$conn_r,
'JOIN %T repository ON repository.id = commit.repositoryID',
id(new PhabricatorRepository())->getTableName());
}
if ($joins) {
return implode(' ', $joins);
} else {
@ -163,6 +180,14 @@ final class PhabricatorAuditQuery {
$this->awaitingUser->getPHID());
}
if ($this->repositoryPHIDs) {
// Filter only for a single repository
$where[] = qsprintf(
$conn_r,
'repository.phid IN (%Ls)',
$this->repositoryPHIDs);
}
$status = $this->status;
switch ($status) {
case self::STATUS_OPEN:

View file

@ -447,6 +447,8 @@ final class PhabricatorObjectHandleData {
} else {
$repository = $objects[$phid];
$handle->setName($repository->getCallsign());
$handle->setFullName("r" . $repository->getCallsign() .
" (" . $repository->getName() . ")");
$handle->setURI('/diffusion/'.$repository->getCallsign().'/');
$handle->setComplete(true);
}