mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-03 12:12:43 +01:00
2b99b4add8
Summary: Fixes T6595. This diff has two issues as is... 1) the differential data fetching is pretty cheesey, but it looks like we can't just issue three separate databases to get the right data? 2) the translations break, since I am turning this into a string (and not an int) so the whole pluralization bit fails. I think 1 is okay as is and 2 needs to be fixed though I am not sure how to best do that... Test Plan: loaded home page and it looked nice...! Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6595 Differential Revision: https://secure.phabricator.com/D10979
94 lines
2.4 KiB
PHP
94 lines
2.4 KiB
PHP
<?php
|
|
|
|
final class PhabricatorAuditApplication extends PhabricatorApplication {
|
|
|
|
public function getBaseURI() {
|
|
return '/audit/';
|
|
}
|
|
|
|
public function getIconName() {
|
|
return 'audit';
|
|
}
|
|
|
|
public function getName() {
|
|
return pht('Audit');
|
|
}
|
|
|
|
public function getShortDescription() {
|
|
return pht('Browse and Audit Commits');
|
|
}
|
|
|
|
public function isPinnedByDefault(PhabricatorUser $viewer) {
|
|
return true;
|
|
}
|
|
|
|
public function getHelpURI() {
|
|
return PhabricatorEnv::getDoclink('Audit User Guide');
|
|
}
|
|
|
|
public function getEventListeners() {
|
|
return array(
|
|
new AuditActionMenuEventListener(),
|
|
);
|
|
}
|
|
|
|
public function getRoutes() {
|
|
return array(
|
|
'/audit/' => array(
|
|
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorAuditListController',
|
|
'addcomment/' => 'PhabricatorAuditAddCommentController',
|
|
'preview/(?P<id>[1-9]\d*)/' => 'PhabricatorAuditPreviewController',
|
|
),
|
|
);
|
|
}
|
|
|
|
public function getApplicationOrder() {
|
|
return 0.130;
|
|
}
|
|
|
|
public function loadStatus(PhabricatorUser $user) {
|
|
$status = array();
|
|
|
|
$phids = PhabricatorAuditCommentEditor::loadAuditPHIDsForUser($user);
|
|
|
|
$query = id(new DiffusionCommitQuery())
|
|
->setViewer($user)
|
|
->withAuthorPHIDs(array($user->getPHID()))
|
|
->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN)
|
|
->setLimit(self::MAX_STATUS_ITEMS);
|
|
$commits = $query->execute();
|
|
|
|
$count = count($commits);
|
|
$count_str = self::formatStatusCount(
|
|
$count,
|
|
'%s Problem Commits',
|
|
'%d Problem Commit(s)');
|
|
$type = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
|
|
$status[] = id(new PhabricatorApplicationStatusView())
|
|
->setType($type)
|
|
->setText($count_str)
|
|
->setCount($count);
|
|
|
|
$query = id(new DiffusionCommitQuery())
|
|
->setViewer($user)
|
|
->withAuditorPHIDs($phids)
|
|
->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_OPEN)
|
|
->withAuditAwaitingUser($user)
|
|
->setLimit(self::MAX_STATUS_ITEMS);
|
|
$commits = $query->execute();
|
|
|
|
$count = count($commits);
|
|
$count_str = self::formatStatusCount(
|
|
$count,
|
|
'%s Commits Awaiting Audit',
|
|
'%d Commit(s) Awaiting Audit');
|
|
$type = PhabricatorApplicationStatusView::TYPE_WARNING;
|
|
$status[] = id(new PhabricatorApplicationStatusView())
|
|
->setType($type)
|
|
->setText($count_str)
|
|
->setCount($count);
|
|
|
|
return $status;
|
|
}
|
|
|
|
}
|