1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-20 12:30:56 +01:00

Modularize config modules + add edges, phid modules

Summary: Fixes T6859. Adds a readout in `/config/` of installed edge and PHID types. See also D13626.

Test Plan: {F643222}

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T6859

Differential Revision: https://secure.phabricator.com/D13662
This commit is contained in:
epriestley 2015-07-20 17:08:37 -07:00
parent e0bba9bae7
commit ffa4cae627
9 changed files with 210 additions and 60 deletions

View file

@ -1741,6 +1741,7 @@ phutil_register_library_map(array(
'PhabricatorConfigDatabaseStatusController' => 'applications/config/controller/PhabricatorConfigDatabaseStatusController.php', 'PhabricatorConfigDatabaseStatusController' => 'applications/config/controller/PhabricatorConfigDatabaseStatusController.php',
'PhabricatorConfigDefaultSource' => 'infrastructure/env/PhabricatorConfigDefaultSource.php', 'PhabricatorConfigDefaultSource' => 'infrastructure/env/PhabricatorConfigDefaultSource.php',
'PhabricatorConfigDictionarySource' => 'infrastructure/env/PhabricatorConfigDictionarySource.php', 'PhabricatorConfigDictionarySource' => 'infrastructure/env/PhabricatorConfigDictionarySource.php',
'PhabricatorConfigEdgeModule' => 'applications/config/module/PhabricatorConfigEdgeModule.php',
'PhabricatorConfigEditController' => 'applications/config/controller/PhabricatorConfigEditController.php', 'PhabricatorConfigEditController' => 'applications/config/controller/PhabricatorConfigEditController.php',
'PhabricatorConfigEditor' => 'applications/config/editor/PhabricatorConfigEditor.php', 'PhabricatorConfigEditor' => 'applications/config/editor/PhabricatorConfigEditor.php',
'PhabricatorConfigEntry' => 'applications/config/storage/PhabricatorConfigEntry.php', 'PhabricatorConfigEntry' => 'applications/config/storage/PhabricatorConfigEntry.php',
@ -1763,14 +1764,17 @@ phutil_register_library_map(array(
'PhabricatorConfigManagementMigrateWorkflow' => 'applications/config/management/PhabricatorConfigManagementMigrateWorkflow.php', 'PhabricatorConfigManagementMigrateWorkflow' => 'applications/config/management/PhabricatorConfigManagementMigrateWorkflow.php',
'PhabricatorConfigManagementSetWorkflow' => 'applications/config/management/PhabricatorConfigManagementSetWorkflow.php', 'PhabricatorConfigManagementSetWorkflow' => 'applications/config/management/PhabricatorConfigManagementSetWorkflow.php',
'PhabricatorConfigManagementWorkflow' => 'applications/config/management/PhabricatorConfigManagementWorkflow.php', 'PhabricatorConfigManagementWorkflow' => 'applications/config/management/PhabricatorConfigManagementWorkflow.php',
'PhabricatorConfigModule' => 'applications/config/module/PhabricatorConfigModule.php',
'PhabricatorConfigModuleController' => 'applications/config/controller/PhabricatorConfigModuleController.php',
'PhabricatorConfigOption' => 'applications/config/option/PhabricatorConfigOption.php', 'PhabricatorConfigOption' => 'applications/config/option/PhabricatorConfigOption.php',
'PhabricatorConfigOptionType' => 'applications/config/custom/PhabricatorConfigOptionType.php', 'PhabricatorConfigOptionType' => 'applications/config/custom/PhabricatorConfigOptionType.php',
'PhabricatorConfigPHIDModule' => 'applications/config/module/PhabricatorConfigPHIDModule.php',
'PhabricatorConfigProxySource' => 'infrastructure/env/PhabricatorConfigProxySource.php', 'PhabricatorConfigProxySource' => 'infrastructure/env/PhabricatorConfigProxySource.php',
'PhabricatorConfigResponse' => 'applications/config/response/PhabricatorConfigResponse.php', 'PhabricatorConfigResponse' => 'applications/config/response/PhabricatorConfigResponse.php',
'PhabricatorConfigSchemaQuery' => 'applications/config/schema/PhabricatorConfigSchemaQuery.php', 'PhabricatorConfigSchemaQuery' => 'applications/config/schema/PhabricatorConfigSchemaQuery.php',
'PhabricatorConfigSchemaSpec' => 'applications/config/schema/PhabricatorConfigSchemaSpec.php', 'PhabricatorConfigSchemaSpec' => 'applications/config/schema/PhabricatorConfigSchemaSpec.php',
'PhabricatorConfigServerSchema' => 'applications/config/schema/PhabricatorConfigServerSchema.php', 'PhabricatorConfigServerSchema' => 'applications/config/schema/PhabricatorConfigServerSchema.php',
'PhabricatorConfigSiteModuleController' => 'applications/config/controller/PhabricatorConfigSiteModuleController.php', 'PhabricatorConfigSiteModule' => 'applications/config/module/PhabricatorConfigSiteModule.php',
'PhabricatorConfigSiteSource' => 'infrastructure/env/PhabricatorConfigSiteSource.php', 'PhabricatorConfigSiteSource' => 'infrastructure/env/PhabricatorConfigSiteSource.php',
'PhabricatorConfigSource' => 'infrastructure/env/PhabricatorConfigSource.php', 'PhabricatorConfigSource' => 'infrastructure/env/PhabricatorConfigSource.php',
'PhabricatorConfigStackSource' => 'infrastructure/env/PhabricatorConfigStackSource.php', 'PhabricatorConfigStackSource' => 'infrastructure/env/PhabricatorConfigStackSource.php',
@ -5478,6 +5482,7 @@ phutil_register_library_map(array(
'PhabricatorConfigDatabaseStatusController' => 'PhabricatorConfigDatabaseController', 'PhabricatorConfigDatabaseStatusController' => 'PhabricatorConfigDatabaseController',
'PhabricatorConfigDefaultSource' => 'PhabricatorConfigProxySource', 'PhabricatorConfigDefaultSource' => 'PhabricatorConfigProxySource',
'PhabricatorConfigDictionarySource' => 'PhabricatorConfigSource', 'PhabricatorConfigDictionarySource' => 'PhabricatorConfigSource',
'PhabricatorConfigEdgeModule' => 'PhabricatorConfigModule',
'PhabricatorConfigEditController' => 'PhabricatorConfigController', 'PhabricatorConfigEditController' => 'PhabricatorConfigController',
'PhabricatorConfigEditor' => 'PhabricatorApplicationTransactionEditor', 'PhabricatorConfigEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorConfigEntry' => array( 'PhabricatorConfigEntry' => array(
@ -5504,17 +5509,20 @@ phutil_register_library_map(array(
'PhabricatorConfigManagementMigrateWorkflow' => 'PhabricatorConfigManagementWorkflow', 'PhabricatorConfigManagementMigrateWorkflow' => 'PhabricatorConfigManagementWorkflow',
'PhabricatorConfigManagementSetWorkflow' => 'PhabricatorConfigManagementWorkflow', 'PhabricatorConfigManagementSetWorkflow' => 'PhabricatorConfigManagementWorkflow',
'PhabricatorConfigManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorConfigManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorConfigModule' => 'Phobject',
'PhabricatorConfigModuleController' => 'PhabricatorConfigController',
'PhabricatorConfigOption' => array( 'PhabricatorConfigOption' => array(
'Phobject', 'Phobject',
'PhabricatorMarkupInterface', 'PhabricatorMarkupInterface',
), ),
'PhabricatorConfigOptionType' => 'Phobject', 'PhabricatorConfigOptionType' => 'Phobject',
'PhabricatorConfigPHIDModule' => 'PhabricatorConfigModule',
'PhabricatorConfigProxySource' => 'PhabricatorConfigSource', 'PhabricatorConfigProxySource' => 'PhabricatorConfigSource',
'PhabricatorConfigResponse' => 'AphrontStandaloneHTMLResponse', 'PhabricatorConfigResponse' => 'AphrontStandaloneHTMLResponse',
'PhabricatorConfigSchemaQuery' => 'Phobject', 'PhabricatorConfigSchemaQuery' => 'Phobject',
'PhabricatorConfigSchemaSpec' => 'Phobject', 'PhabricatorConfigSchemaSpec' => 'Phobject',
'PhabricatorConfigServerSchema' => 'PhabricatorConfigStorageSchema', 'PhabricatorConfigServerSchema' => 'PhabricatorConfigStorageSchema',
'PhabricatorConfigSiteModuleController' => 'PhabricatorConfigController', 'PhabricatorConfigSiteModule' => 'PhabricatorConfigModule',
'PhabricatorConfigSiteSource' => 'PhabricatorConfigProxySource', 'PhabricatorConfigSiteSource' => 'PhabricatorConfigProxySource',
'PhabricatorConfigSource' => 'Phobject', 'PhabricatorConfigSource' => 'Phobject',
'PhabricatorConfigStackSource' => 'PhabricatorConfigSource', 'PhabricatorConfigStackSource' => 'PhabricatorConfigSource',

View file

@ -57,7 +57,7 @@ final class PhabricatorConfigApplication extends PhabricatorApplication {
), ),
'cache/' => 'PhabricatorConfigCacheController', 'cache/' => 'PhabricatorConfigCacheController',
'module/' => array( 'module/' => array(
'sites/' => 'PhabricatorConfigSiteModuleController', '(?P<module>[^/]+)/' => 'PhabricatorConfigModuleController',
), ),
), ),
); );

View file

@ -25,7 +25,11 @@ abstract class PhabricatorConfigController extends PhabricatorController {
$nav->addLabel(pht('Welcome')); $nav->addLabel(pht('Welcome'));
$nav->addFilter('welcome/', pht('Welcome Screen')); $nav->addFilter('welcome/', pht('Welcome Screen'));
$nav->addLabel(pht('Modules')); $nav->addLabel(pht('Modules'));
$nav->addFilter('module/sites/', pht('Sites'));
$modules = PhabricatorConfigModule::getAllModules();
foreach ($modules as $key => $module) {
$nav->addFilter('module/'.$key.'/', $module->getModuleName());
}
return $nav; return $nav;
} }

View file

@ -0,0 +1,37 @@
<?php
final class PhabricatorConfigModuleController
extends PhabricatorConfigController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$key = $request->getURIData('module');
$all_modules = PhabricatorConfigModule::getAllModules();
if (empty($all_modules[$key])) {
return new Aphront404Response();
}
$module = $all_modules[$key];
$content = $module->renderModuleStatus($request);
$name = $module->getModuleName();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($name);
$nav = $this->buildSideNavView();
$nav->selectFilter('module/'.$key.'/');
$nav->appendChild(
array(
$crumbs,
$content,
));
return $this->buildApplicationPage(
$nav,
array(
'title' => $name,
));
}
}

View file

@ -1,56 +0,0 @@
<?php
final class PhabricatorConfigSiteModuleController
extends PhabricatorConfigController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$sites = AphrontSite::getAllSites();
$rows = array();
foreach ($sites as $key => $site) {
$rows[] = array(
$site->getPriority(),
$key,
$site->getDescription(),
);
}
$table = id(new AphrontTableView($rows))
->setHeaders(
array(
pht('Priority'),
pht('Class'),
pht('Description'),
))
->setColumnClasses(
array(
null,
'pri',
'wide',
));
$box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Site Modules'))
->appendChild($table);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Site Modules'));
$nav = $this->buildSideNavView();
$nav->selectFilter('module/sites/');
$nav->appendChild(
array(
$crumbs,
$box,
));
return $this->buildApplicationPage(
$nav,
array(
'title' => array(pht('Site Modules')),
));
}
}

View file

@ -0,0 +1,47 @@
<?php
final class PhabricatorConfigEdgeModule extends PhabricatorConfigModule {
public function getModuleKey() {
return 'edge';
}
public function getModuleName() {
return pht('Edge Types');
}
public function renderModuleStatus(AphrontRequest $request) {
$viewer = $request->getViewer();
$types = PhabricatorEdgeType::getAllTypes();
$types = msort($types, 'getEdgeConstant');
$rows = array();
foreach ($types as $key => $type) {
$rows[] = array(
$type->getEdgeConstant(),
$type->getInverseEdgeConstant(),
get_class($type),
);
}
$table = id(new AphrontTableView($rows))
->setHeaders(
array(
pht('Constant'),
pht('Inverse'),
pht('Class'),
))
->setColumnClasses(
array(
null,
null,
'pri wide',
));
return id(new PHUIObjectBoxView())
->setHeaderText(pht('Edge Types'))
->appendChild($table);
}
}

View file

@ -0,0 +1,17 @@
<?php
abstract class PhabricatorConfigModule extends Phobject {
abstract public function getModuleKey();
abstract public function getModuleName();
abstract public function renderModuleStatus(AphrontRequest $request);
final public static function getAllModules() {
return id(new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setUniqueMethod('getModuleKey')
->setSortMethod('getModuleName')
->execute();
}
}

View file

@ -0,0 +1,47 @@
<?php
final class PhabricatorConfigPHIDModule extends PhabricatorConfigModule {
public function getModuleKey() {
return 'phid';
}
public function getModuleName() {
return pht('PHID Types');
}
public function renderModuleStatus(AphrontRequest $request) {
$viewer = $request->getViewer();
$types = PhabricatorPHIDType::getAllTypes();
$types = msort($types, 'getTypeConstant');
$rows = array();
foreach ($types as $key => $type) {
$rows[] = array(
$type->getTypeConstant(),
get_class($type),
$type->getTypeName(),
);
}
$table = id(new AphrontTableView($rows))
->setHeaders(
array(
pht('Constant'),
pht('Class'),
pht('Name'),
))
->setColumnClasses(
array(
null,
'pri',
'wide',
));
return id(new PHUIObjectBoxView())
->setHeaderText(pht('PHID Types'))
->appendChild($table);
}
}

View file

@ -0,0 +1,46 @@
<?php
final class PhabricatorConfigSiteModule extends PhabricatorConfigModule {
public function getModuleKey() {
return 'site';
}
public function getModuleName() {
return pht('Sites');
}
public function renderModuleStatus(AphrontRequest $request) {
$viewer = $request->getViewer();
$sites = AphrontSite::getAllSites();
$rows = array();
foreach ($sites as $key => $site) {
$rows[] = array(
$site->getPriority(),
$key,
$site->getDescription(),
);
}
$table = id(new AphrontTableView($rows))
->setHeaders(
array(
pht('Priority'),
pht('Class'),
pht('Description'),
))
->setColumnClasses(
array(
null,
'pri',
'wide',
));
return id(new PHUIObjectBoxView())
->setHeaderText(pht('Sites'))
->appendChild($table);
}
}