Differential D20934 Diff 49950 src/applications/config/controller/PhabricatorConfigConsoleController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/controller/PhabricatorConfigConsoleController.php
- This file was moved from src/applications/config/controller/PhabricatorConfigVersionController.php.
<?php | <?php | ||||
final class PhabricatorConfigVersionController | final class PhabricatorConfigConsoleController | ||||
extends PhabricatorConfigController { | extends PhabricatorConfigController { | ||||
public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
$viewer = $request->getViewer(); | $viewer = $request->getViewer(); | ||||
$title = pht('Version Information'); | $menu = id(new PHUIObjectItemListView()) | ||||
$versions = $this->renderModuleStatus($viewer); | ->setViewer($viewer) | ||||
->setBig(true); | |||||
$nav = $this->buildSideNavView(); | |||||
$nav->selectFilter('version/'); | $menu->addItem( | ||||
$header = $this->buildHeaderView($title); | id(new PHUIObjectItemView()) | ||||
->setHeader(pht('Settings')) | |||||
$view = $this->buildConfigBoxView( | ->setHref($this->getApplicationURI('settings/')) | ||||
pht('Installed Versions'), | ->setImageIcon('fa-wrench') | ||||
$versions); | ->setClickable(true) | ||||
->addAttribute( | |||||
pht( | |||||
'Review and modify configuration settings.'))); | |||||
$menu->addItem( | |||||
id(new PHUIObjectItemView()) | |||||
->setHeader(pht('Setup Issues')) | |||||
->setHref($this->getApplicationURI('issue/')) | |||||
->setImageIcon('fa-exclamation-triangle') | |||||
->setClickable(true) | |||||
->addAttribute( | |||||
pht( | |||||
'Show unresolved issues with setup and configuration.'))); | |||||
$menu->addItem( | |||||
id(new PHUIObjectItemView()) | |||||
->setHeader(pht('Services')) | |||||
->setHref($this->getApplicationURI('cluster/databases/')) | |||||
->setImageIcon('fa-server') | |||||
->setClickable(true) | |||||
->addAttribute( | |||||
pht( | |||||
'View status information for databases, caches, repositories, '. | |||||
'and other services.'))); | |||||
$menu->addItem( | |||||
id(new PHUIObjectItemView()) | |||||
->setHeader(pht('Extensions/Modules')) | |||||
->setHref($this->getApplicationURI('module/')) | |||||
->setImageIcon('fa-gear') | |||||
->setClickable(true) | |||||
->addAttribute( | |||||
pht( | |||||
'Show installed extensions and modules.'))); | |||||
$crumbs = $this->buildApplicationCrumbs() | $crumbs = $this->buildApplicationCrumbs() | ||||
->addTextCrumb($title) | ->addTextCrumb(pht('Console')) | ||||
->setBorder(true); | ->setBorder(true); | ||||
$content = id(new PHUITwoColumnView()) | $box = id(new PHUIObjectBoxView()) | ||||
->setHeader($header) | ->setHeaderText(pht('Phabricator Configuation')) | ||||
->setFooter($view); | ->setBackground(PHUIObjectBoxView::WHITE_CONFIG) | ||||
->setObjectList($menu); | |||||
$versions = $this->newLibraryVersionTable($viewer); | |||||
$binary_versions = $this->newBinaryVersionTable(); | |||||
$launcher_view = id(new PHUILauncherView()) | |||||
->appendChild($box) | |||||
->appendChild($versions) | |||||
->appendChild($binary_versions); | |||||
$view = id(new PHUITwoColumnView()) | |||||
->setFooter($launcher_view); | |||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle(pht('Phabricator Configuation')) | ||||
->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
->setNavigation($nav) | ->appendChild($view); | ||||
->appendChild($content); | |||||
} | } | ||||
public function renderModuleStatus($viewer) { | public function newLibraryVersionTable() { | ||||
$viewer = $this->getViewer(); | |||||
$versions = $this->loadVersions($viewer); | $versions = $this->loadVersions($viewer); | ||||
$version_property_list = id(new PHUIPropertyListView()); | $rows = array(); | ||||
foreach ($versions as $name => $info) { | foreach ($versions as $name => $info) { | ||||
$version = $info['version']; | $branchpoint = $info['branchpoint']; | ||||
if (strlen($branchpoint)) { | |||||
if ($info['branchpoint']) { | $branchpoint = substr($branchpoint, 0, 12); | ||||
$display = pht( | |||||
'%s (branched from %s on %s)', | |||||
$version, | |||||
$info['branchpoint'], | |||||
$info['upstream']); | |||||
} else { | } else { | ||||
$display = $version; | $branchpoint = null; | ||||
} | |||||
$version_property_list->addProperty($name, $display); | |||||
} | } | ||||
$phabricator_root = dirname(phutil_get_library_root('phabricator')); | $version = $info['hash']; | ||||
$version_path = $phabricator_root.'/conf/local/VERSION'; | if (strlen($version)) { | ||||
if (Filesystem::pathExists($version_path)) { | $version = substr($version, 0, 12); | ||||
$version_from_file = Filesystem::readFile($version_path); | } else { | ||||
$version_property_list->addProperty( | $version = pht('Unknown'); | ||||
pht('Local Version'), | |||||
$version_from_file); | |||||
} | } | ||||
$version_property_list->addProperty('php', phpversion()); | |||||
$binaries = PhutilBinaryAnalyzer::getAllBinaries(); | $epoch = $info['epoch']; | ||||
foreach ($binaries as $binary) { | if ($epoch) { | ||||
if (!$binary->isBinaryAvailable()) { | $epoch = phabricator_date($epoch, $viewer); | ||||
$binary_info = pht('Not Available'); | |||||
} else { | |||||
$version = $binary->getBinaryVersion(); | |||||
$path = $binary->getBinaryPath(); | |||||
if ($path === null && $version === null) { | |||||
$binary_info = pht('-'); | |||||
} else if ($path === null) { | |||||
$binary_info = $version; | |||||
} else if ($version === null) { | |||||
$binary_info = pht('- at %s', $path); | |||||
} else { | } else { | ||||
$binary_info = pht('%s at %s', $version, $path); | $epoch = null; | ||||
} | |||||
} | } | ||||
$version_property_list->addProperty( | $rows[] = array( | ||||
$binary->getBinaryName(), | $name, | ||||
$binary_info); | $version, | ||||
$epoch, | |||||
$branchpoint, | |||||
); | |||||
} | } | ||||
return $version_property_list; | $table_view = id(new AphrontTableView($rows)) | ||||
->setHeaders( | |||||
array( | |||||
pht('Library'), | |||||
pht('Version'), | |||||
pht('Date'), | |||||
pht('Branchpoint'), | |||||
)) | |||||
->setColumnClasses( | |||||
array( | |||||
'pri', | |||||
null, | |||||
null, | |||||
'wide', | |||||
)); | |||||
return id(new PHUIObjectBoxView()) | |||||
->setHeaderText(pht('Phabricator Version Information')) | |||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
->appendChild($table_view); | |||||
} | } | ||||
private function loadVersions(PhabricatorUser $viewer) { | private function loadVersions(PhabricatorUser $viewer) { | ||||
$specs = array( | $specs = array( | ||||
'phabricator', | 'phabricator', | ||||
'arcanist', | 'arcanist', | ||||
'phutil', | 'phutil', | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | if ($upstream_futures) { | ||||
->resolveAll(); | ->resolveAll(); | ||||
} | } | ||||
$results = array(); | $results = array(); | ||||
foreach ($log_futures as $lib => $future) { | foreach ($log_futures as $lib => $future) { | ||||
list($err, $stdout) = $future->resolve(); | list($err, $stdout) = $future->resolve(); | ||||
if (!$err) { | if (!$err) { | ||||
list($hash, $epoch) = explode(' ', $stdout); | list($hash, $epoch) = explode(' ', $stdout); | ||||
$version = pht('%s (%s)', $hash, phabricator_date($epoch, $viewer)); | |||||
} else { | } else { | ||||
$version = pht('Unknown'); | $hash = null; | ||||
$epoch = null; | |||||
} | } | ||||
$result = array( | $result = array( | ||||
'version' => $version, | 'hash' => $hash, | ||||
'epoch' => $epoch, | |||||
'upstream' => null, | 'upstream' => null, | ||||
'branchpoint' => null, | 'branchpoint' => null, | ||||
); | ); | ||||
$upstream_future = idx($upstream_futures, $lib); | $upstream_future = idx($upstream_futures, $lib); | ||||
if ($upstream_future) { | if ($upstream_future) { | ||||
list($err, $stdout) = $upstream_future->resolve(); | list($err, $stdout) = $upstream_future->resolve(); | ||||
if (!$err) { | if (!$err) { | ||||
Show All 9 Lines | foreach ($log_futures as $lib => $future) { | ||||
} | } | ||||
$results[$lib] = $result; | $results[$lib] = $result; | ||||
} | } | ||||
return $results; | return $results; | ||||
} | } | ||||
private function newBinaryVersionTable() { | |||||
$rows = array(); | |||||
$rows[] = array( | |||||
'php', | |||||
phpversion(), | |||||
php_sapi_name(), | |||||
); | |||||
$binaries = PhutilBinaryAnalyzer::getAllBinaries(); | |||||
foreach ($binaries as $binary) { | |||||
if (!$binary->isBinaryAvailable()) { | |||||
$binary_version = pht('Not Available'); | |||||
$binary_path = null; | |||||
} else { | |||||
$binary_version = $binary->getBinaryVersion(); | |||||
$binary_path = $binary->getBinaryPath(); | |||||
} | |||||
$rows[] = array( | |||||
$binary->getBinaryName(), | |||||
$binary_version, | |||||
$binary_path, | |||||
); | |||||
} | |||||
$table_view = id(new AphrontTableView($rows)) | |||||
->setHeaders( | |||||
array( | |||||
pht('Binary'), | |||||
pht('Version'), | |||||
pht('Path'), | |||||
)) | |||||
->setColumnClasses( | |||||
array( | |||||
'pri', | |||||
null, | |||||
'wide', | |||||
)); | |||||
return id(new PHUIObjectBoxView()) | |||||
->setHeaderText(pht('Other Version Information')) | |||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
->appendChild($table_view); | |||||
} | |||||
} | } |