1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 09:12:41 +01:00

Sort out EditController / ManageController / EditproController Diffusion hierarchy

Summary: Ref T10923. This cleans up the remaining "pro" mess left by the cutover.

Test Plan: Viewed, managed, edited a repository.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10923

Differential Revision: https://secure.phabricator.com/D15871
This commit is contained in:
epriestley 2016-05-09 14:24:21 -07:00
parent f191f66f34
commit 3328e78a7b
11 changed files with 221 additions and 230 deletions

View file

@ -762,10 +762,10 @@ phutil_register_library_map(array(
'DiffusionRepositoryEditDeleteController' => 'applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php', 'DiffusionRepositoryEditDeleteController' => 'applications/diffusion/controller/DiffusionRepositoryEditDeleteController.php',
'DiffusionRepositoryEditEngine' => 'applications/diffusion/editor/DiffusionRepositoryEditEngine.php', 'DiffusionRepositoryEditEngine' => 'applications/diffusion/editor/DiffusionRepositoryEditEngine.php',
'DiffusionRepositoryEditUpdateController' => 'applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php', 'DiffusionRepositoryEditUpdateController' => 'applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php',
'DiffusionRepositoryEditproController' => 'applications/diffusion/controller/DiffusionRepositoryEditproController.php',
'DiffusionRepositoryHistoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php', 'DiffusionRepositoryHistoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php',
'DiffusionRepositoryListController' => 'applications/diffusion/controller/DiffusionRepositoryListController.php', 'DiffusionRepositoryListController' => 'applications/diffusion/controller/DiffusionRepositoryListController.php',
'DiffusionRepositoryManageController' => 'applications/diffusion/controller/DiffusionRepositoryManageController.php', 'DiffusionRepositoryManageController' => 'applications/diffusion/controller/DiffusionRepositoryManageController.php',
'DiffusionRepositoryManagePanelsController' => 'applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php',
'DiffusionRepositoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryManagementPanel.php', 'DiffusionRepositoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryManagementPanel.php',
'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php', 'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php',
'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php', 'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php',
@ -4975,17 +4975,17 @@ phutil_register_library_map(array(
'DiffusionRepositoryDatasource' => 'PhabricatorTypeaheadDatasource', 'DiffusionRepositoryDatasource' => 'PhabricatorTypeaheadDatasource',
'DiffusionRepositoryDefaultController' => 'DiffusionController', 'DiffusionRepositoryDefaultController' => 'DiffusionController',
'DiffusionRepositoryDocumentationManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryDocumentationManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositoryEditActivateController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditActivateController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod', 'DiffusionRepositoryEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'DiffusionRepositoryEditController' => 'DiffusionController', 'DiffusionRepositoryEditController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryEditDangerousController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditDangerousController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryEditDeleteController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditDeleteController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryEditEngine' => 'PhabricatorEditEngine', 'DiffusionRepositoryEditEngine' => 'PhabricatorEditEngine',
'DiffusionRepositoryEditUpdateController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryEditUpdateController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryEditproController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryHistoryManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryHistoryManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositoryListController' => 'DiffusionController', 'DiffusionRepositoryListController' => 'DiffusionController',
'DiffusionRepositoryManageController' => 'DiffusionController', 'DiffusionRepositoryManageController' => 'DiffusionController',
'DiffusionRepositoryManagePanelsController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryManagementPanel' => 'Phobject', 'DiffusionRepositoryManagementPanel' => 'Phobject',
'DiffusionRepositoryPath' => 'Phobject', 'DiffusionRepositoryPath' => 'Phobject',
'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel',
@ -4997,7 +4997,7 @@ phutil_register_library_map(array(
'DiffusionRepositoryStorageManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryStorageManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositorySymbolsManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositorySymbolsManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositoryTag' => 'Phobject', 'DiffusionRepositoryTag' => 'Phobject',
'DiffusionRepositoryTestAutomationController' => 'DiffusionRepositoryEditController', 'DiffusionRepositoryTestAutomationController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryURICredentialController' => 'DiffusionController', 'DiffusionRepositoryURICredentialController' => 'DiffusionController',
'DiffusionRepositoryURIDisableController' => 'DiffusionController', 'DiffusionRepositoryURIDisableController' => 'DiffusionController',
'DiffusionRepositoryURIEditController' => 'DiffusionController', 'DiffusionRepositoryURIEditController' => 'DiffusionController',

View file

@ -58,7 +58,7 @@ final class PhabricatorDiffusionApplication extends PhabricatorApplication {
$this->getQueryRoutePattern() $this->getQueryRoutePattern()
=> 'DiffusionRepositoryListController', => 'DiffusionRepositoryListController',
$this->getEditRoutePattern('edit/') => $this->getEditRoutePattern('edit/') =>
'DiffusionRepositoryEditproController', 'DiffusionRepositoryEditController',
'pushlog/' => array( 'pushlog/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'DiffusionPushLogListController', '(?:query/(?P<queryKey>[^/]+)/)?' => 'DiffusionPushLogListController',
'view/(?P<id>\d+)/' => 'DiffusionPushEventViewController', 'view/(?P<id>\d+)/' => 'DiffusionPushEventViewController',
@ -87,7 +87,7 @@ final class PhabricatorDiffusionApplication extends PhabricatorApplication {
'commit/(?P<commit>[a-z0-9]+)/edit/' 'commit/(?P<commit>[a-z0-9]+)/edit/'
=> 'DiffusionCommitEditController', => 'DiffusionCommitEditController',
'manage/(?:(?P<panel>[^/]+)/)?' 'manage/(?:(?P<panel>[^/]+)/)?'
=> 'DiffusionRepositoryManageController', => 'DiffusionRepositoryManagePanelsController',
'uri/' => array( 'uri/' => array(
'view/(?P<id>[0-9]\d*)/' => 'DiffusionRepositoryURIViewController', 'view/(?P<id>[0-9]\d*)/' => 'DiffusionRepositoryURIViewController',
'disable/(?P<id>[0-9]\d*)/' 'disable/(?P<id>[0-9]\d*)/'

View file

@ -1,7 +1,7 @@
<?php <?php
final class DiffusionRepositoryEditActivateController final class DiffusionRepositoryEditActivateController
extends DiffusionRepositoryEditController { extends DiffusionRepositoryManageController {
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContextForEdit(); $response = $this->loadDiffusionContextForEdit();

View file

@ -1,28 +1,69 @@
<?php <?php
abstract class DiffusionRepositoryEditController final class DiffusionRepositoryEditController
extends DiffusionController { extends DiffusionRepositoryManageController {
protected function buildApplicationCrumbs($is_main = false) { public function handleRequest(AphrontRequest $request) {
$crumbs = parent::buildApplicationCrumbs(); $engine = id(new DiffusionRepositoryEditEngine())
->setController($this);
if ($this->hasDiffusionRequest()) { $id = $request->getURIData('id');
$drequest = $this->getDiffusionRequest(); if (!$id) {
$repository = $drequest->getRepository(); $this->requireApplicationCapability(
$repo_uri = $repository->getURI(); DiffusionCreateRepositoriesCapability::CAPABILITY);
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$crumbs->addTextCrumb($repository->getDisplayname(), $repo_uri); $vcs = $request->getStr('vcs');
$vcs_types = PhabricatorRepositoryType::getRepositoryTypeMap();
if ($is_main) { if (empty($vcs_types[$vcs])) {
$crumbs->addTextCrumb(pht('Edit Repository')); return $this->buildVCSTypeResponse();
} else {
$crumbs->addTextCrumb(pht('Edit'), $edit_uri);
} }
$engine
->addContextParameter('vcs', $vcs)
->setVersionControlSystem($vcs);
} }
return $engine->buildResponse();
}
private function buildVCSTypeResponse() {
$vcs_types = PhabricatorRepositoryType::getRepositoryTypeMap();
$request = $this->getRequest();
$viewer = $this->getViewer();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Create Repository'));
$crumbs->setBorder(true); $crumbs->setBorder(true);
return $crumbs; $title = pht('Choose Repository Type');
$header = id(new PHUIHeaderView())
->setHeader(pht('Create Repository'))
->setHeaderIcon('fa-plus-square');
$layout = id(new AphrontMultiColumnView())
->setFluidLayout(true);
$create_uri = $request->getRequestURI();
foreach ($vcs_types as $vcs_key => $vcs_type) {
$action = id(new PHUIActionPanelView())
->setIcon(idx($vcs_type, 'icon'))
->setHeader(idx($vcs_type, 'create.header'))
->setHref($create_uri->alter('vcs', $vcs_key))
->setSubheader(idx($vcs_type, 'create.subheader'));
$layout->addColumn($action);
}
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter($layout);
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild($view);
} }
} }

View file

@ -1,7 +1,7 @@
<?php <?php
final class DiffusionRepositoryEditDangerousController final class DiffusionRepositoryEditDangerousController
extends DiffusionRepositoryEditController { extends DiffusionRepositoryManageController {
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContextForEdit(); $response = $this->loadDiffusionContextForEdit();

View file

@ -1,7 +1,7 @@
<?php <?php
final class DiffusionRepositoryEditDeleteController final class DiffusionRepositoryEditDeleteController
extends DiffusionRepositoryEditController { extends DiffusionRepositoryManageController {
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContextForEdit(); $response = $this->loadDiffusionContextForEdit();

View file

@ -1,7 +1,7 @@
<?php <?php
final class DiffusionRepositoryEditUpdateController final class DiffusionRepositoryEditUpdateController
extends DiffusionRepositoryEditController { extends DiffusionRepositoryManageController {
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContextForEdit(); $response = $this->loadDiffusionContextForEdit();

View file

@ -1,69 +0,0 @@
<?php
final class DiffusionRepositoryEditproController
extends DiffusionRepositoryEditController {
public function handleRequest(AphrontRequest $request) {
$engine = id(new DiffusionRepositoryEditEngine())
->setController($this);
$id = $request->getURIData('id');
if (!$id) {
$this->requireApplicationCapability(
DiffusionCreateRepositoriesCapability::CAPABILITY);
$vcs = $request->getStr('vcs');
$vcs_types = PhabricatorRepositoryType::getRepositoryTypeMap();
if (empty($vcs_types[$vcs])) {
return $this->buildVCSTypeResponse();
}
$engine
->addContextParameter('vcs', $vcs)
->setVersionControlSystem($vcs);
}
return $engine->buildResponse();
}
private function buildVCSTypeResponse() {
$vcs_types = PhabricatorRepositoryType::getRepositoryTypeMap();
$request = $this->getRequest();
$viewer = $this->getViewer();
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Create Repository'));
$crumbs->setBorder(true);
$title = pht('Choose Repository Type');
$header = id(new PHUIHeaderView())
->setHeader(pht('Create Repository'))
->setHeaderIcon('fa-plus-square');
$layout = id(new AphrontMultiColumnView())
->setFluidLayout(true);
$create_uri = $request->getRequestURI();
foreach ($vcs_types as $vcs_key => $vcs_type) {
$action = id(new PHUIActionPanelView())
->setIcon(idx($vcs_type, 'icon'))
->setHeader(idx($vcs_type, 'create.header'))
->setHref($create_uri->alter('vcs', $vcs_key))
->setSubheader(idx($vcs_type, 'create.subheader'));
$layout->addColumn($action);
}
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter($layout);
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild($view);
}
}

View file

@ -1,139 +1,25 @@
<?php <?php
final class DiffusionRepositoryManageController abstract class DiffusionRepositoryManageController
extends DiffusionController { extends DiffusionController {
private $navigation; protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
public function buildApplicationMenu() { if ($this->hasDiffusionRequest()) {
// TODO: This is messy for now; the mobile menu should be set automatically $drequest = $this->getDiffusionRequest();
// when the body content is a two-column view with navigation. $repository = $drequest->getRepository();
if ($this->navigation) {
return $this->navigation->getMenu(); $crumbs->addTextCrumb(
$repository->getDisplayName(),
$repository->getURI());
$crumbs->addTextCrumb(
pht('Manage'),
$repository->getPathURI('manage/'));
} }
return parent::buildApplicationMenu();
return $crumbs;
} }
public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContext();
if ($response) {
return $response;
}
$viewer = $this->getViewer();
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$panels = DiffusionRepositoryManagementPanel::getAllPanels();
foreach ($panels as $panel) {
$panel
->setViewer($viewer)
->setRepository($repository)
->setController($this);
}
$selected = $request->getURIData('panel');
if (!strlen($selected)) {
$selected = head_key($panels);
}
if (empty($panels[$selected])) {
return new Aphront404Response();
}
$nav = $this->renderSideNav($repository, $panels, $selected);
$this->navigation = $nav;
$panel = $panels[$selected];
$content = $panel->buildManagementPanelContent();
$title = array(
$panel->getManagementPanelLabel(),
$repository->getDisplayName(),
);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(
$repository->getDisplayName(),
$repository->getURI());
$crumbs->addTextCrumb(
pht('Manage'),
$repository->getPathURI('manage/'));
$crumbs->addTextCrumb($panel->getManagementPanelLabel());
$header_text = pht(
'%s: %s',
$repository->getDisplayName(),
$panel->getManagementPanelLabel());
$header = id(new PHUIHeaderView())
->setHeader($header_text)
->setHeaderIcon('fa-pencil');
if ($repository->isTracked()) {
$header->setStatus('fa-check', 'bluegrey', pht('Active'));
} else {
$header->setStatus('fa-ban', 'dark', pht('Inactive'));
}
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setNavigation($nav)
->setMainColumn($content);
$curtain = $panel->buildManagementPanelCurtain();
if ($curtain) {
$view->setCurtain($curtain);
}
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild($view);
}
private function renderSideNav(
PhabricatorRepository $repository,
array $panels,
$selected) {
$base_uri = $repository->getPathURI('manage/');
$base_uri = new PhutilURI($base_uri);
$nav = id(new AphrontSideNavFilterView())
->setBaseURI($base_uri);
foreach ($panels as $panel) {
$key = $panel->getManagementPanelKey();
$label = $panel->getManagementPanelLabel();
$icon = $panel->getManagementPanelIcon();
$href = $panel->getPanelNavigationURI();
$item = id(new PHUIListItemView())
->setKey($key)
->setName($label)
->setType(PHUIListItemView::TYPE_LINK)
->setHref($href)
->setIcon($icon);
$nav->addMenuItem($item);
}
$nav->selectFilter($selected);
return $nav;
}
public function newTimeline(PhabricatorRepository $repository) {
$timeline = $this->buildTransactionTimeline(
$repository,
new PhabricatorRepositoryTransactionQuery());
$timeline->setShouldTerminate(true);
return $timeline;
}
} }

View file

@ -0,0 +1,133 @@
<?php
final class DiffusionRepositoryManagePanelsController
extends DiffusionRepositoryManageController {
private $navigation;
public function buildApplicationMenu() {
// TODO: This is messy for now; the mobile menu should be set automatically
// when the body content is a two-column view with navigation.
if ($this->navigation) {
return $this->navigation->getMenu();
}
return parent::buildApplicationMenu();
}
public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContext();
if ($response) {
return $response;
}
$viewer = $this->getViewer();
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$panels = DiffusionRepositoryManagementPanel::getAllPanels();
foreach ($panels as $panel) {
$panel
->setViewer($viewer)
->setRepository($repository)
->setController($this);
}
$selected = $request->getURIData('panel');
if (!strlen($selected)) {
$selected = head_key($panels);
}
if (empty($panels[$selected])) {
return new Aphront404Response();
}
$nav = $this->renderSideNav($repository, $panels, $selected);
$this->navigation = $nav;
$panel = $panels[$selected];
$content = $panel->buildManagementPanelContent();
$title = array(
$panel->getManagementPanelLabel(),
$repository->getDisplayName(),
);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($panel->getManagementPanelLabel());
$header_text = pht(
'%s: %s',
$repository->getDisplayName(),
$panel->getManagementPanelLabel());
$header = id(new PHUIHeaderView())
->setHeader($header_text)
->setHeaderIcon('fa-pencil');
if ($repository->isTracked()) {
$header->setStatus('fa-check', 'bluegrey', pht('Active'));
} else {
$header->setStatus('fa-ban', 'dark', pht('Inactive'));
}
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setNavigation($nav)
->setMainColumn($content);
$curtain = $panel->buildManagementPanelCurtain();
if ($curtain) {
$view->setCurtain($curtain);
}
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->appendChild($view);
}
private function renderSideNav(
PhabricatorRepository $repository,
array $panels,
$selected) {
$base_uri = $repository->getPathURI('manage/');
$base_uri = new PhutilURI($base_uri);
$nav = id(new AphrontSideNavFilterView())
->setBaseURI($base_uri);
foreach ($panels as $panel) {
$key = $panel->getManagementPanelKey();
$label = $panel->getManagementPanelLabel();
$icon = $panel->getManagementPanelIcon();
$href = $panel->getPanelNavigationURI();
$item = id(new PHUIListItemView())
->setKey($key)
->setName($label)
->setType(PHUIListItemView::TYPE_LINK)
->setHref($href)
->setIcon($icon);
$nav->addMenuItem($item);
}
$nav->selectFilter($selected);
return $nav;
}
public function newTimeline(PhabricatorRepository $repository) {
$timeline = $this->buildTransactionTimeline(
$repository,
new PhabricatorRepositoryTransactionQuery());
$timeline->setShouldTerminate(true);
return $timeline;
}
}

View file

@ -1,7 +1,7 @@
<?php <?php
final class DiffusionRepositoryTestAutomationController final class DiffusionRepositoryTestAutomationController
extends DiffusionRepositoryEditController { extends DiffusionRepositoryManageController {
public function handleRequest(AphrontRequest $request) { public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContextForEdit(); $response = $this->loadDiffusionContextForEdit();