Skip to content

Commit 66ac2af

Browse files
committed
fix Production/Test message for search
1 parent c80ce00 commit 66ac2af

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

src/stores/genericGlobals.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export const useGenericGlobalsStore = defineStore('genericGlobals', {
1515
legacyCveWebsiteLink: 'https://cve.mitre.org/cve/search_cve_list.html'
1616
};
1717
},
18+
getters: {
19+
searchDbType: (state) => state.isProductionWebsite
20+
|| state.currentServicesUrl.toLowerCase().includes('cveawg.mitre.org')
21+
? 'Production' : 'Test',
22+
},
1823
actions: {
1924
setUseSearch(value: boolean) {
2025
this.useSearch = value;
@@ -25,4 +30,4 @@ export const useGenericGlobalsStore = defineStore('genericGlobals', {
2530
sessionStorage.setItem('currentServicesUrl', JSON.stringify(value));
2631
}
2732
},
28-
});
33+
});

src/views/CVERecord/CVERecord.vue

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
<p id="alertIconCveRecordsRequestErrored" class="is-hidden">alert</p>
2727
<font-awesome-icon style="flex: 0 0 40px;" size="1x" icon="triangle-exclamation" role="img"
2828
aria-labelledby="alertIconCveRecordsRequestErrored" aria-hidden="false" />
29-
<p>You are accessing <span class="has-text-weight-bold">{{ usingProd }}</span> data from {{ resultUrl }}</p>
29+
<p>You are accessing <span class="has-text-weight-bold">
30+
{{ genericGlobalsStore.searchDbType }}</span>
31+
data from {{ genericGlobalsStore.currentServicesUrl }}
32+
</p>
3033
</div>
3134
</div>
3235
<PublishedRecord v-if="usecveRecordStore.isPublished"/>
@@ -51,7 +54,10 @@
5154
<p id="alertIconCveRecordsRequestErrored" class="is-hidden">alert</p>
5255
<font-awesome-icon style="flex: 0 0 40px;" size="1x" icon="triangle-exclamation" role="img"
5356
aria-labelledby="alertIconCveRecordsRequestErrored" aria-hidden="false" />
54-
<p>You are accessing <span class="has-text-weight-bold">{{ usingProd }}</span> data from {{ resultUrl }}</p>
57+
<p>You are accessing <span class="has-text-weight-bold">
58+
{{ genericGlobalsStore.searchDbType }}</span>
59+
data from {{ genericGlobalsStore.currentServicesUrl }}
60+
</p>
5561
</div>
5662
</div>
5763
<h1 class="title is-3 is-4 mb-2">{{usecveRecordStore.cveId}} not found.</h1>
@@ -94,13 +100,6 @@ export default {
94100
},
95101
data() {
96102
return {
97-
isResultFromProd: false,
98-
// There is a special case when the website deals with some cached data.
99-
// This ensures that the correct value is shown, even though it is not
100-
// pretty
101-
resultUrl: this.GenericGlobalsStore.useSearch
102-
? this.GenericGlobalsStore.cveServicesBaseUrl
103-
: this.GenericGlobalsStore.cveServiceTestBaseUrl,
104103
usecveRecordStore: usecveRecordStore(),
105104
cveId: usecveRecordStore().cveId,
106105
cveServicesUrl: undefined,
@@ -113,9 +112,6 @@ export default {
113112
};
114113
},
115114
computed: {
116-
usingProd() {
117-
return this.isResultFromProd ? 'Production' : 'Test'
118-
},
119115
isSearching() {
120116
return usecveRecordStore().isSearching;
121117
},

src/views/CVERecord/SearchResults.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
<p id="alertIconCveRecordsRequestErrored" class="is-hidden">alert</p>
3232
<font-awesome-icon style="flex: 0 0 40px;" size="1x" icon="triangle-exclamation" role="alert"
3333
aria-labelledby="alertIconCveRecordsRequestErrored" aria-hidden="false" />
34-
<p>You are accessing <span class="has-text-weight-bold">Production</span> data from {{ resultUrl }}</p>
34+
<p>You are accessing <span class="has-text-weight-bold">
35+
{{ generalGlobalsStore.searchDbType }}</span>
36+
data from {{ generalGlobalsStore.currentServicesUrl }}
37+
</p>
3538
</div>
3639
</div>
3740
<h2 class="title">Search Results</h2>
@@ -282,7 +285,7 @@
282285
import { useCveListSearchStore } from '@/stores/cveListSearch';
283286
import { useGenericGlobalsStore } from '@/stores/genericGlobals';
284287
import { usePartnerStore } from '@/stores/partners';
285-
import { computed, createApp, ref, watch } from 'vue';
288+
import { computed, createApp, watch } from 'vue';
286289
import { useRouter } from 'vue-router';
287290
import ServiceUnavailable from '@/components/ServiceUnavailable.vue'
288291
@@ -291,7 +294,6 @@ const generalGlobalsStore = useGenericGlobalsStore();
291294
const partnerStore = usePartnerStore();
292295
const router = useRouter();
293296
const app = createApp({});
294-
const resultUrl = ref(generalGlobalsStore.cveServicesBaseUrl);
295297
296298
app.component('ServiceUnavailable', ServiceUnavailable);
297299
@@ -314,7 +316,8 @@ function backToTop() {
314316
function cveRecordRoute(cveId) {
315317
let recordRoute = `/CVERecord?id=${cveId}`;
316318
317-
if (!generalGlobalsStore.isProductionWebsite)
319+
if (!generalGlobalsStore.isProductionWebsite
320+
&& generalGlobalsStore.searchDbType === 'Production')
318321
recordRoute += '&prod=true';
319322
320323
return recordRoute

0 commit comments

Comments
 (0)