mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-17 18:21:11 +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:
parent
fe78944c9d
commit
ff1a679709
3 changed files with 63 additions and 4 deletions
|
@ -52,6 +52,10 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
$title = pht('Choose A Project');
|
$title = pht('Choose A Project');
|
||||||
$message = pht('Choose a project to view audits for.');
|
$message = pht('Choose a project to view audits for.');
|
||||||
break;
|
break;
|
||||||
|
case 'repository':
|
||||||
|
$title = pht('Choose A Repository');
|
||||||
|
$message = pht('Choose a repository to view audits for.');
|
||||||
|
break;
|
||||||
case 'package':
|
case 'package':
|
||||||
case 'packagecommits':
|
case 'packagecommits':
|
||||||
$title = pht('Choose a Package');
|
$title = pht('Choose a Package');
|
||||||
|
@ -88,6 +92,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
$nav->addFilter('user', pht('By User'));
|
$nav->addFilter('user', pht('By User'));
|
||||||
$nav->addFilter('project', pht('By Project'));
|
$nav->addFilter('project', pht('By Project'));
|
||||||
$nav->addFilter('package', pht('By Package'));
|
$nav->addFilter('package', pht('By Package'));
|
||||||
|
$nav->addFilter('repository', pht('By Repository'));
|
||||||
|
|
||||||
$nav->addLabel(pht('Commits'));
|
$nav->addLabel(pht('Commits'));
|
||||||
$nav->addFilter('commits', pht('All'));
|
$nav->addFilter('commits', pht('All'));
|
||||||
|
@ -110,6 +115,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
$show_user = false;
|
$show_user = false;
|
||||||
$show_project = false;
|
$show_project = false;
|
||||||
$show_package = false;
|
$show_package = false;
|
||||||
|
$show_repository = false;
|
||||||
|
|
||||||
switch ($this->filter) {
|
switch ($this->filter) {
|
||||||
case 'audits':
|
case 'audits':
|
||||||
|
@ -128,6 +134,10 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
$show_project = true;
|
$show_project = true;
|
||||||
$show_status = true;
|
$show_status = true;
|
||||||
break;
|
break;
|
||||||
|
case 'repository':
|
||||||
|
$show_repository = true;
|
||||||
|
$show_status = true;
|
||||||
|
break;
|
||||||
case 'package':
|
case 'package':
|
||||||
case 'packagecommits':
|
case 'packagecommits':
|
||||||
$show_package = true;
|
$show_package = true;
|
||||||
|
@ -135,7 +145,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($show_user || $show_project || $show_package) {
|
if ($show_user || $show_project || $show_package || $show_repository) {
|
||||||
if ($show_user) {
|
if ($show_user) {
|
||||||
$uri = '/typeahead/common/users/';
|
$uri = '/typeahead/common/users/';
|
||||||
$label = pht('User');
|
$label = pht('User');
|
||||||
|
@ -145,6 +155,9 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
} else if ($show_package) {
|
} else if ($show_package) {
|
||||||
$uri = '/typeahead/common/packages/';
|
$uri = '/typeahead/common/packages/';
|
||||||
$label = pht('Package');
|
$label = pht('Package');
|
||||||
|
} else if ($show_repository) {
|
||||||
|
$uri = '/typeahead/common/repositories/';
|
||||||
|
$label = pht('Repository');
|
||||||
}
|
}
|
||||||
|
|
||||||
$tok_value = null;
|
$tok_value = null;
|
||||||
|
@ -239,6 +252,11 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
throw new Exception("PHID must be a project PHID!");
|
throw new Exception("PHID must be a project PHID!");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'repository':
|
||||||
|
if ($handle->getType() !== PhabricatorPHIDConstants::PHID_TYPE_REPO) {
|
||||||
|
throw new Exception("PHID must be a repository PHID!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'audits':
|
case 'audits':
|
||||||
case 'commits':
|
case 'commits':
|
||||||
break;
|
break;
|
||||||
|
@ -258,6 +276,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
case 'user':
|
case 'user':
|
||||||
case 'package':
|
case 'package':
|
||||||
case 'project':
|
case 'project':
|
||||||
|
case 'repository':
|
||||||
$views[] = $this->buildAuditView($handle);
|
$views[] = $this->buildAuditView($handle);
|
||||||
break;
|
break;
|
||||||
case 'commits':
|
case 'commits':
|
||||||
|
@ -288,6 +307,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
$awaiting = null;
|
$awaiting = null;
|
||||||
|
|
||||||
$phids = null;
|
$phids = null;
|
||||||
|
$repository_phids = null;
|
||||||
switch ($this->filter) {
|
switch ($this->filter) {
|
||||||
case 'user':
|
case 'user':
|
||||||
case 'active':
|
case 'active':
|
||||||
|
@ -304,6 +324,9 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
case 'package':
|
case 'package':
|
||||||
$phids = array($handle->getPHID());
|
$phids = array($handle->getPHID());
|
||||||
break;
|
break;
|
||||||
|
case 'repository':
|
||||||
|
$repository_phids = array($handle->getPHID());
|
||||||
|
break;
|
||||||
case 'audits';
|
case 'audits';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -314,6 +337,10 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
$query->withAuditorPHIDs($phids);
|
$query->withAuditorPHIDs($phids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($repository_phids) {
|
||||||
|
$query->withRepositoryPHIDs($repository_phids);
|
||||||
|
}
|
||||||
|
|
||||||
if ($awaiting) {
|
if ($awaiting) {
|
||||||
$query->withAwaitingUser($awaiting);
|
$query->withAwaitingUser($awaiting);
|
||||||
}
|
}
|
||||||
|
@ -323,6 +350,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
case 'user':
|
case 'user':
|
||||||
case 'project':
|
case 'project':
|
||||||
case 'package':
|
case 'package':
|
||||||
|
case 'repository':
|
||||||
switch ($this->filterStatus) {
|
switch ($this->filterStatus) {
|
||||||
case 'open':
|
case 'open':
|
||||||
$query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
|
$query->withStatus(PhabricatorAuditQuery::STATUS_OPEN);
|
||||||
|
@ -335,7 +363,7 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($handle) {
|
if ($handle) {
|
||||||
$handle_name = $handle->getName();
|
$handle_name = $handle->getFullName();
|
||||||
} else {
|
} else {
|
||||||
$handle_name = null;
|
$handle_name = null;
|
||||||
}
|
}
|
||||||
|
@ -361,6 +389,10 @@ final class PhabricatorAuditListController extends PhabricatorAuditController {
|
||||||
$header = pht("Audits for Package %s", $handle_name);
|
$header = pht("Audits for Package %s", $handle_name);
|
||||||
$nodata = pht("No matching audits in package %s.", $handle_name);
|
$nodata = pht("No matching audits in package %s.", $handle_name);
|
||||||
break;
|
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);
|
$query->needCommitData(true);
|
||||||
|
|
|
@ -8,6 +8,8 @@ final class PhabricatorAuditQuery {
|
||||||
private $auditorPHIDs;
|
private $auditorPHIDs;
|
||||||
private $commitPHIDs;
|
private $commitPHIDs;
|
||||||
|
|
||||||
|
private $repositoryPHIDs;
|
||||||
|
|
||||||
private $needCommits;
|
private $needCommits;
|
||||||
private $needCommitData;
|
private $needCommitData;
|
||||||
|
|
||||||
|
@ -29,6 +31,11 @@ final class PhabricatorAuditQuery {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function withRepositoryPHIDs(array $repository_phids) {
|
||||||
|
$this->repositoryPHIDs = $repository_phids;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function withAwaitingUser(PhabricatorUser $user) {
|
public function withAwaitingUser(PhabricatorUser $user) {
|
||||||
$this->awaitingUser = $user;
|
$this->awaitingUser = $user;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -119,15 +126,25 @@ final class PhabricatorAuditQuery {
|
||||||
awaiting.auditorPHID = %s',
|
awaiting.auditorPHID = %s',
|
||||||
id(new PhabricatorRepositoryAuditRequest())->getTableName(),
|
id(new PhabricatorRepositoryAuditRequest())->getTableName(),
|
||||||
$this->awaitingUser->getPHID());
|
$this->awaitingUser->getPHID());
|
||||||
|
}
|
||||||
|
|
||||||
// Join the commit table so we can get the commit author into the result
|
if ($this->awaitingUser || $this->repositoryPHIDs) {
|
||||||
// row and filter by it later.
|
// 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(
|
$joins[] = qsprintf(
|
||||||
$conn_r,
|
$conn_r,
|
||||||
'JOIN %T commit ON req.commitPHID = commit.phid',
|
'JOIN %T commit ON req.commitPHID = commit.phid',
|
||||||
id(new PhabricatorRepositoryCommit())->getTableName());
|
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) {
|
if ($joins) {
|
||||||
return implode(' ', $joins);
|
return implode(' ', $joins);
|
||||||
} else {
|
} else {
|
||||||
|
@ -163,6 +180,14 @@ final class PhabricatorAuditQuery {
|
||||||
$this->awaitingUser->getPHID());
|
$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;
|
$status = $this->status;
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case self::STATUS_OPEN:
|
case self::STATUS_OPEN:
|
||||||
|
|
|
@ -447,6 +447,8 @@ final class PhabricatorObjectHandleData {
|
||||||
} else {
|
} else {
|
||||||
$repository = $objects[$phid];
|
$repository = $objects[$phid];
|
||||||
$handle->setName($repository->getCallsign());
|
$handle->setName($repository->getCallsign());
|
||||||
|
$handle->setFullName("r" . $repository->getCallsign() .
|
||||||
|
" (" . $repository->getName() . ")");
|
||||||
$handle->setURI('/diffusion/'.$repository->getCallsign().'/');
|
$handle->setURI('/diffusion/'.$repository->getCallsign().'/');
|
||||||
$handle->setComplete(true);
|
$handle->setComplete(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue