Skip to content

Commit

Permalink
feat: add copy button to ticket editor
Browse files Browse the repository at this point in the history
  • Loading branch information
aliraza556 committed Dec 18, 2024
1 parent fe52184 commit f5ba418
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/components/common/TicketEditor/TicketEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,29 @@ const TicketEditor = observer(
}
};

const handleCopy = async () => {
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'
}
]);
}
};

return (
<TicketContainer>
<EuiFlexGroup alignItems="center" gutterSize="s">
Expand Down Expand Up @@ -238,6 +261,14 @@ const TicketEditor = observer(
<EuiBadge color="success" style={{ marginBottom: '12px' }}>
Version {selectedVersion}
</EuiBadge>
<ActionButton
color="primary"
onClick={handleCopy}
style={{ marginLeft: 'auto', marginBottom: '35px' }}
data-testid="copy-description-btn"
>
Copy
</ActionButton>
</TicketHeaderInputWrap>
<TicketTextArea
value={versionTicketData.description}
Expand Down

0 comments on commit f5ba418

Please sign in to comment.