Skip to content

Commit

Permalink
refactor: factor out URL loading mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Junk committed Nov 15, 2023
1 parent cad8cce commit da206b5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 125 deletions.
16 changes: 8 additions & 8 deletions src/lib/feedview/Loader.svelte → src/lib/UrlLoader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
-->

<script lang="ts">
import { appStore } from "$lib/store";
import { goto } from "$app/navigation";
import { onMount } from "svelte";
import { page } from "$app/stores";
import { base } from "$app/paths";
export let baseroute: string;
export let tooltiptext: string;
export let errormessage: string;
let url = "";
/**
* onMount set url if given via query param.
Expand All @@ -28,7 +29,7 @@
* load loads provider metadata / feed and reroute to given URL.
*/
const load = () => {
goto(`${base}/feed?q=${url}`);
goto(baseroute + url);
};
/**
Expand All @@ -42,7 +43,7 @@

<div class="row">
<div class="col-12 outline">
<div class="urlcontainer" title="URL to fetch Advisory from">
<div class="urlcontainer" title={tooltiptext}>
<span class="prepend">
<i class="bx bx-file" />
<span class="prependtext">URL</span>
Expand All @@ -60,11 +61,10 @@
</div>
</div>
</div>
{#if $appStore.ui.feedErrorMsg}
{#if errormessage}
<div class="row">
<div class="col-6 col-3-lg" />
<div class="col-6 col-9-lg">
<div class="errors text-error">{$appStore.ui.feedErrorMsg}</div>
<div class="col">
<div class="errors text-error">{errormessage}</div>
</div>
</div>
{/if}
Expand Down
9 changes: 7 additions & 2 deletions src/lib/feedview/FeedView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@
import Back from "$lib/Back.svelte";
import Collapsible from "$lib/Collapsible.svelte";
import Feed from "./feed/Feed.svelte";
import Loader from "./Loader.svelte";
import Overview from "./feed/Overview.svelte";
import UrlLoader from "$lib/UrlLoader.svelte";
import { base } from "$app/paths";
</script>

<Loader />
<UrlLoader
baseroute={`${base}/feed?q=`}
tooltiptext={"URL to fetch provider metadata or ROLIE-feed"}
errormessage={$appStore.ui.feedErrorMsg}
/>
<Overview />
{#if $appStore.currentFeed}
<Collapsible
Expand Down
113 changes: 0 additions & 113 deletions src/lib/singleview/LoadFromURL.svelte

This file was deleted.

9 changes: 7 additions & 2 deletions src/lib/singleview/SingleView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
import Collapsible from "$lib/Collapsible.svelte";
import Droparea from "$lib/singleview/Droparea.svelte";
import General from "$lib/singleview/general/General.svelte";
import LoadFromUrl from "./LoadFromURL.svelte";
import ProductTree from "./producttree/ProductTree.svelte";
import ProductVulnerabilities from "$lib/singleview/productvulnerabilities/ProductVulnerabilities.svelte";
import Upload from "./Upload.svelte";
import Vulnerabilities from "./vulnerabilities/Vulnerabilities.svelte";
import UrlLoader from "$lib/UrlLoader.svelte";
import { base } from "$app/paths";
$: isCSAF = !(
!$appStore.doc?.isRevisionHistoryPresent &&
!$appStore.doc?.isDocPresent &&
Expand All @@ -30,7 +31,11 @@
</script>

<div class="loadfromurl">
<LoadFromUrl />
<UrlLoader
baseroute={`${base}/?q=`}
tooltiptext={"URL to fetch Advisory from"}
errormessage={$appStore.ui.singleErrorMsg}
/>
</div>
<div class="row">
<div class="col-6 col-3-lg">
Expand Down

0 comments on commit da206b5

Please sign in to comment.