1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Add a summary view of all repository errors to the repository cluster screen

Summary: Ref T11559. This makes managing large numbers of repositories slightly easier.

Test Plan: {F1796119}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11559

Differential Revision: https://secure.phabricator.com/D16472
This commit is contained in:
epriestley 2016-08-30 08:52:46 -07:00
parent 024a6693d3
commit 5504f37eb2
2 changed files with 83 additions and 1 deletions

View file

@ -27,10 +27,15 @@ final class PhabricatorConfigClusterRepositoriesController
->setBorder(true);
$repository_status = $this->buildClusterRepositoryStatus();
$repository_errors = $this->buildClusterRepositoryErrors();
$content = id(new PhabricatorConfigPageView())
->setHeader($header)
->setContent($repository_status);
->setContent(
array(
$repository_status,
$repository_errors,
));
return $this->newPage()
->setTitle($title)
@ -338,4 +343,70 @@ final class PhabricatorConfigClusterRepositoriesController
}
private function buildClusterRepositoryErrors() {
$viewer = $this->getViewer();
$messages = id(new PhabricatorRepositoryStatusMessage())->loadAllWhere(
'statusCode IN (%Ls)',
array(
PhabricatorRepositoryStatusMessage::CODE_ERROR,
));
$repository_ids = mpull($messages, 'getRepositoryID');
if ($repository_ids) {
// NOTE: We're bypassing policies when loading repositories because we
// want to show errors exist even if the viewer can't see the repository.
// We use handles to describe the repository below, so the viewer won't
// actually be able to see any particulars if they can't see the
// repository.
$repositories = id(new PhabricatorRepositoryQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withIDs($repository_ids)
->execute();
$repositories = mpull($repositories, null, 'getID');
}
$rows = array();
foreach ($messages as $message) {
$repository = idx($repositories, $message->getRepositoryID());
if (!$repository) {
continue;
}
if (!$repository->isTracked()) {
continue;
}
$icon = id(new PHUIIconView())
->setIcon('fa-exclamation-triangle red');
$rows[] = array(
$icon,
$viewer->renderHandle($repository->getPHID()),
phutil_tag(
'a',
array(
'href' => $repository->getPathURI('manage/status/'),
),
$message->getStatusTypeName()),
);
}
return id(new AphrontTableView($rows))
->setNoDataString(
pht('No active repositories have outstanding errors.'))
->setHeaders(
array(
null,
pht('Repository'),
pht('Error'),
))
->setColumnClasses(
array(
null,
'pri',
'wide',
));
}
}

View file

@ -40,4 +40,15 @@ final class PhabricatorRepositoryStatusMessage
return idx($this->parameters, $key, $default);
}
public function getStatusTypeName() {
$names = array(
self::TYPE_INIT => pht('Error While Initializing Repository'),
self::TYPE_FETCH => pht('Error While Fetching Changes'),
self::TYPE_NEEDS_UPDATE => pht('Repository Needs Update'),
);
$type = $this->getStatusType();
return idx($names, $type, $type);
}
}