-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: copy link option #292
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<Props> = ({ 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<Props> = ({ module }) => { | |
data={module} | ||
/> | ||
<div className="group/card h-full w-full relative select-none p-2"> | ||
<div className="absolute top-4 right-4 z-10 bg-red-200 opacity-0 group-hover/card:opacity-100"> | ||
<button | ||
type="button" | ||
className="grid h-7 w-7 place-items-center bg-white p-1 text-red-500 outline-none duration-300 hover:bg-red-50" | ||
onClick={() => handleDeleteModule()} | ||
> | ||
<TrashIcon className="h-4 w-4" /> | ||
</button> | ||
<div className="absolute top-4 right-4 "> | ||
<CustomMenu width="auto" ellipsis> | ||
<CustomMenu.MenuItem | ||
onClick={() => | ||
copyTextToClipboard( | ||
`https://app.plane.so/${workspaceSlug}/projects/${projectId}/modules/${module.id}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using an absolute path like this will create an issue. in stage, it will copy the production link. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I get it. I've fixed it. Now, instead of using an absolute path, I'm using the origin. |
||
) | ||
.then(() => { | ||
setToastAlert({ | ||
type: "success", | ||
title: "Module link copied to clipboard", | ||
}); | ||
}) | ||
.catch(() => { | ||
setToastAlert({ | ||
type: "error", | ||
title: "Some error occurred", | ||
}); | ||
}) | ||
} | ||
> | ||
Copy module link | ||
</CustomMenu.MenuItem> | ||
<CustomMenu.MenuItem onClick={handleDeleteModule}> | ||
Delete module permanently | ||
</CustomMenu.MenuItem> | ||
</CustomMenu> | ||
</div> | ||
<Link href={`/${workspaceSlug}/projects/${module.project}/modules/${module.id}`}> | ||
<a className="flex flex-col cursor-pointer rounded-md border bg-white p-3 "> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<TSingleStatProps> = (props) => { | |
|
||
const router = useRouter(); | ||
const { workspaceSlug, projectId } = router.query; | ||
const { setToastAlert } = useToast(); | ||
|
||
const { data: cycleIssues } = useSWR<CycleIssueResponse[]>( | ||
workspaceSlug && projectId && cycle.id ? CYCLE_ISSUES(cycle.id as string) : null, | ||
|
@@ -77,6 +80,27 @@ const SingleStat: React.FC<TSingleStatProps> = (props) => { | |
</a> | ||
</Link> | ||
<CustomMenu width="auto" ellipsis> | ||
<CustomMenu.MenuItem | ||
onClick={() => | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a separate function for this onclick function handleCopyText |
||
copyTextToClipboard( | ||
`https://app.plane.so/${workspaceSlug}/projects/${projectId}/cycles/${cycle.id}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change the Path |
||
) | ||
.then(() => { | ||
setToastAlert({ | ||
type: "success", | ||
title: "Cycle link copied to clipboard", | ||
}); | ||
}) | ||
.catch(() => { | ||
setToastAlert({ | ||
type: "error", | ||
title: "Some error occurred", | ||
}); | ||
}) | ||
} | ||
> | ||
Copy cycle link | ||
</CustomMenu.MenuItem> | ||
<CustomMenu.MenuItem onClick={handleEditCycle}>Edit cycle</CustomMenu.MenuItem> | ||
<CustomMenu.MenuItem onClick={handleDeleteCycle}> | ||
Delete cycle permanently | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the Path