2015-03-12 21:28:53 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorFilesApplicationStorageEnginePanel
|
|
|
|
extends PhabricatorApplicationConfigurationPanel {
|
|
|
|
|
|
|
|
public function getPanelKey() {
|
|
|
|
return 'storage';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function shouldShowForApplication(
|
|
|
|
PhabricatorApplication $application) {
|
|
|
|
return ($application instanceof PhabricatorFilesApplication);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildConfigurationPagePanel() {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$application = $this->getApplication();
|
|
|
|
|
|
|
|
$engines = PhabricatorFileStorageEngine::loadAllEngines();
|
|
|
|
$writable_engines = PhabricatorFileStorageEngine::loadWritableEngines();
|
2015-03-19 03:06:39 +01:00
|
|
|
$chunk_engines = PhabricatorFileStorageEngine::loadWritableChunkEngines();
|
2015-03-12 21:28:53 +01:00
|
|
|
|
|
|
|
$yes = pht('Yes');
|
|
|
|
$no = pht('No');
|
|
|
|
|
|
|
|
$rows = array();
|
|
|
|
$rowc = array();
|
|
|
|
foreach ($engines as $key => $engine) {
|
|
|
|
$limited = $no;
|
|
|
|
$limit = null;
|
|
|
|
if ($engine->hasFilesizeLimit()) {
|
|
|
|
$limited = $yes;
|
|
|
|
$limit = phutil_format_bytes($engine->getFilesizeLimit());
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($engine->canWriteFiles()) {
|
|
|
|
$writable = $yes;
|
|
|
|
} else {
|
|
|
|
$writable = $no;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($engine->isTestEngine()) {
|
|
|
|
$test = $yes;
|
|
|
|
} else {
|
|
|
|
$test = $no;
|
|
|
|
}
|
|
|
|
|
2015-03-19 03:06:39 +01:00
|
|
|
if (isset($writable_engines[$key]) || isset($chunk_engines[$key])) {
|
2015-03-12 21:28:53 +01:00
|
|
|
$rowc[] = 'highlighted';
|
|
|
|
} else {
|
|
|
|
$rowc[] = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$rows[] = array(
|
|
|
|
$key,
|
|
|
|
get_class($engine),
|
|
|
|
$test,
|
|
|
|
$writable,
|
|
|
|
$limited,
|
|
|
|
$limit,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = id(new AphrontTableView($rows))
|
|
|
|
->setNoDataString(pht('No storage engines available.'))
|
|
|
|
->setHeaders(
|
|
|
|
array(
|
|
|
|
pht('Key'),
|
|
|
|
pht('Class'),
|
|
|
|
pht('Unit Test'),
|
|
|
|
pht('Writable'),
|
|
|
|
pht('Has Limit'),
|
|
|
|
pht('Limit'),
|
|
|
|
))
|
|
|
|
->setRowClasses($rowc)
|
|
|
|
->setColumnClasses(
|
|
|
|
array(
|
|
|
|
'',
|
|
|
|
'wide',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'n',
|
|
|
|
));
|
|
|
|
|
|
|
|
$box = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Storage Engines'))
|
[Redesign] Add Table, Collapse support to ObjectBox
Summary: Converts most all tables to be directly set via `setTable` to an ObjectBox. I think this path is more flexible design wise, as we can change the box based on children, and not just CSS. We also already do this with PropertyList, Forms, ObjectList, and Header. `setCollapsed` is added to ObjectBox to all children objects to bleed to the edges (like diffs).
Test Plan: I did a grep of `appendChild($table)` as well as searches for `PHUIObjectBoxView`, also with manual opening of hundreds of files. I'm sure I missed 5-8 places. If you just appendChild($table) nothing breaks, it just looks a little funny.
Reviewers: epriestley, btrahan
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12955
2015-05-20 21:43:34 +02:00
|
|
|
->setTable($table);
|
2015-03-12 21:28:53 +01:00
|
|
|
|
|
|
|
return $box;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handlePanelRequest(
|
|
|
|
AphrontRequest $request,
|
|
|
|
PhabricatorController $controller) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|