From ff3fa9a10a9753a5fecc9b95cc56f7fa8f142cf3 Mon Sep 17 00:00:00 2001 From: TheWitness <1439914+TheWitness@users.noreply.github.com> Date: Mon, 12 Oct 2026 16:31:05 -0400 Subject: [PATCH 1/4] issue: shorten thold VRULE graph drilldown button title The graph action menu now renders each drilldown button's title as a visible label, so 'Toggle Threshold VRULES %s' reads as an overlong menu entry. Shorten it to 'Toggle VRULES %s', add a unit test exercising thold_graph_button()'s VRULE branch (with the two missing request-var stubs it needs) so the changed line stays covered, and regenerate locales/po/cacti.pot. --- CHANGELOG.md | 1 + locales/po/cacti.pot | 6 ++-- setup.php | 2 +- tests/Unit/TholdGraphButtonTest.php | 52 +++++++++++++++++++++++++++++ tests/bootstrap-unit.php | 12 +++++++ 5 files changed, 69 insertions(+), 4 deletions(-) create mode 100644 tests/Unit/TholdGraphButtonTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 07233889..3e414f5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## ChangeLog --- develop --- +* issue: Shorten the VRULE graph drilldown button title from 'Toggle Threshold VRULES %s' to 'Toggle VRULES %s' so it reads cleanly as a label in Cacti's graph action menu * bug: Element-qualify the `.thold-pill` CSS so it outranks the single-class theme rules (e.g. `.deviceUpFull` `width:14%`) that were clipping the pill to a fixed width; status pills now size to their label on the Device Status page and everywhere else * feature: Clicking an already-selected status pill now clears that filter (resets to All) instead of re-applying it, on the Thresholds, Device Status and Threshold Log sub-tabs * bug: Pass a boolean (not the integer `1`) to `api_plugin_register_hook()`'s `$enable` argument so the hook registration stays type-correct under Cacti 1.3's strict `bool $enable` type-hint (the int only coerces while this file lacks `declare(strict_types=1)`) diff --git a/locales/po/cacti.pot b/locales/po/cacti.pot index d0a71f62..5ae4f146 100644 --- a/locales/po/cacti.pot +++ b/locales/po/cacti.pot @@ -8,9 +8,9 @@ msgid "" msgstr "" "Project-Id-Version: Cacti \n" "Report-Msgid-Bugs-To: developers@cacti.net\n" -"POT-Creation-Date: 2026-10-08 16:02-0400\n" +"POT-Creation-Date: 2026-10-12 16:30-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: Cacti Developers \n" +"Last-Translator: Cacti Developers >\n" "Language-Team: Cacti Developers \n" "Language: \n" "MIME-Version: 1.0\n" @@ -2225,7 +2225,7 @@ msgstr "" #: setup.php #, php-format -msgid "Toggle Threshold VRULES %s" +msgid "Toggle VRULES %s" msgstr "" #: setup.php diff --git a/setup.php b/setup.php index ab799d18..979d8181 100644 --- a/setup.php +++ b/setup.php @@ -344,7 +344,7 @@ function thold_graph_button($data) { } if (api_user_realm_auth('thold_graph.php') && !empty($thold_id)) { - print '
'; + print '
'; } // Add Threshold Creation button diff --git a/tests/Unit/TholdGraphButtonTest.php b/tests/Unit/TholdGraphButtonTest.php new file mode 100644 index 00000000..4d2b3ca8 --- /dev/null +++ b/tests/Unit/TholdGraphButtonTest.php @@ -0,0 +1,52 @@ + ['local_graph_id' => 10, 'rra' => 5]]); + $html = ob_get_clean(); + + $this->assertStringContainsString('iconLink tholdVRule', $html); + $this->assertStringContainsString('tholdVRules far fa-chart-bar', $html); + $this->assertStringContainsString('Toggle VRULES', $html); + $this->assertStringNotContainsString('Toggle Threshold VRULES', $html); + } +} diff --git a/tests/bootstrap-unit.php b/tests/bootstrap-unit.php index b64cdde0..ae80db4c 100644 --- a/tests/bootstrap-unit.php +++ b/tests/bootstrap-unit.php @@ -384,6 +384,18 @@ function isset_request_var($name) { } } +if (!function_exists('isempty_request_var')) { + function isempty_request_var($name) { + return !isset(CactiStubs::$requestVars[$name]) || CactiStubs::$requestVars[$name] === ''; + } +} + +if (!function_exists('set_request_var')) { + function set_request_var($name, $value) { + CactiStubs::$requestVars[$name] = $value; + } +} + if (!function_exists('cacti_escapeshellarg')) { function cacti_escapeshellarg($string, $quote = true) { return escapeshellarg((string) $string); From 0eb7732f199d05d9a31188d2a34beb327810046a Mon Sep 17 00:00:00 2001 From: TheWitness Date: Tue, 13 Oct 2026 08:55:58 -0400 Subject: [PATCH 2/4] Update copyright notice in TholdGraphButtonTest.php Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- tests/Unit/TholdGraphButtonTest.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/Unit/TholdGraphButtonTest.php b/tests/Unit/TholdGraphButtonTest.php index 4d2b3ca8..252fc7f8 100644 --- a/tests/Unit/TholdGraphButtonTest.php +++ b/tests/Unit/TholdGraphButtonTest.php @@ -2,8 +2,17 @@ /* +-------------------------------------------------------------------------+ | Copyright (C) 2004-2026 The Cacti Group | + | | + | This program is free software; you can redistribute it and/or | + | modify it under the terms of the GNU General Public License | + | as published by the Free Software Foundation; either version 2 | + | of the License, or (at your option) any later version. | +-------------------------------------------------------------------------+ -*/ + | Cacti: The Complete RRDtool-based Graphing Solution | + +-------------------------------------------------------------------------+ + | http://www.cacti.net/ | + +-------------------------------------------------------------------------+ + */ /** * thold_graph_button() renders this plugin's graph-page drilldown action From cc1458e1a0518c4d317534d83732b4916a722683 Mon Sep 17 00:00:00 2001 From: TheWitness Date: Tue, 13 Oct 2026 08:56:10 -0400 Subject: [PATCH 3/4] Fix Last-Translator entry in cacti.pot Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- locales/po/cacti.pot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locales/po/cacti.pot b/locales/po/cacti.pot index 5ae4f146..58a8b45a 100644 --- a/locales/po/cacti.pot +++ b/locales/po/cacti.pot @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: developers@cacti.net\n" "POT-Creation-Date: 2026-10-12 16:30-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: Cacti Developers >\n" +"Last-Translator: Cacti Developers \n" "Language-Team: Cacti Developers \n" "Language: \n" "MIME-Version: 1.0\n" From 2d4dccc61450fe419d899169c84750a822d23e4e Mon Sep 17 00:00:00 2001 From: TheWitness Date: Tue, 13 Oct 2026 09:28:23 -0400 Subject: [PATCH 4/4] test: cover the VRULEs-enabled 'Off' title branch for patch coverage --- tests/Unit/TholdGraphButtonTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/Unit/TholdGraphButtonTest.php b/tests/Unit/TholdGraphButtonTest.php index aa3906b1..e17371c6 100644 --- a/tests/Unit/TholdGraphButtonTest.php +++ b/tests/Unit/TholdGraphButtonTest.php @@ -60,4 +60,22 @@ public function test_it_prints_the_vrule_button_with_the_shortened_title(): void $this->assertStringContainsString('Toggle Threshold VRULES On', $html); $this->assertStringNotContainsString('Toggle VRULES', $html); } + + /** + * @return void + */ + public function test_it_shows_the_off_title_when_vrules_are_enabled(): void { + CactiStubs::willReturnFor('db_fetch_cell_prepared', 'thold_data', 123); + CactiStubs::willReturnFor('db_fetch_cell_prepared', 'aggregate_graphs', 5); + + $_SERVER['REQUEST_URI'] = '/cacti/graph_view.php?action=preview'; + // VRULEs already drawing (session on) resolves to the 'Off' action title. + $_SESSION = ['sess_config_array' => ['thold_draw_vrules' => 'on']]; + + ob_start(); + thold_graph_button([1 => ['local_graph_id' => 10, 'rra' => 5]]); + $html = ob_get_clean(); + + $this->assertStringContainsString('Toggle Threshold VRULES Off', $html); + } }