mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-26 05:29:06 +01:00
Summary: This removes all calls to addSpacer and the method. We were applying it inconsistently and it was causing spacing issues with redesigning the sidenav. My feeling is we can recreate the space in CSS if the design dictates, which would apply it consistently. Test Plan: Go to Applications, click on every application. Reviewers: epriestley, btrahan Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D4420
86 lines
2 KiB
PHP
86 lines
2 KiB
PHP
<?php
|
|
|
|
final class PhabricatorSettingsMainController
|
|
extends PhabricatorController {
|
|
|
|
private $key;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->key = idx($data, 'key');
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
|
|
$panels = $this->buildPanels();
|
|
$nav = $this->renderSideNav($panels);
|
|
|
|
$key = $nav->selectFilter($this->key, head($panels)->getPanelKey());
|
|
|
|
|
|
$panel = $panels[$key];
|
|
|
|
$response = $panel->processRequest($request);
|
|
if ($response instanceof AphrontResponse) {
|
|
return $response;
|
|
}
|
|
|
|
$nav->appendChild($response);
|
|
return $this->buildApplicationPage(
|
|
$nav,
|
|
array(
|
|
'title' => $panel->getPanelName(),
|
|
));
|
|
}
|
|
|
|
private function buildPanels() {
|
|
$panel_specs = id(new PhutilSymbolLoader())
|
|
->setAncestorClass('PhabricatorSettingsPanel')
|
|
->setConcreteOnly(true)
|
|
->selectAndLoadSymbols();
|
|
|
|
$panels = array();
|
|
foreach ($panel_specs as $spec) {
|
|
$class = newv($spec['name'], array());
|
|
$panels[] = $class->buildPanels();
|
|
}
|
|
|
|
$panels = array_mergev($panels);
|
|
$panels = mpull($panels, null, 'getPanelKey');
|
|
|
|
$result = array();
|
|
foreach ($panels as $key => $panel) {
|
|
if (!$panel->isEnabled()) {
|
|
continue;
|
|
}
|
|
if (!empty($result[$key])) {
|
|
throw new Exception(
|
|
"Two settings panels share the same panel key ('{$key}'): ".
|
|
get_class($panel).', '.get_class($result[$key]).'.');
|
|
}
|
|
$result[$key] = $panel;
|
|
}
|
|
|
|
$result = msort($result, 'getPanelSortKey');
|
|
|
|
return $result;
|
|
}
|
|
|
|
private function renderSideNav(array $panels) {
|
|
$nav = new AphrontSideNavFilterView();
|
|
$nav->setBaseURI(new PhutilURI($this->getApplicationURI('/panel/')));
|
|
|
|
$group = null;
|
|
foreach ($panels as $panel) {
|
|
if ($panel->getPanelGroup() != $group) {
|
|
$group = $panel->getPanelGroup();
|
|
$nav->addLabel($group);
|
|
}
|
|
|
|
$nav->addFilter($panel->getPanelKey(), $panel->getPanelName());
|
|
}
|
|
|
|
return $nav;
|
|
}
|
|
|
|
}
|