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 @@ -1787,6 +1787,7 @@ 'PhabricatorApplicationEmailCommandsController' => 'applications/meta/controller/PhabricatorApplicationEmailCommandsController.php', 'PhabricatorApplicationLaunchView' => 'applications/meta/view/PhabricatorApplicationLaunchView.php', 'PhabricatorApplicationPanelController' => 'applications/meta/controller/PhabricatorApplicationPanelController.php', + 'PhabricatorApplicationProfilePanel' => 'applications/search/profilepanel/PhabricatorApplicationProfilePanel.php', 'PhabricatorApplicationQuery' => 'applications/meta/query/PhabricatorApplicationQuery.php', 'PhabricatorApplicationSearchController' => 'applications/search/controller/PhabricatorApplicationSearchController.php', 'PhabricatorApplicationSearchEngine' => 'applications/search/engine/PhabricatorApplicationSearchEngine.php', @@ -2776,8 +2777,12 @@ 'PhabricatorHeraldContentSource' => 'applications/herald/contentsource/PhabricatorHeraldContentSource.php', 'PhabricatorHighSecurityRequestExceptionHandler' => 'aphront/handler/PhabricatorHighSecurityRequestExceptionHandler.php', 'PhabricatorHomeApplication' => 'applications/home/application/PhabricatorHomeApplication.php', + 'PhabricatorHomeConstants' => 'applications/home/constants/PhabricatorHomeConstants.php', 'PhabricatorHomeController' => 'applications/home/controller/PhabricatorHomeController.php', 'PhabricatorHomeMainController' => 'applications/home/controller/PhabricatorHomeMainController.php', + 'PhabricatorHomeManagePanel' => 'applications/home/profilepanel/PhabricatorHomeManagePanel.php', + 'PhabricatorHomePanelController' => 'applications/home/controller/PhabricatorHomePanelController.php', + 'PhabricatorHomePanelEngine' => 'applications/home/engine/PhabricatorHomePanelEngine.php', 'PhabricatorHomePreferencesSettingsPanel' => 'applications/settings/panel/PhabricatorHomePreferencesSettingsPanel.php', 'PhabricatorHomeQuickCreateController' => 'applications/home/controller/PhabricatorHomeQuickCreateController.php', 'PhabricatorHovercardEngineExtension' => 'applications/search/engineextension/PhabricatorHovercardEngineExtension.php', @@ -6608,6 +6613,7 @@ 'PhabricatorApplicationEmailCommandsController' => 'PhabricatorApplicationsController', 'PhabricatorApplicationLaunchView' => 'AphrontTagView', 'PhabricatorApplicationPanelController' => 'PhabricatorApplicationsController', + 'PhabricatorApplicationProfilePanel' => 'PhabricatorProfilePanel', 'PhabricatorApplicationQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorApplicationSearchController' => 'PhabricatorSearchBaseController', 'PhabricatorApplicationSearchEngine' => 'Phobject', @@ -7766,8 +7772,12 @@ 'PhabricatorHeraldContentSource' => 'PhabricatorContentSource', 'PhabricatorHighSecurityRequestExceptionHandler' => 'PhabricatorRequestExceptionHandler', 'PhabricatorHomeApplication' => 'PhabricatorApplication', + 'PhabricatorHomeConstants' => 'Phobject', 'PhabricatorHomeController' => 'PhabricatorController', 'PhabricatorHomeMainController' => 'PhabricatorHomeController', + 'PhabricatorHomeManagePanel' => 'PhabricatorProfilePanel', + 'PhabricatorHomePanelController' => 'PhabricatorHomeController', + 'PhabricatorHomePanelEngine' => 'PhabricatorProfilePanelEngine', 'PhabricatorHomePreferencesSettingsPanel' => 'PhabricatorSettingsPanel', 'PhabricatorHomeQuickCreateController' => 'PhabricatorHomeController', 'PhabricatorHovercardEngineExtension' => 'Phobject', 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 @@ -24,7 +24,6 @@ private $panels = self::ATTACHABLE; private $edgeProjectPHIDs = self::ATTACHABLE; - public static function initializeNewDashboard(PhabricatorUser $actor) { return id(new PhabricatorDashboard()) ->setName('') diff --git a/src/applications/home/application/PhabricatorHomeApplication.php b/src/applications/home/application/PhabricatorHomeApplication.php --- a/src/applications/home/application/PhabricatorHomeApplication.php +++ b/src/applications/home/application/PhabricatorHomeApplication.php @@ -26,6 +26,8 @@ '/' => 'PhabricatorHomeMainController', '/(?Phome)/' => 'PhabricatorHomeMainController', '/home/' => array( + 'panel/' => + $this->getPanelRouting('PhabricatorHomePanelController'), 'create/' => 'PhabricatorHomeQuickCreateController', ), ); diff --git a/src/applications/home/constants/PhabricatorHomeConstants.php b/src/applications/home/constants/PhabricatorHomeConstants.php new file mode 100644 --- /dev/null +++ b/src/applications/home/constants/PhabricatorHomeConstants.php @@ -0,0 +1,7 @@ +getViewer(); + $object = id(new PhabricatorHomeApplication())->getPHID(); + + $engine = id(new PhabricatorHomePanelEngine()) + ->setProfileObject($object) + ->setController($this); + + $this->setProfilePanelEngine($engine); + + return $engine->buildResponse(); + } + +} diff --git a/src/applications/home/engine/PhabricatorHomePanelEngine.php b/src/applications/home/engine/PhabricatorHomePanelEngine.php new file mode 100644 --- /dev/null +++ b/src/applications/home/engine/PhabricatorHomePanelEngine.php @@ -0,0 +1,24 @@ +newPanel() + ->setBuiltinKey(PhabricatorHomeController::PANEL_MANAGE) + ->setPanelKey(PhabricatorHomeManagePanel::PANELKEY); + + return $panels; + } + +} diff --git a/src/applications/home/profilepanel/PhabricatorHomeManagePanel.php b/src/applications/home/profilepanel/PhabricatorHomeManagePanel.php new file mode 100644 --- /dev/null +++ b/src/applications/home/profilepanel/PhabricatorHomeManagePanel.php @@ -0,0 +1,60 @@ +getPanelProperty('name'); + + if (strlen($name)) { + return $name; + } + + return $this->getDefaultName(); + } + + public function buildEditEngineFields( + PhabricatorProfilePanelConfiguration $config) { + return array( + id(new PhabricatorTextEditField()) + ->setKey('name') + ->setLabel(pht('Name')) + ->setPlaceholder($this->getDefaultName()) + ->setValue($config->getPanelProperty('name')), + ); + } + + protected function newNavigationMenuItems( + PhabricatorProfilePanelConfiguration $config) { + + $name = $this->getDisplayName($config); + $icon = 'fa-gears'; + $href = '/home/manage/'; + + $item = $this->newItem() + ->setHref($href) + ->setName($name) + ->setIcon($icon); + + return array( + $item, + ); + } + +} diff --git a/src/applications/search/profilepanel/PhabricatorApplicationProfilePanel.php b/src/applications/search/profilepanel/PhabricatorApplicationProfilePanel.php new file mode 100644 --- /dev/null +++ b/src/applications/search/profilepanel/PhabricatorApplicationProfilePanel.php @@ -0,0 +1,72 @@ +getApplication($config); + return $app->getName(); + } + + public function buildEditEngineFields( + PhabricatorProfilePanelConfiguration $config) { + return array( + id(new PhabricatorDatasourceEditField()) + ->setKey('application') + ->setLabel(pht('Application')) + ->setDatasource(new PhabricatorApplicationDatasource()) + ->setSingleValue($config->getPanelProperty('application')), + ); + } + + private function getApplication( + PhabricatorProfilePanelConfiguration $config) { + $applications = PhabricatorApplication::getAllInstalledApplications(); + $selected = $config->getPanelProperty('application'); + foreach ($applications as $app) { + if ($app->getPHID() == $selected) { + $selected_app = $app; + break; + } + } + return $selected_app; + } + + protected function newNavigationMenuItems( + PhabricatorProfilePanelConfiguration $config) { + $viewer = $this->getViewer(); + $app = $this->getApplication($config); + + $is_installed = PhabricatorApplication::isClassInstalledForViewer( + get_class($app), + $viewer); + if (!$is_installed) { + return null; + } + + $item = $this->newItem() + ->setHref($app->getApplicationURI()) + ->setName($app->getName()) + ->setIcon($app->getIcon()); + + return array( + $item, + ); + } + +}