2014-09-18 08:22:18 -07:00
|
|
|
<?php
|
|
|
|
|
|
2014-09-19 11:46:30 -07:00
|
|
|
abstract class PhabricatorConfigDatabaseController
|
2014-09-18 08:22:18 -07:00
|
|
|
extends PhabricatorConfigController {
|
|
|
|
|
|
2014-09-19 11:46:30 -07:00
|
|
|
protected function buildSchemaQuery() {
|
2014-09-18 08:22:18 -07:00
|
|
|
$conf = PhabricatorEnv::newObjectFromConfig(
|
|
|
|
|
'mysql.configuration-provider',
|
|
|
|
|
array($dao = null, 'w'));
|
|
|
|
|
|
|
|
|
|
$api = id(new PhabricatorStorageManagementAPI())
|
|
|
|
|
->setUser($conf->getUser())
|
|
|
|
|
->setHost($conf->getHost())
|
|
|
|
|
->setPort($conf->getPort())
|
|
|
|
|
->setNamespace(PhabricatorLiskDAO::getDefaultStorageNamespace())
|
|
|
|
|
->setPassword($conf->getPassword());
|
|
|
|
|
|
|
|
|
|
$query = id(new PhabricatorConfigSchemaQuery())
|
|
|
|
|
->setAPI($api);
|
|
|
|
|
|
2014-09-19 11:46:30 -07:00
|
|
|
return $query;
|
2014-09-18 08:22:54 -07:00
|
|
|
}
|
|
|
|
|
|
2014-09-19 11:46:30 -07:00
|
|
|
protected function renderIcon($status) {
|
2014-09-18 08:22:54 -07:00
|
|
|
switch ($status) {
|
|
|
|
|
case PhabricatorConfigStorageSchema::STATUS_OKAY:
|
|
|
|
|
$icon = 'fa-check-circle green';
|
|
|
|
|
break;
|
|
|
|
|
case PhabricatorConfigStorageSchema::STATUS_WARN:
|
|
|
|
|
$icon = 'fa-exclamation-circle yellow';
|
|
|
|
|
break;
|
|
|
|
|
case PhabricatorConfigStorageSchema::STATUS_FAIL:
|
|
|
|
|
default:
|
|
|
|
|
$icon = 'fa-times-circle red';
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return id(new PHUIIconView())
|
2016-01-27 20:38:01 -08:00
|
|
|
->setIcon($icon);
|
2014-09-18 08:22:54 -07:00
|
|
|
}
|
|
|
|
|
|
2014-09-19 11:46:30 -07:00
|
|
|
protected function renderAttr($attr, $issue) {
|
2014-09-18 08:22:54 -07:00
|
|
|
if ($issue) {
|
|
|
|
|
return phutil_tag(
|
|
|
|
|
'span',
|
|
|
|
|
array(
|
|
|
|
|
'style' => 'color: #aa0000;',
|
|
|
|
|
),
|
|
|
|
|
$attr);
|
|
|
|
|
} else {
|
|
|
|
|
return $attr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-19 11:46:30 -07:00
|
|
|
protected function renderBoolean($value) {
|
2014-09-18 08:32:44 -07:00
|
|
|
if ($value === null) {
|
|
|
|
|
return '';
|
|
|
|
|
} else if ($value === true) {
|
|
|
|
|
return pht('Yes');
|
|
|
|
|
} else {
|
|
|
|
|
return pht('No');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-01 08:25:05 -07:00
|
|
|
protected function buildHeaderWithDocumentationLink($title) {
|
|
|
|
|
|
|
|
|
|
$doc_link = PhabricatorEnv::getDoclink('Managing Storage Adjustments');
|
|
|
|
|
|
|
|
|
|
return id(new PHUIHeaderView())
|
|
|
|
|
->setHeader($title)
|
|
|
|
|
->addActionLink(
|
|
|
|
|
id(new PHUIButtonView())
|
|
|
|
|
->setTag('a')
|
2016-01-27 20:38:01 -08:00
|
|
|
->setIcon('fa-book')
|
2014-11-01 08:25:05 -07:00
|
|
|
->setHref($doc_link)
|
|
|
|
|
->setText(pht('Learn More')));
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-18 08:22:18 -07:00
|
|
|
}
|