1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Remove empty implementations of describeAutomaticCapabilities()

Summary:
This has been replaced by `PolicyCodex` after D16830. Also:

  - Rebuild Celerity map to fix grumpy unit test.
  - Fix one issue on the policy exception workflow to accommodate the new code.

Test Plan:
  - `arc unit --everything`
  - Viewed policy explanations.
  - Viewed policy errors.

Reviewers: chad

Reviewed By: chad

Subscribers: hach-que, PHID-OPKG-gm6ozazyms6q6i22gyam

Differential Revision: https://secure.phabricator.com/D16831
This commit is contained in:
epriestley 2016-11-09 15:13:37 -08:00
parent 4811e6e7c1
commit 706c21375e
65 changed files with 67 additions and 297 deletions

View file

@ -9,7 +9,7 @@ return array(
'names' => array(
'conpherence.pkg.css' => 'cea72e09',
'conpherence.pkg.js' => '6249a1cf',
'core.pkg.css' => 'c99a9eb4',
'core.pkg.css' => 'd2126ffb',
'core.pkg.js' => '1a77dddf',
'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => 'a4ba74b5',
@ -21,7 +21,7 @@ return array(
'maniphest.pkg.js' => '949a7498',
'rsrc/css/aphront/aphront-bars.css' => '231ac33c',
'rsrc/css/aphront/dark-console.css' => 'f54bf286',
'rsrc/css/aphront/dialog-view.css' => '84f1e6a6',
'rsrc/css/aphront/dialog-view.css' => '1e6b8603',
'rsrc/css/aphront/lightbox-attachment.css' => '7acac05d',
'rsrc/css/aphront/list-filter-view.css' => '5d6f0526',
'rsrc/css/aphront/multi-column.css' => '84cc6640',
@ -143,7 +143,7 @@ return array(
'rsrc/css/phui/phui-form-view.css' => 'b5bfd17a',
'rsrc/css/phui/phui-form.css' => 'aac1d51d',
'rsrc/css/phui/phui-head-thing.css' => 'fd311e5f',
'rsrc/css/phui/phui-header-view.css' => '06385974',
'rsrc/css/phui/phui-header-view.css' => '6ec8f155',
'rsrc/css/phui/phui-hovercard.css' => 'de1a2119',
'rsrc/css/phui/phui-icon-set-selector.css' => '1ab67aad',
'rsrc/css/phui/phui-icon.css' => '417f80fb',
@ -553,7 +553,7 @@ return array(
'almanac-css' => 'dbb9b3af',
'aphront-bars' => '231ac33c',
'aphront-dark-console-css' => 'f54bf286',
'aphront-dialog-view-css' => '84f1e6a6',
'aphront-dialog-view-css' => '1e6b8603',
'aphront-list-filter-view-css' => '5d6f0526',
'aphront-multi-column-view-css' => '84cc6640',
'aphront-panel-view-css' => '8427b78d',
@ -867,7 +867,7 @@ return array(
'phui-form-css' => 'aac1d51d',
'phui-form-view-css' => 'b5bfd17a',
'phui-head-thing-view-css' => 'fd311e5f',
'phui-header-view-css' => '06385974',
'phui-header-view-css' => '6ec8f155',
'phui-hovercard' => '1bd28176',
'phui-hovercard-view-css' => 'de1a2119',
'phui-icon-set-selector-css' => '1ab67aad',

View file

@ -167,10 +167,6 @@ final class AlmanacDevice
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorExtendedPolicyInterface )--------------------------------- */

View file

@ -174,10 +174,6 @@ final class AlmanacNamespace
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -92,10 +92,6 @@ final class AlmanacNetwork
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -184,10 +184,6 @@ final class AlmanacService
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorExtendedPolicyInterface )--------------------------------- */

View file

@ -130,8 +130,4 @@ final class PhabricatorAuthProviderConfig
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -125,8 +125,4 @@ final class PhabricatorAuthTemporaryToken extends PhabricatorAuthDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -76,8 +76,4 @@ final class PhabricatorBadgesAward extends PhabricatorBadgesDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -129,10 +129,6 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -483,10 +483,6 @@ abstract class PhabricatorApplication
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( Policies )----------------------------------------------------------- */

View file

@ -121,7 +121,4 @@ final class PhabricatorCalendarEventInvitee extends PhabricatorCalendarDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -159,11 +159,6 @@ final class PhabricatorCalendarExport extends PhabricatorCalendarDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -68,7 +68,4 @@ final class PhabricatorCalendarExternalInvitee
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -132,10 +132,6 @@ final class PhabricatorCalendarImport
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -86,10 +86,6 @@ final class PhabricatorCalendarImportLog
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -48,8 +48,4 @@ final class PhabricatorChatLogChannel
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -56,8 +56,4 @@ final class PhabricatorChatLogEvent
return $this->getChannel()->hasAutomaticCapability($capability, $viewer);
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -372,10 +372,6 @@ abstract class ConduitAPIMethod
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
protected function hasApplicationCapability(
$capability,
PhabricatorUser $viewer) {

View file

@ -52,8 +52,4 @@ final class PhabricatorConduitMethodCallLog
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -95,8 +95,4 @@ final class PhabricatorConfigEntry
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -139,10 +139,6 @@ final class PhabricatorCountdown extends PhabricatorCountdownDAO
return false;
}
public function describeAutomaticCapability($capability) {
return false;
}
/* -( PhabricatorSpacesInterface )------------------------------------------- */
public function getSpacePHID() {

View file

@ -77,8 +77,4 @@ final class PhabricatorDaemonLog extends PhabricatorDaemonDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -160,10 +160,6 @@ final class PhabricatorDashboard extends PhabricatorDashboardDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -159,10 +159,6 @@ final class PhabricatorDashboardPanel
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorCustomFieldInterface )------------------------------------ */

View file

@ -226,8 +226,4 @@ final class DifferentialChangeset extends DifferentialDAO
return $this->getDiff()->hasAutomaticCapability($capability, $viewer);
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -228,8 +228,4 @@ abstract class DifferentialHunk extends DifferentialDAO
return $this->getChangeset()->hasAutomaticCapability($capability, $viewer);
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -114,10 +114,6 @@ final class DivinerLiveBook extends DivinerDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -121,8 +121,4 @@ final class DoorkeeperExternalObject extends DoorkeeperDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -325,10 +325,6 @@ final class DrydockBlueprint extends DrydockDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorCustomFieldInterface )------------------------------------ */

View file

@ -454,11 +454,6 @@ abstract class PhabricatorFeedStory
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorMarkupInterface Implementation )--------------------------- */

View file

@ -77,11 +77,6 @@ final class PhabricatorFileChunk extends PhabricatorFileDAO
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -93,8 +93,4 @@ final class LegalpadDocumentSignature
return ($viewer->getPHID() == $this->getSignerPHID());
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -139,8 +139,4 @@ final class PhabricatorFileImageMacro extends PhabricatorFileDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -63,8 +63,4 @@ final class NuanceImportCursorData
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -48,8 +48,4 @@ final class NuanceItemCommand
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -67,10 +67,6 @@ final class NuanceQueue
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -138,10 +138,6 @@ final class NuanceSource extends NuanceDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorNgramsInterface )----------------------------------------- */

View file

@ -83,10 +83,6 @@ final class PhabricatorOAuthServerClient
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -158,10 +158,6 @@ final class PhabricatorPackagesPackage
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -134,10 +134,6 @@ final class PhabricatorPackagesPublisher
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -126,10 +126,6 @@ final class PhabricatorPackagesVersion
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorExtendedPolicyInterface )--------------------------------- */

View file

@ -155,10 +155,6 @@ final class PassphraseCredential extends PassphraseDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorSubscribableInterface )----------------------------------- */

View file

@ -80,8 +80,4 @@ final class PhluxVariable extends PhluxDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -119,8 +119,4 @@ final class PholioImage extends PholioDAO
return $this->getMock()->hasAutomaticCapability($capability, $viewer);
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -110,8 +110,4 @@ final class PhortuneProduct extends PhortuneDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -345,8 +345,4 @@ final class PhragmentFragment extends PhragmentDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -52,10 +52,6 @@ final class PhabricatorPolicyTestObject
return $this;
}
public function describeAutomaticCapability($capability) {
return null;
}
public function setExtendedPolicies(array $extended_policies) {
$this->extendedPolicies = $extended_policies;
return $this;

View file

@ -262,47 +262,16 @@ final class PhabricatorPolicyExplainController
$capability) {
$viewer = $this->getViewer();
if ($object instanceof PhabricatorPolicyCodexInterface) {
$codex = PhabricatorPolicyCodex::newFromObject($object, $viewer);
$rules = $codex->getPolicySpecialRuleDescriptions();
$exceptions = array();
foreach ($rules as $rule) {
$is_active = $rule->getIsActive();
if ($is_active) {
$rule_capabilities = $rule->getCapabilities();
if ($rule_capabilities) {
if (!in_array($capability, $rule_capabilities)) {
$is_active = false;
}
}
}
$description = $rule->getDescription();
if (!$is_active) {
$description = phutil_tag(
'span',
array(
'class' => 'phui-policy-section-view-inactive-rule',
),
$description);
}
$exceptions[] = $description;
}
} else if (method_exists($object, 'describeAutomaticCapability')) {
$exceptions = (array)$object->describeAutomaticCapability($capability);
$exceptions = array_filter($exceptions);
} else {
$exceptions = array();
}
$exceptions = PhabricatorPolicy::getSpecialRules(
$object,
$viewer,
$capability,
false);
if (!$exceptions) {
return null;
}
return id(new PHUIPolicySectionView())
->setViewer($viewer)
->setIcon('fa-unlock-alt red')

View file

@ -581,9 +581,16 @@ final class PhabricatorPolicyFilter extends Phobject {
}
$more = PhabricatorPolicy::getPolicyExplanation($this->viewer, $policy);
$exceptions = $object->describeAutomaticCapability($capability);
$more = (array)$more;
$more = array_filter($more);
$details = array_filter(array_merge(array($more), (array)$exceptions));
$exceptions = PhabricatorPolicy::getSpecialRules(
$object,
$this->viewer,
$capability,
true);
$details = array_filter(array_merge($more, $exceptions));
$access_denied = $this->renderAccessDenied($object);

View file

@ -422,6 +422,54 @@ final class PhabricatorPolicy
return ($this_strength > $other_strength);
}
public static function getSpecialRules(
PhabricatorPolicyInterface $object,
PhabricatorUser $viewer,
$capability,
$active_only) {
if ($object instanceof PhabricatorPolicyCodexInterface) {
$codex = PhabricatorPolicyCodex::newFromObject($object, $viewer);
$rules = $codex->getPolicySpecialRuleDescriptions();
$exceptions = array();
foreach ($rules as $rule) {
$is_active = $rule->getIsActive();
if ($is_active) {
$rule_capabilities = $rule->getCapabilities();
if ($rule_capabilities) {
if (!in_array($capability, $rule_capabilities)) {
$is_active = false;
}
}
}
if (!$is_active && $active_only) {
continue;
}
$description = $rule->getDescription();
if (!$is_active) {
$description = phutil_tag(
'span',
array(
'class' => 'phui-policy-section-view-inactive-rule',
),
$description);
}
$exceptions[] = $description;
}
} else if (method_exists($object, 'describeAutomaticCapability')) {
$exceptions = (array)$object->describeAutomaticCapability($capability);
$exceptions = array_filter($exceptions);
} else {
$exceptions = array();
}
return $exceptions;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
@ -444,10 +492,6 @@ final class PhabricatorPolicy
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -87,8 +87,4 @@ final class PhabricatorProjectColumnPosition extends PhabricatorProjectDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -153,9 +153,4 @@ final class ReleephProject extends ReleephDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -2330,11 +2330,6 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorMarkupInterface )----------------------------------------- */

View file

@ -130,8 +130,4 @@ final class PhabricatorRepositoryCommitHint
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -45,10 +45,6 @@ final class PhabricatorRepositoryGitLFSRef
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -45,8 +45,4 @@ final class PhabricatorRepositoryOldRef
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -642,10 +642,6 @@ final class PhabricatorRepositoryURI
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorExtendedPolicyInterface )--------------------------------- */

View file

@ -162,11 +162,6 @@ final class PhabricatorProfilePanelConfiguration
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorExtendedPolicyInterface )--------------------------------- */

View file

@ -81,8 +81,4 @@ final class PhabricatorSavedQuery extends PhabricatorSearchDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -222,11 +222,6 @@ final class PhabricatorUserPreferences
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -84,11 +84,6 @@ final class PhabricatorSpacesNamespace
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -28,10 +28,6 @@ final class PhabricatorToken extends PhabricatorTokenDAO
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
public function renderIcon() {
// TODO: Maybe move to a View class?

View file

@ -2275,7 +2275,4 @@ abstract class PhabricatorEditEngine
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
}

View file

@ -302,11 +302,6 @@ final class PhabricatorEditEngineConfiguration
return false;
}
public function describeAutomaticCapability($capability) {
return null;
}
/* -( PhabricatorApplicationTransactionInterface )------------------------- */

View file

@ -190,8 +190,4 @@ final class PhabricatorWorkerTrigger
return true;
}
public function describeAutomaticCapability($capability) {
return null;
}
}