diff --git a/apps/app/components/core/board-view/single-issue.tsx b/apps/app/components/core/board-view/single-issue.tsx index a19c683e2..5762eb0e3 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; @@ -159,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(() => { @@ -187,6 +206,7 @@ export const SingleBoardIssue: React.FC = ({ */} {type && !isNotAllowed && ( + 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 b779db594..9472ccd9b 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; @@ -123,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 ( @@ -181,6 +200,7 @@ export const SingleListIssue: React.FC = ({ )} {type && !isNotAllowed && ( + 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 a53fc4353..d086fe682 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; @@ -32,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 }) => { data={module} />
-
- +
+ + 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 33bc18b05..ff74b714a 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, @@ -63,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 ( <>
@@ -77,6 +98,7 @@ const SingleStat: React.FC = (props) => { + Copy cycle link Edit cycle Delete cycle permanently