1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-19 13:22:42 +01:00

Add PhabricatorOwnersArchiveController

Summary: Ability to Archive and Activate Packages from the view page. Ref T9414

Test Plan: New Package, Edit Package, Archive Package, Activate Package

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9414

Differential Revision: https://secure.phabricator.com/D14728
This commit is contained in:
Chad Little 2015-12-09 13:41:31 -08:00
parent dec69e21b3
commit 90c4880aaa
5 changed files with 94 additions and 13 deletions

View file

@ -2568,6 +2568,7 @@ phutil_register_library_map(array(
'PhabricatorOpcodeCacheSpec' => 'applications/cache/spec/PhabricatorOpcodeCacheSpec.php',
'PhabricatorOwnerPathQuery' => 'applications/owners/query/PhabricatorOwnerPathQuery.php',
'PhabricatorOwnersApplication' => 'applications/owners/application/PhabricatorOwnersApplication.php',
'PhabricatorOwnersArchiveController' => 'applications/owners/controller/PhabricatorOwnersArchiveController.php',
'PhabricatorOwnersConfigOptions' => 'applications/owners/config/PhabricatorOwnersConfigOptions.php',
'PhabricatorOwnersConfiguredCustomField' => 'applications/owners/customfield/PhabricatorOwnersConfiguredCustomField.php',
'PhabricatorOwnersController' => 'applications/owners/controller/PhabricatorOwnersController.php',
@ -6762,6 +6763,7 @@ phutil_register_library_map(array(
'PhabricatorOpcodeCacheSpec' => 'PhabricatorCacheSpec',
'PhabricatorOwnerPathQuery' => 'Phobject',
'PhabricatorOwnersApplication' => 'PhabricatorApplication',
'PhabricatorOwnersArchiveController' => 'PhabricatorOwnersController',
'PhabricatorOwnersConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorOwnersConfiguredCustomField' => array(
'PhabricatorOwnersCustomField',

View file

@ -45,6 +45,7 @@ final class PhabricatorOwnersApplication extends PhabricatorApplication {
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PhabricatorOwnersListController',
'new/' => 'PhabricatorOwnersEditController',
'package/(?P<id>[1-9]\d*)/' => 'PhabricatorOwnersDetailController',
'archive/(?P<id>[1-9]\d*)/' => 'PhabricatorOwnersArchiveController',
'paths/(?P<id>[1-9]\d*)/' => 'PhabricatorOwnersPathsController',
$this->getEditRoutePattern('edit/')

View file

@ -0,0 +1,65 @@
<?php
final class PhabricatorOwnersArchiveController
extends PhabricatorOwnersController {
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$package = id(new PhabricatorOwnersPackageQuery())
->setViewer($viewer)
->withIDs(array($id))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$package) {
return new Aphront404Response();
}
$view_uri = $this->getApplicationURI('package/'.$package->getID().'/');
if ($request->isFormPost()) {
if ($package->isArchived()) {
$new_status = PhabricatorOwnersPackage::STATUS_ACTIVE;
} else {
$new_status = PhabricatorOwnersPackage::STATUS_ARCHIVED;
}
$xactions = array();
$xactions[] = id(new PhabricatorOwnersPackageTransaction())
->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_STATUS)
->setNewValue($new_status);
id(new PhabricatorOwnersPackageTransactionEditor())
->setActor($viewer)
->setContentSourceFromRequest($request)
->setContinueOnNoEffect(true)
->setContinueOnMissingFields(true)
->applyTransactions($package, $xactions);
return id(new AphrontRedirectResponse())->setURI($view_uri);
}
if ($package->isArchived()) {
$title = pht('Activate Package');
$body = pht('This package will become active again.');
$button = pht('Activate Package');
} else {
$title = pht('Archive Package');
$body = pht('This package will be marked as archived.');
$button = pht('Archive Package');
}
return $this->newDialog()
->setTitle($title)
->appendChild($body)
->addCancelButton($view_uri)
->addSubmitButton($button);
}
}

View file

@ -219,17 +219,37 @@ final class PhabricatorOwnersDetailController
$edit_uri = $this->getApplicationURI("/edit/{$id}/");
$paths_uri = $this->getApplicationURI("/paths/{$id}/");
$view = id(new PhabricatorActionListView())
$action_list = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($package)
->addAction(
->setObject($package);
$action_list->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Package'))
->setIcon('fa-pencil')
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)
->setHref($edit_uri))
->addAction(
->setHref($edit_uri));
if ($package->isArchived()) {
$action_list->addAction(
id(new PhabricatorActionView())
->setName(pht('Activate Package'))
->setIcon('fa-check')
->setDisabled(!$can_edit)
->setWorkflow($can_edit)
->setHref($this->getApplicationURI("/archive/{$id}/")));
} else {
$action_list->addAction(
id(new PhabricatorActionView())
->setName(pht('Archive Package'))
->setIcon('fa-ban')
->setDisabled(!$can_edit)
->setWorkflow($can_edit)
->setHref($this->getApplicationURI("/archive/{$id}/")));
}
$action_list->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Paths'))
->setIcon('fa-folder-open')
@ -237,7 +257,7 @@ final class PhabricatorOwnersDetailController
->setWorkflow(!$can_edit)
->setHref($paths_uri));
return $view;
return $action_list;
}
private function renderPathsTable(array $paths, array $repositories) {

View file

@ -60,13 +60,6 @@ final class PhabricatorOwnersPackageEditEngine
->setDatasource(new PhabricatorProjectOrUserDatasource())
->setIsCopyable(true)
->setValue($object->getOwnerPHIDs()),
id(new PhabricatorSelectEditField())
->setKey('status')
->setLabel(pht('Status'))
->setDescription(pht('Archive or enable the package.'))
->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_STATUS)
->setValue($object->getStatus())
->setOptions($object->getStatusNameMap()),
id(new PhabricatorSelectEditField())
->setKey('auditing')
->setLabel(pht('Auditing'))