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
This commit is contained in:
epriestley
2019-11-18 21:53:33 -08:00
parent 1996b0cd55
commit de66a8ece1
8 changed files with 3 additions and 177 deletions

View File

@@ -163,69 +163,6 @@ final class PhabricatorPolicyExplainController
return $space_section;
}
private function getStrengthInformation(
PhabricatorPolicyInterface $object,
PhabricatorPolicy $policy,
$capability) {
$viewer = $this->getViewer();
$strength = null;
if ($object instanceof PhabricatorPolicyCodexInterface) {
$codex = id(PhabricatorPolicyCodex::newFromObject($object, $viewer))
->setCapability($capability);
$strength = $codex->compareToDefaultPolicy($policy);
$default_policy = $codex->getDefaultPolicy();
} else {
$default_policy = PhabricatorPolicyQuery::getDefaultPolicyForObject(
$viewer,
$object,
$capability);
if ($default_policy) {
if ($default_policy->getPHID() == $policy->getPHID()) {
return;
}
if ($default_policy->getPHID() != $policy->getPHID()) {
if ($default_policy->isStrongerThan($policy)) {
$strength = PhabricatorPolicyStrengthConstants::WEAKER;
} else if ($policy->isStrongerThan($default_policy)) {
$strength = PhabricatorPolicyStrengthConstants::STRONGER;
} else {
$strength = PhabricatorPolicyStrengthConstants::ADJUSTED;
}
}
}
}
if (!$strength) {
return;
}
if ($strength == PhabricatorPolicyStrengthConstants::WEAKER) {
$info = pht(
'This object has a less restrictive policy ("%s") than the default '.
'policy for similar objects (which is "%s").',
$policy->getShortName(),
$default_policy->getShortName());
} else if ($strength == PhabricatorPolicyStrengthConstants::STRONGER) {
$info = pht(
'This object has a more restrictive policy ("%s") than the default '.
'policy for similar objects (which is "%s").',
$policy->getShortName(),
$default_policy->getShortName());
} else {
$info = pht(
'This object has a different policy ("%s") than the default policy '.
'for similar objects (which is "%s").',
$policy->getShortName(),
$default_policy->getShortName());
}
return $info;
}
private function getCapabilityName($capability) {
$capability_name = $capability;
$capobj = PhabricatorPolicyCapability::getCapabilityByKey($capability);
@@ -344,11 +281,6 @@ final class PhabricatorPolicyExplainController
$object_section->appendRulesView($rules_view);
}
$strength = $this->getStrengthInformation($object, $policy, $capability);
if ($strength) {
$object_section->appendHint($strength);
}
return $object_section;
}