Implement PhabricatorProjectInterface in Paste
Summary: Ref T2628. Implements PhabricatorProjectInterface (D9340) in Paste. Test Plan: See screenshots. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T2628 Differential Revision: https://secure.phabricator.com/D9341
This commit is contained in:
@@ -75,6 +75,15 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
||||
}
|
||||
$v_policy = $paste->getViewPolicy();
|
||||
|
||||
if ($is_create) {
|
||||
$v_projects = array();
|
||||
} else {
|
||||
$v_projects = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$paste->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT);
|
||||
$v_projects = array_reverse($v_projects);
|
||||
}
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$xactions = array();
|
||||
|
||||
@@ -89,6 +98,7 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
||||
$v_title = $request->getStr('title');
|
||||
$v_language = $request->getStr('language');
|
||||
$v_policy = $request->getStr('can_view');
|
||||
$v_projects = $request->getArr('projects');
|
||||
|
||||
// NOTE: The author is the only editor and can always view the paste,
|
||||
// so it's impossible for them to choose an invalid policy.
|
||||
@@ -114,6 +124,13 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
||||
$xactions[] = id(new PhabricatorPasteTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
|
||||
->setNewValue($v_policy);
|
||||
|
||||
$proj_edge_type = PhabricatorEdgeConfig::TYPE_OBJECT_HAS_PROJECT;
|
||||
$xactions[] = id(new PhabricatorPasteTransaction())
|
||||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue('edge:type', $proj_edge_type)
|
||||
->setNewValue(array('=' => array_fuse($v_projects)));
|
||||
|
||||
$editor = id(new PhabricatorPasteEditor())
|
||||
->setActor($user)
|
||||
->setContentSourceFromRequest($request)
|
||||
@@ -161,6 +178,20 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
||||
->setPolicies($policies)
|
||||
->setName('can_view'));
|
||||
|
||||
|
||||
if ($v_projects) {
|
||||
$project_handles = $this->loadViewerHandles($v_projects);
|
||||
} else {
|
||||
$project_handles = array();
|
||||
}
|
||||
|
||||
$form->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setLabel(pht('Projects'))
|
||||
->setName('projects')
|
||||
->setValue($project_handles)
|
||||
->setDatasource('/typeahead/common/projects/'));
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTextAreaControl())
|
||||
|
||||
Reference in New Issue
Block a user