Page MenuHomePhabricator

D8632.id20473.diff
No OneTemporary

D8632.id20473.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2514,8 +2514,9 @@
'ReleephPHIDTypeBranch' => 'applications/releeph/phid/ReleephPHIDTypeBranch.php',
'ReleephPHIDTypeProject' => 'applications/releeph/phid/ReleephPHIDTypeProject.php',
'ReleephPHIDTypeRequest' => 'applications/releeph/phid/ReleephPHIDTypeRequest.php',
+ 'ReleephProductActionController' => 'applications/releeph/controller/project/ReleephProductActionController.php',
+ 'ReleephProductController' => 'applications/releeph/controller/project/ReleephProductController.php',
'ReleephProject' => 'applications/releeph/storage/ReleephProject.php',
- 'ReleephProjectActionController' => 'applications/releeph/controller/project/ReleephProjectActionController.php',
'ReleephProjectController' => 'applications/releeph/controller/ReleephProjectController.php',
'ReleephProjectCreateController' => 'applications/releeph/controller/project/ReleephProjectCreateController.php',
'ReleephProjectEditController' => 'applications/releeph/controller/project/ReleephProjectEditController.php',
@@ -5487,12 +5488,13 @@
'ReleephPHIDTypeBranch' => 'PhabricatorPHIDType',
'ReleephPHIDTypeProject' => 'PhabricatorPHIDType',
'ReleephPHIDTypeRequest' => 'PhabricatorPHIDType',
+ 'ReleephProductActionController' => 'ReleephProductController',
+ 'ReleephProductController' => 'ReleephController',
'ReleephProject' =>
array(
0 => 'ReleephDAO',
1 => 'PhabricatorPolicyInterface',
),
- 'ReleephProjectActionController' => 'ReleephProjectController',
'ReleephProjectController' => 'ReleephController',
'ReleephProjectCreateController' => 'ReleephProjectController',
'ReleephProjectEditController' => 'ReleephProjectController',
diff --git a/src/applications/releeph/application/PhabricatorApplicationReleeph.php b/src/applications/releeph/application/PhabricatorApplicationReleeph.php
--- a/src/applications/releeph/application/PhabricatorApplicationReleeph.php
+++ b/src/applications/releeph/application/PhabricatorApplicationReleeph.php
@@ -41,7 +41,7 @@
'(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephProjectViewController',
'edit/' => 'ReleephProjectEditController',
'cutbranch/' => 'ReleephBranchCreateController',
- 'action/(?P<action>.+)/' => 'ReleephProjectActionController',
+ 'action/(?P<action>.+)/' => 'ReleephProductActionController',
'history/' => 'ReleephProjectHistoryController',
),
),
diff --git a/src/applications/releeph/controller/project/ReleephProductActionController.php b/src/applications/releeph/controller/project/ReleephProductActionController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/releeph/controller/project/ReleephProductActionController.php
@@ -0,0 +1,78 @@
+<?php
+
+final class ReleephProductActionController extends ReleephProductController {
+
+ private $id;
+ private $action;
+
+ public function willProcessRequest(array $data) {
+ $this->id = $data['projectID'];
+ $this->action = $data['action'];
+ }
+
+ public function processRequest() {
+ $request = $this->getRequest();
+ $viewer = $request->getUser();
+
+ $product = id(new ReleephProjectQuery())
+ ->withIDs(array($this->id))
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->setViewer($viewer)
+ ->executeOne();
+ if (!$product) {
+ return new Aphront404Response();
+ }
+
+ $this->setProduct($product);
+
+ $product_id = $product->getID();
+ $product_uri = $this->getProductViewURI($product);
+
+ $action = $this->action;
+ switch ($action) {
+ case 'deactivate':
+ case 'activate':
+ break;
+ default:
+ throw new Aphront404Response();
+ }
+
+ if ($request->isFormPost()) {
+ if ($action == 'activate') {
+ $product->setIsActive(1)->save();
+ } else {
+ $product->deactivate($viewer)->save();
+ }
+
+ return id(new AphrontRedirectResponse())->setURI($product_uri);
+ }
+
+ if ($action == 'activate') {
+ $title = pht('Activate Product?');
+ $body = pht(
+ 'Reactivate the product %s?',
+ phutil_tag('strong', array(), $product->getName()));
+ $submit = pht('Reactivate Product');
+ $short = pht('Deactivate');
+ } else {
+ $title = pht('Really Deactivate Product?');
+ $body = pht(
+ 'Really deactivate the product %s?',
+ phutil_tag('strong', array(), $product->getName()));
+ $submit = pht('Deactivate Product');
+ $short = pht('Activate');
+ }
+
+ return $this->newDialog()
+ ->setTitle($title)
+ ->setShortTitle($short)
+ ->appendParagraph($body)
+ ->addSubmitButton($submit)
+ ->addCancelButton($product_uri);
+ }
+
+}
diff --git a/src/applications/releeph/controller/project/ReleephProductController.php b/src/applications/releeph/controller/project/ReleephProductController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/releeph/controller/project/ReleephProductController.php
@@ -0,0 +1,30 @@
+<?php
+
+abstract class ReleephProductController extends ReleephController {
+
+ private $product;
+
+ protected function setProduct(ReleephProject $product) {
+ $this->product = $product;
+ return $this;
+ }
+
+ protected function getProductViewURI(ReleephProject $product) {
+ return $this->getApplicationURI('project/'.$product->getID().'/');
+ }
+
+ protected function buildApplicationCrumbs() {
+ $crumbs = parent::buildApplicationCrumbs();
+
+ $product = $this->product;
+ if ($product) {
+ $crumbs->addTextCrumb(
+ $product->getName(),
+ $this->getProductViewURI($product));
+ }
+
+ return $crumbs;
+ }
+
+
+}
diff --git a/src/applications/releeph/controller/project/ReleephProjectActionController.php b/src/applications/releeph/controller/project/ReleephProjectActionController.php
deleted file mode 100644
--- a/src/applications/releeph/controller/project/ReleephProjectActionController.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-final class ReleephProjectActionController extends ReleephProjectController {
-
- private $action;
-
- public function willProcessRequest(array $data) {
- parent::willProcessRequest($data);
- $this->action = $data['action'];
- }
-
- public function processRequest() {
- $request = $this->getRequest();
- $viewer = $request->getUser();
-
- $action = $this->action;
-
- $project = id(new ReleephProjectQuery())
- ->withIDs(array($this->getReleephProject()->getID()))
- ->requireCapabilities(
- array(
- PhabricatorPolicyCapability::CAN_VIEW,
- PhabricatorPolicyCapability::CAN_EDIT,
- ))
- ->setViewer($viewer)
- ->executeOne();
- if (!$project) {
- return new Aphront404Response();
- }
-
- $project_id = $project->getID();
- $project_uri = $this->getApplicationURI("project/{$project_id}/");
-
- switch ($action) {
- case 'deactivate':
- if ($request->isDialogFormPost()) {
- $project->deactivate($viewer)->save();
- return id(new AphrontRedirectResponse())->setURI($project_uri);
- }
-
- $dialog = id(new AphrontDialogView())
- ->setUser($request->getUser())
- ->setTitle(pht('Really deactivate Releeph Project?'))
- ->appendChild(phutil_tag(
- 'p',
- array(),
- pht('Really deactivate the Releeph project: %s?',
- $project->getName())))
- ->addSubmitButton(pht('Deactivate Project'))
- ->addCancelButton($project_uri);
-
- return id(new AphrontDialogResponse())->setDialog($dialog);
- case 'activate':
- $project->setIsActive(1)->save();
- return id(new AphrontRedirectResponse())->setURI($project_uri);
- }
- }
-}
diff --git a/src/applications/releeph/controller/project/ReleephProjectViewController.php b/src/applications/releeph/controller/project/ReleephProjectViewController.php
--- a/src/applications/releeph/controller/project/ReleephProjectViewController.php
+++ b/src/applications/releeph/controller/project/ReleephProjectViewController.php
@@ -177,13 +177,6 @@
PhabricatorPolicyCapability::CAN_EDIT);
$edit_uri = $this->getApplicationURI("project/{$id}/edit/");
-
- $deactivate_uri = "project/{$id}/action/deactivate/";
- $deactivate_uri = $this->getApplicationURI($deactivate_uri);
-
- $reactivate_uri = "project/{$id}/action/activate/";
- $reactivate_uri = $this->getApplicationURI($reactivate_uri);
-
$history_uri = $this->getApplicationURI("project/{$id}/history/");
$actions->addAction(
@@ -195,27 +188,25 @@
->setWorkflow(!$can_edit));
if ($project->getIsActive()) {
- $actions->addAction(
- id(new PhabricatorActionView())
- ->setName(pht('Deactivate Project'))
- ->setHref($deactivate_uri)
- ->setIcon('delete')
- ->setDisabled(!$can_edit)
- ->setWorkflow(true));
+ $status_name = pht('Deactivate Product');
+ $status_href = "project/{$id}/action/deactivate/";
+ $status_icon = 'delete';
} else {
- $actions->addAction(
- id(new PhabricatorActionView())
- ->setName(pht('Reactivate Project'))
- ->setHref($reactivate_uri)
- ->setIcon('new')
- ->setUser($viewer)
- ->setRenderAsForm(true)
- ->setDisabled(!$can_edit)
- ->setWorkflow(true));
+ $status_name = pht('Reactivate Product');
+ $status_href = "project/{$id}/action/activate/";
+ $status_icon = 'new';
}
$actions->addAction(
id(new PhabricatorActionView())
+ ->setName($status_name)
+ ->setHref($this->getApplicationURI($status_href))
+ ->setIcon($status_icon)
+ ->setDisabled(!$can_edit)
+ ->setWorkflow(true));
+
+ $actions->addAction(
+ id(new PhabricatorActionView())
->setName(pht('View History'))
->setHref($history_uri)
->setIcon('transcript'));

File Metadata

Mime Type
text/plain
Expires
Thu, Jul 4, 2:22 PM (1 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6287257
Default Alt Text
D8632.id20473.diff (10 KB)

Event Timeline