1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52:41 +01:00

Modernize Pholio edges

Summary: Modernize Pholio edges to subclass `PhabricatorEdgeType`. Largely based on D11045.

Test Plan: Attached a mock to a task, observed the expected comment in the transaction view (both ways).

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: Korvin, epriestley

Differential Revision: https://secure.phabricator.com/D11113
This commit is contained in:
Joshua Spence 2015-01-02 10:11:41 +11:00
parent f0db6e4818
commit a6acedef0b
8 changed files with 218 additions and 46 deletions

View file

@ -1026,6 +1026,7 @@ phutil_register_library_map(array(
'ManiphestTaskDetailController' => 'applications/maniphest/controller/ManiphestTaskDetailController.php',
'ManiphestTaskEditController' => 'applications/maniphest/controller/ManiphestTaskEditController.php',
'ManiphestTaskHasCommitEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasCommitEdgeType.php',
'ManiphestTaskHasMockEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasMockEdgeType.php',
'ManiphestTaskHasRevisionEdgeType' => 'applications/maniphest/edge/ManiphestTaskHasRevisionEdgeType.php',
'ManiphestTaskListController' => 'applications/maniphest/controller/ManiphestTaskListController.php',
'ManiphestTaskListView' => 'applications/maniphest/view/ManiphestTaskListView.php',
@ -2649,6 +2650,7 @@ phutil_register_library_map(array(
'PholioMockEditController' => 'applications/pholio/controller/PholioMockEditController.php',
'PholioMockEditor' => 'applications/pholio/editor/PholioMockEditor.php',
'PholioMockEmbedView' => 'applications/pholio/view/PholioMockEmbedView.php',
'PholioMockHasTaskEdgeType' => 'applications/pholio/edge/PholioMockHasTaskEdgeType.php',
'PholioMockImagesView' => 'applications/pholio/view/PholioMockImagesView.php',
'PholioMockListController' => 'applications/pholio/controller/PholioMockListController.php',
'PholioMockMailReceiver' => 'applications/pholio/mail/PholioMockMailReceiver.php',
@ -4151,6 +4153,7 @@ phutil_register_library_map(array(
'ManiphestTaskDetailController' => 'ManiphestController',
'ManiphestTaskEditController' => 'ManiphestController',
'ManiphestTaskHasCommitEdgeType' => 'PhabricatorEdgeType',
'ManiphestTaskHasMockEdgeType' => 'PhabricatorEdgeType',
'ManiphestTaskHasRevisionEdgeType' => 'PhabricatorEdgeType',
'ManiphestTaskListController' => 'ManiphestController',
'ManiphestTaskListView' => 'ManiphestView',
@ -5907,6 +5910,7 @@ phutil_register_library_map(array(
'PholioMockEditController' => 'PholioController',
'PholioMockEditor' => 'PhabricatorApplicationTransactionEditor',
'PholioMockEmbedView' => 'AphrontView',
'PholioMockHasTaskEdgeType' => 'PhabricatorEdgeType',
'PholioMockImagesView' => 'AphrontView',
'PholioMockListController' => 'PholioController',
'PholioMockMailReceiver' => 'PhabricatorObjectMailReceiver',

View file

@ -49,7 +49,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
$e_dep_on = ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
$e_dep_by = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST;
$e_rev = ManiphestTaskHasRevisionEdgeType::EDGECONST;
$e_mock = PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK;
$e_mock = ManiphestTaskHasMockEdgeType::EDGECONST;
$phid = $task->getPHID();
@ -489,7 +489,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
=> pht('Blocked By'),
ManiphestTaskHasRevisionEdgeType::EDGECONST
=> pht('Differential Revisions'),
PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK
ManiphestTaskHasMockEdgeType::EDGECONST
=> pht('Pholio Mocks'),
);

View file

@ -0,0 +1,102 @@
<?php
final class ManiphestTaskHasMockEdgeType extends PhabricatorEdgeType {
const EDGECONST = 38;
public function getInverseEdgeConstant() {
return PholioMockHasTaskEdgeType::EDGECONST;
}
public function shouldWriteInverseTransactions() {
return true;
}
public function getTransactionAddString(
$actor,
$add_count,
$add_edges) {
return pht(
'%s added %s mock(s): %s.',
$actor,
$add_count,
$add_edges);
}
public function getTransactionRemoveString(
$actor,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s mock(s): %s.',
$actor,
$rem_count,
$rem_edges);
}
public function getTransactionEditString(
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited mock(s), added %s: %s; removed %s: %s.',
$actor,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
public function getFeedAddString(
$actor,
$object,
$add_count,
$add_edges) {
return pht(
'%s added %s mock(s) for %s: %s.',
$actor,
$add_count,
$object,
$add_edges);
}
public function getFeedRemoveString(
$actor,
$object,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s mock(s) for %s: %s.',
$actor,
$rem_count,
$object,
$rem_edges);
}
public function getFeedEditString(
$actor,
$object,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited mock(s) for %s, added %s: %s; removed %s: %s.',
$actor,
$object,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
}

View file

@ -40,7 +40,7 @@ final class PholioMockViewController extends PholioController {
$phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
$mock->getPHID(),
PhabricatorEdgeConfig::TYPE_MOCK_HAS_TASK);
PholioMockHasTaskEdgeType::EDGECONST);
$this->setManiphestTaskPHIDs($phids);
$phids[] = $mock->getAuthorPHID();
$this->loadHandles($phids);

View file

@ -0,0 +1,102 @@
<?php
final class PholioMockHasTaskEdgeType extends PhabricatorEdgeType {
const EDGECONST = 37;
public function getInverseEdgeConstant() {
return ManiphestTaskHasMockEdgeType::EDGECONST;
}
public function shouldWriteInverseTransactions() {
return true;
}
public function getTransactionAddString(
$actor,
$add_count,
$add_edges) {
return pht(
'%s added %s task(s): %s.',
$actor,
$add_count,
$add_edges);
}
public function getTransactionRemoveString(
$actor,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s task(s): %s.',
$actor,
$rem_count,
$rem_edges);
}
public function getTransactionEditString(
$actor,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited task(s), added %s: %s; removed %s: %s.',
$actor,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
public function getFeedAddString(
$actor,
$object,
$add_count,
$add_edges) {
return pht(
'%s added %s task(s) for %s: %s.',
$actor,
$add_count,
$object,
$add_edges);
}
public function getFeedRemoveString(
$actor,
$object,
$rem_count,
$rem_edges) {
return pht(
'%s removed %s task(s) for %s: %s.',
$actor,
$rem_count,
$object,
$rem_edges);
}
public function getFeedEditString(
$actor,
$object,
$total_count,
$add_count,
$add_edges,
$rem_count,
$rem_edges) {
return pht(
'%s edited task(s) for %s, added %s: %s; removed %s: %s.',
$actor,
$object,
$add_count,
$add_edges,
$rem_count,
$rem_edges);
}
}

View file

@ -294,14 +294,14 @@ final class PhabricatorSearchAttachController
$t_cmit => ManiphestTaskHasCommitEdgeType::EDGECONST,
$t_task => ManiphestTaskDependsOnTaskEdgeType::EDGECONST,
$t_drev => ManiphestTaskHasRevisionEdgeType::EDGECONST,
$t_mock => PhabricatorEdgeConfig::TYPE_TASK_HAS_MOCK,
$t_mock => ManiphestTaskHasMockEdgeType::EDGECONST,
),
$t_drev => array(
$t_drev => DifferentialRevisionDependsOnRevisionEdgeType::EDGECONST,
$t_task => DifferentialRevisionHasTaskEdgeType::EDGECONST,
),
$t_mock => array(
$t_task => PhabricatorEdgeConfig::TYPE_MOCK_HAS_TASK,
$t_task => PholioMockHasTaskEdgeType::EDGECONST,
),
);

View file

@ -17,9 +17,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
const TYPE_OBJECT_HAS_CONTRIBUTOR = 33;
const TYPE_CONTRIBUTED_TO_OBJECT = 34;
const TYPE_MOCK_HAS_TASK = 37;
const TYPE_TASK_HAS_MOCK = 38;
const TYPE_OBJECT_USES_CREDENTIAL = 39;
const TYPE_CREDENTIAL_USED_BY_OBJECT = 40;
@ -112,9 +109,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
self::TYPE_OBJECT_HAS_CONTRIBUTOR => self::TYPE_CONTRIBUTED_TO_OBJECT,
self::TYPE_CONTRIBUTED_TO_OBJECT => self::TYPE_OBJECT_HAS_CONTRIBUTOR,
self::TYPE_TASK_HAS_MOCK => self::TYPE_MOCK_HAS_TASK,
self::TYPE_MOCK_HAS_TASK => self::TYPE_TASK_HAS_MOCK,
self::TYPE_PHOB_HAS_ASANATASK => self::TYPE_ASANATASK_HAS_PHOB,
self::TYPE_ASANATASK_HAS_PHOB => self::TYPE_PHOB_HAS_ASANATASK,
@ -171,8 +165,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
public static function getEditStringForEdgeType($type) {
switch ($type) {
case self::TYPE_MOCK_HAS_TASK:
return '%s edited task(s), added %d: %s; removed %d: %s.';
case self::TYPE_OBJECT_HAS_SUBSCRIBER:
return '%s edited subscriber(s), added %d: %s; removed %d: %s.';
case self::TYPE_SUBSCRIBED_TO_OBJECT:
@ -186,8 +178,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
return '%s edited file(s), added %d: %s; removed %d: %s.';
case self::TYPE_OBJECT_HAS_CONTRIBUTOR:
return '%s edited contributor(s), added %d: %s; removed %d: %s.';
case self::TYPE_TASK_HAS_MOCK:
return '%s edited mock(s), added %d: %s; removed %d: %s.';
case self::TYPE_DASHBOARD_HAS_PANEL:
return '%s edited panel(s), added %d: %s; removed %d: %s.';
case self::TYPE_PANEL_HAS_DASHBOARD:
@ -204,8 +194,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
public static function getAddStringForEdgeType($type) {
switch ($type) {
case self::TYPE_MOCK_HAS_TASK:
return '%s added %d task(s): %s.';
case self::TYPE_OBJECT_HAS_SUBSCRIBER:
return '%s added %d subscriber(s): %s.';
case self::TYPE_OBJECT_HAS_UNSUBSCRIBER:
@ -214,8 +202,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
return '%s added %d file(s): %s.';
case self::TYPE_OBJECT_HAS_CONTRIBUTOR:
return '%s added %d contributor(s): %s.';
case self::TYPE_TASK_HAS_MOCK:
return '%s added %d mock(s): %s.';
case self::TYPE_DASHBOARD_HAS_PANEL:
return '%s added %d panel(s): %s.';
case self::TYPE_PANEL_HAS_DASHBOARD:
@ -234,8 +220,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
public static function getRemoveStringForEdgeType($type) {
switch ($type) {
case self::TYPE_MOCK_HAS_TASK:
return '%s removed %d task(s): %s.';
case self::TYPE_OBJECT_HAS_SUBSCRIBER:
return '%s removed %d subscriber(s): %s.';
case self::TYPE_OBJECT_HAS_UNSUBSCRIBER:
@ -244,8 +228,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
return '%s removed %d file(s): %s.';
case self::TYPE_OBJECT_HAS_CONTRIBUTOR:
return '%s removed %d contributor(s): %s.';
case self::TYPE_TASK_HAS_MOCK:
return '%s removed %d mock(s): %s.';
case self::TYPE_DASHBOARD_HAS_PANEL:
return '%s removed %d panel(s): %s.';
case self::TYPE_PANEL_HAS_DASHBOARD:
@ -264,8 +246,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
public static function getFeedStringForEdgeType($type) {
switch ($type) {
case self::TYPE_MOCK_HAS_TASK:
return '%s updated tasks of %s.';
case self::TYPE_OBJECT_HAS_SUBSCRIBER:
return '%s updated subscribers of %s.';
case self::TYPE_OBJECT_HAS_UNSUBSCRIBER:
@ -274,8 +254,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
return '%s updated files of %s.';
case self::TYPE_OBJECT_HAS_CONTRIBUTOR:
return '%s updated contributors of %s.';
case self::TYPE_TASK_HAS_MOCK:
return '%s updated mocks of %s.';
case self::TYPE_PANEL_HAS_DASHBOARD:
return '%s updated panels for %s.';
case self::TYPE_PANEL_HAS_DASHBOARD:

View file

@ -294,31 +294,31 @@ abstract class PhabricatorBaseEnglishTranslation
),
),
'%s edited mock(s), added %d: %s; removed %d: %s.' =>
'%s edited mock(s), added %s: %s; removed %s: %s.' =>
'%s edited mocks, added: %3$s; removed: %5$s.',
'%s added %d mock(s): %s.' => array(
'%s added %s mock(s): %s.' => array(
array(
'%s added a mock: %3$s.',
'%s added mocks: %3$s.',
),
),
'%s removed %d mock(s): %s.' => array(
'%s removed %s mock(s): %s.' => array(
array(
'%s removed a mock: %3$s.',
'%s removed mocks: %3$s.',
),
),
'%s added %d task(s): %s.' => array(
'%s added %s task(s): %s.' => array(
array(
'%s added a task: %3$s.',
'%s added tasks: %3$s.',
),
),
'%s removed %d task(s): %s.' => array(
'%s removed %s task(s): %s.' => array(
array(
'%s removed a task: %3$s.',
'%s removed tasks: %3$s.',
@ -704,20 +704,6 @@ abstract class PhabricatorBaseEnglishTranslation
'%s updated JIRA issue(s): added %d %s; removed %d %s.' =>
'%s updated JIRA issues: added %3$s; removed %5$s.',
'%s added %s task(s): %s.' => array(
array(
'%s added a task: %3$s.',
'%s added tasks: %3$s.',
),
),
'%s removed %s task(s): %s.' => array(
array(
'%s removed a task: %3$s.',
'%s removed tasks: %3$s.',
),
),
'%s edited %s task(s), added %s: %s; removed %s: %s.' =>
'%s edited tasks, added %4$s; removed %6$s.',