diff --git a/src/components/common/TicketEditor/TicketEditor.tsx b/src/components/common/TicketEditor/TicketEditor.tsx index ed69d39c..40563fda 100644 --- a/src/components/common/TicketEditor/TicketEditor.tsx +++ b/src/components/common/TicketEditor/TicketEditor.tsx @@ -10,7 +10,11 @@ import { EuiBadge } from '@elastic/eui'; import { phaseTicketStore } from '../../../store/phase'; -import { ActionButton, TicketButtonGroup } from '../../../people/widgetViews/workspace/style'; +import { + ActionButton, + CopyButtonGroup, + TicketButtonGroup +} from '../../../people/widgetViews/workspace/style'; import { TicketContainer, TicketHeader, @@ -49,6 +53,7 @@ const TicketEditor = observer( ); const [selectedVersion, setSelectedVersion] = useState(latestTicket?.version as number); const [versionTicketData, setVersionTicketData] = useState(latestTicket as Ticket); + const [isCopying, setIsCopying] = useState(false); const { main } = useStores(); const groupTickets = useMemo( @@ -207,6 +212,33 @@ const TicketEditor = observer( } } }; + const handleCopy = async () => { + if (isCopying) return; + + setIsCopying(true); + try { + await navigator.clipboard.writeText(versionTicketData.description); + setToasts([ + { + id: `${Date.now()}-copy-success`, + title: 'Hive', + color: 'success', + text: 'Description copied to clipboard!' + } + ]); + } catch (err) { + setToasts([ + { + id: `${Date.now()}-copy-error`, + title: 'Hive', + color: 'danger', + text: 'Failed to copy description' + } + ]); + } finally { + setIsCopying(false); + } + }; return ( @@ -238,6 +270,16 @@ const TicketEditor = observer( Version {selectedVersion} + + + Copy + +