Differential D16472 Diff 39630 src/applications/config/controller/PhabricatorConfigClusterRepositoriesController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/controller/PhabricatorConfigClusterRepositoriesController.php
| Show All 21 Lines | $header = id(new PHUIHeaderView()) | ||||
| ->setText(pht('Documentation'))); | ->setText(pht('Documentation'))); | ||||
| $crumbs = $this | $crumbs = $this | ||||
| ->buildApplicationCrumbs($nav) | ->buildApplicationCrumbs($nav) | ||||
| ->addTextCrumb(pht('Repository Servers')) | ->addTextCrumb(pht('Repository Servers')) | ||||
| ->setBorder(true); | ->setBorder(true); | ||||
| $repository_status = $this->buildClusterRepositoryStatus(); | $repository_status = $this->buildClusterRepositoryStatus(); | ||||
| $repository_errors = $this->buildClusterRepositoryErrors(); | |||||
| $content = id(new PhabricatorConfigPageView()) | $content = id(new PhabricatorConfigPageView()) | ||||
| ->setHeader($header) | ->setHeader($header) | ||||
| ->setContent($repository_status); | ->setContent( | ||||
| array( | |||||
| $repository_status, | |||||
| $repository_errors, | |||||
| )); | |||||
| return $this->newPage() | return $this->newPage() | ||||
| ->setTitle($title) | ->setTitle($title) | ||||
| ->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
| ->setNavigation($nav) | ->setNavigation($nav) | ||||
| ->appendChild($content) | ->appendChild($content) | ||||
| ->addClass('white-background'); | ->addClass('white-background'); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 291 Lines • ▼ Show 20 Lines | foreach ($leader_versions as $key => $version) { | ||||
| $result[$key] = $event->getEpoch(); | $result[$key] = $event->getEpoch(); | ||||
| } | } | ||||
| return $result; | return $result; | ||||
| } | } | ||||
| 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. | |||||
| $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', | |||||
| )); | |||||
| } | |||||
| } | } | ||||