From 840a7fab2bc8844c52c3fb3b09d3e2afc84e7879 Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Tue, 1 Aug 2023 09:39:18 +0200 Subject: [PATCH] Hide Archived Panels from Dashboards Summary: In edit mode, Archived Panels are shown differently, with content text in grey and with the usual red tag. In view mode, Archived Panels are just not rendered. This makes it easier to design Dashboards with individual components that can be de-activated and re-activated on the fly. Closes T15366. {F325637} Test Plan: Have a Dashboard somewhere (e.g in your homepage). Visit a Panel (W-ID) and Archive it. See that now the Panel is not shown anymore on the Dashboard. Edit the Dashboard and you see the Panel again as "Archived". Anything around is just normal. Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: avivey, speck, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15366 Differential Revision: https://we.phorge.it/D25368 --- resources/celerity/map.php | 6 +++--- .../PhabricatorDashboardPanelRenderingEngine.php | 15 +++++++++++++++ .../PhabricatorDashboardRenderingEngine.php | 8 +++++++- .../query/PhabricatorDashboardPanelQuery.php | 7 +++++++ webroot/rsrc/css/phui/phui-list.css | 4 ++++ 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index e31d56d36f..3fc6387e77 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -9,7 +9,7 @@ return array( 'names' => array( 'conpherence.pkg.css' => '76ed87e3', 'conpherence.pkg.js' => '020aebcf', - 'core.pkg.css' => '67a5ecf3', + 'core.pkg.css' => '1a5169fe', 'core.pkg.js' => '2eeda9e0', 'dark-console.pkg.js' => '187792c2', 'differential.pkg.css' => '525f9a1d', @@ -167,7 +167,7 @@ return array( 'rsrc/css/phui/phui-invisible-character-view.css' => 'c694c4a4', 'rsrc/css/phui/phui-left-right.css' => '68513c34', 'rsrc/css/phui/phui-lightbox.css' => '4ebf22da', - 'rsrc/css/phui/phui-list.css' => '0c04affd', + 'rsrc/css/phui/phui-list.css' => 'ccf73664', 'rsrc/css/phui/phui-object-box.css' => 'fdffed5c', 'rsrc/css/phui/phui-pager.css' => 'd022c7ad', 'rsrc/css/phui/phui-pinboard-view.css' => '1f08f5d8', @@ -864,7 +864,7 @@ return array( 'phui-invisible-character-view-css' => 'c694c4a4', 'phui-left-right-css' => '68513c34', 'phui-lightbox-css' => '4ebf22da', - 'phui-list-view-css' => '0c04affd', + 'phui-list-view-css' => 'ccf73664', 'phui-object-box-css' => 'fdffed5c', 'phui-oi-big-ui-css' => 'fa74cc35', 'phui-oi-color-css' => 'b517bfa0', diff --git a/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php b/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php index 52e8cc70d5..cce6ee768f 100644 --- a/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php +++ b/src/applications/dashboard/engine/PhabricatorDashboardPanelRenderingEngine.php @@ -273,6 +273,11 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject { ->addClass('dashboard-box') ->addSigil('dashboard-panel'); + // Allow to style Archived Panels differently. + if ($panel && $panel->getIsArchived()) { + $box->addClass('dashboard-panel-disabled'); + } + if ($this->getMovable()) { $box->addSigil('panel-movable'); } @@ -302,6 +307,16 @@ final class PhabricatorDashboardPanelRenderingEngine extends Phobject { $header = id(new PHUIHeaderView()) ->setHeader($header_text); $header = $this->addPanelHeaderActions($header); + + // If the Panel is Archived, show in edit mode as such. + if ($panel && $panel->getIsArchived()) { + $header->setSubheader( + id(new PHUITagView()) + ->setType(PHUITagView::TYPE_SHADE) + ->setColor(PHUITagView::COLOR_RED) + ->setIcon('fa-ban') + ->setName(pht('Archived'))); + } break; case self::HEADER_MODE_NORMAL: default: diff --git a/src/applications/dashboard/engine/PhabricatorDashboardRenderingEngine.php b/src/applications/dashboard/engine/PhabricatorDashboardRenderingEngine.php index 9b63fcac55..935e85f8bb 100644 --- a/src/applications/dashboard/engine/PhabricatorDashboardRenderingEngine.php +++ b/src/applications/dashboard/engine/PhabricatorDashboardRenderingEngine.php @@ -71,6 +71,13 @@ final class PhabricatorDashboardRenderingEngine extends Phobject { foreach ($column->getPanelRefs() as $panel_ref) { $panel_phid = $panel_ref->getPanelPHID(); + $panel = idx($panels, $panel_phid); + + // Do not render Archived panels in view mode. + if ($panel && $panel->getIsArchived() && !$is_editable) { + continue; + } + $panel_engine = id(new PhabricatorDashboardPanelRenderingEngine()) ->setViewer($viewer) ->setEnableAsyncRendering(true) @@ -83,7 +90,6 @@ final class PhabricatorDashboardRenderingEngine extends Phobject { ->setMovable(true) ->setPanelHandle($handles[$panel_phid]); - $panel = idx($panels, $panel_phid); if ($panel) { $panel_engine->setPanel($panel); } diff --git a/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php b/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php index c67b756262..54f627eb00 100644 --- a/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php +++ b/src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php @@ -19,6 +19,13 @@ final class PhabricatorDashboardPanelQuery return $this; } + /** + * Whether to get only the Archived (`true`), only the not + * Archived (`false`) or all (`null`). Default to `null` (no filter). + * + * @param null|bool $archived + * @return self + */ public function withArchived($archived) { $this->archived = $archived; return $this; diff --git a/webroot/rsrc/css/phui/phui-list.css b/webroot/rsrc/css/phui/phui-list.css index dee105f25b..0289c58fff 100644 --- a/webroot/rsrc/css/phui/phui-list.css +++ b/webroot/rsrc/css/phui/phui-list.css @@ -287,6 +287,10 @@ border-bottom: 1px solid {$thinblueborder}; } +.dashboard-panel-disabled { + color: {$lightgreytext}; +} + /* - Info Stack ------------------------------------------------------------ */ .phui-info-view + .phui-list-view {