mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
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:
parent
4cda3e5811
commit
4b9765b896
4 changed files with 36 additions and 1 deletions
|
@ -4663,6 +4663,7 @@ phutil_register_library_map(array(
|
||||||
2 => 'PhabricatorTokenReceiverInterface',
|
2 => 'PhabricatorTokenReceiverInterface',
|
||||||
3 => 'PhabricatorFlaggableInterface',
|
3 => 'PhabricatorFlaggableInterface',
|
||||||
4 => 'PhabricatorPolicyInterface',
|
4 => 'PhabricatorPolicyInterface',
|
||||||
|
5 => 'PhabricatorProjectInterface',
|
||||||
),
|
),
|
||||||
'PhabricatorPasteCommentController' => 'PhabricatorPasteController',
|
'PhabricatorPasteCommentController' => 'PhabricatorPasteController',
|
||||||
'PhabricatorPasteConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorPasteConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
|
|
|
@ -75,6 +75,15 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
||||||
}
|
}
|
||||||
$v_policy = $paste->getViewPolicy();
|
$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()) {
|
if ($request->isFormPost()) {
|
||||||
$xactions = array();
|
$xactions = array();
|
||||||
|
|
||||||
|
@ -89,6 +98,7 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
||||||
$v_title = $request->getStr('title');
|
$v_title = $request->getStr('title');
|
||||||
$v_language = $request->getStr('language');
|
$v_language = $request->getStr('language');
|
||||||
$v_policy = $request->getStr('can_view');
|
$v_policy = $request->getStr('can_view');
|
||||||
|
$v_projects = $request->getArr('projects');
|
||||||
|
|
||||||
// NOTE: The author is the only editor and can always view the paste,
|
// NOTE: The author is the only editor and can always view the paste,
|
||||||
// so it's impossible for them to choose an invalid policy.
|
// so it's impossible for them to choose an invalid policy.
|
||||||
|
@ -114,6 +124,13 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
||||||
$xactions[] = id(new PhabricatorPasteTransaction())
|
$xactions[] = id(new PhabricatorPasteTransaction())
|
||||||
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
|
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY)
|
||||||
->setNewValue($v_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())
|
$editor = id(new PhabricatorPasteEditor())
|
||||||
->setActor($user)
|
->setActor($user)
|
||||||
->setContentSourceFromRequest($request)
|
->setContentSourceFromRequest($request)
|
||||||
|
@ -161,6 +178,20 @@ final class PhabricatorPasteEditController extends PhabricatorPasteController {
|
||||||
->setPolicies($policies)
|
->setPolicies($policies)
|
||||||
->setName('can_view'));
|
->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
|
$form
|
||||||
->appendChild(
|
->appendChild(
|
||||||
id(new AphrontFormTextAreaControl())
|
id(new AphrontFormTextAreaControl())
|
||||||
|
|
|
@ -77,6 +77,7 @@ final class PhabricatorPasteEditor
|
||||||
return;
|
return;
|
||||||
case PhabricatorTransactions::TYPE_COMMENT:
|
case PhabricatorTransactions::TYPE_COMMENT:
|
||||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||||
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,6 +95,7 @@ final class PhabricatorPasteEditor
|
||||||
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
||||||
case PhabricatorTransactions::TYPE_COMMENT:
|
case PhabricatorTransactions::TYPE_COMMENT:
|
||||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
||||||
|
case PhabricatorTransactions::TYPE_EDGE:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
|
||||||
PhabricatorSubscribableInterface,
|
PhabricatorSubscribableInterface,
|
||||||
PhabricatorTokenReceiverInterface,
|
PhabricatorTokenReceiverInterface,
|
||||||
PhabricatorFlaggableInterface,
|
PhabricatorFlaggableInterface,
|
||||||
PhabricatorPolicyInterface {
|
PhabricatorPolicyInterface,
|
||||||
|
PhabricatorProjectInterface {
|
||||||
|
|
||||||
protected $title;
|
protected $title;
|
||||||
protected $authorPHID;
|
protected $authorPHID;
|
||||||
|
|
Loading…
Reference in a new issue