Page MenuHomePhabricator

Add a "members of project" policy rule
AbandonedPublic

Authored by epriestley on Nov 12 2015, 8:06 AM.
Tags
None
Referenced Files
F14009791: D14467.diff
Wed, Oct 30, 11:50 PM
F14008166: D14467.diff
Tue, Oct 29, 4:42 PM
F14006917: D14467.id35018.diff
Mon, Oct 28, 9:07 PM
F13979114: D14467.id34987.diff
Sat, Oct 19, 2:45 AM
F13968632: D14467.id35018.diff
Wed, Oct 16, 10:25 PM
F13968327: D14467.id35020.diff
Wed, Oct 16, 8:07 PM
F13957594: D14467.id35041.diff
Mon, Oct 14, 10:10 AM
Unknown Object (File)
Sep 30 2024, 11:33 PM
Subscribers

Details

Summary

Fixes T9019. Adds a project.members object policy rule, similar to the existing subscriptions.subscribers object policy rule.

Test Plan

Created a project with Edit Policy: Members. Tried to edit the project without membership and hit "You shall not passed". Joined the project and was able to edit project details.

Diff Detail

Event Timeline

joshuaspence retitled this revision from to Add a "members of project" policy rule.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.

One issue here is that you can't create a new project with the edit policy of "Members", specifically:

You can not select this edit policy, because you would no longer be able to edit the object.

I'm not entirely sure how to fix this.

src/applications/project/controller/PhabricatorProjectProfileController.php
95–97

Unrelated minor fix.

src/applications/project/policyrule/PhabricatorProjectProjectMembersPolicyRule.php
3–4

I renamed this class to make it a little more clear.

epriestley edited edge metadata.

The phabricator_policy.policy table encodes rules by using class names. As written, this patch changes a class name but does not migrate rules, so I expect it to break all existing rules which use the "Project Members" rule.

I'm not entirely sure how to fix [creating a project with this rule].

It's pretty messy right now (and I don't really have any ideas on how to get out of it cleanly). The getTransactionHint() mechanism is used to tell rules about what state we expect after transactions apply, so we can validate the expected state. PhabricatorSubscriptionsSubscribersPolicyRule and PhabricatorApplicationTransactionEditor->adjustObjectForPolicyChecks() have examples of how the "Subscribers" rule currently accomplishes this. You'll need to do something similar (or come up with a better approach to this problem -- the current one is admittedly pretty gross).

src/applications/policy/rule/PhabricatorPolicyRule.php
39

Maybe "...can only operate on tasks".

src/applications/subscriptions/policyrule/PhabricatorSubscriptionsSubscribersPolicyRule.php
105–119

Minor, but I think these classes read slightly better if these short, descriptive methods are at the top of the file. If you're seeking to understand what a class does, these methods are more informative at a glance than methods like applyRule().

This revision now requires changes to proceed.Nov 15 2015, 4:04 PM
joshuaspence edited edge metadata.
joshuaspence marked an inline comment as done.
  • Rebase
  • Add migration
epriestley edited reviewers, added: joshuaspence; removed: epriestley.

I can take a crack at navigating the "create a project with this policy" issue, I think I want this policy soon-ish to do T6502.

Split into D14868 + D14869. I didn't pick up the rule rename. Given that it needs a migration, I'm not sure it's really worth it (if we're going to migrate, maybe we'd be better moving all rules to constants? I think constants have pretty clearly won the day over class names in terms of "stuff we stick in the database" in modern code).