Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14351457
D17092.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D17092.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2471,6 +2471,7 @@
'PhabricatorDashboardPanelTransactionQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelTransactionQuery.php',
'PhabricatorDashboardPanelType' => 'applications/dashboard/paneltype/PhabricatorDashboardPanelType.php',
'PhabricatorDashboardPanelViewController' => 'applications/dashboard/controller/PhabricatorDashboardPanelViewController.php',
+ 'PhabricatorDashboardProfileMenuItem' => 'applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php',
'PhabricatorDashboardQuery' => 'applications/dashboard/query/PhabricatorDashboardQuery.php',
'PhabricatorDashboardQueryPanelType' => 'applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php',
'PhabricatorDashboardRemarkupRule' => 'applications/dashboard/remarkup/PhabricatorDashboardRemarkupRule.php',
@@ -7439,6 +7440,7 @@
'PhabricatorDashboardPanelTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorDashboardPanelType' => 'Phobject',
'PhabricatorDashboardPanelViewController' => 'PhabricatorDashboardController',
+ 'PhabricatorDashboardProfileMenuItem' => 'PhabricatorProfileMenuItem',
'PhabricatorDashboardQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorDashboardQueryPanelType' => 'PhabricatorDashboardPanelType',
'PhabricatorDashboardRemarkupRule' => 'PhabricatorObjectRemarkupRule',
diff --git a/src/applications/dashboard/storage/PhabricatorDashboard.php b/src/applications/dashboard/storage/PhabricatorDashboard.php
--- a/src/applications/dashboard/storage/PhabricatorDashboard.php
+++ b/src/applications/dashboard/storage/PhabricatorDashboard.php
@@ -120,6 +120,10 @@
return ($this->getStatus() == self::STATUS_ARCHIVED);
}
+ public function getViewURI() {
+ return '/dashboard/view/'.$this->getID().'/';
+ }
+
/* -( PhabricatorApplicationTransactionInterface )------------------------- */
diff --git a/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php b/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
new file mode 100644
--- /dev/null
+++ b/src/applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php
@@ -0,0 +1,112 @@
+<?php
+
+final class PhabricatorDashboardProfileMenuItem
+ extends PhabricatorProfileMenuItem {
+
+ const MENUITEMKEY = 'dashboard';
+
+ private $dashboard;
+
+ public function getMenuItemTypeIcon() {
+ return 'fa-dashboard';
+ }
+
+ public function getMenuItemTypeName() {
+ return pht('Dashboard');
+ }
+
+ public function canAddToObject($object) {
+ return true;
+ }
+
+ public function attachDashboard($dashboard) {
+ $this->dashboard = $dashboard;
+ return $this;
+ }
+
+ public function getDashboard() {
+ $dashboard = $this->dashboard;
+ if (!$dashboard) {
+ return null;
+ } else if ($dashboard->isArchived()) {
+ return null;
+ }
+ return $dashboard;
+ }
+
+ public function willBuildNavigationItems(array $items) {
+ $viewer = $this->getViewer();
+ $dashboard_phids = array();
+ foreach ($items as $item) {
+ $dashboard_phids[] = $item->getMenuItemProperty('dashboardPHID');
+ }
+
+ $dashboards = id(new PhabricatorDashboardQuery())
+ ->setViewer($viewer)
+ ->withPHIDs($dashboard_phids)
+ ->execute();
+
+ $dashboards = mpull($dashboards, null, 'getPHID');
+ foreach ($items as $item) {
+ $dashboard_phid = $item->getMenuItemProperty('dashboardPHID');
+ $dashboard = idx($dashboards, $dashboard_phid, null);
+ $item->getMenuItem()->attachDashboard($dashboard);
+ }
+ }
+
+ public function getDisplayName(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ $dashboard = $this->getDashboard();
+ if (!$dashboard) {
+ return pht('(Restricted/Invalid Dashboard)');
+ }
+ if (strlen($this->getName($config))) {
+ return $this->getName($config);
+ } else {
+ return $dashboard->getName();
+ }
+ }
+
+ public function buildEditEngineFields(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return array(
+ id(new PhabricatorTextEditField())
+ ->setKey('name')
+ ->setLabel(pht('Name'))
+ ->setValue($this->getName($config)),
+ id(new PhabricatorDatasourceEditField())
+ ->setKey('dashboardPHID')
+ ->setLabel(pht('Dashboard'))
+ ->setDatasource(new PhabricatorDashboardDatasource())
+ ->setSingleValue($config->getMenuItemProperty('dashboardPHID')),
+ );
+ }
+
+ private function getName(
+ PhabricatorProfileMenuItemConfiguration $config) {
+ return $config->getMenuItemProperty('name');
+ }
+
+ protected function newNavigationMenuItems(
+ PhabricatorProfileMenuItemConfiguration $config) {
+
+ $dashboard = $this->getDashboard();
+ if (!$dashboard) {
+ return array();
+ }
+
+ $icon = $dashboard->getIcon();
+ $name = $this->getDisplayName($config);
+ $href = $dashboard->getViewURI();
+
+ $item = $this->newItem()
+ ->setHref($href)
+ ->setName($name)
+ ->setIcon($icon);
+
+ return array(
+ $item,
+ );
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 20, 7:44 AM (20 h, 31 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6909876
Default Alt Text
D17092.diff (5 KB)
Attached To
Mode
D17092: Add a Dashboard MenuItem
Attached
Detach File
Event Timeline
Log In to Comment