github.com/argoproj/argo-cd/v2@v2.10.9/ui/src/app/shared/components/clipboard-text.tsx (about) 1 import {Tooltip} from 'argo-ui'; 2 import * as React from 'react'; 3 import {useState} from 'react'; 4 5 export const ClipboardText = ({text}: {text: string}) => { 6 const [justClicked, setJustClicked] = useState<boolean>(false); 7 8 if (!text) { 9 return <></>; 10 } 11 12 return ( 13 <> 14 {text} 15 16 <Tooltip content={justClicked ? 'Copied!' : 'Copy to clipboard'}> 17 <a> 18 <i 19 className={'fa fa-clipboard'} 20 onClick={() => { 21 setJustClicked(true); 22 navigator.clipboard.writeText(text); 23 setInterval(() => setJustClicked(false), 2000); 24 }} 25 /> 26 </a> 27 </Tooltip> 28 </> 29 ); 30 };