Skip to content

Commit 56ac5cc

Browse files
committed
cveRecordSearchModule: change "cveId" to ref
1 parent 113b1e8 commit 56ac5cc

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

src/components/cveRecordSearchModule.vue

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ let queryString = ref('');
8686
8787
let cveGenericGlobalsStore = useGenericGlobalsStore();
8888
let searchType = ref('');
89-
let cveId = '';
89+
let cveId = ref('');
9090
9191
// this seems redundant, but it fixes an edge case. if a user searches for a
9292
// particular field, then on the results page flips the toggle, THEN refreshes
@@ -101,6 +101,7 @@ let searchTypeBoolean = computed(() => {
101101
102102
if (!cveGenericGlobalsStore.isProductionWebsite)
103103
watch(searchType, () => {
104+
104105
resetStates();
105106
106107
if (searchType.value == legacyOptionLabel && route.query?.id) {
@@ -109,20 +110,24 @@ if (!cveGenericGlobalsStore.isProductionWebsite)
109110
// in the input field. Because it's a valid CVEID, the search button
110111
// is enabled.
111112
112-
cveId = route.query.id;
113+
cveId.value = route.query.id;
113114
cveListSearchStore.isSearchButtonDisabled = false;
114115
}
115116
});
116117
117-
searchType.value = searchOptionLabel;
118+
searchType.value = cveGenericGlobalsStore.useSearch ? searchOptionLabel
119+
: legacyOptionLabel;
118120
119121
watch(
120122
() => route.query,
121123
() => {
122-
if (searchTypeBoolean.value && route.query?.query) {
124+
if (searchTypeBoolean.value) {
125+
if (route.query?.query) {
123126
queryString.value = route.query.query.trim();
124127
validate();
125-
}
128+
}
129+
} else if (route.query.id)
130+
cveId.value = route.query.id;
126131
}
127132
)
128133
@@ -133,7 +138,7 @@ function resetStates() {
133138
cveGenericGlobalsStore.setUseSearch(isSearch);
134139
cveGenericGlobalsStore.setCurrentServicesUrl(servicesUrl);
135140
cveListSearchStore.searchType = isSearch;
136-
cveId = '';
141+
cveId.value = '';
137142
queryString.value = cveListSearchStore.query = '';
138143
errorMessageStore.$reset();
139144
cveListSearchStore.isSearchButtonDisabled = true;
@@ -152,13 +157,13 @@ function startSearch() {
152157
} else
153158
cveListSearchStore.search();
154159
} else if (route.name !== 'CVERecord' || !route.query?.id
155-
|| (route.query.id !== cveId)) {
160+
|| (route.query.id !== cveId.value)) {
156161
157162
// This is for the legacy find and is only applicable on the non-production
158163
// websites. This push to the router will trigger a lookup for the CVE
159164
// record.
160165
161-
router.push({name: cveRecordRouteName, query: {id: cveId}});
166+
router.push({name: cveRecordRouteName, query: {id: cveId.value}});
162167
} else {
163168
164169
// Non-production website in legacy find, with the user possibly wanting
@@ -173,7 +178,7 @@ function startSearch() {
173178
function validateQueryString() {
174179
175180
const isSearch = searchTypeBoolean.value;
176-
const searchValue = isSearch ? queryString.value : cveId;
181+
const searchValue = isSearch ? queryString.value : cveId.value;
177182
178183
cveListSearchStore.isSearchButtonDisabled = true;
179184
errorMessageStore.$reset();
@@ -197,7 +202,7 @@ function validateQueryString() {
197202
if (isSearch)
198203
queryString.value = normalizedCveId;
199204
else
200-
cveId = normalizedCveId;
205+
cveId.value = normalizedCveId;
201206
} else {
202207
errorMessageStore.setErrorMessage(`Invalid CVE ID "${normalizedCveId}" - identifier out of range`);
203208
}
@@ -252,7 +257,7 @@ function onInputChange() {
252257
// the validity of the search string when initiated.
253258
254259
const isSearch = searchTypeBoolean.value;
255-
const searchValue = isSearch ? queryString.value : cveId;
260+
const searchValue = isSearch ? queryString.value : cveId.value;
256261
257262
if (!searchValue.length) {
258263
// This handles the case when the user clears the input field, by using the

0 commit comments

Comments
 (0)