From 7c063c7d634eafbd847a9cbab825bfeaead7558a Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 5 May 2015 15:59:56 -0700 Subject: [PATCH] Show which capability is being edited in custom policy dialog Summary: Fixes T7867. Test Plan: {F392844} Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7867 Differential Revision: https://secure.phabricator.com/D12716 --- resources/celerity/map.php | 26 +++++++++---------- .../PhabricatorPolicyEditController.php | 23 +++++++++------- .../form/control/AphrontFormPolicyControl.php | 1 + .../policy/behavior-policy-control.js | 5 ++-- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 903c0668b3..68403f3d52 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -116,7 +116,7 @@ return array( 'rsrc/css/font/font-source-sans-pro.css' => '8906c07b', 'rsrc/css/font/phui-font-icon-base.css' => '3dad2ae3', 'rsrc/css/layout/phabricator-filetree-view.css' => 'fccf9f82', - 'rsrc/css/layout/phabricator-hovercard-view.css' => 'f5f18f7d', + 'rsrc/css/layout/phabricator-hovercard-view.css' => '44394670', 'rsrc/css/layout/phabricator-side-menu-view.css' => 'c1db9e9c', 'rsrc/css/layout/phabricator-source-code-view.css' => '2ceee894', 'rsrc/css/phui/calendar/phui-calendar-day.css' => '75b8cc4a', @@ -411,7 +411,7 @@ return array( 'rsrc/js/application/phortune/behavior-stripe-payment-form.js' => '3f5d6dbf', 'rsrc/js/application/phortune/behavior-test-payment-form.js' => 'fc91ab6c', 'rsrc/js/application/phortune/phortune-credit-card-form.js' => '2290aeef', - 'rsrc/js/application/policy/behavior-policy-control.js' => '1ed33505', + 'rsrc/js/application/policy/behavior-policy-control.js' => '9a340b3d', 'rsrc/js/application/policy/behavior-policy-rule-editor.js' => '5e9f347c', 'rsrc/js/application/ponder/behavior-votebox.js' => '4e9b766b', 'rsrc/js/application/projects/behavior-project-boards.js' => '60292820', @@ -639,7 +639,7 @@ return array( 'javelin-behavior-pholio-mock-view' => 'e58bf807', 'javelin-behavior-phui-object-box-tabs' => '2bfa2836', 'javelin-behavior-phui-timeline-dropdown-menu' => '4d94d9c3', - 'javelin-behavior-policy-control' => '1ed33505', + 'javelin-behavior-policy-control' => '9a340b3d', 'javelin-behavior-policy-rule-editor' => '5e9f347c', 'javelin-behavior-ponder-votebox' => '4e9b766b', 'javelin-behavior-project-boards' => '60292820', @@ -734,7 +734,7 @@ return array( 'phabricator-filetree-view-css' => 'fccf9f82', 'phabricator-flag-css' => '5337623f', 'phabricator-hovercard' => '7e8468ae', - 'phabricator-hovercard-view-css' => 'f5f18f7d', + 'phabricator-hovercard-view-css' => '44394670', 'phabricator-keyboard-shortcut' => '1ae869f2', 'phabricator-keyboard-shortcut-manager' => 'c1700f6f', 'phabricator-main-menu-view' => '663e3810', @@ -954,15 +954,6 @@ return array( 'javelin-dom', 'javelin-reactor-dom', ), - '1ed33505' => array( - 'javelin-behavior', - 'javelin-dom', - 'javelin-util', - 'phuix-dropdown-menu', - 'phuix-action-list-view', - 'phuix-action-view', - 'javelin-workflow', - ), '2035b9cb' => array( 'javelin-behavior', 'javelin-dom', @@ -1604,6 +1595,15 @@ return array( 'javelin-dom', 'javelin-reactor-dom', ), + '9a340b3d' => array( + 'javelin-behavior', + 'javelin-dom', + 'javelin-util', + 'phuix-dropdown-menu', + 'phuix-action-list-view', + 'phuix-action-view', + 'javelin-workflow', + ), '9c2623f4' => array( 'javelin-behavior', 'javelin-stratcom', diff --git a/src/applications/policy/controller/PhabricatorPolicyEditController.php b/src/applications/policy/controller/PhabricatorPolicyEditController.php index d8cf20d38a..4c044a6dc7 100644 --- a/src/applications/policy/controller/PhabricatorPolicyEditController.php +++ b/src/applications/policy/controller/PhabricatorPolicyEditController.php @@ -3,13 +3,7 @@ final class PhabricatorPolicyEditController extends PhabricatorPolicyController { - private $phid; - - public function willProcessRequest(array $data) { - $this->phid = idx($data, 'phid'); - } - - public function processRequest() { + public function handleRequest(AphrontRequest $request) { $request = $this->getRequest(); $viewer = $request->getUser(); @@ -29,10 +23,11 @@ final class PhabricatorPolicyEditController 'value' => null, ); - if ($this->phid) { + $phid = $request->getURIData('phid'); + if ($phid) { $policies = id(new PhabricatorPolicyQuery()) ->setViewer($viewer) - ->withPHIDs(array($this->phid)) + ->withPHIDs(array($phid)) ->execute(); if (!$policies) { return new Aphront404Response(); @@ -208,10 +203,18 @@ final class PhabricatorPolicyEditController 'defaultRule' => $default_rule, )); + $title = pht('Custom Policy'); + + $key = $request->getStr('capability'); + if ($key) { + $capability = PhabricatorPolicyCapability::getCapabilityByKey($key); + $title = pht('Custom "%s" Policy', $capability->getCapabilityName()); + } + $dialog = id(new AphrontDialogView()) ->setWidth(AphrontDialogView::WIDTH_FULL) ->setUser($viewer) - ->setTitle(pht('Edit Policy')) + ->setTitle($title) ->appendChild($form) ->addSubmitButton(pht('Save Policy')) ->addCancelButton('#'); diff --git a/src/view/form/control/AphrontFormPolicyControl.php b/src/view/form/control/AphrontFormPolicyControl.php index 2b588a8a33..2997969c77 100644 --- a/src/view/form/control/AphrontFormPolicyControl.php +++ b/src/view/form/control/AphrontFormPolicyControl.php @@ -179,6 +179,7 @@ final class AphrontFormPolicyControl extends AphrontFormControl { 'icons' => $icons, 'labels' => $labels, 'value' => $this->getValue(), + 'capability' => $this->capability, 'customPlaceholder' => $this->getCustomPolicyPlaceholder(), )); diff --git a/webroot/rsrc/js/application/policy/behavior-policy-control.js b/webroot/rsrc/js/application/policy/behavior-policy-control.js index 22998576a8..ddbe9f17ec 100644 --- a/webroot/rsrc/js/application/policy/behavior-policy-control.js +++ b/webroot/rsrc/js/application/policy/behavior-policy-control.js @@ -35,7 +35,7 @@ JX.behavior('policy-control', function(config) { var onselect; if (group == 'custom') { onselect = JX.bind(null, function(phid) { - var uri = get_custom_uri(phid); + var uri = get_custom_uri(phid, config.capability); new JX.Workflow(uri) .setHandler(function(response) { @@ -100,11 +100,12 @@ JX.behavior('policy-control', function(config) { /** * Get the workflow URI to create or edit a policy with a given PHID. */ - var get_custom_uri = function(phid) { + var get_custom_uri = function(phid, capability) { var uri = '/policy/edit/'; if (phid != config.customPlaceholder) { uri += phid + '/'; } + uri += '?capability=' + capability; return uri; };