From 6d45409928eed1a1c58a6af0ad44a43b50d82a6a Mon Sep 17 00:00:00 2001 From: Sergio <77530549+sergi0g@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:59:42 +0300 Subject: [PATCH] Add copy pull command button to image info --- web/src/components/Image.tsx | 40 +++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/web/src/components/Image.tsx b/web/src/components/Image.tsx index a2c5182..09afe41 100644 --- a/web/src/components/Image.tsx +++ b/web/src/components/Image.tsx @@ -8,8 +8,10 @@ import { import { IconAlertTriangleFilled, IconArrowUpRight, + IconCheck, IconCircleArrowUpFilled, IconCircleCheckFilled, + IconCopy, IconCube, IconHelpCircleFilled, IconStopwatch, @@ -28,12 +30,23 @@ const clickable_registries = [ export default function Image({ data }: { data: Image }) { const [open, setOpen] = useState(false); + const [copySuccess, setCopySuccess] = useState(false); const handleOpen = () => { setOpen(true); }; const handleClose = () => { setOpen(false); }; + const handleCopy = (text: string) => { + return () => { + navigator.clipboard.writeText(text).then(() => { + setCopySuccess(true); + setTimeout(() => { + setCopySuccess(false); + }, 3000); + }); + }; + }; var url: string | null = null; if (clickable_registries.includes(data.parts.registry)) { switch (data.parts.registry) { @@ -142,11 +155,36 @@ export default function Image({ data }: { data: Image }) { Checked in {data.time} ms {data.result.error && ( -
+
{data.result.error}
)} + {data.result.has_update && ( +
+ Pull command +
+

+ docker pull {data.reference} +

+ {navigator.clipboard && + (copySuccess ? ( + + ) : ( + + ))} +
+
+ )}
Local digests