From 28a6776412fd7e2edc9da4fb5ea0f807d3de96be Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Thu, 16 Feb 2023 18:24:59 +0530 Subject: [PATCH 1/4] feat: copy issue link added in issue card --- .../core/board-view/single-issue.tsx | 25 ++++++++++++++++++- .../core/list-view/single-issue.tsx | 25 ++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/apps/app/components/core/board-view/single-issue.tsx b/apps/app/components/core/board-view/single-issue.tsx index a19c683e2be..ccaa5557f9a 100644 --- a/apps/app/components/core/board-view/single-issue.tsx +++ b/apps/app/components/core/board-view/single-issue.tsx @@ -37,6 +37,8 @@ import { } from "types"; // fetch-keys import { CYCLE_ISSUES, MODULE_ISSUES, PROJECT_ISSUES_LIST } from "constants/fetch-keys"; +import { copyTextToClipboard } from "helpers/string.helper"; +import useToast from "hooks/use-toast"; type Props = { type?: string; @@ -69,7 +71,7 @@ export const SingleBoardIssue: React.FC = ({ }) => { const router = useRouter(); const { workspaceSlug, projectId, cycleId, moduleId } = router.query; - + const { setToastAlert } = useToast(); const partialUpdateIssue = useCallback( (formData: Partial) => { if (!workspaceSlug || !projectId) return; @@ -187,6 +189,27 @@ export const SingleBoardIssue: React.FC = ({ */} {type && !isNotAllowed && ( + + copyTextToClipboard( + `https://app.plane.so/${workspaceSlug}/projects/${projectId}/issues/${issue.id}` + ) + .then(() => { + setToastAlert({ + type: "success", + title: "Issue link copied to clipboard", + }); + }) + .catch(() => { + setToastAlert({ + type: "error", + title: "Some error occurred", + }); + }) + } + > + Copy issue link + Edit {type !== "issue" && removeIssue && ( diff --git a/apps/app/components/core/list-view/single-issue.tsx b/apps/app/components/core/list-view/single-issue.tsx index b779db59470..b8fce3c106a 100644 --- a/apps/app/components/core/list-view/single-issue.tsx +++ b/apps/app/components/core/list-view/single-issue.tsx @@ -27,6 +27,8 @@ import { } from "types"; // fetch-keys import { CYCLE_ISSUES, MODULE_ISSUES, PROJECT_ISSUES_LIST, STATE_LIST } from "constants/fetch-keys"; +import { copyTextToClipboard } from "helpers/string.helper"; +import useToast from "hooks/use-toast"; type Props = { type?: string; @@ -49,7 +51,7 @@ export const SingleListIssue: React.FC = ({ }) => { const router = useRouter(); const { workspaceSlug, projectId, cycleId, moduleId } = router.query; - + const { setToastAlert } = useToast(); const partialUpdateIssue = useCallback( (formData: Partial) => { if (!workspaceSlug || !projectId) return; @@ -181,6 +183,27 @@ export const SingleListIssue: React.FC = ({ )} {type && !isNotAllowed && ( + + copyTextToClipboard( + `https://app.plane.so/${workspaceSlug}/projects/${projectId}/issues/${issue.id}` + ) + .then(() => { + setToastAlert({ + type: "success", + title: "Issue link copied to clipboard", + }); + }) + .catch(() => { + setToastAlert({ + type: "error", + title: "Some error occurred", + }); + }) + } + > + Copy issue link + Edit {type !== "issue" && removeIssue && ( From 35d52a186898c6184e0f8576d353a84d644e4740 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Thu, 16 Feb 2023 18:46:00 +0530 Subject: [PATCH 2/4] feat: copy cycle link added --- .../project/cycles/stats-view/single-stat.tsx | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/apps/app/components/project/cycles/stats-view/single-stat.tsx b/apps/app/components/project/cycles/stats-view/single-stat.tsx index 33bc18b055c..b8c5c51387d 100644 --- a/apps/app/components/project/cycles/stats-view/single-stat.tsx +++ b/apps/app/components/project/cycles/stats-view/single-stat.tsx @@ -21,6 +21,8 @@ import { groupBy } from "helpers/array.helper"; import { CycleIssueResponse, ICycle } from "types"; // fetch-keys import { CYCLE_ISSUES } from "constants/fetch-keys"; +import { copyTextToClipboard } from "helpers/string.helper"; +import useToast from "hooks/use-toast"; type TSingleStatProps = { cycle: ICycle; @@ -43,6 +45,7 @@ const SingleStat: React.FC = (props) => { const router = useRouter(); const { workspaceSlug, projectId } = router.query; + const { setToastAlert } = useToast(); const { data: cycleIssues } = useSWR( workspaceSlug && projectId && cycle.id ? CYCLE_ISSUES(cycle.id as string) : null, @@ -77,6 +80,27 @@ const SingleStat: React.FC = (props) => { + + copyTextToClipboard( + `https://app.plane.so/${workspaceSlug}/projects/${projectId}/cycles/${cycle.id}` + ) + .then(() => { + setToastAlert({ + type: "success", + title: "Cycle link copied to clipboard", + }); + }) + .catch(() => { + setToastAlert({ + type: "error", + title: "Some error occurred", + }); + }) + } + > + Copy cycle link + Edit cycle Delete cycle permanently From 499263cda607503aaf2df9f6f48b887794b8cf54 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Fri, 17 Feb 2023 10:58:29 +0530 Subject: [PATCH 3/4] feat: ellipsis added in module card --- .../components/modules/single-module-card.tsx | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/apps/app/components/modules/single-module-card.tsx b/apps/app/components/modules/single-module-card.tsx index a53fc435343..0c7627c0d96 100644 --- a/apps/app/components/modules/single-module-card.tsx +++ b/apps/app/components/modules/single-module-card.tsx @@ -6,7 +6,7 @@ import { useRouter } from "next/router"; // components import { DeleteModuleModal } from "components/modules"; // ui -import { AssigneesList, Avatar } from "components/ui"; +import { AssigneesList, Avatar, CustomMenu } from "components/ui"; // icons import { CalendarDaysIcon, TrashIcon } from "@heroicons/react/24/outline"; // helpers @@ -15,6 +15,8 @@ import { renderShortNumericDateFormat } from "helpers/date-time.helper"; import { IModule } from "types"; // common import { MODULE_STATUS } from "constants/module"; +import useToast from "hooks/use-toast"; +import { copyTextToClipboard } from "helpers/string.helper"; type Props = { module: IModule; @@ -24,7 +26,8 @@ export const SingleModuleCard: React.FC = ({ module }) => { const [moduleDeleteModal, setModuleDeleteModal] = useState(false); const router = useRouter(); - const { workspaceSlug } = router.query; + const { workspaceSlug, projectId } = router.query; + const { setToastAlert } = useToast(); const handleDeleteModule = () => { if (!module) return; @@ -40,14 +43,33 @@ export const SingleModuleCard: React.FC = ({ module }) => { data={module} />
-
- +
+ + + copyTextToClipboard( + `https://app.plane.so/${workspaceSlug}/projects/${projectId}/modules/${module.id}` + ) + .then(() => { + setToastAlert({ + type: "success", + title: "Module link copied to clipboard", + }); + }) + .catch(() => { + setToastAlert({ + type: "error", + title: "Some error occurred", + }); + }) + } + > + Copy module link + + + Delete module permanently + +
From 4b0673c916fb07ad72fffec4e8f9e70179f40b3c Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Fri, 17 Feb 2023 13:42:56 +0530 Subject: [PATCH 4/4] fix: origin path and handlecopytext added --- .../core/board-view/single-issue.tsx | 39 +++++++++--------- .../core/list-view/single-issue.tsx | 39 +++++++++--------- .../components/modules/single-module-card.tsx | 40 +++++++++---------- .../project/cycles/stats-view/single-stat.tsx | 40 +++++++++---------- 4 files changed, 74 insertions(+), 84 deletions(-) diff --git a/apps/app/components/core/board-view/single-issue.tsx b/apps/app/components/core/board-view/single-issue.tsx index ccaa5557f9a..5762eb0e395 100644 --- a/apps/app/components/core/board-view/single-issue.tsx +++ b/apps/app/components/core/board-view/single-issue.tsx @@ -161,6 +161,23 @@ export const SingleBoardIssue: React.FC = ({ }; } + const handleCopyText = () => { + const originURL = + typeof window !== "undefined" && window.location.origin ? window.location.origin : ""; + copyTextToClipboard(`${originURL}/${workspaceSlug}/projects/${projectId}/issues/${issue.id}`) + .then(() => { + setToastAlert({ + type: "success", + title: "Issue link copied to clipboard", + }); + }) + .catch(() => { + setToastAlert({ + type: "error", + title: "Some error occurred", + }); + }); + }; const isNotAllowed = userAuth.isGuest || userAuth.isViewer; useEffect(() => { @@ -189,27 +206,7 @@ export const SingleBoardIssue: React.FC = ({ */} {type && !isNotAllowed && ( - - copyTextToClipboard( - `https://app.plane.so/${workspaceSlug}/projects/${projectId}/issues/${issue.id}` - ) - .then(() => { - setToastAlert({ - type: "success", - title: "Issue link copied to clipboard", - }); - }) - .catch(() => { - setToastAlert({ - type: "error", - title: "Some error occurred", - }); - }) - } - > - Copy issue link - + Copy issue link Edit {type !== "issue" && removeIssue && ( diff --git a/apps/app/components/core/list-view/single-issue.tsx b/apps/app/components/core/list-view/single-issue.tsx index b8fce3c106a..9472ccd9beb 100644 --- a/apps/app/components/core/list-view/single-issue.tsx +++ b/apps/app/components/core/list-view/single-issue.tsx @@ -125,6 +125,23 @@ export const SingleListIssue: React.FC = ({ [workspaceSlug, projectId, cycleId, moduleId, issue] ); + const handleCopyText = () => { + const originURL = + typeof window !== "undefined" && window.location.origin ? window.location.origin : ""; + copyTextToClipboard(`${originURL}/${workspaceSlug}/projects/${projectId}/issues/${issue.id}`) + .then(() => { + setToastAlert({ + type: "success", + title: "Issue link copied to clipboard", + }); + }) + .catch(() => { + setToastAlert({ + type: "error", + title: "Some error occurred", + }); + }); + }; const isNotAllowed = userAuth.isGuest || userAuth.isViewer; return ( @@ -183,27 +200,7 @@ export const SingleListIssue: React.FC = ({ )} {type && !isNotAllowed && ( - - copyTextToClipboard( - `https://app.plane.so/${workspaceSlug}/projects/${projectId}/issues/${issue.id}` - ) - .then(() => { - setToastAlert({ - type: "success", - title: "Issue link copied to clipboard", - }); - }) - .catch(() => { - setToastAlert({ - type: "error", - title: "Some error occurred", - }); - }) - } - > - Copy issue link - + Copy issue link Edit {type !== "issue" && removeIssue && ( diff --git a/apps/app/components/modules/single-module-card.tsx b/apps/app/components/modules/single-module-card.tsx index 0c7627c0d96..d086fe682ad 100644 --- a/apps/app/components/modules/single-module-card.tsx +++ b/apps/app/components/modules/single-module-card.tsx @@ -35,6 +35,24 @@ export const SingleModuleCard: React.FC = ({ module }) => { setModuleDeleteModal(true); }; + const handleCopyText = () => { + const originURL = + typeof window !== "undefined" && window.location.origin ? window.location.origin : ""; + copyTextToClipboard(`${originURL}/${workspaceSlug}/projects/${projectId}/modules/${module.id}`) + .then(() => { + setToastAlert({ + type: "success", + title: "Module link copied to clipboard", + }); + }) + .catch(() => { + setToastAlert({ + type: "error", + title: "Some error occurred", + }); + }); + }; + return ( <> = ({ module }) => {
- - copyTextToClipboard( - `https://app.plane.so/${workspaceSlug}/projects/${projectId}/modules/${module.id}` - ) - .then(() => { - setToastAlert({ - type: "success", - title: "Module link copied to clipboard", - }); - }) - .catch(() => { - setToastAlert({ - type: "error", - title: "Some error occurred", - }); - }) - } - > - Copy module link - + Copy module link Delete module permanently diff --git a/apps/app/components/project/cycles/stats-view/single-stat.tsx b/apps/app/components/project/cycles/stats-view/single-stat.tsx index b8c5c51387d..ff74b714a1c 100644 --- a/apps/app/components/project/cycles/stats-view/single-stat.tsx +++ b/apps/app/components/project/cycles/stats-view/single-stat.tsx @@ -66,6 +66,24 @@ const SingleStat: React.FC = (props) => { ...groupBy(cycleIssues ?? [], "issue_detail.state_detail.group"), }; + const handleCopyText = () => { + const originURL = + typeof window !== "undefined" && window.location.origin ? window.location.origin : ""; + copyTextToClipboard(`${originURL}/${workspaceSlug}/projects/${projectId}/cycles/${cycle.id}`) + .then(() => { + setToastAlert({ + type: "success", + title: "Cycle link copied to clipboard", + }); + }) + .catch(() => { + setToastAlert({ + type: "error", + title: "Some error occurred", + }); + }); + }; + return ( <>
@@ -80,27 +98,7 @@ const SingleStat: React.FC = (props) => { - - copyTextToClipboard( - `https://app.plane.so/${workspaceSlug}/projects/${projectId}/cycles/${cycle.id}` - ) - .then(() => { - setToastAlert({ - type: "success", - title: "Cycle link copied to clipboard", - }); - }) - .catch(() => { - setToastAlert({ - type: "error", - title: "Some error occurred", - }); - }) - } - > - Copy cycle link - + Copy cycle link Edit cycle Delete cycle permanently