diff --git a/web/src/components/Image.tsx b/web/src/components/Image.tsx index 4e3a82a..bf3de6d 100644 --- a/web/src/components/Image.tsx +++ b/web/src/components/Image.tsx @@ -38,6 +38,7 @@ export default function Image({ data }: { data: Image }) { data.result.info?.type == "version" ? data.reference.split(":")[0] + ":" + data.result.info.new_tag : data.reference; + const info = getInfo(data)!; let url: string | null = null; if (clickable_registries.includes(data.parts.registry)) { switch (data.parts.registry) { @@ -57,7 +58,12 @@ export default function Image({ data }: { data: Image }) { > {data.reference} - + + + @@ -113,7 +119,8 @@ export default function Image({ data }: { data: Image }) {
- + + {info.description}
@@ -164,118 +171,54 @@ export default function Image({ data }: { data: Image }) { ); } -function Icon({ data }: { data: Image }) { +function getInfo(data: Image): + | { + color: string; + icon: typeof HelpCircle; + description: string; + } + | undefined { switch (data.result.has_update) { case null: - return ( - - - - ); + return { + color: "text-gray-500", + icon: HelpCircle, + description: "Unknown", + }; case false: - return ( - - - - ); + return { + color: "text-green-500", + icon: CircleCheck, + description: "Up to date", + }; case true: if (data.result.info?.type === "version") { switch (data.result.info.version_update_type) { case "major": - return ( - - - - ); + return { + color: "text-red-500", + icon: CircleArrowUp, + description: "Major update", + }; case "minor": - return ( - - - - ); + return { + color: "text-yellow-500", + icon: CircleArrowUp, + description: "Minor update", + }; case "patch": - return ( - - - - ); + return { + color: "text-blue-500", + icon: CircleArrowUp, + description: "Patch update", + }; } } else if (data.result.info?.type === "digest") { - return ( - - - - ); - } - } -} - -function DialogIcon({ data }: { data: Image }) { - switch (data.result.has_update) { - case null: - return ( - <> - - Unknown - - ); - case false: - return ( - <> - - Up to date - - ); - case true: - if (data.result.info?.type === "version") { - switch (data.result.info.version_update_type) { - case "major": - return ( - <> - - Major update - - ); - case "minor": - return ( - <> - - Minor update - - ); - case "patch": - return ( - <> - - Patch update - - ); - } - } else if (data.result.info?.type === "digest") { - return ( - <> - - Update available - - ); + return { + color: "text-blue-500", + icon: CircleArrowUp, + description: "Update available", + }; } } }