1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00

Convert all standard relationship-editing actions to modern Relationships code

Summary: Ref T4788. This moves everything except "merge" to the new code.

Test Plan:
  - Edited relationships in Differential, Diffusion, and Pholio.
  - Uninstalled Pholio, made sure "Edit Mocks..." actions vanished.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4788

Differential Revision: https://secure.phabricator.com/D16193
This commit is contained in:
epriestley 2016-06-28 18:38:45 -07:00
parent 25cc90d632
commit dc9283b85d
24 changed files with 471 additions and 54 deletions

View file

@ -381,6 +381,7 @@ phutil_register_library_map(array(
'DifferentialChangesetTwoUpRenderer' => 'applications/differential/render/DifferentialChangesetTwoUpRenderer.php',
'DifferentialChangesetTwoUpTestRenderer' => 'applications/differential/render/DifferentialChangesetTwoUpTestRenderer.php',
'DifferentialChangesetViewController' => 'applications/differential/controller/DifferentialChangesetViewController.php',
'DifferentialChildRevisionsField' => 'applications/differential/customfield/DifferentialChildRevisionsField.php',
'DifferentialCloseConduitAPIMethod' => 'applications/differential/conduit/DifferentialCloseConduitAPIMethod.php',
'DifferentialCommentPreviewController' => 'applications/differential/controller/DifferentialCommentPreviewController.php',
'DifferentialCommentSaveController' => 'applications/differential/controller/DifferentialCommentSaveController.php',
@ -407,8 +408,6 @@ phutil_register_library_map(array(
'DifferentialCustomFieldStringIndex' => 'applications/differential/storage/DifferentialCustomFieldStringIndex.php',
'DifferentialDAO' => 'applications/differential/storage/DifferentialDAO.php',
'DifferentialDefaultViewCapability' => 'applications/differential/capability/DifferentialDefaultViewCapability.php',
'DifferentialDependenciesField' => 'applications/differential/customfield/DifferentialDependenciesField.php',
'DifferentialDependsOnField' => 'applications/differential/customfield/DifferentialDependsOnField.php',
'DifferentialDiff' => 'applications/differential/storage/DifferentialDiff.php',
'DifferentialDiffAffectedFilesHeraldField' => 'applications/differential/herald/DifferentialDiffAffectedFilesHeraldField.php',
'DifferentialDiffAuthorHeraldField' => 'applications/differential/herald/DifferentialDiffAuthorHeraldField.php',
@ -476,6 +475,7 @@ phutil_register_library_map(array(
'DifferentialManiphestTasksField' => 'applications/differential/customfield/DifferentialManiphestTasksField.php',
'DifferentialModernHunk' => 'applications/differential/storage/DifferentialModernHunk.php',
'DifferentialNextStepField' => 'applications/differential/customfield/DifferentialNextStepField.php',
'DifferentialParentRevisionsField' => 'applications/differential/customfield/DifferentialParentRevisionsField.php',
'DifferentialParseCacheGarbageCollector' => 'applications/differential/garbagecollector/DifferentialParseCacheGarbageCollector.php',
'DifferentialParseCommitMessageConduitAPIMethod' => 'applications/differential/conduit/DifferentialParseCommitMessageConduitAPIMethod.php',
'DifferentialParseRenderTestCase' => 'applications/differential/__tests__/DifferentialParseRenderTestCase.php',
@ -521,9 +521,13 @@ phutil_register_library_map(array(
'DifferentialRevisionDependsOnRevisionEdgeType' => 'applications/differential/edge/DifferentialRevisionDependsOnRevisionEdgeType.php',
'DifferentialRevisionEditController' => 'applications/differential/controller/DifferentialRevisionEditController.php',
'DifferentialRevisionFulltextEngine' => 'applications/differential/search/DifferentialRevisionFulltextEngine.php',
'DifferentialRevisionHasChildRelationship' => 'applications/differential/relationships/DifferentialRevisionHasChildRelationship.php',
'DifferentialRevisionHasCommitEdgeType' => 'applications/differential/edge/DifferentialRevisionHasCommitEdgeType.php',
'DifferentialRevisionHasCommitRelationship' => 'applications/differential/relationships/DifferentialRevisionHasCommitRelationship.php',
'DifferentialRevisionHasParentRelationship' => 'applications/differential/relationships/DifferentialRevisionHasParentRelationship.php',
'DifferentialRevisionHasReviewerEdgeType' => 'applications/differential/edge/DifferentialRevisionHasReviewerEdgeType.php',
'DifferentialRevisionHasTaskEdgeType' => 'applications/differential/edge/DifferentialRevisionHasTaskEdgeType.php',
'DifferentialRevisionHasTaskRelationship' => 'applications/differential/relationships/DifferentialRevisionHasTaskRelationship.php',
'DifferentialRevisionHeraldField' => 'applications/differential/herald/DifferentialRevisionHeraldField.php',
'DifferentialRevisionHeraldFieldGroup' => 'applications/differential/herald/DifferentialRevisionHeraldFieldGroup.php',
'DifferentialRevisionIDField' => 'applications/differential/customfield/DifferentialRevisionIDField.php',
@ -536,6 +540,7 @@ phutil_register_library_map(array(
'DifferentialRevisionPackageHeraldField' => 'applications/differential/herald/DifferentialRevisionPackageHeraldField.php',
'DifferentialRevisionPackageOwnerHeraldField' => 'applications/differential/herald/DifferentialRevisionPackageOwnerHeraldField.php',
'DifferentialRevisionQuery' => 'applications/differential/query/DifferentialRevisionQuery.php',
'DifferentialRevisionRelationship' => 'applications/differential/relationships/DifferentialRevisionRelationship.php',
'DifferentialRevisionRelationshipSource' => 'applications/search/relationship/DifferentialRevisionRelationshipSource.php',
'DifferentialRevisionRepositoryHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryHeraldField.php',
'DifferentialRevisionRepositoryProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionRepositoryProjectsHeraldField.php',
@ -601,7 +606,9 @@ phutil_register_library_map(array(
'DiffusionCommitEditController' => 'applications/diffusion/controller/DiffusionCommitEditController.php',
'DiffusionCommitFulltextEngine' => 'applications/repository/search/DiffusionCommitFulltextEngine.php',
'DiffusionCommitHasRevisionEdgeType' => 'applications/diffusion/edge/DiffusionCommitHasRevisionEdgeType.php',
'DiffusionCommitHasRevisionRelationship' => 'applications/diffusion/relationships/DiffusionCommitHasRevisionRelationship.php',
'DiffusionCommitHasTaskEdgeType' => 'applications/diffusion/edge/DiffusionCommitHasTaskEdgeType.php',
'DiffusionCommitHasTaskRelationship' => 'applications/diffusion/relationships/DiffusionCommitHasTaskRelationship.php',
'DiffusionCommitHash' => 'applications/diffusion/data/DiffusionCommitHash.php',
'DiffusionCommitHeraldField' => 'applications/diffusion/herald/DiffusionCommitHeraldField.php',
'DiffusionCommitHeraldFieldGroup' => 'applications/diffusion/herald/DiffusionCommitHeraldFieldGroup.php',
@ -615,6 +622,7 @@ phutil_register_library_map(array(
'DiffusionCommitParentsQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionCommitParentsQueryConduitAPIMethod.php',
'DiffusionCommitQuery' => 'applications/diffusion/query/DiffusionCommitQuery.php',
'DiffusionCommitRef' => 'applications/diffusion/data/DiffusionCommitRef.php',
'DiffusionCommitRelationship' => 'applications/diffusion/relationships/DiffusionCommitRelationship.php',
'DiffusionCommitRelationshipSource' => 'applications/search/relationship/DiffusionCommitRelationshipSource.php',
'DiffusionCommitRemarkupRule' => 'applications/diffusion/remarkup/DiffusionCommitRemarkupRule.php',
'DiffusionCommitRemarkupRuleTestCase' => 'applications/diffusion/remarkup/__tests__/DiffusionCommitRemarkupRuleTestCase.php',
@ -3867,6 +3875,7 @@ phutil_register_library_map(array(
'PholioMockEmbedView' => 'applications/pholio/view/PholioMockEmbedView.php',
'PholioMockFulltextEngine' => 'applications/pholio/search/PholioMockFulltextEngine.php',
'PholioMockHasTaskEdgeType' => 'applications/pholio/edge/PholioMockHasTaskEdgeType.php',
'PholioMockHasTaskRelationship' => 'applications/pholio/relationships/PholioMockHasTaskRelationship.php',
'PholioMockHeraldField' => 'applications/pholio/herald/PholioMockHeraldField.php',
'PholioMockHeraldFieldGroup' => 'applications/pholio/herald/PholioMockHeraldFieldGroup.php',
'PholioMockImagesView' => 'applications/pholio/view/PholioMockImagesView.php',
@ -3875,6 +3884,7 @@ phutil_register_library_map(array(
'PholioMockNameHeraldField' => 'applications/pholio/herald/PholioMockNameHeraldField.php',
'PholioMockPHIDType' => 'applications/pholio/phid/PholioMockPHIDType.php',
'PholioMockQuery' => 'applications/pholio/query/PholioMockQuery.php',
'PholioMockRelationship' => 'applications/pholio/relationships/PholioMockRelationship.php',
'PholioMockRelationshipSource' => 'applications/search/relationship/PholioMockRelationshipSource.php',
'PholioMockSearchEngine' => 'applications/pholio/query/PholioMockSearchEngine.php',
'PholioMockThumbGridView' => 'applications/pholio/view/PholioMockThumbGridView.php',
@ -4709,6 +4719,7 @@ phutil_register_library_map(array(
'DifferentialChangesetTwoUpRenderer' => 'DifferentialChangesetHTMLRenderer',
'DifferentialChangesetTwoUpTestRenderer' => 'DifferentialChangesetTestRenderer',
'DifferentialChangesetViewController' => 'DifferentialController',
'DifferentialChildRevisionsField' => 'DifferentialCustomField',
'DifferentialCloseConduitAPIMethod' => 'DifferentialConduitAPIMethod',
'DifferentialCommentPreviewController' => 'DifferentialController',
'DifferentialCommentSaveController' => 'DifferentialController',
@ -4735,8 +4746,6 @@ phutil_register_library_map(array(
'DifferentialCustomFieldStringIndex' => 'PhabricatorCustomFieldStringIndexStorage',
'DifferentialDAO' => 'PhabricatorLiskDAO',
'DifferentialDefaultViewCapability' => 'PhabricatorPolicyCapability',
'DifferentialDependenciesField' => 'DifferentialCustomField',
'DifferentialDependsOnField' => 'DifferentialCustomField',
'DifferentialDiff' => array(
'DifferentialDAO',
'PhabricatorPolicyInterface',
@ -4817,6 +4826,7 @@ phutil_register_library_map(array(
'DifferentialManiphestTasksField' => 'DifferentialCoreCustomField',
'DifferentialModernHunk' => 'DifferentialHunk',
'DifferentialNextStepField' => 'DifferentialCustomField',
'DifferentialParentRevisionsField' => 'DifferentialCustomField',
'DifferentialParseCacheGarbageCollector' => 'PhabricatorGarbageCollector',
'DifferentialParseCommitMessageConduitAPIMethod' => 'DifferentialConduitAPIMethod',
'DifferentialParseRenderTestCase' => 'PhabricatorTestCase',
@ -4878,9 +4888,13 @@ phutil_register_library_map(array(
'DifferentialRevisionDependsOnRevisionEdgeType' => 'PhabricatorEdgeType',
'DifferentialRevisionEditController' => 'DifferentialController',
'DifferentialRevisionFulltextEngine' => 'PhabricatorFulltextEngine',
'DifferentialRevisionHasChildRelationship' => 'DifferentialRevisionRelationship',
'DifferentialRevisionHasCommitEdgeType' => 'PhabricatorEdgeType',
'DifferentialRevisionHasCommitRelationship' => 'DifferentialRevisionRelationship',
'DifferentialRevisionHasParentRelationship' => 'DifferentialRevisionRelationship',
'DifferentialRevisionHasReviewerEdgeType' => 'PhabricatorEdgeType',
'DifferentialRevisionHasTaskEdgeType' => 'PhabricatorEdgeType',
'DifferentialRevisionHasTaskRelationship' => 'DifferentialRevisionRelationship',
'DifferentialRevisionHeraldField' => 'HeraldField',
'DifferentialRevisionHeraldFieldGroup' => 'HeraldFieldGroup',
'DifferentialRevisionIDField' => 'DifferentialCustomField',
@ -4893,6 +4907,7 @@ phutil_register_library_map(array(
'DifferentialRevisionPackageHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionPackageOwnerHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DifferentialRevisionRelationship' => 'PhabricatorObjectRelationship',
'DifferentialRevisionRelationshipSource' => 'PhabricatorObjectRelationshipSource',
'DifferentialRevisionRepositoryHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionRepositoryProjectsHeraldField' => 'DifferentialRevisionHeraldField',
@ -4958,7 +4973,9 @@ phutil_register_library_map(array(
'DiffusionCommitEditController' => 'DiffusionController',
'DiffusionCommitFulltextEngine' => 'PhabricatorFulltextEngine',
'DiffusionCommitHasRevisionEdgeType' => 'PhabricatorEdgeType',
'DiffusionCommitHasRevisionRelationship' => 'DiffusionCommitRelationship',
'DiffusionCommitHasTaskEdgeType' => 'PhabricatorEdgeType',
'DiffusionCommitHasTaskRelationship' => 'DiffusionCommitRelationship',
'DiffusionCommitHash' => 'Phobject',
'DiffusionCommitHeraldField' => 'HeraldField',
'DiffusionCommitHeraldFieldGroup' => 'HeraldFieldGroup',
@ -4972,6 +4989,7 @@ phutil_register_library_map(array(
'DiffusionCommitParentsQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod',
'DiffusionCommitQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DiffusionCommitRef' => 'Phobject',
'DiffusionCommitRelationship' => 'PhabricatorObjectRelationship',
'DiffusionCommitRelationshipSource' => 'PhabricatorObjectRelationshipSource',
'DiffusionCommitRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'DiffusionCommitRemarkupRuleTestCase' => 'PhabricatorTestCase',
@ -8793,6 +8811,7 @@ phutil_register_library_map(array(
'PholioMockEmbedView' => 'AphrontView',
'PholioMockFulltextEngine' => 'PhabricatorFulltextEngine',
'PholioMockHasTaskEdgeType' => 'PhabricatorEdgeType',
'PholioMockHasTaskRelationship' => 'PholioMockRelationship',
'PholioMockHeraldField' => 'HeraldField',
'PholioMockHeraldFieldGroup' => 'HeraldFieldGroup',
'PholioMockImagesView' => 'AphrontView',
@ -8801,6 +8820,7 @@ phutil_register_library_map(array(
'PholioMockNameHeraldField' => 'PholioMockHeraldField',
'PholioMockPHIDType' => 'PhabricatorPHIDType',
'PholioMockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PholioMockRelationship' => 'PhabricatorObjectRelationship',
'PholioMockRelationshipSource' => 'PhabricatorObjectRelationshipSource',
'PholioMockSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PholioMockThumbGridView' => 'AphrontView',

View file

@ -40,8 +40,8 @@ final class PhabricatorDifferentialConfigOptions
new DifferentialViewPolicyField(),
new DifferentialEditPolicyField(),
new DifferentialDependsOnField(),
new DifferentialDependenciesField(),
new DifferentialParentRevisionsField(),
new DifferentialChildRevisionsField(),
new DifferentialManiphestTasksField(),
new DifferentialCommitsField(),

View file

@ -516,28 +516,6 @@ final class DifferentialRevisionViewController extends DifferentialController {
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit));
$this->requireResource('phabricator-object-selector-css');
$this->requireResource('javelin-behavior-phabricator-object-selector');
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-link')
->setName(pht('Edit Dependencies'))
->setHref("/search/attach/{$revision_phid}/DREV/dependencies/")
->setWorkflow(true)
->setDisabled(!$can_edit));
$maniphest = 'PhabricatorManiphestApplication';
if (PhabricatorApplication::isClassInstalled($maniphest)) {
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-anchor')
->setName(pht('Edit Maniphest Tasks'))
->setHref("/search/attach/{$revision_phid}/TASK/")
->setWorkflow(true)
->setDisabled(!$can_edit));
}
$request_uri = $this->getRequest()->getRequestURI();
$curtain->addAction(
id(new PhabricatorActionView())
@ -545,6 +523,32 @@ final class DifferentialRevisionViewController extends DifferentialController {
->setName(pht('Download Raw Diff'))
->setHref($request_uri->alter('download', 'true')));
$relationship_list = PhabricatorObjectRelationshipList::newForObject(
$viewer,
$revision);
$parent_key = DifferentialRevisionHasParentRelationship::RELATIONSHIPKEY;
$child_key = DifferentialRevisionHasChildRelationship::RELATIONSHIPKEY;
$revision_submenu = array();
$revision_submenu[] = $relationship_list->getRelationship($parent_key)
->newAction($revision);
$revision_submenu[] = $relationship_list->getRelationship($child_key)
->newAction($revision);
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Related Revisions...'))
->setIcon('fa-cog')
->setSubmenu($revision_submenu));
$relationship_submenu = $relationship_list->newActionMenu();
if ($relationship_submenu) {
$curtain->addAction($relationship_submenu);
}
return $curtain;
}

View file

@ -1,6 +1,6 @@
<?php
final class DifferentialDependenciesField
final class DifferentialChildRevisionsField
extends DifferentialCustomField {
public function getFieldKey() {
@ -8,7 +8,7 @@ final class DifferentialDependenciesField
}
public function getFieldName() {
return pht('Dependencies');
return pht('Child Revisions');
}
public function canDisableField() {

View file

@ -1,6 +1,6 @@
<?php
final class DifferentialDependsOnField
final class DifferentialParentRevisionsField
extends DifferentialCustomField {
public function getFieldKey() {
@ -12,7 +12,7 @@ final class DifferentialDependsOnField
}
public function getFieldName() {
return pht('Depends On');
return pht('Parent Revisions');
}
public function canDisableField() {

View file

@ -0,0 +1,44 @@
<?php
final class DifferentialRevisionHasChildRelationship
extends DifferentialRevisionRelationship {
const RELATIONSHIPKEY = 'revision.has-child';
public function getEdgeConstant() {
return DifferentialRevisionDependedOnByRevisionEdgeType::EDGECONST;
}
protected function getActionName() {
return pht('Edit Child Revisions');
}
protected function getActionIcon() {
return 'fa-chevron-circle-down';
}
public function canRelateObjects($src, $dst) {
return ($dst instanceof DifferentialRevision);
}
public function shouldAppearInActionMenu() {
return false;
}
public function getDialogTitleText() {
return pht('Edit Child Revisions');
}
public function getDialogHeaderText() {
return pht('Current Child Revisions');
}
public function getDialogButtonText() {
return pht('Save Child Revisions');
}
protected function newRelationshipSource() {
return new DifferentialRevisionRelationshipSource();
}
}

View file

@ -0,0 +1,40 @@
<?php
final class DifferentialRevisionHasCommitRelationship
extends DifferentialRevisionRelationship {
const RELATIONSHIPKEY = 'revision.has-commit';
public function getEdgeConstant() {
return DifferentialRevisionHasCommitEdgeType::EDGECONST;
}
protected function getActionName() {
return pht('Edit Commits');
}
protected function getActionIcon() {
return 'fa-code';
}
public function canRelateObjects($src, $dst) {
return ($dst instanceof PhabricatorRepositoryCommit);
}
public function getDialogTitleText() {
return pht('Edit Related Commits');
}
public function getDialogHeaderText() {
return pht('Current Commits');
}
public function getDialogButtonText() {
return pht('Save Related Commits');
}
protected function newRelationshipSource() {
return new DiffusionCommitRelationshipSource();
}
}

View file

@ -0,0 +1,44 @@
<?php
final class DifferentialRevisionHasParentRelationship
extends DifferentialRevisionRelationship {
const RELATIONSHIPKEY = 'revision.has-parent';
public function getEdgeConstant() {
return DifferentialRevisionDependsOnRevisionEdgeType::EDGECONST;
}
protected function getActionName() {
return pht('Edit Parent Revisions');
}
protected function getActionIcon() {
return 'fa-chevron-circle-up';
}
public function canRelateObjects($src, $dst) {
return ($dst instanceof DifferentialRevision);
}
public function shouldAppearInActionMenu() {
return false;
}
public function getDialogTitleText() {
return pht('Edit Parent Revisions');
}
public function getDialogHeaderText() {
return pht('Current Parent Revisions');
}
public function getDialogButtonText() {
return pht('Save Parent Revisions');
}
protected function newRelationshipSource() {
return new DifferentialRevisionRelationshipSource();
}
}

View file

@ -0,0 +1,40 @@
<?php
final class DifferentialRevisionHasTaskRelationship
extends DifferentialRevisionRelationship {
const RELATIONSHIPKEY = 'revision.has-task';
public function getEdgeConstant() {
return DifferentialRevisionHasTaskEdgeType::EDGECONST;
}
protected function getActionName() {
return pht('Edit Tasks');
}
protected function getActionIcon() {
return 'fa-anchor';
}
public function canRelateObjects($src, $dst) {
return ($dst instanceof ManiphestTask);
}
public function getDialogTitleText() {
return pht('Edit Related Tasks');
}
public function getDialogHeaderText() {
return pht('Current Tasks');
}
public function getDialogButtonText() {
return pht('Save Related Tasks');
}
protected function newRelationshipSource() {
return new ManiphestTaskRelationshipSource();
}
}

View file

@ -0,0 +1,19 @@
<?php
abstract class DifferentialRevisionRelationship
extends PhabricatorObjectRelationship {
public function isEnabledForObject($object) {
$viewer = $this->getViewer();
$has_app = PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorDifferentialApplication',
$viewer);
if (!$has_app) {
return false;
}
return ($object instanceof DifferentialRevision);
}
}

View file

@ -968,26 +968,21 @@ final class DiffusionCommitController extends DiffusionController {
->setWorkflow(!$can_edit);
$curtain->addAction($action);
require_celerity_resource('phabricator-object-selector-css');
require_celerity_resource('javelin-behavior-phabricator-object-selector');
$maniphest = 'PhabricatorManiphestApplication';
if (PhabricatorApplication::isClassInstalled($maniphest)) {
$action = id(new PhabricatorActionView())
->setName(pht('Edit Maniphest Tasks'))
->setIcon('fa-anchor')
->setHref('/search/attach/'.$commit->getPHID().'/TASK/edge/')
->setWorkflow(true)
->setDisabled(!$can_edit);
$curtain->addAction($action);
}
$action = id(new PhabricatorActionView())
->setName(pht('Download Raw Diff'))
->setHref($request->getRequestURI()->alter('diff', true))
->setIcon('fa-download');
$curtain->addAction($action);
$relationship_list = PhabricatorObjectRelationshipList::newForObject(
$viewer,
$commit);
$relationship_submenu = $relationship_list->newActionMenu();
if ($relationship_submenu) {
$curtain->addAction($relationship_submenu);
}
return $curtain;
}

View file

@ -0,0 +1,40 @@
<?php
final class DiffusionCommitHasRevisionRelationship
extends DiffusionCommitRelationship {
const RELATIONSHIPKEY = 'commit.has-revision';
public function getEdgeConstant() {
return DiffusionCommitHasRevisionEdgeType::EDGECONST;
}
protected function getActionName() {
return pht('Edit Revisions');
}
protected function getActionIcon() {
return 'fa-cog';
}
public function canRelateObjects($src, $dst) {
return ($dst instanceof DifferentialRevision);
}
public function getDialogTitleText() {
return pht('Edit Related Revisions');
}
public function getDialogHeaderText() {
return pht('Current Revisions');
}
public function getDialogButtonText() {
return pht('Save Related Revisions');
}
protected function newRelationshipSource() {
return new DifferentialRevisionRelationshipSource();
}
}

View file

@ -0,0 +1,40 @@
<?php
final class DiffusionCommitHasTaskRelationship
extends DiffusionCommitRelationship {
const RELATIONSHIPKEY = 'commit.has-task';
public function getEdgeConstant() {
return DiffusionCommitHasTaskEdgeType::EDGECONST;
}
protected function getActionName() {
return pht('Edit Tasks');
}
protected function getActionIcon() {
return 'fa-anchor';
}
public function canRelateObjects($src, $dst) {
return ($dst instanceof ManiphestTask);
}
public function getDialogTitleText() {
return pht('Edit Related Tasks');
}
public function getDialogHeaderText() {
return pht('Current Tasks');
}
public function getDialogButtonText() {
return pht('Save Related Tasks');
}
protected function newRelationshipSource() {
return new ManiphestTaskRelationshipSource();
}
}

View file

@ -0,0 +1,19 @@
<?php
abstract class DiffusionCommitRelationship
extends PhabricatorObjectRelationship {
public function isEnabledForObject($object) {
$viewer = $this->getViewer();
$has_app = PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorDiffusionApplication',
$viewer);
if (!$has_app) {
return false;
}
return ($object instanceof PhabricatorRepositoryCommit);
}
}

View file

@ -150,13 +150,14 @@ final class PholioMockViewController extends PholioController {
->setWorkflow(true));
}
$curtain->addAction(
id(new PhabricatorActionView())
->setIcon('fa-anchor')
->setName(pht('Edit Maniphest Tasks'))
->setHref("/search/attach/{$mock->getPHID()}/TASK/edge/")
->setDisabled(!$viewer->isLoggedIn())
->setWorkflow(true));
$relationship_list = PhabricatorObjectRelationshipList::newForObject(
$viewer,
$mock);
$relationship_submenu = $relationship_list->newActionMenu();
if ($relationship_submenu) {
$curtain->addAction($relationship_submenu);
}
if ($this->getManiphestTaskPHIDs()) {
$curtain->newPanel()

View file

@ -0,0 +1,40 @@
<?php
final class PholioMockHasTaskRelationship
extends PholioMockRelationship {
const RELATIONSHIPKEY = 'mock.has-task';
public function getEdgeConstant() {
return PholioMockHasTaskEdgeType::EDGECONST;
}
protected function getActionName() {
return pht('Edit Tasks');
}
protected function getActionIcon() {
return 'fa-anchor';
}
public function canRelateObjects($src, $dst) {
return ($dst instanceof ManiphestTask);
}
public function getDialogTitleText() {
return pht('Edit Related Tasks');
}
public function getDialogHeaderText() {
return pht('Current Tasks');
}
public function getDialogButtonText() {
return pht('Save Related Tasks');
}
protected function newRelationshipSource() {
return new ManiphestTaskRelationshipSource();
}
}

View file

@ -0,0 +1,19 @@
<?php
abstract class PholioMockRelationship
extends PhabricatorObjectRelationship {
public function isEnabledForObject($object) {
$viewer = $this->getViewer();
$has_app = PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorPholioApplication',
$viewer);
if (!$has_app) {
return false;
}
return ($object instanceof PholioMock);
}
}

View file

@ -3,6 +3,14 @@
final class DifferentialRevisionRelationshipSource
extends PhabricatorObjectRelationshipSource {
public function isEnabledForObject($object) {
$viewer = $this->getViewer();
return PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorDifferentialApplication',
$viewer);
}
public function getResultPHIDTypes() {
return array(
DifferentialRevisionPHIDType::TYPECONST,

View file

@ -3,6 +3,14 @@
final class DiffusionCommitRelationshipSource
extends PhabricatorObjectRelationshipSource {
public function isEnabledForObject($object) {
$viewer = $this->getViewer();
return PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorDiffusionApplication',
$viewer);
}
public function getResultPHIDTypes() {
return array(
PhabricatorRepositoryCommitPHIDType::TYPECONST,

View file

@ -3,6 +3,14 @@
final class ManiphestTaskRelationshipSource
extends PhabricatorObjectRelationshipSource {
public function isEnabledForObject($object) {
$viewer = $this->getViewer();
return PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorManiphestApplication',
$viewer);
}
public function getResultPHIDTypes() {
return array(
ManiphestTaskPHIDType::TYPECONST,

View file

@ -54,7 +54,10 @@ abstract class PhabricatorObjectRelationship extends Phobject {
}
final public function newSource() {
return $this->newRelationshipSource();
$viewer = $this->getViewer();
return $this->newRelationshipSource()
->setViewer($viewer);
}
abstract protected function newRelationshipSource();

View file

@ -87,6 +87,11 @@ final class PhabricatorObjectRelationshipList extends Phobject {
continue;
}
$source = $relationship->newSource();
if (!$source->isEnabledForObject($object)) {
continue;
}
$results[$key] = $relationship;
}

View file

@ -2,6 +2,18 @@
abstract class PhabricatorObjectRelationshipSource extends Phobject {
private $viewer;
final public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
final public function getViewer() {
return $this->viewer;
}
abstract public function isEnabledForObject($object);
abstract public function getResultPHIDTypes();
}

View file

@ -3,6 +3,14 @@
final class PholioMockRelationshipSource
extends PhabricatorObjectRelationshipSource {
public function isEnabledForObject($object) {
$viewer = $this->getViewer();
return PhabricatorApplication::isClassInstalledForViewer(
'PhabricatorPholioApplication',
$viewer);
}
public function getResultPHIDTypes() {
return array(
PholioMockPHIDType::TYPECONST,