Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 3 additions & 8 deletions locales/po/cacti.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 <developers@cacti.net>\n"
"Language-Team: Cacti Developers <developers@cacti.net>\n"
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,15 @@ function thold_graph_button($data) {
}

if (api_user_realm_auth('thold_graph.php') && !empty($thold_id)) {
print '<a class="iconLink tholdVRule" href="' . html_escape($url . $separator . 'thold_vrule=' . $vrules) . '" title="' . __esc('Toggle Threshold VRULES %s', ($vrules == 'on' ? __('Off') : __('On')), 'thold') . '"><i class="tholdVRules far fa-chart-bar"></i></a><br>';
// 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 '<a class="iconLink tholdVRule" href="' . html_escape($url . $separator . 'thold_vrule=' . $vrules) . '" title="' . $vrule_title . '"><i class="tholdVRules far fa-chart-bar"></i></a><br>';
}

// Add Threshold Creation button
Expand Down
81 changes: 81 additions & 0 deletions tests/Unit/TholdGraphButtonTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php
/*
+-------------------------------------------------------------------------+
| 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
* icons. This covers the VRULE toggle button's markup, including the
* 'Toggle Threshold VRULES On'/'Off' title that shows as a label in Cacti's
* graph action menu.
*/
final class TholdGraphButtonTest extends TestCase {
/**
* @return void
*/
public static function setUpBeforeClass(): void {
self::loadPluginSource('setup.php');
}

/**
* @return void
*/
protected function setUp(): void {
parent::setUp();

CactiStubs::reset();
}

/**
* @return void
*/
public function test_it_prints_the_vrule_button_with_the_shortened_title(): void {
// A threshold exists for the graph, so the VRULE toggle is shown; the
// aggregate lookup returns a row so the Create Threshold branch is skipped.
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';
$_SESSION = [];

ob_start();
thold_graph_button([1 => ['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);
}
}
12 changes: 12 additions & 0 deletions tests/bootstrap-unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading