Skip to content

refactor: DRY quicktree action form wrappers#10

Open
somethingwithproof wants to merge 2 commits intoCacti:mainfrom
somethingwithproof:fix/dry-form-wrapper-9
Open

refactor: DRY quicktree action form wrappers#10
somethingwithproof wants to merge 2 commits intoCacti:mainfrom
somethingwithproof:fix/dry-form-wrapper-9

Conversation

@somethingwithproof
Copy link

Summary

  • add shared action-form wrapper helpers in ui_helpers.php
  • route add_tree and add_branch form wrappers through shared begin/end helpers
  • preserve behavior while reducing duplicated conditional-header and form wrapper scaffolding

Tests

  • php -l quicktree.php
  • php -l ui_helpers.php
  • php -l tests/test_form_wrapper.php
  • php tests/test_form_wrapper.php

Closes #9

Copilot AI review requested due to automatic review settings March 15, 2026 23:27
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

Refactors the QuickTree plugin’s action form wrapper scaffolding to reduce duplication by introducing shared begin/end helpers and routing existing add_tree/add_branch flows through them.

Changes:

  • Added shared quicktree_action_form_begin() / quicktree_action_form_end() helpers in ui_helpers.php.
  • Updated quicktree.php to include the helper file and use the shared wrappers for add_tree and add_branch.
  • Added a standalone regression test validating wrapper call order and verifying helper usage in quicktree.php.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
ui_helpers.php Introduces shared begin/end helpers for QuickTree action form scaffolding.
quicktree.php Replaces duplicated wrapper code in add_tree/add_branch with the shared helpers and includes the helper file.
tests/test_form_wrapper.php Adds regression coverage for wrapper call order and helper adoption in quicktree.php.

💡 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 +87 to +95
strpos($source, "include_once('plugins/quicktree/ui_helpers.php');") !== false
);
assert_true(
'quicktree.php uses begin wrapper in add-tree and add-branch',
substr_count($source, 'quicktree_action_form_begin(') >= 2
);
assert_true(
'quicktree.php uses end wrapper in add-tree and add-branch',
substr_count($source, 'quicktree_action_form_end();') >= 2
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 03a99e7: switched source assertions to regex-based checks and added readability guards to reduce quote/whitespace brittleness.

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 quicktree action form wrappers

2 participants