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 @@ -2568,6 +2568,7 @@ '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 @@ 'PhabricatorOpcodeCacheSpec' => 'PhabricatorCacheSpec', 'PhabricatorOwnerPathQuery' => 'Phobject', 'PhabricatorOwnersApplication' => 'PhabricatorApplication', + 'PhabricatorOwnersArchiveController' => 'PhabricatorOwnersController', 'PhabricatorOwnersConfigOptions' => 'PhabricatorApplicationConfigOptions', 'PhabricatorOwnersConfiguredCustomField' => array( 'PhabricatorOwnersCustomField', diff --git a/src/applications/owners/application/PhabricatorOwnersApplication.php b/src/applications/owners/application/PhabricatorOwnersApplication.php --- a/src/applications/owners/application/PhabricatorOwnersApplication.php +++ b/src/applications/owners/application/PhabricatorOwnersApplication.php @@ -45,6 +45,7 @@ '(?:query/(?P[^/]+)/)?' => 'PhabricatorOwnersListController', 'new/' => 'PhabricatorOwnersEditController', 'package/(?P[1-9]\d*)/' => 'PhabricatorOwnersDetailController', + 'archive/(?P[1-9]\d*)/' => 'PhabricatorOwnersArchiveController', 'paths/(?P[1-9]\d*)/' => 'PhabricatorOwnersPathsController', $this->getEditRoutePattern('edit/') diff --git a/src/applications/owners/controller/PhabricatorOwnersArchiveController.php b/src/applications/owners/controller/PhabricatorOwnersArchiveController.php new file mode 100644 --- /dev/null +++ b/src/applications/owners/controller/PhabricatorOwnersArchiveController.php @@ -0,0 +1,65 @@ +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); + } + +} diff --git a/src/applications/owners/controller/PhabricatorOwnersDetailController.php b/src/applications/owners/controller/PhabricatorOwnersDetailController.php --- a/src/applications/owners/controller/PhabricatorOwnersDetailController.php +++ b/src/applications/owners/controller/PhabricatorOwnersDetailController.php @@ -219,17 +219,37 @@ $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 @@ ->setWorkflow(!$can_edit) ->setHref($paths_uri)); - return $view; + return $action_list; } private function renderPathsTable(array $paths, array $repositories) { diff --git a/src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php b/src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php --- a/src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php +++ b/src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php @@ -61,13 +61,6 @@ ->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')) ->setDescription(