mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
modal search param for copied issue links
This commit is contained in:
@@ -280,7 +280,9 @@ export function IssueDetails({
|
||||
|
||||
const handleCopyLink = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(window.location.href);
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.set("modal", "true");
|
||||
await navigator.clipboard.writeText(url.toString());
|
||||
setLinkCopied(true);
|
||||
if (copyTimeoutRef.current) {
|
||||
window.clearTimeout(copyTimeoutRef.current);
|
||||
|
||||
@@ -19,7 +19,7 @@ export function IssueModal({
|
||||
issueData: IssueResponse | null;
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
trigger: ReactNode;
|
||||
trigger?: ReactNode;
|
||||
}) {
|
||||
const selectedOrganisation = useSelectedOrganisation();
|
||||
const selectedProject = useSelectedProject();
|
||||
@@ -35,7 +35,7 @@ export function IssueModal({
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogTrigger asChild>{trigger}</DialogTrigger>
|
||||
{trigger && <DialogTrigger asChild>{trigger}</DialogTrigger>}
|
||||
<DialogContent className="w-lg p-0" showCloseButton={false}>
|
||||
<DialogTitle className="sr-only">
|
||||
{issueID(selectedProject.Project.key, issueData.Issue.number)}
|
||||
|
||||
@@ -39,6 +39,7 @@ const updateUrlParams = (updates: {
|
||||
orgSlug?: string | null;
|
||||
projectKey?: string | null;
|
||||
issueNumber?: number | null;
|
||||
modal?: boolean | null;
|
||||
}) => {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
|
||||
@@ -57,6 +58,11 @@ const updateUrlParams = (updates: {
|
||||
else params.delete("i");
|
||||
}
|
||||
|
||||
if (updates.modal !== undefined) {
|
||||
if (updates.modal) params.set("modal", "true");
|
||||
else params.delete("modal");
|
||||
}
|
||||
|
||||
const search = params.toString();
|
||||
const nextUrl = `${window.location.pathname}${search ? `?${search}` : ""}`;
|
||||
window.history.replaceState(null, "", nextUrl);
|
||||
@@ -141,7 +147,7 @@ export function SelectionProvider({ children }: { children: ReactNode }) {
|
||||
localStorage.removeItem("selectedIssueNumber");
|
||||
}
|
||||
if (!options?.skipUrlUpdate) {
|
||||
updateUrlParams({ issueNumber: issue?.Issue.number ?? null });
|
||||
updateUrlParams({ issueNumber: issue?.Issue.number ?? null, modal: null });
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user