Skip to content

intropage: adopt shared bundled card chrome for dashboard panels - #423

Merged
TheWitness merged 5 commits into
developfrom
feature/shared-card-chrome
Oct 10, 2026
Merged

TheWitness merged 5 commits into
developfrom
feature/shared-card-chrome

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Ports intropage's dashboard panels onto a shared, bundled card chrome so
the panel look/interaction matches the syslog Status cards, while keeping
intropage's own backend (panel registration, update_func data, DB cache,
poller refresh, dashboards) completely unchanged.

Hard requirement

Self-contained and dependency-free: the chrome is bundled inside this
plugin (includes/cards/cards.css, includes/cards/cards.js). No cross-plugin
reference and no new Cacti-version dependency — it works with intropage
installed alone, and preserves the 1.2.x floor. The same two files will be
copied (byte-identical) into plugin_syslog in a separate PR.

What changed

  • Bundled chrome includes/cards/cards.{css,js} — neutral cc* classes,
    theme-variable driven, an idempotent window.CactiCards controller with
    keyboard-accessible drag and an adapter seam. Drag events are delegated
    from the card
    so they survive intropage's header-replacing AJAX reloads.
  • Header now rendered by a testable intropage_panel_header() helper: a
    left-hand drag handle, the title, and unified tools (shrink/grow height,
    maximize, reload, remove). Severity stays on the existing
    color_<alarm> class, so it keeps the per-theme palettes from Theme-appropriate panel titlebar severity palettes across all themes #421.
  • includes/intropage.js drives reorder + tools through
    CactiCards.init() with an adapter that maps to the existing endpoints
    (order / droppanel / details / heightmore/heightless / reload).
    jQuery UI Sortable is removed in favour of the shared keyboard-accessible
    drag.
  • Height grow/shrink now resizes the card's grid span instantly
    client-side, then persists + reloads the body — removing the old
    "nothing happens until a reload" two-step.
  • intropage_panel_reload_button() re-expressed as a ccTool; unit tests
    updated and a new IntropagePanelHeaderTest added. POT regenerated.

Please test (I can't verify UI headless)

  • Drag-reorder panels (mouse + keyboard arrows on the handle); order
    persists across reload.
  • Grow/shrink height resizes immediately and persists.
  • Maximize (details), reload (force), and remove (disable) tools.
  • "Copy text" toggle (#switch_copytext) locks/unlocks dragging.
  • Charts/graphs still resize on panel resize and window resize.
  • Severity header colours across light/dark themes.

Reviewers: @bmfmancini @xmacan

…ad it

First piece of the shared card-chrome port: bundle self-contained cards.css + cards.js (neutral cc* classes, theme-variable-driven, keyboard-accessible drag controller with an adapter seam) under includes/cards/, loaded on the dashboard page. No cross-plugin or core dependency. Panel markup/JS rewiring follows.
…eader replacement

Hosts like intropage replace a card's header (where .ccDrag lives) on AJAX reload; delegating mousedown/touchstart/keydown from the persistent card element keeps drag/keyboard reorder working without rebinding. bindCard is now idempotent per card.
…Sortable

Panels now use the bundled cc* card chrome: intropage_panel_header() emits the left drag handle + unified tools (shrink/grow, maximize, reload, remove), severity stays on the color_<alarm> class (reuses the per-theme palettes), and includes/intropage.js drives reorder + tools through CactiCards.init with an adapter mapping to the existing order/droppanel/details/height/reload endpoints. Sortable is replaced by the shared keyboard-accessible drag. Grow/shrink now resize the card instantly client-side before the persist+reload round-trip. Header markup is unit-tested via intropage_panel_header(); POT regenerated.
@TheWitness
TheWitness requested review from bmfmancini and xmacan and a balanced review from Copilot October 10, 2026 13:31

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.

🟡 Changes recommended

The shared container styling is not activated, and several interaction failure paths can leave incorrect state or trigger concurrent updates.

5 open findings
What changed in this PR

Introduces bundled shared card chrome for intropage dashboard panels while retaining existing backend endpoints and persistence.

Changes:

  • Adds reusable card CSS/JavaScript with keyboard reordering and panel tools.
  • Refactors panel headers and frontend adapters for resize, refresh, details, and removal.
  • Updates unit tests and translation templates.
File Description
display.php Loads the card controller.
includes/​cards/​cards.css Defines shared card presentation.
includes/​cards/​cards.js Implements card interactions.
includes/​functions.php Generates the new panel header.
includes/​intropage.js Connects card actions to existing endpoints.
locales/​po/​cacti.pot Updates translatable strings.
setup.php Loads card styles.
tests/​Unit/​IntropagePanelHeaderTest.php Tests header markup and tools.
tests/​Unit/​IntropagePanelReloadButtonTest.php Updates reload-tool assertions.

🧠 Review effort: Balanced


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

Comment thread includes/cards/cards.css
Comment thread includes/intropage.js
Comment thread includes/intropage.js
Comment thread includes/intropage.js
Comment thread includes/cards/cards.js
bmfmancini
bmfmancini previously approved these changes Oct 10, 2026
…details error, test, changelog)

Restore the 1s reload throttle on the card; roll back an optimistic grow/shrink on a failed persist (overlap-safe); fix a ReferenceError in the details error path (href -> url); correct the header test's single-quoted refresh assertion; add a CHANGELOG entry.
…ore block

patch-coverage flagged the changed panel_data/ccCardBody print in the exit-bound intropage_reload_panel(); it is the same view glue as the header call, so it belongs inside the existing @codeCoverageIgnore.
@TheWitness
TheWitness merged commit 8a8493a into develop Oct 10, 2026
5 checks passed
@TheWitness
TheWitness deleted the feature/shared-card-chrome branch October 10, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants