Skip to content

refactor: DRY flowview filters layout wrapper#246

Open
somethingwithproof wants to merge 2 commits intoCacti:developfrom
somethingwithproof:fix/dry-layout-245
Open

refactor: DRY flowview filters layout wrapper#246
somethingwithproof wants to merge 2 commits intoCacti:developfrom
somethingwithproof:fix/dry-layout-245

Conversation

@somethingwithproof
Copy link

Summary

This PR implements issue #245 by removing repeated page layout wrapper logic from flowview_filters.php.

Changes

  • added ui_helpers.php with shared helper:
    • flowview_filters_render_with_layout($renderer, $respect_embed = false)
  • updated flowview_filters.php action routing:
    • edit now calls flowview_filters_render_with_layout('edit_filter', true)
    • default path now calls flowview_filters_render_with_layout('show_filters')
  • preserved existing embed behavior for edit rendering

Validation

  • php -l flowview_filters.php
  • php -l ui_helpers.php
  • php -l tests/test_layout_wrapper.php
  • php tests/test_layout_wrapper.php

Issue

Closes #245

Copilot AI review requested due to automatic review settings March 15, 2026 23:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a shared helper to wrap FlowView filter page rendering with the standard Cacti header/footer (optionally respecting embed mode), updates flowview_filters.php to use it, and adds a small regression test script.

Changes:

  • Introduce flowview_filters_render_with_layout() helper to centralize header/footer wrapping logic.
  • Refactor flowview_filters.php edit and default actions to use the shared helper.
  • Add tests/test_layout_wrapper.php to verify wrapper behavior (and that flowview_filters.php uses the helper).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
ui_helpers.php Adds a helper function to wrap a renderer callback with header/footer, optionally respecting embed.
flowview_filters.php Uses the shared helper for edit and default rendering paths and includes the helper file.
tests/test_layout_wrapper.php Adds a basic regression test for wrapper behavior and checks that flowview_filters.php invokes the helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +9 to +10
| of the License, or (at your option) any later version. |
+-------------------------------------------------------------------------+
Copy link
Author

Choose a reason for hiding this comment

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

Addressed in 9f37b1d: expanded ui_helpers.php to the standard full Cacti header block used by this plugin.

Comment on lines +55 to +60
if (strpos($source, "flowview_filters_render_with_layout('edit_filter', true);") === false) {
fwrite(STDERR, 'Expected edit action to use shared layout helper.' . PHP_EOL);
exit(1);
}

if (strpos($source, "flowview_filters_render_with_layout('show_filters');") === false) {
Copy link
Author

Choose a reason for hiding this comment

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

Addressed in 9f37b1d: converted source checks in the regression test to regex-based assertions with formatting tolerance.

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.

refactor: DRY flowview filters page layout wrapper

2 participants