Differential D18519 Diff 44486 src/applications/config/controller/PhabricatorConfigDatabaseStatusController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/config/controller/PhabricatorConfigDatabaseStatusController.php
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | private function buildResponse($title, $body) { | ||||
if ($key) { | if ($key) { | ||||
$links[] = array( | $links[] = array( | ||||
$key, | $key, | ||||
"database/{$ref}/{$database}/{$table}/key/{$key}/", | "database/{$ref}/{$database}/{$table}/key/{$key}/", | ||||
); | ); | ||||
} | } | ||||
// TODO: Make these work in header | |||||
Lint: TODO Comment: This comment has a TODO. | |||||
$crumbs = $this->buildApplicationCrumbs(); | $crumbs = $this->buildApplicationCrumbs(); | ||||
$crumbs->setBorder(true); | $crumbs->setBorder(true); | ||||
$last_key = last_key($links); | $last_key = last_key($links); | ||||
foreach ($links as $link_key => $link) { | foreach ($links as $link_key => $link) { | ||||
list($name, $href) = $link; | list($name, $href) = $link; | ||||
if ($link_key == $last_key) { | if ($link_key == $last_key) { | ||||
$crumbs->addTextCrumb($name); | $crumbs->addTextCrumb($name); | ||||
} else { | } else { | ||||
$crumbs->addTextCrumb($name, $this->getApplicationURI($href)); | $crumbs->addTextCrumb($name, $this->getApplicationURI($href)); | ||||
} | } | ||||
} | } | ||||
$doc_link = PhabricatorEnv::getDoclink('Managing Storage Adjustments'); | $doc_link = PhabricatorEnv::getDoclink('Managing Storage Adjustments'); | ||||
$button = id(new PHUIButtonView()) | |||||
$header = id(new PHUIHeaderView()) | |||||
->setHeader($title) | |||||
->setProfileHeader(true) | |||||
->addActionLink( | |||||
id(new PHUIButtonView()) | |||||
->setTag('a') | ->setTag('a') | ||||
->setIcon('fa-book') | ->setIcon('fa-book') | ||||
->setHref($doc_link) | ->setHref($doc_link) | ||||
->setText(pht('Learn More'))); | ->setText(pht('Documentation')); | ||||
$header = $this->buildHeaderView($title, $button); | |||||
$content = id(new PhabricatorConfigPageView()) | $content = id(new PHUITwoColumnView()) | ||||
->setHeader($header) | ->setHeader($header) | ||||
->setContent($body); | ->setNavigation($nav) | ||||
->setFixed(true) | |||||
->setMainColumn($body); | |||||
return $this->newPage() | return $this->newPage() | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setCrumbs($crumbs) | ->appendChild($content); | ||||
->setNavigation($nav) | |||||
->appendChild($content) | |||||
->addClass('white-background'); | |||||
} | } | ||||
private function renderServers( | private function renderServers( | ||||
array $comp_servers, | array $comp_servers, | ||||
array $expect_servers, | array $expect_servers, | ||||
array $actual_servers) { | array $actual_servers) { | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | $table = id(new AphrontTableView($rows)) | ||||
null, | null, | ||||
null, | null, | ||||
'wide pri', | 'wide pri', | ||||
null, | null, | ||||
null, | null, | ||||
)); | )); | ||||
$title = pht('Database Status'); | $title = pht('Database Status'); | ||||
$properties = $this->buildProperties( | $properties = $this->buildProperties( | ||||
array( | array( | ||||
), | ), | ||||
$comp->getIssues()); | $comp->getIssues()); | ||||
$properties = $this->buildConfigBoxView(pht('Properties'), $properties); | |||||
$table = $this->buildConfigBoxView(pht('Database'), $table); | |||||
return $this->buildResponse($title, array($properties, $table)); | return $this->buildResponse($title, array($properties, $table)); | ||||
} | } | ||||
private function renderDatabase( | private function renderDatabase( | ||||
PhabricatorConfigServerSchema $comp, | PhabricatorConfigServerSchema $comp, | ||||
PhabricatorConfigServerSchema $expect, | PhabricatorConfigServerSchema $expect, | ||||
PhabricatorConfigServerSchema $actual, | PhabricatorConfigServerSchema $actual, | ||||
Show All 38 Lines | $table = id(new AphrontTableView($rows)) | ||||
)) | )) | ||||
->setColumnClasses( | ->setColumnClasses( | ||||
array( | array( | ||||
null, | null, | ||||
'wide pri', | 'wide pri', | ||||
null, | null, | ||||
)); | )); | ||||
$title = pht('Database: %s', $database_name); | $title = $database_name; | ||||
$actual_database = $actual->getDatabase($database_name); | $actual_database = $actual->getDatabase($database_name); | ||||
if ($actual_database) { | if ($actual_database) { | ||||
$actual_charset = $actual_database->getCharacterSet(); | $actual_charset = $actual_database->getCharacterSet(); | ||||
$actual_collation = $actual_database->getCollation(); | $actual_collation = $actual_database->getCollation(); | ||||
} else { | } else { | ||||
$actual_charset = null; | $actual_charset = null; | ||||
$actual_collation = null; | $actual_collation = null; | ||||
Show All 28 Lines | $properties = $this->buildProperties( | ||||
), | ), | ||||
array( | array( | ||||
pht('Expected Collation'), | pht('Expected Collation'), | ||||
$expect_collation, | $expect_collation, | ||||
), | ), | ||||
), | ), | ||||
$database->getIssues()); | $database->getIssues()); | ||||
$properties = $this->buildConfigBoxView(pht('Properties'), $properties); | |||||
$table = $this->buildConfigBoxView(pht('Database'), $table); | |||||
return $this->buildResponse($title, array($properties, $table)); | return $this->buildResponse($title, array($properties, $table)); | ||||
} | } | ||||
private function renderTable( | private function renderTable( | ||||
PhabricatorConfigServerSchema $comp, | PhabricatorConfigServerSchema $comp, | ||||
PhabricatorConfigServerSchema $expect, | PhabricatorConfigServerSchema $expect, | ||||
PhabricatorConfigServerSchema $actual, | PhabricatorConfigServerSchema $actual, | ||||
$database_name, | $database_name, | ||||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Lines | $keys_view = id(new AphrontTableView($key_rows)) | ||||
array( | array( | ||||
null, | null, | ||||
'wide pri', | 'wide pri', | ||||
null, | null, | ||||
null, | null, | ||||
null, | null, | ||||
)); | )); | ||||
$title = pht('Database: %s.%s', $database_name, $table_name); | $title = pht('%s.%s', $database_name, $table_name); | ||||
if ($actual_table) { | if ($actual_table) { | ||||
$actual_collation = $actual_table->getCollation(); | $actual_collation = $actual_table->getCollation(); | ||||
} else { | } else { | ||||
$actual_collation = null; | $actual_collation = null; | ||||
} | } | ||||
if ($expect_table) { | if ($expect_table) { | ||||
Show All 14 Lines | $properties = $this->buildProperties( | ||||
), | ), | ||||
array( | array( | ||||
pht('Expected Collation'), | pht('Expected Collation'), | ||||
$expect_collation, | $expect_collation, | ||||
), | ), | ||||
), | ), | ||||
$table->getIssues()); | $table->getIssues()); | ||||
$box_header = pht('%s.%s', $database_name, $table_name); | |||||
$properties = $this->buildConfigBoxView(pht('Properties'), $properties); | |||||
$table = $this->buildConfigBoxView(pht('Database'), $table_view); | |||||
$keys = $this->buildConfigBoxView(pht('Keys'), $keys_view); | |||||
return $this->buildResponse( | return $this->buildResponse( | ||||
$title, array($properties, $table_view, $keys_view)); | $title, array($properties, $table, $keys)); | ||||
} | } | ||||
private function renderColumn( | private function renderColumn( | ||||
PhabricatorConfigServerSchema $comp, | PhabricatorConfigServerSchema $comp, | ||||
PhabricatorConfigServerSchema $expect, | PhabricatorConfigServerSchema $expect, | ||||
PhabricatorConfigServerSchema $actual, | PhabricatorConfigServerSchema $actual, | ||||
$database_name, | $database_name, | ||||
$table_name, | $table_name, | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | if ($expect_column) { | ||||
$expect_charset = null; | $expect_charset = null; | ||||
$expect_collation = null; | $expect_collation = null; | ||||
$expect_nullable = null; | $expect_nullable = null; | ||||
$expect_auto = null; | $expect_auto = null; | ||||
} | } | ||||
$title = pht( | $title = pht( | ||||
'Database Status: %s.%s.%s', | '%s.%s.%s', | ||||
$database_name, | $database_name, | ||||
$table_name, | $table_name, | ||||
$column_name); | $column_name); | ||||
$properties = $this->buildProperties( | $properties = $this->buildProperties( | ||||
array( | array( | ||||
array( | array( | ||||
pht('Server'), | pht('Server'), | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | $properties = $this->buildProperties( | ||||
), | ), | ||||
array( | array( | ||||
pht('Expected Autoincrement'), | pht('Expected Autoincrement'), | ||||
$this->renderBoolean($expect_auto), | $this->renderBoolean($expect_auto), | ||||
), | ), | ||||
), | ), | ||||
$column->getIssues()); | $column->getIssues()); | ||||
$properties = $this->buildConfigBoxView(pht('Properties'), $properties); | |||||
return $this->buildResponse($title, $properties); | return $this->buildResponse($title, $properties); | ||||
} | } | ||||
private function renderKey( | private function renderKey( | ||||
PhabricatorConfigServerSchema $comp, | PhabricatorConfigServerSchema $comp, | ||||
PhabricatorConfigServerSchema $expect, | PhabricatorConfigServerSchema $expect, | ||||
PhabricatorConfigServerSchema $actual, | PhabricatorConfigServerSchema $actual, | ||||
$database_name, | $database_name, | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if ($expect_key) { | ||||
$expect_columns = $expect_key->getColumnNames(); | $expect_columns = $expect_key->getColumnNames(); | ||||
$expect_unique = $expect_key->getUnique(); | $expect_unique = $expect_key->getUnique(); | ||||
} else { | } else { | ||||
$expect_columns = array(); | $expect_columns = array(); | ||||
$expect_unique = null; | $expect_unique = null; | ||||
} | } | ||||
$title = pht( | $title = pht( | ||||
'Database Status: %s.%s (%s)', | '%s.%s (%s)', | ||||
$database_name, | $database_name, | ||||
$table_name, | $table_name, | ||||
$key_name); | $key_name); | ||||
$properties = $this->buildProperties( | $properties = $this->buildProperties( | ||||
array( | array( | ||||
array( | array( | ||||
pht('Server'), | pht('Server'), | ||||
Show All 13 Lines | $properties = $this->buildProperties( | ||||
), | ), | ||||
array( | array( | ||||
pht('Expected Columns'), | pht('Expected Columns'), | ||||
implode(', ', $expect_columns), | implode(', ', $expect_columns), | ||||
), | ), | ||||
), | ), | ||||
$key->getIssues()); | $key->getIssues()); | ||||
$properties = $this->buildConfigBoxView(pht('Properties'), $properties); | |||||
return $this->buildResponse($title, $properties); | return $this->buildResponse($title, $properties); | ||||
} | } | ||||
private function buildProperties(array $properties, array $issues) { | private function buildProperties(array $properties, array $issues) { | ||||
$view = id(new PHUIPropertyListView()) | $view = id(new PHUIPropertyListView()) | ||||
->setUser($this->getRequest()->getUser()); | ->setUser($this->getRequest()->getUser()); | ||||
foreach ($properties as $property) { | foreach ($properties as $property) { | ||||
▲ Show 20 Lines • Show All 77 Lines • Show Last 20 Lines |
This comment has a TODO.