From 8a429c51ac44b0397aaefd2d04ffeb3684eefe67 Mon Sep 17 00:00:00 2001 From: lkassianik Date: Tue, 20 May 2014 10:53:27 -0700 Subject: [PATCH] Embed dashboard panels in comments Summary: Fixes T4983, Panel prefix 'W' should be recognized as a shortcut to a dashboard panel Test Plan: Open any comment input, type '{W1}', or other existing panel, preview should embed that panel. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: epriestley, Korvin Maniphest Tasks: T4983 Differential Revision: https://secure.phabricator.com/D9215 --- src/__phutil_library_map__.php | 2 ++ .../PhabricatorApplicationDashboard.php | 6 ++++ .../PhabricatorDashboardRemarkupRule.php | 30 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 src/applications/dashboard/remarkup/PhabricatorDashboardRemarkupRule.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 437aedb09b..49089fb340 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1489,6 +1489,7 @@ phutil_register_library_map(array( 'PhabricatorDashboardPanelTypeText' => 'applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php', 'PhabricatorDashboardPanelViewController' => 'applications/dashboard/controller/PhabricatorDashboardPanelViewController.php', 'PhabricatorDashboardQuery' => 'applications/dashboard/query/PhabricatorDashboardQuery.php', + 'PhabricatorDashboardRemarkupRule' => 'applications/dashboard/remarkup/PhabricatorDashboardRemarkupRule.php', 'PhabricatorDashboardRemovePanelController' => 'applications/dashboard/controller/PhabricatorDashboardRemovePanelController.php', 'PhabricatorDashboardRenderingEngine' => 'applications/dashboard/engine/PhabricatorDashboardRenderingEngine.php', 'PhabricatorDashboardSearchEngine' => 'applications/dashboard/query/PhabricatorDashboardSearchEngine.php', @@ -4284,6 +4285,7 @@ phutil_register_library_map(array( 'PhabricatorDashboardPanelTypeText' => 'PhabricatorDashboardPanelType', 'PhabricatorDashboardPanelViewController' => 'PhabricatorDashboardController', 'PhabricatorDashboardQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', + 'PhabricatorDashboardRemarkupRule' => 'PhabricatorRemarkupRuleObject', 'PhabricatorDashboardRemovePanelController' => 'PhabricatorDashboardController', 'PhabricatorDashboardRenderingEngine' => 'Phobject', 'PhabricatorDashboardSearchEngine' => 'PhabricatorApplicationSearchEngine', diff --git a/src/applications/dashboard/application/PhabricatorApplicationDashboard.php b/src/applications/dashboard/application/PhabricatorApplicationDashboard.php index d18aa348a6..f4989c7806 100644 --- a/src/applications/dashboard/application/PhabricatorApplicationDashboard.php +++ b/src/applications/dashboard/application/PhabricatorApplicationDashboard.php @@ -41,6 +41,12 @@ final class PhabricatorApplicationDashboard extends PhabricatorApplication { ); } + public function getRemarkupRules() { + return array( + new PhabricatorDashboardRemarkupRule(), + ); + } + public function shouldAppearInLaunchView() { return false; } diff --git a/src/applications/dashboard/remarkup/PhabricatorDashboardRemarkupRule.php b/src/applications/dashboard/remarkup/PhabricatorDashboardRemarkupRule.php new file mode 100644 index 0000000000..44499d0aa1 --- /dev/null +++ b/src/applications/dashboard/remarkup/PhabricatorDashboardRemarkupRule.php @@ -0,0 +1,30 @@ +getEngine()->getConfig('viewer'); + + return id(new PhabricatorDashboardPanelQuery()) + ->setViewer($viewer) + ->withIDs($ids) + ->execute(); + + } + + protected function renderObjectEmbed($object, $handle, $options) { + $viewer = $this->getEngine()->getConfig('viewer'); + + return id(new PhabricatorDashboardPanelRenderingEngine()) + ->setViewer($viewer) + ->setPanel($object) + ->setParentPanelPHIDs(array()) + ->renderPanel(); + + } +} -- 2.51.2