Implement policies in Phragment

Summary: This implements support for enforcing and setting policies in Phragment.

Test Plan: Set policies and ensured they were enforced successfully.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T4205

Differential Revision: https://secure.phabricator.com/D7751
This commit is contained in:
James Rhodes
2013-12-13 14:42:12 +11:00
parent 7f45824984
commit 86ec4d6021
23 changed files with 350 additions and 47 deletions

View File

@@ -4,6 +4,10 @@ final class PhragmentSnapshotViewController extends PhragmentController {
private $id;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->id = idx($data, "id", "");
}
@@ -72,6 +76,7 @@ final class PhragmentSnapshotViewController extends PhragmentController {
return $this->buildApplicationPage(
array(
$crumbs,
$this->renderConfigurationWarningIfRequired(),
$box,
$list),
array(
@@ -100,6 +105,11 @@ final class PhragmentSnapshotViewController extends PhragmentController {
"zip@".$snapshot->getName().
"/".$snapshot->getPrimaryFragment()->getPath());
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$snapshot,
PhabricatorPolicyCapability::CAN_EDIT);
$actions = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($snapshot)
@@ -107,24 +117,24 @@ final class PhragmentSnapshotViewController extends PhragmentController {
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Download Snapshot as ZIP'))
->setHref($zip_uri)
->setDisabled(false) // TODO: Policy
->setHref($this->isCorrectlyConfigured() ? $zip_uri : null)
->setDisabled(!$this->isCorrectlyConfigured())
->setIcon('zip'));
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Delete Snapshot'))
->setHref($this->getApplicationURI(
"snapshot/delete/".$snapshot->getID()."/"))
->setDisabled(!$can_edit)
->setWorkflow(true)
->setDisabled(false) // TODO: Policy
->setIcon('delete'));
$actions->addAction(
id(new PhabricatorActionView())
->setName(pht('Promote Another Snapshot to Here'))
->setHref($this->getApplicationURI(
"snapshot/promote/".$snapshot->getID()."/"))
->setDisabled(!$can_edit)
->setWorkflow(true)
->setDisabled(false) // TODO: Policy
->setIcon('promote'));
$properties = id(new PHUIPropertyListView())