@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve messaging of special policy rules in applications

Summary: Ref T603. When the user encounters an action which is controlled by a special policy rule in the application, make it easier for applications to show the user what policy controls the action and what the setting is. I took this about halfway before and left a TODO, but turn it into something more useful.

Test Plan: See screenshots.

Reviewers: btrahan, chad

Reviewed By: chad

CC: chad, aran

Maniphest Tasks: T603

Differential Revision: https://secure.phabricator.com/D7265

+85 -24
+9
src/__celerity_resource_map__.php
··· 3884 3884 ), 3885 3885 'disk' => '/rsrc/css/phui/phui-workpanel-view.css', 3886 3886 ), 3887 + 'policy-css' => 3888 + array( 3889 + 'uri' => '/res/ebb12aa0/rsrc/css/application/policy/policy.css', 3890 + 'type' => 'css', 3891 + 'requires' => 3892 + array( 3893 + ), 3894 + 'disk' => '/rsrc/css/application/policy/policy.css', 3895 + ), 3887 3896 'ponder-comment-table-css' => 3888 3897 array( 3889 3898 'uri' => '/res/4aa4b865/rsrc/css/application/ponder/comments.css',
+40 -3
src/applications/base/controller/PhabricatorController.php
··· 364 364 $capability); 365 365 } 366 366 367 - protected function explainApplicationCapability($capability, $message) { 368 - // TODO: Render a link to get more information. 369 - return $message; 367 + protected function explainApplicationCapability( 368 + $capability, 369 + $positive_message, 370 + $negative_message) { 371 + 372 + $can_act = $this->hasApplicationCapability($capability); 373 + if ($can_act) { 374 + $message = $positive_message; 375 + $icon_name = 'enable-grey'; 376 + } else { 377 + $message = $negative_message; 378 + $icon_name = 'lock'; 379 + } 380 + 381 + $icon = id(new PHUIIconView()) 382 + ->setSpriteSheet(PHUIIconView::SPRITE_ICONS) 383 + ->setSpriteIcon($icon_name); 384 + 385 + require_celerity_resource('policy-css'); 386 + 387 + $phid = $this->getCurrentApplication()->getPHID(); 388 + $explain_uri = "/policy/explain/{$phid}/{$capability}/"; 389 + 390 + $message = phutil_tag( 391 + 'div', 392 + array( 393 + 'class' => 'policy-capability-explanation', 394 + ), 395 + array( 396 + $icon, 397 + javelin_tag( 398 + 'a', 399 + array( 400 + 'href' => $explain_uri, 401 + 'sigil' => 'workflow', 402 + ), 403 + $message), 404 + )); 405 + 406 + return array($can_act, $message); 370 407 } 371 408 372 409 }
+10 -19
src/applications/herald/controller/HeraldNewController.php
··· 17 17 $this->requireApplicationCapability( 18 18 HeraldCapabilityCreateRules::CAPABILITY); 19 19 20 - $can_global = $this->hasApplicationCapability( 21 - HeraldCapabilityManageGlobalRules::CAPABILITY); 22 - 23 20 $content_type_map = HeraldAdapter::getEnabledAdapterMap($user); 24 21 if (empty($content_type_map[$this->contentType])) { 25 22 $this->contentType = head_key($content_type_map); ··· 37 34 HeraldRuleTypeConfig::RULE_TYPE_PERSONAL, 38 35 )) + $rule_type_map; 39 36 40 - if (!$can_global) { 41 - $global_link = $this->explainApplicationCapability( 42 - HeraldCapabilityManageGlobalRules::CAPABILITY, 43 - pht('You do not have permission to create or manage global rules.')); 44 - } else { 45 - $global_link = null; 46 - } 37 + list($can_global, $global_link) = $this->explainApplicationCapability( 38 + HeraldCapabilityManageGlobalRules::CAPABILITY, 39 + pht('You have permission to create and manage global rules.'), 40 + pht('You do not have permission to create or manage global rules.')); 47 41 48 42 $captions = array( 49 43 HeraldRuleTypeConfig::RULE_TYPE_PERSONAL => ··· 52 46 'only affect you. Personal rules only trigger for objects you have '. 53 47 'permission to see.'), 54 48 HeraldRuleTypeConfig::RULE_TYPE_GLOBAL => 55 - phutil_implode_html( 56 - phutil_tag('br'), 57 - array_filter( 58 - array( 59 - pht( 60 - 'Global rules notify anyone about events. Global rules can '. 61 - 'bypass access control policies and act on any object.'), 62 - $global_link, 63 - ))), 49 + array( 50 + pht( 51 + 'Global rules notify anyone about events. Global rules can '. 52 + 'bypass access control policies and act on any object.'), 53 + $global_link, 54 + ), 64 55 ); 65 56 66 57 $radio = id(new AphrontFormRadioButtonControl())
+7 -1
src/applications/policy/controller/PhabricatorPolicyExplainController.php
··· 63 63 $auto_info = phutil_tag('ul', array(), $auto_info); 64 64 } 65 65 66 + $capability_name = $capability; 67 + $capobj = PhabricatorPolicyCapability::getCapabilityByKey($capability); 68 + if ($capobj) { 69 + $capability_name = $capobj->getCapabilityName(); 70 + } 71 + 66 72 $content = array( 67 - pht('Users with the "%s" capability:', "Can View"), 73 + pht('Users with the "%s" capability:', $capability_name), 68 74 $auto_info, 69 75 ); 70 76
+1 -1
src/view/form/control/AphrontFormRadioButtonControl.php
··· 50 50 ), 51 51 $button['label']); 52 52 53 - if (strlen($button['caption'])) { 53 + if ($button['caption']) { 54 54 $label = hsprintf( 55 55 '%s<div class="aphront-form-radio-caption">%s</div>', 56 56 $label,
+18
webroot/rsrc/css/application/policy/policy.css
··· 1 + /** 2 + * @provides policy-css 3 + */ 4 + 5 + .policy-capability-explanation .phui-icon-view { 6 + display: inline-block; 7 + vertical-align: text-top; 8 + } 9 + 10 + .policy-capability-explanation { 11 + margin: 8px 0 0; 12 + } 13 + 14 + .policy-capability-explanation a { 15 + line-height: 14px; 16 + margin-left: 4px; 17 + color: {$bluetext}; 18 + }