@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

Remove "stronger/weaker" policy color hints from object headers

Summary:
Fixes T13461. Some applications provide hints about policy strength in the header, but these hints are inconsistent and somewhat confusing. They don't make much sense for modern objects with Custom Forms, which don't have a single "default" policy.

Remove this feature since it seems to be confusing things more than illuminating them.

Test Plan:
- Viewed various objects, no longer saw colored policy hints.
- Grepped for all removed symbols.

Maniphest Tasks: T13461

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

+3 -177
+3 -3
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => '3c8a0668', 11 11 'conpherence.pkg.js' => '020aebcf', 12 - 'core.pkg.css' => '77de226f', 12 + 'core.pkg.css' => 'b88ac037', 13 13 'core.pkg.js' => '705aec2c', 14 14 'differential.pkg.css' => '607c84be', 15 15 'differential.pkg.js' => '1b97518d', ··· 155 155 'rsrc/css/phui/phui-form-view.css' => '01b796c0', 156 156 'rsrc/css/phui/phui-form.css' => '159e2d9c', 157 157 'rsrc/css/phui/phui-head-thing.css' => 'd7f293df', 158 - 'rsrc/css/phui/phui-header-view.css' => 'b500eeea', 158 + 'rsrc/css/phui/phui-header-view.css' => 'be09cc83', 159 159 'rsrc/css/phui/phui-hovercard.css' => '6ca90fa0', 160 160 'rsrc/css/phui/phui-icon-set-selector.css' => '7aa5f3ec', 161 161 'rsrc/css/phui/phui-icon.css' => '4cbc684a', ··· 843 843 'phui-form-css' => '159e2d9c', 844 844 'phui-form-view-css' => '01b796c0', 845 845 'phui-head-thing-view-css' => 'd7f293df', 846 - 'phui-header-view-css' => 'b500eeea', 846 + 'phui-header-view-css' => 'be09cc83', 847 847 'phui-hovercard' => '074f0783', 848 848 'phui-hovercard-view-css' => '6ca90fa0', 849 849 'phui-icon-set-selector-css' => '7aa5f3ec',
-2
src/__phutil_library_map__.php
··· 4218 4218 'PhabricatorPolicyRule' => 'applications/policy/rule/PhabricatorPolicyRule.php', 4219 4219 'PhabricatorPolicyRulesView' => 'applications/policy/view/PhabricatorPolicyRulesView.php', 4220 4220 'PhabricatorPolicySearchEngineExtension' => 'applications/policy/engineextension/PhabricatorPolicySearchEngineExtension.php', 4221 - 'PhabricatorPolicyStrengthConstants' => 'applications/policy/constants/PhabricatorPolicyStrengthConstants.php', 4222 4221 'PhabricatorPolicyTestCase' => 'applications/policy/__tests__/PhabricatorPolicyTestCase.php', 4223 4222 'PhabricatorPolicyTestObject' => 'applications/policy/__tests__/PhabricatorPolicyTestObject.php', 4224 4223 'PhabricatorPolicyType' => 'applications/policy/constants/PhabricatorPolicyType.php', ··· 10730 10729 'PhabricatorPolicyRule' => 'Phobject', 10731 10730 'PhabricatorPolicyRulesView' => 'AphrontView', 10732 10731 'PhabricatorPolicySearchEngineExtension' => 'PhabricatorSearchEngineExtension', 10733 - 'PhabricatorPolicyStrengthConstants' => 'PhabricatorPolicyConstants', 10734 10732 'PhabricatorPolicyTestCase' => 'PhabricatorTestCase', 10735 10733 'PhabricatorPolicyTestObject' => array( 10736 10734 'Phobject',
-17
src/applications/phriction/codex/PhrictionDocumentPolicyCodex.php
··· 41 41 ->executeOne(); 42 42 } 43 43 44 - public function compareToDefaultPolicy(PhabricatorPolicy $policy) { 45 - $root_policy = $this->getDefaultPolicy(); 46 - $strongest_policy = $this->getStrongestPolicy(); 47 - 48 - // Note that we never return 'weaker', because Phriction documents can 49 - // never have weaker permissions than their parents. If this object has 50 - // been set to weaker permissions anyway, return 'adjusted'. 51 - if ($root_policy == $strongest_policy) { 52 - $strength = null; 53 - } else if ($strongest_policy->isStrongerThan($root_policy)) { 54 - $strength = PhabricatorPolicyStrengthConstants::STRONGER; 55 - } else { 56 - $strength = PhabricatorPolicyStrengthConstants::ADJUSTED; 57 - } 58 - return $strength; 59 - } 60 - 61 44 private function getStrongestPolicy() { 62 45 $ancestors = $this->getObject()->getAncestors(); 63 46 $ancestors[] = $this->getObject();
-4
src/applications/policy/codex/PhabricatorPolicyCodex.php
··· 40 40 $this->capability); 41 41 } 42 42 43 - public function compareToDefaultPolicy(PhabricatorPolicy $policy) { 44 - return null; 45 - } 46 - 47 43 final protected function newRule() { 48 44 return new PhabricatorPolicyCodexRuleDescription(); 49 45 }
-9
src/applications/policy/constants/PhabricatorPolicyStrengthConstants.php
··· 1 - <?php 2 - 3 - final class PhabricatorPolicyStrengthConstants 4 - extends PhabricatorPolicyConstants { 5 - 6 - const WEAKER = 'weaker'; 7 - const STRONGER = 'stronger'; 8 - const ADJUSTED = 'adjusted'; 9 - }
-68
src/applications/policy/controller/PhabricatorPolicyExplainController.php
··· 163 163 return $space_section; 164 164 } 165 165 166 - private function getStrengthInformation( 167 - PhabricatorPolicyInterface $object, 168 - PhabricatorPolicy $policy, 169 - $capability) { 170 - $viewer = $this->getViewer(); 171 - 172 - 173 - $strength = null; 174 - if ($object instanceof PhabricatorPolicyCodexInterface) { 175 - $codex = id(PhabricatorPolicyCodex::newFromObject($object, $viewer)) 176 - ->setCapability($capability); 177 - $strength = $codex->compareToDefaultPolicy($policy); 178 - $default_policy = $codex->getDefaultPolicy(); 179 - } else { 180 - $default_policy = PhabricatorPolicyQuery::getDefaultPolicyForObject( 181 - $viewer, 182 - $object, 183 - $capability); 184 - 185 - if ($default_policy) { 186 - if ($default_policy->getPHID() == $policy->getPHID()) { 187 - return; 188 - } 189 - 190 - if ($default_policy->getPHID() != $policy->getPHID()) { 191 - if ($default_policy->isStrongerThan($policy)) { 192 - $strength = PhabricatorPolicyStrengthConstants::WEAKER; 193 - } else if ($policy->isStrongerThan($default_policy)) { 194 - $strength = PhabricatorPolicyStrengthConstants::STRONGER; 195 - } else { 196 - $strength = PhabricatorPolicyStrengthConstants::ADJUSTED; 197 - } 198 - } 199 - } 200 - } 201 - 202 - if (!$strength) { 203 - return; 204 - } 205 - 206 - if ($strength == PhabricatorPolicyStrengthConstants::WEAKER) { 207 - $info = pht( 208 - 'This object has a less restrictive policy ("%s") than the default '. 209 - 'policy for similar objects (which is "%s").', 210 - $policy->getShortName(), 211 - $default_policy->getShortName()); 212 - } else if ($strength == PhabricatorPolicyStrengthConstants::STRONGER) { 213 - $info = pht( 214 - 'This object has a more restrictive policy ("%s") than the default '. 215 - 'policy for similar objects (which is "%s").', 216 - $policy->getShortName(), 217 - $default_policy->getShortName()); 218 - } else { 219 - $info = pht( 220 - 'This object has a different policy ("%s") than the default policy '. 221 - 'for similar objects (which is "%s").', 222 - $policy->getShortName(), 223 - $default_policy->getShortName()); 224 - } 225 - 226 - return $info; 227 - } 228 - 229 166 private function getCapabilityName($capability) { 230 167 $capability_name = $capability; 231 168 $capobj = PhabricatorPolicyCapability::getCapabilityByKey($capability); ··· 342 279 ->setViewer($viewer) 343 280 ->setPolicy($policy); 344 281 $object_section->appendRulesView($rules_view); 345 - } 346 - 347 - $strength = $this->getStrengthInformation($object, $policy, $capability); 348 - if ($strength) { 349 - $object_section->appendHint($strength); 350 282 } 351 283 352 284 return $object_section;
-47
src/view/phui/PHUIHeaderView.php
··· 469 469 $container_classes[] = 'policy-header-callout'; 470 470 $phid = $object->getPHID(); 471 471 472 - // If we're going to show the object policy, try to determine if the object 473 - // policy differs from the default policy. If it does, we'll call it out 474 - // as changed. 475 - if (!$use_space_policy) { 476 - $strength = null; 477 - if ($object instanceof PhabricatorPolicyCodexInterface) { 478 - $codex = id(PhabricatorPolicyCodex::newFromObject($object, $viewer)) 479 - ->setCapability($view_capability); 480 - $strength = $codex->compareToDefaultPolicy($policy); 481 - } else { 482 - $default_policy = PhabricatorPolicyQuery::getDefaultPolicyForObject( 483 - $viewer, 484 - $object, 485 - $view_capability); 486 - 487 - if ($default_policy) { 488 - if ($default_policy->getPHID() != $policy->getPHID()) { 489 - if ($default_policy->isStrongerThan($policy)) { 490 - $strength = PhabricatorPolicyStrengthConstants::WEAKER; 491 - } else if ($policy->isStrongerThan($default_policy)) { 492 - $strength = PhabricatorPolicyStrengthConstants::STRONGER; 493 - } else { 494 - $strength = PhabricatorPolicyStrengthConstants::ADJUSTED; 495 - } 496 - } 497 - } 498 - } 499 - 500 - if ($strength) { 501 - if ($strength == PhabricatorPolicyStrengthConstants::WEAKER) { 502 - // The policy has strictly been weakened. For example, the 503 - // default might be "All Users" and the current policy is "Public". 504 - $container_classes[] = 'policy-adjusted-weaker'; 505 - } else if ($strength == PhabricatorPolicyStrengthConstants::STRONGER) { 506 - // The policy has strictly been strengthened, and is now more 507 - // restrictive than the default. For example, "All Users" has 508 - // been replaced with "No One". 509 - $container_classes[] = 'policy-adjusted-stronger'; 510 - } else { 511 - // The policy has been adjusted but not strictly strengthened 512 - // or weakened. For example, "Members of X" has been replaced with 513 - // "Members of Y". 514 - $container_classes[] = 'policy-adjusted-different'; 515 - } 516 - } 517 - } 518 - 519 472 $policy_name = array($policy->getShortName()); 520 473 $policy_icon = $policy->getIcon().' bluegrey'; 521 474
-27
webroot/rsrc/css/phui/phui-header-view.css
··· 213 213 -webkit-font-smoothing: auto; 214 214 } 215 215 216 - .policy-header-callout.policy-adjusted-weaker { 217 - background: {$sh-greenbackground}; 218 - } 219 - 220 - .policy-header-callout.policy-adjusted-weaker .policy-link, 221 - .policy-header-callout.policy-adjusted-weaker .phui-icon-view { 222 - color: {$sh-greentext}; 223 - } 224 - 225 - .policy-header-callout.policy-adjusted-stronger { 226 - background: {$sh-redbackground}; 227 - } 228 - 229 - .policy-header-callout.policy-adjusted-stronger .policy-link, 230 - .policy-header-callout.policy-adjusted-stronger .phui-icon-view { 231 - color: {$sh-redtext}; 232 - } 233 - 234 - .policy-header-callout.policy-adjusted-different { 235 - background: {$sh-orangebackground}; 236 - } 237 - 238 - .policy-header-callout.policy-adjusted-different .policy-link, 239 - .policy-header-callout.policy-adjusted-different .phui-icon-view { 240 - color: {$sh-orangetext}; 241 - } 242 - 243 216 .policy-header-callout.policy-adjusted-special { 244 217 background: {$sh-indigobackground}; 245 218 }