1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42: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',
'DiffusionRepositoryEditEngine' => 'applications/diffusion/editor/DiffusionRepositoryEditEngine.php',
'DiffusionRepositoryEditUpdateController' => 'applications/diffusion/controller/DiffusionRepositoryEditUpdateController.php',
'DiffusionRepositoryEditproController' => 'applications/diffusion/controller/DiffusionRepositoryEditproController.php',
'DiffusionRepositoryHistoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php',
'DiffusionRepositoryListController' => 'applications/diffusion/controller/DiffusionRepositoryListController.php',
'DiffusionRepositoryManageController' => 'applications/diffusion/controller/DiffusionRepositoryManageController.php',
'DiffusionRepositoryManagePanelsController' => 'applications/diffusion/controller/DiffusionRepositoryManagePanelsController.php',
'DiffusionRepositoryManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryManagementPanel.php',
'DiffusionRepositoryPath' => 'applications/diffusion/data/DiffusionRepositoryPath.php',
'DiffusionRepositoryPoliciesManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryPoliciesManagementPanel.php',
@ -4975,17 +4975,17 @@ phutil_register_library_map(array(
'DiffusionRepositoryDatasource' => 'PhabricatorTypeaheadDatasource',
'DiffusionRepositoryDefaultController' => 'DiffusionController',
'DiffusionRepositoryDocumentationManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositoryEditActivateController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryEditActivateController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryEditConduitAPIMethod' => 'PhabricatorEditEngineAPIMethod',
'DiffusionRepositoryEditController' => 'DiffusionController',
'DiffusionRepositoryEditDangerousController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryEditDeleteController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryEditController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryEditDangerousController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryEditDeleteController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryEditEngine' => 'PhabricatorEditEngine',
'DiffusionRepositoryEditUpdateController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryEditproController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryEditUpdateController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryHistoryManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositoryListController' => 'DiffusionController',
'DiffusionRepositoryManageController' => 'DiffusionController',
'DiffusionRepositoryManagePanelsController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryManagementPanel' => 'Phobject',
'DiffusionRepositoryPath' => 'Phobject',
'DiffusionRepositoryPoliciesManagementPanel' => 'DiffusionRepositoryManagementPanel',
@ -4997,7 +4997,7 @@ phutil_register_library_map(array(
'DiffusionRepositoryStorageManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositorySymbolsManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositoryTag' => 'Phobject',
'DiffusionRepositoryTestAutomationController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryTestAutomationController' => 'DiffusionRepositoryManageController',
'DiffusionRepositoryURICredentialController' => 'DiffusionController',
'DiffusionRepositoryURIDisableController' => 'DiffusionController',
'DiffusionRepositoryURIEditController' => 'DiffusionController',

View file

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

View file

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

View file

@ -1,28 +1,69 @@
<?php
abstract class DiffusionRepositoryEditController
extends DiffusionController {
final class DiffusionRepositoryEditController
extends DiffusionRepositoryManageController {
protected function buildApplicationCrumbs($is_main = false) {
$crumbs = parent::buildApplicationCrumbs();
public function handleRequest(AphrontRequest $request) {
$engine = id(new DiffusionRepositoryEditEngine())
->setController($this);
if ($this->hasDiffusionRequest()) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$repo_uri = $repository->getURI();
$edit_uri = $this->getRepositoryControllerURI($repository, 'edit/');
$id = $request->getURIData('id');
if (!$id) {
$this->requireApplicationCapability(
DiffusionCreateRepositoriesCapability::CAPABILITY);
$crumbs->addTextCrumb($repository->getDisplayname(), $repo_uri);
if ($is_main) {
$crumbs->addTextCrumb(pht('Edit Repository'));
} else {
$crumbs->addTextCrumb(pht('Edit'), $edit_uri);
$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);
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
final class DiffusionRepositoryEditDangerousController
extends DiffusionRepositoryEditController {
extends DiffusionRepositoryManageController {
public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContextForEdit();

View file

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

View file

@ -1,7 +1,7 @@
<?php
final class DiffusionRepositoryEditUpdateController
extends DiffusionRepositoryEditController {
extends DiffusionRepositoryManageController {
public function handleRequest(AphrontRequest $request) {
$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
final class DiffusionRepositoryManageController
abstract class DiffusionRepositoryManageController
extends DiffusionController {
private $navigation;
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
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();
if ($this->hasDiffusionRequest()) {
$drequest = $this->getDiffusionRequest();
$repository = $drequest->getRepository();
$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
final class DiffusionRepositoryTestAutomationController
extends DiffusionRepositoryEditController {
extends DiffusionRepositoryManageController {
public function handleRequest(AphrontRequest $request) {
$response = $this->loadDiffusionContextForEdit();