From 1375a19031fa1100f478cffb6676f0524b0d4db8 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Wed, 11 Nov 2026 15:03:00 -0500 Subject: [PATCH] intropage: Panel Library status pills, column order, and add-panel prefix Panel Library list page: - Move the Status column to sit immediately after Source. - Swap the Update Function and Refresh columns so Update Function comes first (matches the requested layout). - Render Status as Enabled/Disabled pills (green/red) and center the column, with the pill styles added to css/common.css. Add-panel menu: - Prefix each option label with the panel's source via intropage_prefix_panel_name(), so the dropdown matches the Panel Library list. The name is prefixed once at the top of the loop so every option (including the '(no permission)' entries) stays consistent without duplicating the render branches. Tests: - Unit coverage for the add-panel source prefix (tests/Unit/IntropageAddPanelSelectTest.php). - Exercise the Enabled/Disabled pill styles and assert their label contrast across every theme in the e2e status-contrast test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- css/common.css | 22 +++ includes/functions.php | 24 ++- intropage_panels.php | 80 ++++----- tests/Unit/IntropageAddPanelSelectTest.php | 186 +++++++++++++++++++++ tests/e2e/cacti-theme.spec.cjs | 8 +- 5 files changed, 263 insertions(+), 57 deletions(-) create mode 100644 tests/Unit/IntropageAddPanelSelectTest.php diff --git a/css/common.css b/css/common.css index ba07e3f..bf7da83 100644 --- a/css/common.css +++ b/css/common.css @@ -214,6 +214,28 @@ color: black !important; } +/* Enabled/Disabled status pills on the Panel Library page */ +.intropage_status_pill { + display: inline-block; + min-width: 72px; + padding: 2px 10px; + border-radius: 10px; + font-size: 0.85em; + font-weight: bold; + line-height: 1.5; + text-align: center; +} + +.intropage_status_pill.enabled { + background: rgba(148,179,107,1); + color: #000; +} + +.intropage_status_pill.disabled { + background: #cc0000; + color: #fff; +} + #intropage_main .fa, #overlay .fa { padding-right: 3px; diff --git a/includes/functions.php b/includes/functions.php index 9947dd2..0e3bca0 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -2503,10 +2503,26 @@ function intropage_addpanel_select(int $dashboard_id): void { ON pda.id = pd.panel_id WHERE pd.user_id IN (0, ?) AND pd.dashboard_id = ? - ) - ORDER BY pd.name', + )', [$_SESSION['sess_user_id'], $dashboard_id]); + // Prefix each option label with the panel's source ("Core - " / + // " - "), matching the Panel Library list, and HTML-escape it once + // here so every option below (including the "(no permission)" entries) + // renders the plugin-derived name safely without re-escaping per branch. + // Then order by the prefixed label, rather than with ORDER BY pd.name, so + // the menu stays grouped by source and reads as sorted even though the + // displayed label no longer matches the unprefixed database name. + foreach ($add_panels as &$panel) { + $panel['name'] = html_escape(intropage_prefix_panel_name($panel['panel_id'], (string) $panel['name'])); + } + + unset($panel); + + usort($add_panels, function ($a, $b) { + return strnatcasecmp($a['name'], $b['name']); + }); + // display always, even if it is empty print "