Prevent watcher from being triggered unnecessarily
What does this MR do?
This prevents a watcher from being triggered unnecessarily, which would in turn spam the API with unwanted requests.
The RefSelector
component fetches refs via the API whenever its enabled-ref-types
property changes. However, the OnDemandScansForm
computed the enabled ref types array in its template, which seemed to result in the property being constantly replaced whenever some other value got updated in the form. By declaring the array in the component's options, we seem to ensure that the same reference is passed to RefSelector
, thus preventing the watcher from firing for identical values.
Note: I did not add tests for this. I feel like this is a Vue caveat that might not be worth testing for here
🤷
How to test this?
- Enable the
dast_branch_selection
feature flag.
echo "Feature.enable(:dast_branch_selection)" | rails c
- Navigate to the on-demand scans form at
/:namespace/:project/-/on_demand_scans/new
. - Change any input's value in the page.
Screenshots (strongly suggested)
Before | After |
---|---|
before | after |
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?- [-] I have included a changelog entry.
-
I have not included a changelog entry because this is behind the dast_branch_selection
feature flag.
- [-] Documentation (if required)
-
Code review guidelines - [-] Merge request performance guidelines
-
Style guides - [-] Database guides
-
Separation of EE specific content
Availability and Testing
- [-] Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
- [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Related to #324199 (closed)
Edited by Paul Gascou-Vaillancourt