From cbf83a55ff3a9a69873d29519c1502e9a3602df0 Mon Sep 17 00:00:00 2001 From: Denis Maslennikov <41147528+disant1@users.noreply.github.com> Date: Fri, 16 Dec 2022 14:10:52 +0700 Subject: [PATCH] Add copy link button to notification (#2444) Signed-off-by: Denis Maslennikov <denis.maslennikov@gmail.com> --- .../src/components/CreateIssue.svelte | 5 ++-- .../issues/IssueNotification.svelte | 26 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/plugins/tracker-resources/src/components/CreateIssue.svelte b/plugins/tracker-resources/src/components/CreateIssue.svelte index 0d4aa68c20..0b02dabd4f 100644 --- a/plugins/tracker-resources/src/components/CreateIssue.svelte +++ b/plugins/tracker-resources/src/components/CreateIssue.svelte @@ -70,7 +70,7 @@ import view from '@hcengineering/view' import { ObjectBox } from '@hcengineering/view-resources' import { createEventDispatcher } from 'svelte' - import { activeProject, activeSprint, updateIssueRelation } from '../issues' + import { activeProject, activeSprint, generateIssueShortLink, getIssueId, updateIssueRelation } from '../issues' import tracker from '../plugin' import AssigneeEditor from './issues/AssigneeEditor.svelte' import ParentIssue from './issues/ParentIssue.svelte' @@ -555,7 +555,8 @@ addNotification(tracker.string.IssueCreated, getTitle(object.title), IssueNotification, { issueId: objectId, - subTitlePostfix: (await translate(tracker.string.Created, { value: 1 })).toLowerCase() + subTitlePostfix: (await translate(tracker.string.Created, { value: 1 })).toLowerCase(), + issueUrl: currentTeam && generateIssueShortLink(getIssueId(currentTeam, value as Issue)) }) objectId = generateId() diff --git a/plugins/tracker-resources/src/components/issues/IssueNotification.svelte b/plugins/tracker-resources/src/components/issues/IssueNotification.svelte index 5652aa8bdf..01d1875309 100644 --- a/plugins/tracker-resources/src/components/issues/IssueNotification.svelte +++ b/plugins/tracker-resources/src/components/issues/IssueNotification.svelte @@ -11,7 +11,7 @@ Label, showPanel } from '@hcengineering/ui' - import { createQuery } from '@hcengineering/presentation' + import { copyTextToClipboard, createQuery } from '@hcengineering/presentation' import { Issue, IssueStatus } from '@hcengineering/tracker' import IssueStatusIcon from './IssueStatusIcon.svelte' @@ -79,6 +79,11 @@ onRemove() } + const handleCopyUrl = () => { + if (issue) { + copyTextToClipboard(params?.issueUrl) + } + } </script> <div class="root" in:fade out:fade> @@ -104,8 +109,18 @@ </div> </div> </div> - <div class="view-issue-button"> - <Button label={tracker.string.ViewIssue} kind="link" size="medium" on:click={handleIssueOpened} /> + <div class="row"> + <div class="view-issue-button"> + <Button label={tracker.string.ViewIssue} kind="link" size="medium" on:click={handleIssueOpened} /> + </div> + <div class="copy-link-button"> + <Button + icon={tracker.icon.CopyURL} + kind={'link'} + label={tracker.string.CopyIssueUrl} + on:click={handleCopyUrl} + /> + </div> </div> </div> @@ -152,6 +167,11 @@ margin-left: -5px; } + .copy-link-button { + margin-top: 10px; + margin-left: 5px; + } + .title { display: flex; align-items: center;