Allow pastes to be edited

Summary: Permits the name and langauge of a paste to be edited. This will eventually allow the visibility policy to be edited as well.

Test Plan: Edited name/langauge of some pastes. Tried to edit a paste I didn't own, was harshly rebuffed.

Reviewers: vrana, btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1690

Differential Revision: https://secure.phabricator.com/D3376
This commit is contained in:
epriestley
2012-08-24 13:19:30 -07:00
parent fed30dfb4c
commit 36e71a0601
9 changed files with 144 additions and 49 deletions

View File

@@ -59,7 +59,7 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
$fork_phids));
$header = $this->buildHeaderView($paste);
$actions = $this->buildActionView($paste, $file);
$actions = $this->buildActionView($user, $paste, $file);
$properties = $this->buildPropertyView($paste, $fork_phids);
$source_code = $this->buildSourceCodeView($paste, $file);
@@ -89,9 +89,15 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
}
private function buildActionView(
PhabricatorUser $user,
PhabricatorPaste $paste,
PhabricatorFile $file) {
$can_edit = PhabricatorPolicyFilter::hasCapability(
$user,
$paste,
PhabricatorPolicyCapability::CAN_EDIT);
return id(new PhabricatorActionListView())
->addAction(
id(new PhabricatorActionView())
@@ -102,7 +108,14 @@ final class PhabricatorPasteViewController extends PhabricatorPasteController {
id(new PhabricatorActionView())
->setName(pht('View Raw File'))
->setIcon('file')
->setHref($file->getBestURI()));
->setHref($file->getBestURI()))
->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Paste'))
->setIcon('edit')
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)
->setHref($this->getApplicationURI('/edit/'.$paste->getID().'/')));
}
private function buildPropertyView(