feat(task-context-menu): add copy link functionality and update translations

- Implemented a new "Copy link to task" feature in the task context menu, allowing users to easily copy task links to the clipboard.
- Added corresponding success and error messages for link copying.
- Updated localization files for Albanian, German, English, Spanish, Portuguese, and Chinese to include new translation keys for the copy link feature.
This commit is contained in:
chamikaJ
2025-07-29 12:49:51 +05:30
parent c2b231d5cc
commit 29b8c1b2af
8 changed files with 50 additions and 1 deletions

View File

@@ -32,6 +32,8 @@ import {
RetweetOutlined,
UserAddOutlined,
LoadingOutlined,
CopyOutlined,
message,
} from '@/shared/antd-imports';
interface TaskContextMenuProps {
@@ -325,6 +327,21 @@ const TaskContextMenu: React.FC<TaskContextMenuProps> = ({
}
}, [task?.id, projectId, dispatch, onClose]);
const handleCopyLink = useCallback(async () => {
if (!projectId || !task.id) return;
try {
const taskLink = `${window.location.origin}/worklenz/projects/${projectId}?tab=tasks-list&pinned_tab=tasks-list&task=${task.id}`;
await navigator.clipboard.writeText(taskLink);
message.success(t('contextMenu.linkCopied'));
} catch (error) {
logger.error('Error copying link:', error);
message.error(t('contextMenu.linkCopyFailed'));
} finally {
onClose();
}
}, [projectId, task.id, onClose, t]);
const menuItems = useMemo(() => {
const items = [
{
@@ -344,6 +361,18 @@ const TaskContextMenu: React.FC<TaskContextMenuProps> = ({
</button>
),
},
{
key: 'copyLink',
label: (
<button
onClick={handleCopyLink}
className="flex items-center gap-2 px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 w-full text-left"
>
<CopyOutlined className="text-gray-500 dark:text-gray-400" />
<span>{t('contextMenu.copyLink')}</span>
</button>
),
},
];
// Add Move To submenu if there are options
@@ -500,6 +529,7 @@ const TaskContextMenu: React.FC<TaskContextMenuProps> = ({
handleArchive,
handleDelete,
handleConvertToTask,
handleCopyLink,
getMoveToOptions,
dispatch,
t,

View File

@@ -182,7 +182,8 @@ export {
InfoCircleOutlined,
WarningTwoTone,
ShareAltOutlined,
CloudDownloadOutlined
CloudDownloadOutlined,
CopyOutlined
} from '@ant-design/icons';
// Re-export all components with React