mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
Add PholioMockArchiveController
Summary: Allows closing a mock from the action list. Ref T9414 Test Plan: New Mock, Edit Mock, Close Mock, Open Mock Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9414 Differential Revision: https://secure.phabricator.com/D14726
This commit is contained in:
parent
2e6c69e07e
commit
192a11bfdc
5 changed files with 87 additions and 18 deletions
|
@ -3386,6 +3386,7 @@ phutil_register_library_map(array(
|
|||
'PholioInlineController' => 'applications/pholio/controller/PholioInlineController.php',
|
||||
'PholioInlineListController' => 'applications/pholio/controller/PholioInlineListController.php',
|
||||
'PholioMock' => 'applications/pholio/storage/PholioMock.php',
|
||||
'PholioMockArchiveController' => 'applications/pholio/controller/PholioMockArchiveController.php',
|
||||
'PholioMockAuthorHeraldField' => 'applications/pholio/herald/PholioMockAuthorHeraldField.php',
|
||||
'PholioMockCommentController' => 'applications/pholio/controller/PholioMockCommentController.php',
|
||||
'PholioMockDescriptionHeraldField' => 'applications/pholio/herald/PholioMockDescriptionHeraldField.php',
|
||||
|
@ -7762,6 +7763,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorSpacesInterface',
|
||||
'PhabricatorMentionableInterface',
|
||||
),
|
||||
'PholioMockArchiveController' => 'PholioController',
|
||||
'PholioMockAuthorHeraldField' => 'PholioMockHeraldField',
|
||||
'PholioMockCommentController' => 'PholioController',
|
||||
'PholioMockDescriptionHeraldField' => 'PholioMockHeraldField',
|
||||
|
|
|
@ -45,6 +45,7 @@ final class PhabricatorPholioApplication extends PhabricatorApplication {
|
|||
'(?:query/(?P<queryKey>[^/]+)/)?' => 'PholioMockListController',
|
||||
'new/' => 'PholioMockEditController',
|
||||
'edit/(?P<id>\d+)/' => 'PholioMockEditController',
|
||||
'archive/(?P<id>\d+)/' => 'PholioMockArchiveController',
|
||||
'comment/(?P<id>\d+)/' => 'PholioMockCommentController',
|
||||
'inline/' => array(
|
||||
'(?:(?P<id>\d+)/)?' => 'PholioInlineController',
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
final class PholioMockArchiveController
|
||||
extends PholioController {
|
||||
|
||||
public function handleRequest(AphrontRequest $request) {
|
||||
$viewer = $request->getViewer();
|
||||
$id = $request->getURIData('id');
|
||||
|
||||
$mock = id(new PholioMockQuery())
|
||||
->setViewer($viewer)
|
||||
->withIDs(array($id))
|
||||
->requireCapabilities(
|
||||
array(
|
||||
PhabricatorPolicyCapability::CAN_VIEW,
|
||||
PhabricatorPolicyCapability::CAN_EDIT,
|
||||
))
|
||||
->executeOne();
|
||||
if (!$mock) {
|
||||
return new Aphront404Response();
|
||||
}
|
||||
|
||||
$view_uri = '/M'.$mock->getID();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
if ($mock->isClosed()) {
|
||||
$new_status = PholioMock::STATUS_OPEN;
|
||||
} else {
|
||||
$new_status = PholioMock::STATUS_CLOSED;
|
||||
}
|
||||
|
||||
$xactions = array();
|
||||
|
||||
$xactions[] = id(new PholioTransaction())
|
||||
->setTransactionType(PholioTransaction::TYPE_STATUS)
|
||||
->setNewValue($new_status);
|
||||
|
||||
id(new PholioMockEditor())
|
||||
->setActor($viewer)
|
||||
->setContentSourceFromRequest($request)
|
||||
->setContinueOnNoEffect(true)
|
||||
->setContinueOnMissingFields(true)
|
||||
->applyTransactions($mock, $xactions);
|
||||
|
||||
return id(new AphrontRedirectResponse())->setURI($view_uri);
|
||||
}
|
||||
|
||||
if ($mock->isClosed()) {
|
||||
$title = pht('Open Pholio Mock');
|
||||
$body = pht('This mock will become open again.');
|
||||
$button = pht('Open Mock');
|
||||
} else {
|
||||
$title = pht('Close Pholio Mock');
|
||||
$body = pht('This mock will be closed.');
|
||||
$button = pht('Close Mock');
|
||||
}
|
||||
|
||||
return $this->newDialog()
|
||||
->setTitle($title)
|
||||
->appendChild($body)
|
||||
->addCancelButton($view_uri)
|
||||
->addSubmitButton($button);
|
||||
}
|
||||
|
||||
}
|
|
@ -54,7 +54,6 @@ final class PholioMockEditController extends PholioController {
|
|||
|
||||
$v_name = $mock->getName();
|
||||
$v_desc = $mock->getDescription();
|
||||
$v_status = $mock->getStatus();
|
||||
$v_view = $mock->getViewPolicy();
|
||||
$v_edit = $mock->getEditPolicy();
|
||||
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID(
|
||||
|
@ -66,7 +65,6 @@ final class PholioMockEditController extends PholioController {
|
|||
|
||||
$type_name = PholioTransaction::TYPE_NAME;
|
||||
$type_desc = PholioTransaction::TYPE_DESCRIPTION;
|
||||
$type_status = PholioTransaction::TYPE_STATUS;
|
||||
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
|
||||
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
|
||||
$type_cc = PhabricatorTransactions::TYPE_SUBSCRIBERS;
|
||||
|
@ -74,7 +72,6 @@ final class PholioMockEditController extends PholioController {
|
|||
|
||||
$v_name = $request->getStr('name');
|
||||
$v_desc = $request->getStr('description');
|
||||
$v_status = $request->getStr('status');
|
||||
$v_view = $request->getStr('can_view');
|
||||
$v_edit = $request->getStr('can_edit');
|
||||
$v_cc = $request->getArr('cc');
|
||||
|
@ -84,7 +81,6 @@ final class PholioMockEditController extends PholioController {
|
|||
$mock_xactions = array();
|
||||
$mock_xactions[$type_name] = $v_name;
|
||||
$mock_xactions[$type_desc] = $v_desc;
|
||||
$mock_xactions[$type_status] = $v_status;
|
||||
$mock_xactions[$type_view] = $v_view;
|
||||
$mock_xactions[$type_edit] = $v_edit;
|
||||
$mock_xactions[$type_cc] = array('=' => $v_cc);
|
||||
|
@ -315,20 +311,7 @@ final class PholioMockEditController extends PholioController {
|
|||
->setName('description')
|
||||
->setValue($v_desc)
|
||||
->setLabel(pht('Description'))
|
||||
->setUser($viewer));
|
||||
|
||||
if ($id) {
|
||||
$form->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setLabel(pht('Status'))
|
||||
->setName('status')
|
||||
->setValue($mock->getStatus())
|
||||
->setOptions($mock->getStatuses()));
|
||||
} else {
|
||||
$form->addHiddenInput('status', 'open');
|
||||
}
|
||||
|
||||
$form
|
||||
->setUser($viewer))
|
||||
->appendControl(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel(pht('Projects'))
|
||||
|
|
|
@ -133,6 +133,24 @@ final class PholioMockViewController extends PholioController {
|
|||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit));
|
||||
|
||||
if ($mock->isClosed()) {
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-check')
|
||||
->setName(pht('Open Mock'))
|
||||
->setHref($this->getApplicationURI('/archive/'.$mock->getID().'/'))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(true));
|
||||
} else {
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-ban')
|
||||
->setName(pht('Close Mock'))
|
||||
->setHref($this->getApplicationURI('/archive/'.$mock->getID().'/'))
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(true));
|
||||
}
|
||||
|
||||
$actions->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-anchor')
|
||||
|
|
Loading…
Reference in a new issue