From f103b6aa253d495bbdc2f17568c7a383e06d7090 Mon Sep 17 00:00:00 2001 From: Piyush Kumar Date: Thu, 14 Mar 2024 15:10:13 +0530 Subject: [PATCH 1/2] update copy button --- src/apps/console/components/commons.tsx | 12 ++++--- .../packages+/repos/repo-resources.tsx | 34 +++++++++++++------ 2 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/apps/console/components/commons.tsx b/src/apps/console/components/commons.tsx index f243b659a..8a37341b8 100644 --- a/src/apps/console/components/commons.tsx +++ b/src/apps/console/components/commons.tsx @@ -1,4 +1,4 @@ -import { CopySimple, Question } from '@jengaicons/react'; +import { CopySimple, Question, Check } from '@jengaicons/react'; import { ReactNode, useState } from 'react'; import { ProdLogo } from '~/components/branding/prod-logo'; import { WorkspacesLogo } from '~/components/branding/workspace-logo'; @@ -82,25 +82,27 @@ export const CopyButton = ({ title: ReactNode; value: string; }) => { - const [_, setCopyIcon] = useState(); + // const [_, setCopyIcon] = useState(); + const [copied, setCopied] = useState(false); const { copy } = useClipboard({ onSuccess: () => { setTimeout(() => { - setCopyIcon(); - }, 1000); + setCopied(false); + }, 4000); }, }); return (
{ + setCopied(true); copy(value); }} className="flex flex-row gap-md items-center select-none group cursor-pointer" > {title} - + {copied ? : }
); diff --git a/src/apps/console/routes/_main+/$account+/packages+/repos/repo-resources.tsx b/src/apps/console/routes/_main+/$account+/packages+/repos/repo-resources.tsx index 9f6dd1c9c..9161cba7e 100644 --- a/src/apps/console/routes/_main+/$account+/packages+/repos/repo-resources.tsx +++ b/src/apps/console/routes/_main+/$account+/packages+/repos/repo-resources.tsx @@ -1,4 +1,4 @@ -import { Copy, Trash } from '@jengaicons/react'; +import { Copy, Trash, Check } from '@jengaicons/react'; import { Link, useParams } from '@remix-run/react'; import { useState } from 'react'; import { toast } from '~/components/molecule/toast'; @@ -58,12 +58,20 @@ const ExtraButton = ({ onDelete }: { onDelete: () => void }) => { const RepoUrlView = ({ name }: { name: string }) => { const { account } = useParams(); - const { copy } = useClipboard({ - onSuccess() { - toast.success('Registry url copied successfully.'); - }, - }); + const { copy } = useClipboard({}); const url = `${registryHost}/${account}/${name}`; + const [copied, setCopied] = useState(false); + + const handleCopy = () => { + copy(url); + setCopied(true); + toast.success('Registry url copied successfully.'); + + setTimeout(() => { + setCopied(false); + }, 3000); + }; + return ( { onClick={(e) => { e.preventDefault(); e.stopPropagation(); - copy(url); + handleCopy(); }} title={url} > {url} - - - + {copied ? ( + + + + ) : ( + + + + )} } /> From 8c9ad8406e5cf6f6860cf24b5873498a9cd703a6 Mon Sep 17 00:00:00 2001 From: Piyush Kumar Date: Thu, 14 Mar 2024 15:13:36 +0530 Subject: [PATCH 2/2] update copy button --- src/apps/console/components/commons.tsx | 2 +- .../_main+/$account+/packages+/repos/repo-resources.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/apps/console/components/commons.tsx b/src/apps/console/components/commons.tsx index 8a37341b8..75ecf66bf 100644 --- a/src/apps/console/components/commons.tsx +++ b/src/apps/console/components/commons.tsx @@ -88,7 +88,7 @@ export const CopyButton = ({ onSuccess: () => { setTimeout(() => { setCopied(false); - }, 4000); + }, 1000); }, }); diff --git a/src/apps/console/routes/_main+/$account+/packages+/repos/repo-resources.tsx b/src/apps/console/routes/_main+/$account+/packages+/repos/repo-resources.tsx index 9161cba7e..235cdad01 100644 --- a/src/apps/console/routes/_main+/$account+/packages+/repos/repo-resources.tsx +++ b/src/apps/console/routes/_main+/$account+/packages+/repos/repo-resources.tsx @@ -80,7 +80,9 @@ const RepoUrlView = ({ name }: { name: string }) => { onClick={(e) => { e.preventDefault(); e.stopPropagation(); - handleCopy(); + if (!copied) { + handleCopy(); + } }} title={url} >