diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e2966ba..805b501d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## ChangeLog --- develop --- +* issue: Shorten the VRULE graph drilldown button title so it reads cleanly as a label in Cacti's graph action menu, using two complete 'Toggle Threshold VRULES On'/'Off' strings (keeping the Threshold reference) so the label stays grammatical across translations * issue: Log each template import error using its own message (#757) * 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 diff --git a/locales/po/cacti.pot b/locales/po/cacti.pot index d0a71f62..99110d06 100644 --- a/locales/po/cacti.pot +++ b/locales/po/cacti.pot @@ -8,7 +8,7 @@ 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-13 09:23-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Cacti Developers \n" "Language-Team: Cacti Developers \n" @@ -2216,16 +2216,11 @@ msgid "No Notifications" msgstr "" #: setup.php -msgid "Off" +msgid "Toggle Threshold VRULES Off" msgstr "" #: setup.php -msgid "On" -msgstr "" - -#: setup.php -#, php-format -msgid "Toggle Threshold VRULES %s" +msgid "Toggle Threshold VRULES On" msgstr "" #: setup.php diff --git a/setup.php b/setup.php index ab799d18..c5ceaf19 100644 --- a/setup.php +++ b/setup.php @@ -344,7 +344,15 @@ function thold_graph_button($data) { } if (api_user_realm_auth('thold_graph.php') && !empty($thold_id)) { - print '
'; + // Two complete strings rather than a trailing On/Off fragment so the + // label stays grammatical when a translation reorders the words. + if ($vrules == 'on') { + $vrule_title = __esc('Toggle Threshold VRULES Off', 'thold'); + } else { + $vrule_title = __esc('Toggle Threshold VRULES On', 'thold'); + } + + print '
'; } // Add Threshold Creation button diff --git a/tests/Unit/TholdGraphButtonTest.php b/tests/Unit/TholdGraphButtonTest.php new file mode 100644 index 00000000..e17371c6 --- /dev/null +++ b/tests/Unit/TholdGraphButtonTest.php @@ -0,0 +1,81 @@ + ['local_graph_id' => 10, 'rra' => 5]]); + $html = ob_get_clean(); + + $this->assertStringContainsString('iconLink tholdVRule', $html); + $this->assertStringContainsString('tholdVRules far fa-chart-bar', $html); + // Default state (no session/request var) resolves to the 'On' action and + // keeps the Thold-specific 'Threshold' reference. + $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); + } +} 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);