Commit 398b4b18 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'djadmin-dast-ls-key-update' into 'master'

Update localStorage key for On-demand scans form

See merge request gitlab-org/gitlab!57224
parents 0a4ac46a 873dc49a
......@@ -221,16 +221,20 @@ export default {
return isFormInvalid || (loading && loading !== saveScanBtnId);
},
formFieldValues() {
const { selectedScannerProfileId, selectedSiteProfileId } = this;
const { selectedScannerProfileId, selectedSiteProfileId, selectedBranch } = this;
return {
...serializeFormObject(this.form.fields),
selectedScannerProfileId,
selectedSiteProfileId,
selectedBranch,
};
},
hasExcludedUrls() {
return this.selectedSiteProfile.excludedUrls?.length > 0;
},
storageKey() {
return `${this.projectPath}/${ON_DEMAND_SCANS_STORAGE_KEY}`;
},
},
created() {
const params = queryToObject(window.location.search);
......@@ -307,17 +311,22 @@ export default {
this.showAlert = false;
},
updateFromStorage(val) {
const { selectedSiteProfileId, selectedScannerProfileId, name, description } = val;
const {
selectedSiteProfileId,
selectedScannerProfileId,
name,
description,
selectedBranch,
} = val;
this.form.fields.name.value = name ?? this.form.fields.name.value;
this.form.fields.description.value = description ?? this.form.fields.description.value;
this.selectedBranch = selectedBranch;
// precedence is given to profile IDs passed from the query params
this.selectedSiteProfileId = this.selectedSiteProfileId ?? selectedSiteProfileId;
this.selectedScannerProfileId = this.selectedScannerProfileId ?? selectedScannerProfileId;
},
},
ON_DEMAND_SCANS_STORAGE_KEY,
EXCLUDED_URLS_SEPARATOR,
};
</script>
......@@ -327,7 +336,7 @@ export default {
<local-storage-sync
v-if="!isEdit"
as-json
:storage-key="$options.ON_DEMAND_SCANS_STORAGE_KEY"
:storage-key="storageKey"
:clear="clearStorage"
:value="formFieldValues"
@input="updateFromStorage"
......
---
title: Update localStorage key for On-demand scans form
merge_request: 57224
author:
type: other
......@@ -56,7 +56,7 @@ jest.mock('~/lib/utils/url_utility', () => ({
redirectTo: jest.fn(),
}));
const LOCAL_STORAGE_KEY = 'on-demand-scans-new-form';
const LOCAL_STORAGE_KEY = 'group/project/on-demand-scans-new-form';
describe('OnDemandScansForm', () => {
let localVue;
......@@ -268,6 +268,7 @@ describe('OnDemandScansForm', () => {
name: 'My daily scan',
selectedScannerProfileId: 'gid://gitlab/DastScannerProfile/1',
selectedSiteProfileId: 'gid://gitlab/DastSiteProfile/1',
selectedBranch: 'some-other-branch',
}),
],
]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment