From 80b3120f524e62543bc8e1de11fbcaf10b06de47 Mon Sep 17 00:00:00 2001 From: Milan <111341101+milan-deepfence@users.noreply.github.com> Date: Tue, 18 Jun 2024 10:58:32 +0530 Subject: [PATCH] Remove duplicate copy button (#2205) remove duplicate copy button --- .../src/components/CopyToClipboard.tsx | 47 +++++++++++++++++++ .../malwares/pages/MalwareDetailModal.tsx | 43 +++-------------- .../pages/PostureCloudDetailModal.tsx | 43 +++-------------- .../postures/pages/PostureDetailModal.tsx | 43 +++-------------- .../secrets/pages/SecretDetailModal.tsx | 43 +++-------------- .../settings/pages/UserManagement.tsx | 24 +--------- .../pages/VulnerabilityDetailModal.tsx | 43 +++-------------- 7 files changed, 79 insertions(+), 207 deletions(-) diff --git a/deepfence_frontend/apps/dashboard/src/components/CopyToClipboard.tsx b/deepfence_frontend/apps/dashboard/src/components/CopyToClipboard.tsx index c63b806e31..03a36ed8a9 100644 --- a/deepfence_frontend/apps/dashboard/src/components/CopyToClipboard.tsx +++ b/deepfence_frontend/apps/dashboard/src/components/CopyToClipboard.tsx @@ -1,5 +1,10 @@ import { useEffect, useRef, useState } from 'react'; import { useCopyToClipboard } from 'react-use'; +import { cn } from 'tailwind-preset'; +import { IconButton } from 'ui-components'; + +import { CheckIcon } from '@/components/icons/common/Check'; +import { CopyLineIcon } from '@/components/icons/common/CopyLine'; export function useCopyToClipboardState() { const [_, copyToClipboard] = useCopyToClipboard(); @@ -26,3 +31,45 @@ export function useCopyToClipboardState() { isCopied: isCopied, }; } + +export const CopyButton = ({ + value, + className, + iconStyle, +}: { + value: string; + className?: string; + iconStyle?: string; +}) => { + const { copy, isCopied } = useCopyToClipboardState(); + + return ( +