@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.

Dashboards: add capability who can create Dashboards

Summary:
Add a `dashboard.create` capability to allow limiting dashboard creation (and creation of related panels).
This can reduce spam in open Phorge installations in which anyone can create an account while you still want anyone to be able to view existing dashboards.

Closes T15438

Test Plan:
1. As an admin, go to `/applications/view/PhabricatorDashboardApplication/`
2. See only two options "Can Use Application: All Users" and "Can Configure Application: Administrators"
3. Apply patch
4. As an admin, go to `/applications/view/PhabricatorDashboardApplication/` and see the new option "Can Create Dashboards" set to "All Users"
5. As an average user, go to `/dashboard/` and successfully create a new Dashboard
6. As an admin, go to `/applications/edit/PhabricatorDashboardApplication/` and change "Can Create Dashboards" from "All Users" to "Administrators", select "Save Policies" button
7. As an average user, go to `/dashboard/` and see that "Create Dashboard" is disabled
8. As an average user, go to an existing dashboard not created by this user and see that selecting "Edit Dashboard" shows "You do not have permission to edit this object."
9. As an average user, go to the existing dashboard that you created yourself and see that the Edit Policy is set to this user.
10. As an average user, go to the existing dashboard that you created yourself and see that you can still create or add panels.

Reviewers: O1 Blessed Committers, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

Maniphest Tasks: T15438

Differential Revision: https://we.phorge.it/D25270

+31
+2
src/__phutil_library_map__.php
··· 3081 3081 'PhabricatorDashboardColumn' => 'applications/dashboard/layoutconfig/PhabricatorDashboardColumn.php', 3082 3082 'PhabricatorDashboardConsoleController' => 'applications/dashboard/controller/PhabricatorDashboardConsoleController.php', 3083 3083 'PhabricatorDashboardController' => 'applications/dashboard/controller/PhabricatorDashboardController.php', 3084 + 'PhabricatorDashboardCreateCapability' => 'applications/countdown/capability/PhabricatorDashboardCreateCapability.php', 3084 3085 'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php', 3085 3086 'PhabricatorDashboardDashboardPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardDashboardPHIDType.php', 3086 3087 'PhabricatorDashboardDatasource' => 'applications/dashboard/typeahead/PhabricatorDashboardDatasource.php', ··· 9496 9497 'PhabricatorDashboardColumn' => 'Phobject', 9497 9498 'PhabricatorDashboardConsoleController' => 'PhabricatorDashboardController', 9498 9499 'PhabricatorDashboardController' => 'PhabricatorController', 9500 + 'PhabricatorDashboardCreateCapability' => 'PhabricatorPolicyCapability', 9499 9501 'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO', 9500 9502 'PhabricatorDashboardDashboardPHIDType' => 'PhabricatorPHIDType', 9501 9503 'PhabricatorDashboardDatasource' => 'PhabricatorTypeaheadDatasource',
+16
src/applications/countdown/capability/PhabricatorDashboardCreateCapability.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardCreateCapability 4 + extends PhabricatorPolicyCapability { 5 + 6 + const CAPABILITY = 'dashboard.create'; 7 + 8 + public function getCapabilityName() { 9 + return pht('Can Create Dashboards'); 10 + } 11 + 12 + public function describeCapabilityRejection() { 13 + return pht('You do not have permission to create a dashboard.'); 14 + } 15 + 16 + }
+8
src/applications/dashboard/application/PhabricatorDashboardApplication.php
··· 83 83 ); 84 84 } 85 85 86 + protected function getCustomCapabilities() { 87 + return array( 88 + PhabricatorDashboardCreateCapability::CAPABILITY => array( 89 + 'default' => PhabricatorPolicies::POLICY_USER, 90 + 'caption' => pht('Default create policy for Dashboards.'), 91 + ), 92 + ); 93 + } 86 94 }
+5
src/applications/dashboard/editor/PhabricatorDashboardEditEngine.php
··· 66 66 return $object->getURI(); 67 67 } 68 68 69 + protected function getCreateNewObjectPolicy() { 70 + return $this->getApplication()->getPolicy( 71 + PhabricatorDashboardCreateCapability::CAPABILITY); 72 + } 73 + 69 74 protected function buildCustomEditFields($object) { 70 75 $layout_options = PhabricatorDashboardLayoutMode::getLayoutModeMap(); 71 76