4141 </button >
4242 </p >
4343 </div >
44- <div class =" notification is-warning is-light" role =" alert" v-if =" errorMessage.length > 0 " >
44+ <div class =" notification is-warning is-light" role =" alert" v-if =" errorMessageStore.showErrorMessage " >
4545 <div class =" is-flex is-align-content-flex-start" >
4646 <p id =" alertIcon" class =" is-hidden" >alert</p >
4747 <font-awesome-icon style =" flex : 0 0 40px ; margin-top :3px " size =" lg" icon =" exclamation-triangle" role =" alert"
4848 aria-labelledby =" alertIcon" aria-hidden =" false" />
4949 <p class =" cve-help-text" >
50- {{ errorMessage }}
50+ {{ errorMessageStore. errorMessage }}
5151 </p >
5252 </div >
5353 </div >
@@ -59,7 +59,7 @@ import { useCveListSearchStore } from '@/stores/cveListSearch';
5959import { computed , ref , watch } from ' vue' ;
6060import { useRoute , useRouter } from ' vue-router' ;
6161// Legacy Search Import
62- import { usecveRecordStore } from ' @/stores/cveRecord' ;
62+ import { usecveRecordStore , useErrorMessageStore } from ' @/stores/cveRecord' ;
6363import { useGenericGlobalsStore } from ' @/stores/genericGlobals' ;
6464
6565const cveIdRegex = / ^ CVE\p {Pd}(?<year>\d {4} )\p {Pd}(?<id>\d {4,} )$ / iu ;
@@ -74,6 +74,8 @@ const isProductionWebsite = import.meta.env.VITE_WEBSITE_ENVIRONMENT === 'prd';
7474const maxCveIdSuffix = 7 ;
7575
7676let cveListSearchStore = useCveListSearchStore ();
77+ const errorMessageStore = useErrorMessageStore ();
78+
7779const route = useRoute ();
7880const router = useRouter ();
7981
@@ -127,22 +129,11 @@ function resetStates() {
127129 cveListSearchStore .searchType = cveGenericGlobalsStore .useSearch = searchTypeBoolean .value ;
128130 cveId = ' ' ;
129131 queryString .value = cveListSearchStore .query = ' ' ;
130- showHelpMessage ( ' ' );
132+ errorMessageStore . $reset ( );
131133 cveListSearchStore .isSearchButtonDisabled = true ;
132134 resetSearch ();
133135}
134136
135- function showHelpMessage (helpText ) {
136-
137- if (helpText .length ) {
138- errorMessage .value = helpText;
139- cveListSearchStore .showHelpText = true ;
140- } else {
141- errorMessage .value = ' ' ;
142- cveListSearchStore .showHelpText = false ;
143- }
144- }
145-
146137function startSearch () {
147138 // We only want to flip the search item _When we actually do a search_
148139 // otherwise we should default back to what we were on a page refresh
@@ -182,7 +173,7 @@ function validateQueryString() {
182173
183174 prevSearchValue.value = searchValue;
184175 cveListSearchStore.isSearchButtonDisabled = true;
185- showHelpMessage('' );
176+ errorMessageStore.$reset( );
186177
187178 if (!searchValue)
188179 return !cveListSearchStore.isSearchButtonDisabled;
@@ -205,7 +196,7 @@ function validateQueryString() {
205196 else
206197 cveId = normalizedCveId;
207198 } else {
208- showHelpMessage (` Invalid CVE ID " ${normalizedCveId}" - identifier out of range` );
199+ errorMessageStore.setErrorMessage (` Invalid CVE ID " ${normalizedCveId}" - identifier out of range` );
209200 }
210201 }
211202
@@ -215,7 +206,7 @@ function validateQueryString() {
215206 // of "typical" words (alphanumeric phrases), then it's an error.
216207
217208 if (!cveIdMatch && !wordRegex.test(searchValue)) {
218- showHelpMessage (contentMessage);
209+ errorMessageStore.setErrorMessage (contentMessage);
219210 } else if (!errorMessage.value) {
220211
221212 // The provided search string is good.
@@ -229,7 +220,7 @@ function validateQueryString() {
229220 } else if (!errorMessage.value) {
230221
231222 // Legacy Find by CVE ID but the query string is not a CVE ID.
232- showHelpMessage('Required CVE ID format: CVE-YYYY-NNNN' );
223+ errorMessageStore.cveIdFormatMessage( );
233224 }
234225
235226 return !cveListSearchStore.isSearchButtonDisabled;
@@ -252,7 +243,7 @@ function onInputChange() {
252243 // input field.
253244
254245 resetSearch();
255- showHelpMessage('' );
246+ errorMessageStore.$reset( );
256247 cveListSearchStore.isSearchButtonDisabled = true;
257248
258249 } else if (cveListSearchStore.isSearchButtonDisabled
0 commit comments