From d029ce204b867981e071cf787062fdd80cd58fae Mon Sep 17 00:00:00 2001 From: Thomas Junk Date: Tue, 5 Sep 2023 11:27:47 +0200 Subject: [PATCH] fix: open vulnerabilities section when CVE is clicked --- src/lib/Collapsible.svelte | 7 ++++++- .../singleview/vulnerabilities/Vulnerability.svelte | 3 ++- src/lib/store.ts | 13 ++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/lib/Collapsible.svelte b/src/lib/Collapsible.svelte index 6b77b3b..09dfdf6 100644 --- a/src/lib/Collapsible.svelte +++ b/src/lib/Collapsible.svelte @@ -3,7 +3,12 @@ export let open: boolean = false; export let index: string = "2"; export let class_: string = ""; - let visibility = open ? "block" : "none"; + let visibility = "none"; + $: if (open) { + visibility = "block"; + } else { + visibility = "none"; + } let icon = "bx-chevron-down"; const toggle = (e: Event) => { if (visibility === "block") visibility = "none"; diff --git a/src/lib/singleview/vulnerabilities/Vulnerability.svelte b/src/lib/singleview/vulnerabilities/Vulnerability.svelte index a97594d..33bfc3e 100644 --- a/src/lib/singleview/vulnerabilities/Vulnerability.svelte +++ b/src/lib/singleview/vulnerabilities/Vulnerability.svelte @@ -9,7 +9,8 @@ $: if (vulnerability.cve) { header = vulnerability.cve; } - $: if (vulnerability.cve && $appStore.ui.selectedCVE === vulnerability.cve) { + $: if ($appStore.ui.selectedCVE !== "") { + appStore.setVulnerabilitiesSectionVisible(); open = true; } diff --git a/src/lib/store.ts b/src/lib/store.ts index 21f2aed..a8541d4 100644 --- a/src/lib/store.ts +++ b/src/lib/store.ts @@ -42,7 +42,6 @@ function createStore() { }), setSelectedCVE: (cve: string) => { update((settings) => { - console.log(cve); settings.ui.selectedCVE = cve; return settings; }); @@ -53,6 +52,18 @@ function createStore() { return settings; }); }, + setVulnerabilitiesSectionVisible: () => { + update((settings) => { + settings.ui.isVulnerabilisiesSectionVisible = true; + return settings; + }); + }, + setVulnerabilitiesSectionInvisible: () => { + update((settings) => { + settings.ui.isVulnerabilisiesSectionVisible = false; + return settings; + }); + }, reset: () => set({ ...appDefault }) }; }