Skip to content

Commit 8484cfa

Browse files
committed
cveRecordSearchModule: define isProductionWebsite boolean
1 parent 0d2c58e commit 8484cfa

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/components/cveRecordSearchModule.vue

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="mt-1">
3-
<div v-if="websiteEnv !== 'prd'" role="alert" class="notification is-warning is-light">
3+
<div v-if="!isProductionWebsite" role="alert" class="notification is-warning is-light">
44
<div class="is-flex is-align-items-flex-start mt-1" style="max-width: 820px; column-gap: 1rem;">
55
<div class="pl-3">
66
<p id="alertIconVariousFormts" class="is-hidden">alert</p>
@@ -18,10 +18,10 @@
1818
</div>
1919
<div class="field has-addons mt-1">
2020
<p class="control">
21-
<span v-if="websiteEnv !== 'prd'" class="select cve-search-selector">
21+
<span v-if="!isProductionWebsite" class="select cve-search-selector">
2222
<select v-model="searchType">
23-
<option>Search CVE List</option>
24-
<option>Find a Test CVE Record/ID (Legacy)</option>
23+
<option>{{ searchOptionLabel }}</option>
24+
<option>{{ legacyOptionLabel }}</option>
2525
</select>
2626
</span>
2727
</p>
@@ -65,6 +65,8 @@ import { useGenericGlobalsStore } from '@/stores/genericGlobals';
6565
const cveIdRegex = /^CVE\p{Pd}(?<year>\d{4})\p{Pd}(?<id>\d{4,})$/iu;
6666
const wordRegex = /^[a-z0-9 ]+$/i;
6767
68+
const isProductionWebsite = import.meta.env.VITE_WEBSITE_ENVIRONMENT === 'prd';
69+
6870
// This is the current maximum supported length of the "suffix" portion of
6971
// the CVE ID. The schema defines a suffix length up to 19, but code in
7072
// other modules only supports what's defined here.
@@ -75,20 +77,24 @@ let cveListSearchStore = useCveListSearchStore();
7577
const route = useRoute();
7678
const router = useRouter();
7779
80+
const cveRecordRouteName = 'CVERecord';
81+
const legacyOptionLabel = 'Find a Test CVE Record/ID (Legacy)';
82+
const searchOptionLabel = 'Search CVE List';
83+
7884
let prevSearchValue = ref('');
7985
let queryString = ref('');
8086
let errorMessage = ref('');
8187
8288
let cveGenericGlobalsStore = useGenericGlobalsStore();
8389
let cveRecordStore = usecveRecordStore();
84-
let searchType = ref('Search CVE List');
90+
let searchType = ref(searchOptionLabel);
8591
let cveId = cveRecordStore.cveId;
8692
8793
// this seems redundant, but it fixes an edge case. if a user searches for a
8894
// particular field, then on the results page flips the toggle, THEN refreshes
8995
// without searching, this will keep the correct helper text showing.
9096
let searchTypeBoolean = computed(() => {
91-
return searchType.value == 'Search CVE List' ? true : false;
97+
return searchType.value === searchOptionLabel ? true : false;
9298
});
9399
94100
watch(searchType, () => {
@@ -99,8 +105,8 @@ watch(
99105
() => route.query,
100106
() => {
101107
if (searchTypeBoolean.value && route.query?.query) {
102-
queryString.value = route.query.query.trim();
103-
validate();
108+
queryString.value = route.query.query.trim();
109+
validate();
104110
}
105111
}
106112
)
@@ -283,10 +289,6 @@ function resetSearch() {
283289
if (route?.name != 'home' || route?.query)
284290
router.push({name: 'home', query: {}});
285291
}
286-
287-
const websiteEnv = computed(() => {
288-
return import.meta.env.VITE_WEBSITE_ENVIRONMENT;
289-
});
290292
</script>
291293
292294
<style scoped lang="scss">

0 commit comments

Comments
 (0)