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 { ...@@ -221,16 +221,20 @@ export default {
return isFormInvalid || (loading && loading !== saveScanBtnId); return isFormInvalid || (loading && loading !== saveScanBtnId);
}, },
formFieldValues() { formFieldValues() {
const { selectedScannerProfileId, selectedSiteProfileId } = this; const { selectedScannerProfileId, selectedSiteProfileId, selectedBranch } = this;
return { return {
...serializeFormObject(this.form.fields), ...serializeFormObject(this.form.fields),
selectedScannerProfileId, selectedScannerProfileId,
selectedSiteProfileId, selectedSiteProfileId,
selectedBranch,
}; };
}, },
hasExcludedUrls() { hasExcludedUrls() {
return this.selectedSiteProfile.excludedUrls?.length > 0; return this.selectedSiteProfile.excludedUrls?.length > 0;
}, },
storageKey() {
return `${this.projectPath}/${ON_DEMAND_SCANS_STORAGE_KEY}`;
},
}, },
created() { created() {
const params = queryToObject(window.location.search); const params = queryToObject(window.location.search);
...@@ -307,17 +311,22 @@ export default { ...@@ -307,17 +311,22 @@ export default {
this.showAlert = false; this.showAlert = false;
}, },
updateFromStorage(val) { 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.name.value = name ?? this.form.fields.name.value;
this.form.fields.description.value = description ?? this.form.fields.description.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 // precedence is given to profile IDs passed from the query params
this.selectedSiteProfileId = this.selectedSiteProfileId ?? selectedSiteProfileId; this.selectedSiteProfileId = this.selectedSiteProfileId ?? selectedSiteProfileId;
this.selectedScannerProfileId = this.selectedScannerProfileId ?? selectedScannerProfileId; this.selectedScannerProfileId = this.selectedScannerProfileId ?? selectedScannerProfileId;
}, },
}, },
ON_DEMAND_SCANS_STORAGE_KEY,
EXCLUDED_URLS_SEPARATOR, EXCLUDED_URLS_SEPARATOR,
}; };
</script> </script>
...@@ -327,7 +336,7 @@ export default { ...@@ -327,7 +336,7 @@ export default {
<local-storage-sync <local-storage-sync
v-if="!isEdit" v-if="!isEdit"
as-json as-json
:storage-key="$options.ON_DEMAND_SCANS_STORAGE_KEY" :storage-key="storageKey"
:clear="clearStorage" :clear="clearStorage"
:value="formFieldValues" :value="formFieldValues"
@input="updateFromStorage" @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', () => ({ ...@@ -56,7 +56,7 @@ jest.mock('~/lib/utils/url_utility', () => ({
redirectTo: jest.fn(), 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', () => { describe('OnDemandScansForm', () => {
let localVue; let localVue;
...@@ -268,6 +268,7 @@ describe('OnDemandScansForm', () => { ...@@ -268,6 +268,7 @@ describe('OnDemandScansForm', () => {
name: 'My daily scan', name: 'My daily scan',
selectedScannerProfileId: 'gid://gitlab/DastScannerProfile/1', selectedScannerProfileId: 'gid://gitlab/DastScannerProfile/1',
selectedSiteProfileId: 'gid://gitlab/DastSiteProfile/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