mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 09:20:58 +01:00
Modernize Dashboard edges
Summary: Modernize Dashboard edges to subclass `PhabricatorEdgeType`. Largely based on D11045. Test Plan: Attached a panel to a dashboard, observed the expected comment in the transaction view (both ways). Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley Differential Revision: https://secure.phabricator.com/D11114
This commit is contained in:
parent
a6acedef0b
commit
44ec1d7374
12 changed files with 250 additions and 29 deletions
|
@ -1583,6 +1583,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDashboardController' => 'applications/dashboard/controller/PhabricatorDashboardController.php',
|
||||
'PhabricatorDashboardCopyController' => 'applications/dashboard/controller/PhabricatorDashboardCopyController.php',
|
||||
'PhabricatorDashboardDAO' => 'applications/dashboard/storage/PhabricatorDashboardDAO.php',
|
||||
'PhabricatorDashboardDashboardHasPanelEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardDashboardHasPanelEdgeType.php',
|
||||
'PhabricatorDashboardDashboardPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardDashboardPHIDType.php',
|
||||
'PhabricatorDashboardEditController' => 'applications/dashboard/controller/PhabricatorDashboardEditController.php',
|
||||
'PhabricatorDashboardHistoryController' => 'applications/dashboard/controller/PhabricatorDashboardHistoryController.php',
|
||||
|
@ -1597,6 +1598,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDashboardPanelCoreCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php',
|
||||
'PhabricatorDashboardPanelCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php',
|
||||
'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php',
|
||||
'PhabricatorDashboardPanelHasDashboardEdgeType' => 'applications/dashboard/edge/PhabricatorDashboardPanelHasDashboardEdgeType.php',
|
||||
'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/PhabricatorDashboardPanelListController.php',
|
||||
'PhabricatorDashboardPanelPHIDType' => 'applications/dashboard/phid/PhabricatorDashboardPanelPHIDType.php',
|
||||
'PhabricatorDashboardPanelQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelQuery.php',
|
||||
|
@ -4754,6 +4756,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorDashboardController' => 'PhabricatorController',
|
||||
'PhabricatorDashboardCopyController' => 'PhabricatorDashboardController',
|
||||
'PhabricatorDashboardDAO' => 'PhabricatorLiskDAO',
|
||||
'PhabricatorDashboardDashboardHasPanelEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhabricatorDashboardDashboardPHIDType' => 'PhabricatorPHIDType',
|
||||
'PhabricatorDashboardEditController' => 'PhabricatorDashboardController',
|
||||
'PhabricatorDashboardHistoryController' => 'PhabricatorDashboardController',
|
||||
|
@ -4776,6 +4779,7 @@ phutil_register_library_map(array(
|
|||
),
|
||||
'PhabricatorDashboardPanelCustomField' => 'PhabricatorCustomField',
|
||||
'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController',
|
||||
'PhabricatorDashboardPanelHasDashboardEdgeType' => 'PhabricatorEdgeType',
|
||||
'PhabricatorDashboardPanelListController' => 'PhabricatorDashboardController',
|
||||
'PhabricatorDashboardPanelPHIDType' => 'PhabricatorPHIDType',
|
||||
'PhabricatorDashboardPanelQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
|
|
|
@ -38,7 +38,7 @@ final class PhabricatorDashboardCopyController
|
|||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue(
|
||||
'edge:type',
|
||||
PhabricatorEdgeConfig::TYPE_DASHBOARD_HAS_PANEL)
|
||||
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
|
||||
->setNewValue(
|
||||
array(
|
||||
'=' => array_fuse($dashboard->getPanelPHIDs()),
|
||||
|
|
|
@ -297,7 +297,7 @@ final class PhabricatorDashboardEditController
|
|||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue(
|
||||
'edge:type',
|
||||
PhabricatorEdgeConfig::TYPE_DASHBOARD_HAS_PANEL)
|
||||
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
|
||||
->setNewValue(
|
||||
array(
|
||||
'+' => array_fuse($panel_phids),
|
||||
|
|
|
@ -405,7 +405,7 @@ final class PhabricatorDashboardPanelEditController
|
|||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue(
|
||||
'edge:type',
|
||||
PhabricatorEdgeConfig::TYPE_DASHBOARD_HAS_PANEL)
|
||||
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
|
||||
->setNewValue(
|
||||
array(
|
||||
'+' => array(
|
||||
|
|
|
@ -155,7 +155,7 @@ final class PhabricatorDashboardPanelViewController
|
|||
|
||||
$dashboard_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
|
||||
$panel->getPHID(),
|
||||
PhabricatorEdgeConfig::TYPE_PANEL_HAS_DASHBOARD);
|
||||
PhabricatorDashboardPanelHasDashboardEdgeType::EDGECONST);
|
||||
$this->loadHandles($dashboard_phids);
|
||||
|
||||
$does_not_appear = pht(
|
||||
|
|
|
@ -45,7 +45,7 @@ final class PhabricatorDashboardRemovePanelController
|
|||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue(
|
||||
'edge:type',
|
||||
PhabricatorEdgeConfig::TYPE_DASHBOARD_HAS_PANEL)
|
||||
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
|
||||
->setNewValue(
|
||||
array(
|
||||
'-' => array(
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorDashboardDashboardHasPanelEdgeType
|
||||
extends PhabricatorEdgeType {
|
||||
|
||||
const EDGECONST = 45;
|
||||
|
||||
public function getInverseEdgeConstant() {
|
||||
return PhabricatorDashboardPanelHasDashboardEdgeType::EDGECONST;
|
||||
}
|
||||
|
||||
public function shouldWriteInverseTransactions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getTransactionAddString(
|
||||
$actor,
|
||||
$add_count,
|
||||
$add_edges) {
|
||||
|
||||
return pht(
|
||||
'%s added %s panel(s): %s.',
|
||||
$actor,
|
||||
$add_count,
|
||||
$add_edges);
|
||||
}
|
||||
|
||||
public function getTransactionRemoveString(
|
||||
$actor,
|
||||
$rem_count,
|
||||
$rem_edges) {
|
||||
|
||||
return pht(
|
||||
'%s removed %s panel(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 panel(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 panel(s) for %s: %s.',
|
||||
$actor,
|
||||
$add_count,
|
||||
$object,
|
||||
$add_edges);
|
||||
}
|
||||
|
||||
public function getFeedRemoveString(
|
||||
$actor,
|
||||
$object,
|
||||
$rem_count,
|
||||
$rem_edges) {
|
||||
|
||||
return pht(
|
||||
'%s removed %s panel(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 panel(s) for %s, added %s: %s; removed %s: %s.',
|
||||
$actor,
|
||||
$object,
|
||||
$add_count,
|
||||
$add_edges,
|
||||
$rem_count,
|
||||
$rem_edges);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorDashboardPanelHasDashboardEdgeType
|
||||
extends PhabricatorEdgeType {
|
||||
|
||||
const EDGECONST = 46;
|
||||
|
||||
public function getInverseEdgeConstant() {
|
||||
return PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST;
|
||||
}
|
||||
|
||||
public function shouldWriteInverseTransactions() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getTransactionAddString(
|
||||
$actor,
|
||||
$add_count,
|
||||
$add_edges) {
|
||||
|
||||
return pht(
|
||||
'%s added %s dashboard(s): %s.',
|
||||
$actor,
|
||||
$add_count,
|
||||
$add_edges);
|
||||
}
|
||||
|
||||
public function getTransactionRemoveString(
|
||||
$actor,
|
||||
$rem_count,
|
||||
$rem_edges) {
|
||||
|
||||
return pht(
|
||||
'%s removed %s dashboard(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 dashboard(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 dashboard(s) for %s: %s.',
|
||||
$actor,
|
||||
$add_count,
|
||||
$object,
|
||||
$add_edges);
|
||||
}
|
||||
|
||||
public function getFeedRemoveString(
|
||||
$actor,
|
||||
$object,
|
||||
$rem_count,
|
||||
$rem_edges) {
|
||||
|
||||
return pht(
|
||||
'%s removed %s dashboard(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 dashboard(s) for %s, added %s: %s; removed %s: %s.',
|
||||
$actor,
|
||||
$object,
|
||||
$add_count,
|
||||
$add_edges,
|
||||
$rem_count,
|
||||
$rem_edges);
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ final class PhabricatorDashboardTransactionEditor
|
|||
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
||||
->setMetadataValue(
|
||||
'edge:type',
|
||||
PhabricatorEdgeConfig::TYPE_DASHBOARD_HAS_PANEL)
|
||||
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST)
|
||||
->setNewValue(
|
||||
array(
|
||||
'+' => array(
|
||||
|
|
|
@ -44,7 +44,7 @@ final class PhabricatorDashboardQuery
|
|||
->withSourcePHIDs(mpull($dashboards, 'getPHID'))
|
||||
->withEdgeTypes(
|
||||
array(
|
||||
PhabricatorEdgeConfig::TYPE_DASHBOARD_HAS_PANEL,
|
||||
PhabricatorDashboardDashboardHasPanelEdgeType::EDGECONST,
|
||||
));
|
||||
$edge_query->execute();
|
||||
|
||||
|
|
|
@ -20,9 +20,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
const TYPE_OBJECT_USES_CREDENTIAL = 39;
|
||||
const TYPE_CREDENTIAL_USED_BY_OBJECT = 40;
|
||||
|
||||
const TYPE_DASHBOARD_HAS_PANEL = 45;
|
||||
const TYPE_PANEL_HAS_DASHBOARD = 46;
|
||||
|
||||
const TYPE_OBJECT_HAS_WATCHER = 47;
|
||||
const TYPE_WATCHER_HAS_OBJECT = 48;
|
||||
|
||||
|
@ -121,9 +118,6 @@ final class PhabricatorEdgeConfig extends PhabricatorEdgeConstants {
|
|||
self::TYPE_OBJECT_USES_CREDENTIAL => self::TYPE_CREDENTIAL_USED_BY_OBJECT,
|
||||
self::TYPE_CREDENTIAL_USED_BY_OBJECT => self::TYPE_OBJECT_USES_CREDENTIAL,
|
||||
|
||||
self::TYPE_PANEL_HAS_DASHBOARD => self::TYPE_DASHBOARD_HAS_PANEL,
|
||||
self::TYPE_DASHBOARD_HAS_PANEL => self::TYPE_PANEL_HAS_DASHBOARD,
|
||||
|
||||
self::TYPE_OBJECT_HAS_WATCHER => self::TYPE_WATCHER_HAS_OBJECT,
|
||||
self::TYPE_WATCHER_HAS_OBJECT => self::TYPE_OBJECT_HAS_WATCHER,
|
||||
);
|
||||
|
@ -178,10 +172,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_DASHBOARD_HAS_PANEL:
|
||||
return '%s edited panel(s), added %d: %s; removed %d: %s.';
|
||||
case self::TYPE_PANEL_HAS_DASHBOARD:
|
||||
return '%s edited dashboard(s), added %d: %s; removed %d: %s.';
|
||||
case self::TYPE_SUBSCRIBED_TO_OBJECT:
|
||||
case self::TYPE_UNSUBSCRIBED_FROM_OBJECT:
|
||||
case self::TYPE_FILE_HAS_OBJECT:
|
||||
|
@ -202,10 +192,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_DASHBOARD_HAS_PANEL:
|
||||
return '%s added %d panel(s): %s.';
|
||||
case self::TYPE_PANEL_HAS_DASHBOARD:
|
||||
return '%s added %d dashboard(s): %s.';
|
||||
case self::TYPE_OBJECT_HAS_WATCHER:
|
||||
return '%s added %d watcher(s): %s.';
|
||||
case self::TYPE_SUBSCRIBED_TO_OBJECT:
|
||||
|
@ -228,10 +214,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_DASHBOARD_HAS_PANEL:
|
||||
return '%s removed %d panel(s): %s.';
|
||||
case self::TYPE_PANEL_HAS_DASHBOARD:
|
||||
return '%s removed %d dashboard(s): %s.';
|
||||
case self::TYPE_OBJECT_HAS_WATCHER:
|
||||
return '%s removed %d watcher(s): %s.';
|
||||
case self::TYPE_SUBSCRIBED_TO_OBJECT:
|
||||
|
@ -254,10 +236,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_PANEL_HAS_DASHBOARD:
|
||||
return '%s updated panels for %s.';
|
||||
case self::TYPE_PANEL_HAS_DASHBOARD:
|
||||
return '%s updated dashboards for %s.';
|
||||
case self::TYPE_OBJECT_HAS_WATCHER:
|
||||
return '%s updated watchers for %s.';
|
||||
case self::TYPE_SUBSCRIBED_TO_OBJECT:
|
||||
|
|
|
@ -798,6 +798,39 @@ abstract class PhabricatorBaseEnglishTranslation
|
|||
'%s edited %s project(s) for %s, added %s: %s; removed %s: %s.' =>
|
||||
'%s edited projects for %3$s, added: %5$s; removed %7$s.',
|
||||
|
||||
'%s added %s panel(s): %s.' => array(
|
||||
array(
|
||||
'%s added a panel: %3$s.',
|
||||
'%s added panels: %3$s.',
|
||||
),
|
||||
),
|
||||
|
||||
'%s removed %s panel(s): %s.' => array(
|
||||
array(
|
||||
'%s removed a panel: %3$s.',
|
||||
'%s removed panels: %3$s.',
|
||||
),
|
||||
),
|
||||
|
||||
'%s edited %s panel(s), added %s: %s; removed %s: %s.' =>
|
||||
'%s edited panels, added %4$s; removed %6$s.',
|
||||
|
||||
'%s added %s dashboard(s): %s.' => array(
|
||||
array(
|
||||
'%s added a dashboard: %3$s.',
|
||||
'%s added dashboards: %3$s.',
|
||||
),
|
||||
),
|
||||
|
||||
'%s removed %s dashboard(s): %s.' => array(
|
||||
array(
|
||||
'%s removed a dashboard: %3$s.',
|
||||
'%s removed dashboards: %3$s.',
|
||||
),
|
||||
),
|
||||
|
||||
'%s edited %s dashboard(s), added %s: %s; removed %s: %s.' =>
|
||||
'%s edited dashboards, added %4$s; removed %6$s.',
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue