mirror of
https://github.com/hex248/sprint.git
synced 2026-02-07 18:23:03 +00:00
modal search param for copied issue links
This commit is contained in:
@@ -280,7 +280,9 @@ export function IssueDetails({
|
|||||||
|
|
||||||
const handleCopyLink = async () => {
|
const handleCopyLink = async () => {
|
||||||
try {
|
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);
|
setLinkCopied(true);
|
||||||
if (copyTimeoutRef.current) {
|
if (copyTimeoutRef.current) {
|
||||||
window.clearTimeout(copyTimeoutRef.current);
|
window.clearTimeout(copyTimeoutRef.current);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export function IssueModal({
|
|||||||
issueData: IssueResponse | null;
|
issueData: IssueResponse | null;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
trigger: ReactNode;
|
trigger?: ReactNode;
|
||||||
}) {
|
}) {
|
||||||
const selectedOrganisation = useSelectedOrganisation();
|
const selectedOrganisation = useSelectedOrganisation();
|
||||||
const selectedProject = useSelectedProject();
|
const selectedProject = useSelectedProject();
|
||||||
@@ -35,7 +35,7 @@ export function IssueModal({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogTrigger asChild>{trigger}</DialogTrigger>
|
{trigger && <DialogTrigger asChild>{trigger}</DialogTrigger>}
|
||||||
<DialogContent className="w-lg p-0" showCloseButton={false}>
|
<DialogContent className="w-lg p-0" showCloseButton={false}>
|
||||||
<DialogTitle className="sr-only">
|
<DialogTitle className="sr-only">
|
||||||
{issueID(selectedProject.Project.key, issueData.Issue.number)}
|
{issueID(selectedProject.Project.key, issueData.Issue.number)}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ const updateUrlParams = (updates: {
|
|||||||
orgSlug?: string | null;
|
orgSlug?: string | null;
|
||||||
projectKey?: string | null;
|
projectKey?: string | null;
|
||||||
issueNumber?: number | null;
|
issueNumber?: number | null;
|
||||||
|
modal?: boolean | null;
|
||||||
}) => {
|
}) => {
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
@@ -57,6 +58,11 @@ const updateUrlParams = (updates: {
|
|||||||
else params.delete("i");
|
else params.delete("i");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updates.modal !== undefined) {
|
||||||
|
if (updates.modal) params.set("modal", "true");
|
||||||
|
else params.delete("modal");
|
||||||
|
}
|
||||||
|
|
||||||
const search = params.toString();
|
const search = params.toString();
|
||||||
const nextUrl = `${window.location.pathname}${search ? `?${search}` : ""}`;
|
const nextUrl = `${window.location.pathname}${search ? `?${search}` : ""}`;
|
||||||
window.history.replaceState(null, "", nextUrl);
|
window.history.replaceState(null, "", nextUrl);
|
||||||
@@ -141,7 +147,7 @@ export function SelectionProvider({ children }: { children: ReactNode }) {
|
|||||||
localStorage.removeItem("selectedIssueNumber");
|
localStorage.removeItem("selectedIssueNumber");
|
||||||
}
|
}
|
||||||
if (!options?.skipUrlUpdate) {
|
if (!options?.skipUrlUpdate) {
|
||||||
updateUrlParams({ issueNumber: issue?.Issue.number ?? null });
|
updateUrlParams({ issueNumber: issue?.Issue.number ?? null, modal: null });
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { useEffect, useMemo, useRef } from "react";
|
import { useEffect, useMemo, useRef } from "react";
|
||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
import { IssueDetailPane } from "@/components/issue-detail-pane";
|
import { IssueDetailPane } from "@/components/issue-detail-pane";
|
||||||
|
import { IssueModal } from "@/components/issue-modal";
|
||||||
import { IssuesTable } from "@/components/issues-table";
|
import { IssuesTable } from "@/components/issues-table";
|
||||||
import { useSelection } from "@/components/selection-provider";
|
import { useSelection } from "@/components/selection-provider";
|
||||||
import TopBar from "@/components/top-bar";
|
import TopBar from "@/components/top-bar";
|
||||||
@@ -35,6 +36,9 @@ export default function Issues() {
|
|||||||
};
|
};
|
||||||
}, [location.search]);
|
}, [location.search]);
|
||||||
|
|
||||||
|
const showIssueModal =
|
||||||
|
new URLSearchParams(window.location.search).get("modal")?.trim().toLowerCase() === "true";
|
||||||
|
|
||||||
const { data: organisationsData = [] } = useOrganisations();
|
const { data: organisationsData = [] } = useOrganisations();
|
||||||
const { data: projectsData = [] } = useProjects(selectedOrganisationId);
|
const { data: projectsData = [] } = useProjects(selectedOrganisationId);
|
||||||
const { data: issuesData = [], isFetched: issuesFetched } = useIssues(selectedProjectId);
|
const { data: issuesData = [], isFetched: issuesFetched } = useIssues(selectedProjectId);
|
||||||
@@ -170,7 +174,7 @@ export default function Issues() {
|
|||||||
</div>
|
</div>
|
||||||
</ResizablePanel>
|
</ResizablePanel>
|
||||||
|
|
||||||
{selectedIssue && (
|
{selectedIssue && !showIssueModal && (
|
||||||
<>
|
<>
|
||||||
<ResizableSeparator />
|
<ResizableSeparator />
|
||||||
<ResizablePanel id={"right"} defaultSize={"30%"} minSize={363} maxSize={"60%"}>
|
<ResizablePanel id={"right"} defaultSize={"30%"} minSize={363} maxSize={"60%"}>
|
||||||
@@ -182,6 +186,18 @@ export default function Issues() {
|
|||||||
)}
|
)}
|
||||||
</ResizablePanelGroup>
|
</ResizablePanelGroup>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{selectedIssue && showIssueModal && (
|
||||||
|
<IssueModal
|
||||||
|
issueData={selectedIssue}
|
||||||
|
open={true}
|
||||||
|
onOpenChange={(open) => {
|
||||||
|
if (!open) {
|
||||||
|
selectIssue(null);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user