Skip to content

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?

  1. Enable the dast_branch_selection feature flag.
echo "Feature.enable(:dast_branch_selection)" | rails c
  1. Navigate to the on-demand scans form at /:namespace/:project/-/on_demand_scans/new.
  2. Change any input's value in the page.

Screenshots (strongly suggested)

Before After
before after

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Related to #324199 (closed)

Edited by Paul Gascou-Vaillancourt

Merge request reports