From 89dcbe125c6c9d6f92b1c01dd1dda86d465b027f Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Tue, 4 Jun 2024 01:44:41 +0200 Subject: [PATCH] Panels list: fix missing welcome page Summary: The method getNewUserBody() was never designed for a list controller. The method was just orphan. Now, instead, it's non-orphan, and it works as expected. This bug was highlighted by Andre Klapper, since their linter was screaming about inconsistences in the current nonsense usage of getNewUserBody(): D25649 The code was just moved from the list controller, to the search engine. - PhabricatorDashboardPanelListController (from) - PhabricatorDashboardPanelSearchEngine (to) Bonus point: Adjusted the icon and the title to talk about "Panels" and not "Dashboards". Added also some inline documentation with an hint about `?nux=1`. So now we can easily remember how to test this kind of things. Closes T15844 Test Plan: In both these pages, you finally see a welcome message, not just in Maniphest: - http://phorge.localhost/dashboard/panel/?nux=1 - http://phorge.localhost/maniphest/?nux=1 In both these pages, if you have no elements, you finally see a welcome message, and not just in Maniphest: - http://phorge.localhost/dashboard/panel/ - http://phorge.localhost/maniphest/ Check that the welcome message helps you in creating a new Panel, and that talks about Panels, and that have the lovely icon of a Panel. Reviewers: aklapper, O1 Blessed Committers Reviewed By: aklapper, O1 Blessed Committers Subscribers: tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15844 Differential Revision: https://we.phorge.it/D25674 --- ...habricatorDashboardPanelListController.php | 19 ------------------- .../PhabricatorDashboardPanelSearchEngine.php | 18 ++++++++++++++++++ .../PhabricatorApplicationSearchEngine.php | 12 ++++++++++++ 3 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/applications/dashboard/controller/panel/PhabricatorDashboardPanelListController.php b/src/applications/dashboard/controller/panel/PhabricatorDashboardPanelListController.php index 1eab148261..c9cefca707 100644 --- a/src/applications/dashboard/controller/panel/PhabricatorDashboardPanelListController.php +++ b/src/applications/dashboard/controller/panel/PhabricatorDashboardPanelListController.php @@ -48,23 +48,4 @@ final class PhabricatorDashboardPanelListController return $crumbs; } - protected function getNewUserBody() { - $create_button = id(new PHUIButtonView()) - ->setTag('a') - ->setText(pht('Create a Panel')) - ->setHref('/dashboard/panel/edit/') - ->setColor(PHUIButtonView::GREEN); - - $icon = $this->getApplication()->getIcon(); - $app_name = $this->getApplication()->getName(); - $view = id(new PHUIBigInfoView()) - ->setIcon($icon) - ->setTitle(pht('Welcome to %s', $app_name)) - ->setDescription( - pht('Build individual panels to display on your homepage dashboard.')) - ->addAction($create_button); - - return $view; - } - } diff --git a/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php b/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php index be59345aaa..c4b30652b9 100644 --- a/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php +++ b/src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php @@ -147,4 +147,22 @@ final class PhabricatorDashboardPanelSearchEngine return $result; } + protected function getNewUserBody() { + $create_button = id(new PHUIButtonView()) + ->setTag('a') + ->setText(pht('Create a Panel')) + ->setHref('/dashboard/panel/edit/') + ->setColor(PHUIButtonView::GREEN); + + $app_name = pht('Panels'); + $view = id(new PHUIBigInfoView()) + ->setIcon('fa-line-chart') + ->setTitle(pht('Welcome to %s', $app_name)) + ->setDescription( + pht('Build individual panels to display on your homepage dashboard.')) + ->addAction($create_button); + + return $view; + } + } diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php index 9094ead227..489dd08065 100644 --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -1454,6 +1454,12 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject { return $attachments; } + /** + * Render a content body (if available) to onboard new users. + * This body is usually visible when you have no elements in a list, + * or when you force the rendering on a list with the `?nux=1` URL. + * @return wild|PhutilSafeHTML|null + */ final public function renderNewUserView() { $body = $this->getNewUserBody(); @@ -1464,6 +1470,12 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject { return $body; } + /** + * Get a content body to onboard new users. + * Traditionally this content is shown from an empty list, to explain + * what a certain entity does, and how to create a new one. + * @return wild|PhutilSafeHTML|null + */ protected function getNewUserHeader() { return null; }