Skip to content

Commit

Permalink
feat: Add revision history
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Junk committed Sep 4, 2023
1 parent 45c2b25 commit 99aeff7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
23 changes: 23 additions & 0 deletions src/lib/singleview/general/General.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,29 @@
</dl>
</div>

{#if $appStore.doc?.isRevisionHistoryPresent}
<div>
<h3>Revision History</h3>
<table class="striped">
<thead>
<tr
><th>date</th>
<th>number</th>
<th>summary</th>
<th>legacy_version</th>
</tr>
</thead>
<tbody>
{#each $appStore.doc?.revisionHistory as entry}
<td>{entry.date}</td><td>{entry.number}</td><td>{entry.summary}</td><td
>{#if entry.legacyVersion}{entry.legacyVersion}{/if}</td
>
{/each}
</tbody>
</table>
</div>
{/if}

<style>
dt {
font-size: large;
Expand Down
16 changes: 14 additions & 2 deletions src/lib/singleview/general/docmodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
Status,
EMPTY,
CSAFDocProps,
type Publisher
type Publisher,
type RevisionHistoryEntry
} from "$lib/singleview/general/docmodeltypes";

const checkDocumentPresent = (csafDoc: any): boolean => {
Expand Down Expand Up @@ -138,6 +139,17 @@ const getVulnerabilities = (csafDoc: any) => {
return csafDoc.vulnerabilities;
};

const getRevisionHistory = (csafDoc: any): RevisionHistoryEntry[] => {
if (!checkRevisionHistoryPresent(csafDoc)) return [];
const result: RevisionHistoryEntry[] = csafDoc.document.tracking[CSAFDocProps.REVISIONHISTORY];
result.sort((entry1: RevisionHistoryEntry, entry2: RevisionHistoryEntry) => {
if (entry1.date < entry2.date) return -1;
if (entry1.date > entry2.date) return 1;
return 0;
});
return result;
};

const convertToDocModel = (csafDoc: any): DocModel => {
const docModel: DocModel = {
title: getTitle(csafDoc),
Expand All @@ -150,7 +162,7 @@ const convertToDocModel = (csafDoc: any): DocModel => {
published: getPublished(csafDoc),
publisher: getPublisher(csafDoc),
trackingVersion: getTrackingVersion(csafDoc),
revisionHistory: [],
revisionHistory: getRevisionHistory(csafDoc),
lastUpdate: getLastUpdate(csafDoc),
vulnerabilities: getVulnerabilities(csafDoc),
productVulnerabilities: [],
Expand Down

0 comments on commit 99aeff7

Please sign in to comment.