Allow any user to watch any project they can see

Summary:
Ref T6183. Ref T10054. Historically, only members could watch projects because there were some weird special cases with policies. These policy issues have been resolved and Herald is generally powerful enough to do equivalent watches on most objects anyway.

Also puts a "Watch Project" button on the feed panel to make the behavior and meaning more obvious.

Test Plan:
  - Watched a project I was not a member of.
  - Clicked the feed watch/unwatch button.

{F1064909}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T6183, T10054

Differential Revision: https://secure.phabricator.com/D15063
This commit is contained in:
epriestley
2016-01-19 17:43:14 -08:00
parent 01afb50406
commit 5c2e49a812
32 changed files with 87 additions and 177 deletions

View File

@@ -18,11 +18,11 @@ final class PhabricatorProjectWatchController
return new Aphront404Response();
}
$done_uri = "/project/members/{$id}/";
// You must be a member of a project to watch it.
if (!$project->isUserMember($viewer->getPHID())) {
return new Aphront400Response();
$via = $request->getStr('via');
if ($via == 'profile') {
$done_uri = $project->getURI();
} else {
$done_uri = "/project/members/{$id}/";
}
if ($request->isDialogFormPost()) {
@@ -38,7 +38,7 @@ final class PhabricatorProjectWatchController
break;
}
$type_member = PhabricatorObjectHasWatcherEdgeType::EDGECONST;
$type_watcher = PhabricatorObjectHasWatcherEdgeType::EDGECONST;
$member_spec = array(
$edge_action => array($viewer->getPHID() => $viewer->getPHID()),
);
@@ -46,7 +46,7 @@ final class PhabricatorProjectWatchController
$xactions = array();
$xactions[] = id(new PhabricatorProjectTransaction())
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
->setMetadataValue('edge:type', $type_member)
->setMetadataValue('edge:type', $type_watcher)
->setNewValue($member_spec);
$editor = id(new PhabricatorProjectTransactionEditor($project))
@@ -82,6 +82,7 @@ final class PhabricatorProjectWatchController
return $this->newDialog()
->setTitle($title)
->addHiddenInput('via', $via)
->appendParagraph($body)
->addCancelButton($done_uri)
->addSubmitButton($submit);