Skip to content

intropage: Panel Library status pills, column order, and add-panel prefix - #476

Merged
somethingwithproof merged 1 commit into
developfrom
feature/panellib-status-pills-prefix
Nov 11, 2026
Merged

somethingwithproof merged 1 commit into
developfrom
feature/panellib-status-pills-prefix

Conversation

@TheWitness

@TheWitness TheWitness commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Panel Library list page

  • Column order: moved the Status column to sit immediately after Source.
  • Swapped the Update Function and Refresh columns so Update Function comes first.
  • Status pills: the Status value now renders as an Enabled (green) / Disabled (red) pill, and the column is center-aligned. Pill styles were added to css/common.css (reusing the existing intropage green/red palette), so they load on every page via the page_head hook.
  • The column definitions are built from a compact [display, tip, align?, sort?] table rather than a repeated per-column array.

Add-panel menu (dashboard toolbar)

  • The Panels ... dropdown now applies intropage_prefix_panel_name() to its option labels, so the source prefix (e.g. Core - , <Plugin> - ) shows there too, matching the Panel Library list. The name is prefixed once at the top of the loop, so every option (including the (no permission) entries) stays consistent without duplicating the render branches.

Tests

  • tests/Unit/IntropageAddPanelSelectTest.php covers the add-panel source prefix.
  • The e2e status-contrast test now renders the Enabled/Disabled pills and asserts their label contrast across every theme.

Notes

  • Disabled pills use red (#cc0000) and enabled use the intropage green (rgba(148,179,107,1)); easy to switch Disabled to grey if preferred.

Copilot AI balanced review requested due to automatic review settings November 11, 2026 20:03

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.

🟢 Approval recommended

No active review issues are reported for the dashboard status and source-label updates.

No open issues 🎉

What changed in this PR

Updates the Intropage dashboard UI to make panel status clearer and source labels consistent between the Panel Library and add-panel menu.

Changes:

  • Moves Status immediately after Source and Update Function before Refresh.
  • Displays status as centered green Enabled or red Disabled pills.
  • Adds source prefixes to add-panel option labels, including options marked “no permission.”
File Description
intropage_panels.php Reorders columns and renders escaped status labels as centered pills.
includes/​functions.php Applies source prefixes to add-panel dropdown labels.
css/​common.css Adds shared styling for enabled and disabled status pills.

Review effort: Balanced

@somethingwithproof somethingwithproof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • Blocker: CI is red on two coverage gates. PHP patch coverage is 0/5: includes/functions.php:2528,2533,2536,2541,2544 are uncovered, and intropage_panels.php is missing from Clover. The theme browser job reports css/common.css 218-236 (the new pill rules) as 0/15 covered. Both need tests: a unit case for intropage_addpanel_select() asserting the prefixed labels, and an e2e pass over the Panel Library page that renders an enabled and a disabled pill.
  • Suggestion: The (no permission) options print __('%s (no permission)', $label, 'intropage') unescaped, while the enabled branches use html_escape($label). $label now also includes a prefix derived from the registering plugin's name. Use __esc() there so all four branches escape the same way.
  • Suggestion: The add-panel query still sorts with ORDER BY pd.name, but the labels are now prefixed. Third-party panels therefore interleave with Core - ... entries by their unprefixed names, and the dropdown no longer reads as sorted. Sort $add_panels by the computed label in PHP, or group by source.

@TheWitness
TheWitness force-pushed the feature/panellib-status-pills-prefix branch from 4743327 to 8a086cf Compare November 11, 2026 21:29
@TheWitness
TheWitness dismissed somethingwithproof’s stale review November 11, 2026 21:31

Still work in progress.

@TheWitness
TheWitness force-pushed the feature/panellib-status-pills-prefix branch from 8a086cf to 0c5ad4b Compare November 11, 2026 21:35
@TheWitness

Copy link
Copy Markdown
Member Author

Addressed the CI failures on this PR:

SonarCloud quality gate (was failing):

  • Reliability (bug): SonarCloud flagged __('%s (no permission)', …, 'intropage') as passing too many arguments (it models gettext's __($text, $domain) as 2-arg; Cacti's __() is variadic). Reworked the add-panel change so the source prefix is applied once to the fetched name at the top of the loop, leaving the existing __() option lines untouched — so they are no longer "new" code. Reliability on new code is back to A.
  • Duplication (23.3% → now 0%): The reorder had marked the whole $display_text column array as new, and its identical per-column blocks tripped copy-paste detection. Collapsed the array into a compact, loop-built form (defaults for the common left/ASC columns), eliminating the repeated block.

PHP integration (patch coverage gate):

  • Added tests/Unit/IntropageAddPanelSelectTest.php covering the new add-panel source-prefix line (verified locally: 100% patch coverage, line covered twice).

Cacti theme browser regressions (changed-CSS coverage gate):

  • The new .intropage_status_pill rules were unexercised. Extended the e2e status-contrast test to render Enabled/Disabled pills and assert their label contrast (≥ 4.5) on every theme, which also exercises the new CSS.

All checks are green now.

@somethingwithproof somethingwithproof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No blockers found. CI is green, and the new IntropageAddPanelSelectTest and the pill contrast assertion in cacti-theme.spec.cjs cover the changed lines.

Two non-blocking leftovers from the last round, fine as a follow-up:

  • The (no permission) options still print __('%s (no permission)', $panel['name'], 'intropage') unescaped, while the enabled options use html_escape(). Since the label now carries the source prefix, __esc() there would make all four branches consistent.
  • ORDER BY pd.name still sorts on the unprefixed name, so <Plugin> - ... options interleave with Core - ... ones in the dropdown.

@TheWitness

Copy link
Copy Markdown
Member Author

Thanks @somethingwithproof — all three points addressed in the latest push (f164622):

Blocker (coverage gates): resolved. Reworked the change to keep CI green — PHP patch coverage is back to 100% and the new pill CSS is exercised:

  • Added tests/Unit/IntropageAddPanelSelectTest.php (5 cases) covering intropage_addpanel_select(): the prefixed label, the identity (no-source) case, the new sort order, and both (no permission) branches.
  • Extended the e2e status-contrast test to render an Enabled and a Disabled pill and assert their label contrast on every theme, which also covers css/common.css 218–236.

Suggestion 1 (escaping): done. Both (no permission) options now use __esc('%s (no permission)', $panel['name'], 'intropage'), so the plugin-derived prefix is HTML-escaped the same way the enabled branches escape with html_escape().

Suggestion 2 (sort order): done. Dropped ORDER BY pd.name from the query and instead prefix every label first, then usort() by the prefixed label (strnatcasecmp). The menu now groups by source and reads as sorted instead of interleaving Core - … with third-party entries by their unprefixed names. The new orders options by the prefixed label test asserts this.

As a side effect of an earlier Sonar duplication finding, the Panel Library column table was also collapsed into a compact definition loop rather than a repeated per-column array.

…efix

Panel Library list page:
- Move the Status column to sit immediately after Source.
- Swap the Update Function and Refresh columns so Update Function
  comes first (matches the requested layout).
- Render Status as Enabled/Disabled pills (green/red) and center the
  column, with the pill styles added to css/common.css.

Add-panel menu:
- Prefix each option label with the panel's source via
  intropage_prefix_panel_name(), so the dropdown matches the Panel
  Library list. The name is prefixed once at the top of the loop so
  every option (including the '(no permission)' entries) stays
  consistent without duplicating the render branches.

Tests:
- Unit coverage for the add-panel source prefix
  (tests/Unit/IntropageAddPanelSelectTest.php).
- Exercise the Enabled/Disabled pill styles and assert their label
  contrast across every theme in the e2e status-contrast test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@TheWitness
TheWitness force-pushed the feature/panellib-status-pills-prefix branch from f164622 to 1375a19 Compare November 11, 2026 22:05
@sonarqubecloud

Copy link
Copy Markdown

@TheWitness

Copy link
Copy Markdown
Member Author

Follow-up on the escaping fix (@somethingwithproof): I switched away from __esc() after it turned out SonarCloud models __esc as a 2-argument gettext helper too, so __esc('%s (no permission)', $name, 'intropage') tripped the same false-positive reliability bug that the bare 3-argument __() did.

Instead, the source-prefixed label is now HTML-escaped once (right after it is built, before the sort), and the four option branches consume that pre-escaped value:

  • the enabled options print $panel['name'] directly (no second escape);
  • the two (no permission) options are left exactly as on develop (__('%s (no permission)', $panel['name'], 'intropage')), so they are not “new” code for Sonar, yet they now render an already-escaped, plugin-derived name.

Net result: the disabled options are escaped the same way as the enabled ones (your original concern), the i18n template needs no change, and SonarCloud stays green (reliability A, 0 issues, 0% duplication). All PHP/theme/coverage checks pass.

@somethingwithproof somethingwithproof left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Clean, focused change; column/cell order lines up, the reference loop is unset correctly, and centralizing the escape also closes the raw name in the (no permission) branches. Matrix is green. Two optional follow-ups: usort runs on the html_escaped label (cosmetic ordering for names with entities), and the (string) cast on the name is inconsistent with intropage_panels.php.

@somethingwithproof
somethingwithproof merged commit 91bfc66 into develop Nov 11, 2026
10 checks passed
@somethingwithproof
somethingwithproof deleted the feature/panellib-status-pills-prefix branch November 11, 2026 22:47
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