From 57a76d8a70a124c76025dcdf4427e624138687fb Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 26 Apr 2016 15:54:01 -0700 Subject: [PATCH] Port "Automation" panel to new Repository Manage UI Summary: Ref T10748. Ports this UI and exposes it on the EditEngine. Test Plan: - Edited via EditEngine. - Viewed new manage UI. Reviewers: chad Reviewed By: chad Subscribers: hach-que Maniphest Tasks: T10748 Differential Revision: https://secure.phabricator.com/D15804 --- src/__phutil_library_map__.php | 2 + .../editor/DiffusionRepositoryEditEngine.php | 11 +++ ...ionRepositoryAutomationManagementPanel.php | 69 +++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 src/applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 953e5a4eb8..337d4406a9 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -743,6 +743,7 @@ phutil_register_library_map(array( 'DiffusionRefTableController' => 'applications/diffusion/controller/DiffusionRefTableController.php', 'DiffusionRefsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionRefsQueryConduitAPIMethod.php', 'DiffusionRenameHistoryQuery' => 'applications/diffusion/query/DiffusionRenameHistoryQuery.php', + 'DiffusionRepositoryAutomationManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php', 'DiffusionRepositoryBasicsManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryBasicsManagementPanel.php', 'DiffusionRepositoryByIDRemarkupRule' => 'applications/diffusion/remarkup/DiffusionRepositoryByIDRemarkupRule.php', 'DiffusionRepositoryClusterEngine' => 'applications/diffusion/protocol/DiffusionRepositoryClusterEngine.php', @@ -4959,6 +4960,7 @@ phutil_register_library_map(array( 'DiffusionRefTableController' => 'DiffusionController', 'DiffusionRefsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 'DiffusionRenameHistoryQuery' => 'Phobject', + 'DiffusionRepositoryAutomationManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryBasicsManagementPanel' => 'DiffusionRepositoryManagementPanel', 'DiffusionRepositoryByIDRemarkupRule' => 'PhabricatorObjectRemarkupRule', 'DiffusionRepositoryClusterEngine' => 'Phobject', diff --git a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php index 0a33d87712..dc3db7d0d5 100644 --- a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php +++ b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php @@ -162,6 +162,17 @@ final class DiffusionRepositoryEditEngine ->setConduitDescription(pht('Set the staging area URI.')) ->setConduitTypeDescription(pht('New staging area URI.')) ->setValue($object->getStagingURI()), + id(new PhabricatorDatasourceEditField()) + ->setKey('automationBlueprintPHIDs') + ->setLabel(pht('Use Blueprints')) + ->setTransactionType( + PhabricatorRepositoryTransaction::TYPE_AUTOMATION_BLUEPRINTS) + ->setIsCopyable(true) + ->setDatasource(new DrydockBlueprintDatasource()) + ->setDescription(pht('Automation blueprints.')) + ->setConduitDescription(pht('Change automation blueprints.')) + ->setConduitTypeDescription(pht('New blueprint PHIDs.')) + ->setValue($object->getAutomationBlueprintPHIDs()), id(new PhabricatorPolicyEditField()) ->setKey('policy.push') ->setLabel(pht('Push Policy')) diff --git a/src/applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php new file mode 100644 index 0000000000..beed039c4f --- /dev/null +++ b/src/applications/diffusion/management/DiffusionRepositoryAutomationManagementPanel.php @@ -0,0 +1,69 @@ +getRepository(); + $viewer = $this->getViewer(); + + $can_edit = PhabricatorPolicyFilter::hasCapability( + $viewer, + $repository, + PhabricatorPolicyCapability::CAN_EDIT); + + $can_test = $can_edit && $repository->canPerformAutomation(); + + $automation_uri = $repository->getPathURI('edit/automation/'); + $test_uri = $repository->getPathURI('edit/testautomation/'); + + return array( + id(new PhabricatorActionView()) + ->setIcon('fa-pencil') + ->setName(pht('Edit Automation')) + ->setHref($automation_uri) + ->setDisabled(!$can_edit) + ->setWorkflow(!$can_edit), + id(new PhabricatorActionView()) + ->setIcon('fa-gamepad') + ->setName(pht('Test Configuration')) + ->setWorkflow(true) + ->setDisabled(!$can_test) + ->setHref($test_uri), + ); + } + + public function buildManagementPanelContent() { + $repository = $this->getRepository(); + $viewer = $this->getViewer(); + + $view = id(new PHUIPropertyListView()) + ->setViewer($viewer) + ->setActionList($this->newActions()); + + $blueprint_phids = $repository->getAutomationBlueprintPHIDs(); + if (!$blueprint_phids) { + $blueprint_view = phutil_tag('em', array(), pht('Not Configured')); + } else { + $blueprint_view = id(new DrydockObjectAuthorizationView()) + ->setUser($viewer) + ->setObjectPHID($repository->getPHID()) + ->setBlueprintPHIDs($blueprint_phids); + } + + $view->addProperty(pht('Automation'), $blueprint_view); + + return $this->newBox(pht('Automation'), $view); + } + +}