Skip to content

Persist On-demand Scans form values in localStorage

Dheeraj Joshi requested to merge djadmin-dast-local-storage into master

Implements #293844 (closed)

What does this MR do?

This MR uses LocalStorageSync component to persist On-demand scans form values.

  • Cleans storage on successful form submissions
  • Skips restoring from local storage while editing a form

Note: The changes are behind the feature flag dast_saved_scans.

Demo

on-demand-scan-persist720

Please note that the current demo clears the storage on failed form submissions as well, which is just for testing purposes.

How to test this?

  1. Enable the :dast_saved_scans feature flag.
echo "Feature.disable(:dast_saved_scans)" | rails c
  1. Navigate to the DAST scans management page at /:namespace/:project/-/on_demand_scans/new

  2. Add this line to clear storage on form submits even when it fails

diff --git a/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue b/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
index 7b611e5a4e3..336aede5cb8 100644
--- a/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
+++ b/ee/app/assets/javascripts/on_demand_scans/components/on_demand_scans_form.vue
@@ -314,6 +314,7 @@ export default {
       this.errorType = errorType;
       this.errors = errors;
       this.showAlert = true;
+      this.clearStorage = true; // Todo: Remove this, it's only for testing purposess
     },
     hideErrors() {
       this.errorType = null;
  1. Fill out the form and reload the page
Edited by Dheeraj Joshi

Merge request reports