diff --git a/web/src/components/CodeBlock.tsx b/web/src/components/CodeBlock.tsx
new file mode 100644
index 0000000..c1c7fa2
--- /dev/null
+++ b/web/src/components/CodeBlock.tsx
@@ -0,0 +1,43 @@
+import { ReactNode, useState } from "react";
+import { theme } from "../theme";
+import { IconCheck, IconClipboard } from "@tabler/icons-react";
+
+export function CodeBlock({
+ children,
+ enableCopy,
+}: {
+ children: ReactNode;
+ enableCopy?: boolean;
+}) {
+ const [copySuccess, setCopySuccess] = useState(false);
+ const handleCopy = (text: string) => {
+ return () => {
+ navigator.clipboard.writeText(text).then(() => {
+ setCopySuccess(true);
+ setTimeout(() => {
+ setCopySuccess(false);
+ }, 3000);
+ });
+ };
+ };
+
+ return (
+
+
{children}
+ {enableCopy &&
+ navigator.clipboard &&
+ (copySuccess ? (
+
+ ) : (
+
+ ))}
+
+ );
+}
diff --git a/web/src/components/Image.tsx b/web/src/components/Image.tsx
index 968ff7c..a8fea52 100644
--- a/web/src/components/Image.tsx
+++ b/web/src/components/Image.tsx
@@ -17,7 +17,7 @@ import {
import { WithTooltip } from "./Tooltip";
import type { Image } from "../types";
import { theme } from "../theme";
-import { PullCommand } from "./PullCommand";
+import { CodeBlock } from "./CodeBlock";
const clickable_registries = [
"registry-1.docker.io",
@@ -125,7 +125,10 @@ export default function Image({ data }: { data: Image }) {
)}
{data.result.has_update && (
-
+
+ Pull command
+ {new_reference}
+
)}
{data.result.info?.type == "digest" && (
@@ -133,23 +136,15 @@ export default function Image({ data }: { data: Image }) {
{data.result.info.local_digests.length > 1
? "Local digests"
: "Local digest"}
-
-
- {data.result.info.local_digests.join("\n")}
-
-
+
+ {data.result.info.local_digests.join("\n")}
+
{data.result.info.remote_digest && (
Remote digest
-
-
- {data.result.info.remote_digest}
-
-
+
+ {data.result.info.remote_digest}
+
)}
>
diff --git a/web/src/components/PullCommand.tsx b/web/src/components/PullCommand.tsx
deleted file mode 100644
index e436b8b..0000000
--- a/web/src/components/PullCommand.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { useState } from "react";
-import { theme } from "../theme";
-import { IconCheck, IconClipboard } from "@tabler/icons-react";
-
-export function PullCommand({ reference }: { reference: string }) {
- const [copySuccess, setCopySuccess] = useState(false);
- const handleCopy = (text: string) => {
- return () => {
- navigator.clipboard.writeText(text).then(() => {
- setCopySuccess(true);
- setTimeout(() => {
- setCopySuccess(false);
- }, 3000);
- });
- };
- };
- return (
-
- Pull command
-
-
docker pull {reference}
- {navigator.clipboard &&
- (copySuccess ? (
-
- ) : (
-
- ))}
-
-
- );
-}