diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 6a996f445f..b9478aab7d 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -349,6 +349,7 @@ phutil_register_library_map(array( 'DifferentialDiffTableOfContentsView' => 'applications/differential/view/DifferentialDiffTableOfContentsView.php', 'DifferentialDiffTestCase' => 'applications/differential/storage/__tests__/DifferentialDiffTestCase.php', 'DifferentialDiffViewController' => 'applications/differential/controller/DifferentialDiffViewController.php', + 'DifferentialDiffViewPolicyFieldSpecification' => 'applications/differential/field/specification/DifferentialDiffViewPolicyFieldSpecification.php', 'DifferentialException' => 'applications/differential/exception/DifferentialException.php', 'DifferentialExceptionMail' => 'applications/differential/mail/DifferentialExceptionMail.php', 'DifferentialExportPatchFieldSpecification' => 'applications/differential/field/specification/DifferentialExportPatchFieldSpecification.php', @@ -424,6 +425,7 @@ phutil_register_library_map(array( 'DifferentialUnitFieldSpecification' => 'applications/differential/field/specification/DifferentialUnitFieldSpecification.php', 'DifferentialUnitStatus' => 'applications/differential/constants/DifferentialUnitStatus.php', 'DifferentialUnitTestResult' => 'applications/differential/constants/DifferentialUnitTestResult.php', + 'DifferentialViewPolicyFieldSpecification' => 'applications/differential/field/specification/DifferentialViewPolicyFieldSpecification.php', 'DiffusionBranchInformation' => 'applications/diffusion/data/DiffusionBranchInformation.php', 'DiffusionBranchTableController' => 'applications/diffusion/controller/DiffusionBranchTableController.php', 'DiffusionBranchTableView' => 'applications/diffusion/view/DiffusionBranchTableView.php', @@ -2279,6 +2281,7 @@ phutil_register_library_map(array( 'DifferentialDiffTableOfContentsView' => 'AphrontView', 'DifferentialDiffTestCase' => 'ArcanistPhutilTestCase', 'DifferentialDiffViewController' => 'DifferentialController', + 'DifferentialDiffViewPolicyFieldSpecification' => 'DifferentialFieldSpecification', 'DifferentialException' => 'Exception', 'DifferentialExceptionMail' => 'DifferentialMail', 'DifferentialExportPatchFieldSpecification' => 'DifferentialFieldSpecification', @@ -2357,6 +2360,7 @@ phutil_register_library_map(array( 'DifferentialTransaction' => 'PhabricatorApplicationTransaction', 'DifferentialTransactionComment' => 'PhabricatorApplicationTransactionComment', 'DifferentialUnitFieldSpecification' => 'DifferentialFieldSpecification', + 'DifferentialViewPolicyFieldSpecification' => 'DifferentialFieldSpecification', 'DiffusionBranchTableController' => 'DiffusionController', 'DiffusionBranchTableView' => 'DiffusionView', 'DiffusionBrowseController' => 'DiffusionController', diff --git a/src/applications/differential/field/selector/DifferentialDefaultFieldSelector.php b/src/applications/differential/field/selector/DifferentialDefaultFieldSelector.php index 63aa657325..7d0498d51d 100644 --- a/src/applications/differential/field/selector/DifferentialDefaultFieldSelector.php +++ b/src/applications/differential/field/selector/DifferentialDefaultFieldSelector.php @@ -13,6 +13,7 @@ final class DifferentialDefaultFieldSelector new DifferentialReviewersFieldSpecification(), new DifferentialReviewedByFieldSpecification(), new DifferentialCCsFieldSpecification(), + new DifferentialViewPolicyFieldSpecification(), new DifferentialLintFieldSpecification(), new DifferentialUnitFieldSpecification(), new DifferentialCommitsFieldSpecification(), @@ -30,6 +31,7 @@ final class DifferentialDefaultFieldSelector new DifferentialDateModifiedFieldSpecification(), new DifferentialDateCreatedFieldSpecification(), new DifferentialAuditorsFieldSpecification(), + new DifferentialDiffViewPolicyFieldSpecification(), ); return $fields; diff --git a/src/applications/differential/field/specification/DifferentialDiffViewPolicyFieldSpecification.php b/src/applications/differential/field/specification/DifferentialDiffViewPolicyFieldSpecification.php new file mode 100644 index 0000000000..857db99f2c --- /dev/null +++ b/src/applications/differential/field/specification/DifferentialDiffViewPolicyFieldSpecification.php @@ -0,0 +1,25 @@ +getUser(); + $diff = $this->getDiff(); + + $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( + $user, + $diff); + + return idx($descriptions, PhabricatorPolicyCapability::CAN_VIEW); + } + +} diff --git a/src/applications/differential/field/specification/DifferentialViewPolicyFieldSpecification.php b/src/applications/differential/field/specification/DifferentialViewPolicyFieldSpecification.php new file mode 100644 index 0000000000..52235eb3e4 --- /dev/null +++ b/src/applications/differential/field/specification/DifferentialViewPolicyFieldSpecification.php @@ -0,0 +1,25 @@ +getUser(); + $revision = $this->getRevision(); + + $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions( + $user, + $revision); + + return idx($descriptions, PhabricatorPolicyCapability::CAN_VIEW); + } + +}