Skip to content

Commit

Permalink
refactor: reorganizing components
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Junk committed Sep 4, 2023
1 parent 2cde21e commit 45c2b25
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
-->
<script lang="ts">
import { appStore } from "$lib/store";
import { convertToDocModel } from "$lib/singleview/docmodel/docmodel";
import { generateProductVulnerabilities } from "../productvulnerabilities/productvulnerabilities";
import { convertToDocModel } from "$lib/singleview/general/docmodel";
import { generateProductVulnerabilities } from "./productvulnerabilities/productvulnerabilities";
let hover: boolean = false;
let valid: boolean | null = null;
Expand Down
10 changes: 5 additions & 5 deletions src/lib/singleview/SingleView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
<script lang="ts">
import { appStore } from "$lib/store";
import Collapsible from "$lib/Collapsible.svelte";
import General from "$lib/singleview/components/General.svelte";
import Droparea from "$lib/singleview/components/Droparea.svelte";
import ProductVulnerabilities from "$lib/singleview/components/ProductVulnerabilities.svelte";
import Vulnerabilities from "./components/vulnerabilities/Vulnerabilities.svelte";
import { CSAFDocProps, DocumentCategory } from "./docmodel/docmodeltypes";
import General from "$lib/singleview/general/General.svelte";
import Droparea from "$lib/singleview/Droparea.svelte";
import ProductVulnerabilities from "$lib/singleview/productvulnerabilities/ProductVulnerabilities.svelte";
import Vulnerabilities from "./vulnerabilities/Vulnerabilities.svelte";
import { CSAFDocProps, DocumentCategory } from "./general/docmodeltypes";
$: isDocumentASecurityAdvisory =
$appStore.doc &&
$appStore.doc[CSAFDocProps.CATEGORY] === DocumentCategory.CSAF_SECURITY_ADVISORY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Software-Engineering: 2023 Intevation GmbH <https://intevation.de
-->
<script lang="ts">
import { Status, TLP } from "$lib/singleview/docmodel/docmodeltypes";
import { Status, TLP } from "$lib/singleview/general/docmodeltypes";
import { appStore } from "$lib/store";
let tlpStyle: string = "";
$: trackingVersion = $appStore.doc?.trackingVersion;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
// Software-Engineering: 2023 Intevation GmbH <https://intevation.de>

import { describe, it, expect } from "vitest";
import { convertToDocModel } from "$lib/singleview/docmodel/docmodel";
import { convertToDocModel } from "$lib/singleview/general/docmodel";
import {
EMPTY,
Status,
CSAFDocProps,
type DocModel,
type DocModelKey,
TLP
} from "$lib/singleview/docmodel/docmodeltypes";
} from "$lib/singleview/general/docmodeltypes";

const allEmpty = (docModel: DocModel, properties: DocModelKey[]) => {
properties.forEach((p) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
EMPTY,
CSAFDocProps,
type Publisher
} from "$lib/singleview/docmodel/docmodeltypes";
} from "$lib/singleview/general/docmodeltypes";

const checkDocumentPresent = (csafDoc: any): boolean => {
return csafDoc.hasOwnProperty(CSAFDocProps.DOCUMENT);
Expand Down Expand Up @@ -43,6 +43,10 @@ const checkVulnerabilities = (csafDoc: any): boolean => {
return csafDoc.hasOwnProperty(CSAFDocProps.VULNERABILITIES);
};

const checkRevisionHistoryPresent = (csafDoc: any): boolean => {
return checkTrackingPresent(csafDoc) && csafDoc.document.tracking[CSAFDocProps.REVISIONHISTORY];
};

const getTitle = (csafDoc: any): string => {
if (!checkDocumentPresent(csafDoc)) return EMPTY;
return csafDoc.document[CSAFDocProps.TITLE] || EMPTY;
Expand Down Expand Up @@ -155,7 +159,8 @@ const convertToDocModel = (csafDoc: any): DocModel => {
isDistributionPresent: checkDistributionPresent(csafDoc),
isTLPPresent: checkTLPPresent(csafDoc),
isPublisherPresent: checkPublisher(csafDoc),
isVulnerabilitiesPresent: checkVulnerabilities(csafDoc)
isVulnerabilitiesPresent: checkVulnerabilities(csafDoc),
isRevisionHistoryPresent: checkRevisionHistoryPresent(csafDoc)
};
return docModel;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type Publisher = {

export type RevisionHistoryEntry = {
date: string;
legacyVersion?: string;
number: number;
summary: string;
};
Expand All @@ -88,6 +89,7 @@ export type DocModel = {
isTLPPresent: boolean;
isPublisherPresent: boolean;
isVulnerabilitiesPresent: boolean;
isRevisionHistoryPresent: boolean;
};

export type DocModelKey = keyof DocModel;
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<script lang="ts">
import { appStore } from "$lib/store";
import { ProductStatusSymbol } from "../productvulnerabilities/productvulnerabilitiestypes";
import { ProductStatusSymbol } from "./productvulnerabilitiestypes";
let headerColumns: string[] = [];
let productLines: string[][];
$: if ($appStore.doc) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Software-Engineering: 2023 Intevation GmbH <https://intevation.de>

import { writable } from "svelte/store";
import type { DocModel } from "./singleview/docmodel/docmodeltypes";
import type { DocModel } from "./singleview/general/docmodeltypes";

type AppStore = {
doc: DocModel | null;
Expand Down

0 comments on commit 45c2b25

Please sign in to comment.