Skip to content

Theme the syslog severity legends as rounded, solid-colour chips - #385

Merged
TheWitness merged 7 commits into
developfrom
feature/legend-theme-chips
Oct 6, 2026
Merged

TheWitness merged 7 commits into
developfrom
feature/legend-theme-chips

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Description

Restyle the System Logs and Alert Logs severity legends so they line up with the Thold status legends (PR Cacti/plugin_thold#831): rounded corners, even spacing, and solid, opaque theme-appropriate background colours instead of flat, edge-to-edge table cells.

Changes:

  • The two legend renderers now emit a .syslogLegend flex row of .syslogLegendItem chips. Each chip keeps the same log* severity class the result rows use (logEmergency, logWarning, …), so the active theme's legend stylesheet supplies the background colour.
  • syslog_include_js() loads a per-theme legend palette from css/<theme>.css when one exists, and falls back to css/syslog.css otherwise. The theme name comes from get_selected_theme() and is sanitised before it ever reaches the filesystem (path-traversal hardening).
  • Added a css/<theme>.css file for every packaged Cacti theme — light palette for classic, modern, paw; dark palette for dark, midwinter, sunrise, paper-plane. The base light palette also lives in css/syslog.css as the fallback for themes that ship no dedicated file (e.g. carrot, cacti).
  • The two legend functions were moved from the syslog.php web entry point into the unit-testable functions.php (their call sites in syslog.php are unchanged), matching the Thold legend layout and keeping them within the plugin's coverage model.

No translatable strings were added or removed (only moved between files), so locales/po/cacti.pot needs no regeneration.

Related Issue

Follow-on styling parity with Cacti/plugin_thold#831 (rounded, solid-colour status legend chips).

Motivation and Context

The syslog legends were rendered as plain full-width table cells, which did not match the newer Thold status legends and did not adapt their chip colours to light vs dark themes. This brings the two plugins' status keys into visual alignment and makes each severity recognisable on every packaged theme.

How Has This Been Tested?

  • php -l on the changed PHP files.
  • New tests/Unit/SyslogLegendTest.php (Pest) asserts: one chip per severity for both legends with the correct log* class and label; the theme stylesheet is linked when the theme ships one; the syslog.css fallback is used otherwise; and the theme name is sanitised against path traversal.
  • Verified the check-i18n-pot.php gate reports no required .pot update.
  • CSS brace balance and per-file severity-rule counts verified for all eight stylesheets.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation repository accordingly.

Restyle the System Logs and Alert Logs legends to match the Thold status legends: rounded, evenly spaced, solid-colour severity chips. Move the two legend renderers into functions.php (so they are unit-testable) emitting .syslogLegend/.syslogLegendItem markup, and have syslog_include_js() load a per-theme css/<theme>.css legend palette with a css/syslog.css fallback. Ship light (classic, modern, paw) and dark (dark, midwinter, sunrise, paper-plane) palettes, plus the base fallback palette in syslog.css.
Copilot AI balanced review requested due to automatic review settings October 6, 2026 17:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The fallback loads email-oriented global CSS into web pages, and several light-theme chip colors have insufficient text contrast.

Review effort: Balanced
Findings: 5 Medium severity · 1 Low severity

Open (6)
What changed in this PR

Restyles Syslog severity legends as theme-aware chips and moves rendering into shared, testable functions.

Changes:

  • Adds flex-based legend markup and per-theme palettes.
  • Adds sanitized theme stylesheet selection with fallback behavior.
  • Adds unit coverage and changelog documentation.
File Description
functions.php Renders legends and selects theme CSS.
syslog.php Removes relocated legend functions.
css/​syslog.css Adds fallback legend styling.
css/​classic.css Adds classic-theme palette.
css/​dark.css Adds dark-theme palette.
css/​midwinter.css Adds midwinter palette.
css/​modern.css Adds modern-theme palette.
css/​paper-plane.css Adds paper-plane palette.
css/​paw.css Adds paw-theme palette.
css/​sunrise.css Adds sunrise palette.
tests/​Unit/​SyslogLegendTest.php Tests markup and stylesheet selection.
CHANGELOG.md Documents the feature.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread css/classic.css
Comment thread css/modern.css
Comment thread css/paw.css
Comment thread css/syslog.css Outdated
Comment thread functions.php Outdated
Comment thread tests/Unit/SyslogLegendTest.php
Cacti Group added 5 commits October 6, 2026 13:27
Relocate the shared Syslog function library to includes/functions.php and load it once via a top-level require in setup.php (removing the two redundant lazy include_once calls in syslog_connect()/syslog_poller_bottom()). Update every entry-point include, the 33 test loaders, IncludePathNormalizationTest, CsrfPurgeTest's sandbox layout, and fix the library's internal __DIR__ paths to dirname(__DIR__). Point phpunit.xml coverage source at includes/functions.php, and move the unloadable web/CLI entry points out of <source> into the patch-coverage allowlist.
Revert the top-level require_once added to setup.php (it pulled functions.php into every page that loads the plugin's setup.php for hook registration). Restore the original on-demand include_once of the library inside syslog_connect() and syslog_poller_bottom() at the new includes/ path. Those two lines run only in a live Cacti/poller process and cannot be unit-covered, so setup.php moves out of phpunit.xml <source> into the patch-coverage allowlist; SetupSmallHelpersTest still exercises its pure helpers.
Darken the light-theme warning (#b5730e -> #9c5d0a) and info (#3f8f4a -> #2f7d3a) chips so white label text meets WCAG AA 4.5:1. Replace the email-oriented syslog.css web fallback with a new legend-only css/legend.css so themes without a dedicated palette (carrot, cacti) no longer inherit syslog.css's global body/table/th rules; syslog.css returns to report/email styling only. Add the full GPL v2 header to every new css file.
The plugin ships no Ruby source, so 'codeql database finalize' for Ruby failed with 'no source code seen'. Analyze only the languages actually present (javascript-typescript, python).
xmacan
xmacan previously approved these changes Oct 6, 2026
database.php is a pure library (function definitions only, no top-level execution), so it joins includes/functions.php. Update every entry-point include, phpunit.xml coverage source, and IncludePathNormalizationTest at the new path. The move is a 100%-identical rename (gate-excluded); the touched entry points and setup.php are already in the patch-coverage allowlist.
@TheWitness
TheWitness merged commit 5f9e2a7 into develop Oct 6, 2026
6 checks passed
@TheWitness
TheWitness deleted the feature/legend-theme-chips branch October 6, 2026 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants