Skip to content

Commit

Permalink
Merge pull request #7 from ether/add_plugin_version_update_info
Browse files Browse the repository at this point in the history
Add information about plugin version and if update is available
  • Loading branch information
Gared authored Sep 10, 2024
2 parents e47baad + 9c7a38a commit 97f7b85
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/pages/instances.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useEffect, useMemo, useState} from "react";
import axios, {AxiosError, AxiosResponse} from "axios";
import {Instance, InstancesResponse} from "@/types/InstancesResponse.ts";
import {Instance, InstancesResponse, PluginData} from "@/types/InstancesResponse.ts";
import {AlertTriangle, Check, NotepadText, PlusIcon} from 'lucide-react'

import {
Expand Down Expand Up @@ -69,6 +69,16 @@ export const Instances = () => {
return replacedVersion < "200"
}

const renderPluginInfo = (plugin: PluginData) => {
if (plugin.update_available) {
return <span className="text-red-700">
{plugin.name} (Update available: {plugin.version} => {plugin.latest_version})

Check failure on line 75 in src/pages/instances.tsx

View workflow job for this annotation

GitHub Actions / deploy

Unexpected token. Did you mean `{'>'}` or `&gt;`?
</span>
}

return <>{plugin.name} ({plugin.version})</>
}

if (!filteredInstances) return <LoadingSpinner/>

const dbFailures = (instance?.scan.db_reads_failed || 0) + (instance?.scan.db_writes_failed || 0)
Expand Down Expand Up @@ -225,8 +235,9 @@ export const Instances = () => {
<CardTitle>Plugins</CardTitle>
</CardHeader>
<CardContent className="">
<ul className="list-disc ml-5">{instance?.scan.plugins.map(p =>
<li key={p}>{p}</li>)}</ul>
<ul className="list-disc ml-5">{instance?.scan.plugin_data.map(p =>
<li key={p.name}>{renderPluginInfo(p)}</li>)}
</ul>
</CardContent>
</Card>
</div>
Expand Down
8 changes: 8 additions & 0 deletions src/types/InstancesResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ type ScanResult = {
version: string,
scan_time: string,
plugins: string[],
plugin_data: PluginData[],
websocket_available: boolean | null,
db_reads_failed: number,
db_writes_failed: number,
}

export type PluginData = {
name: string,
version: string,
latest_version: string | null,
update_available: boolean,
}

0 comments on commit 97f7b85

Please sign in to comment.