Fix issue workspace detail links

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta 2026-03-28 10:12:11 -05:00
parent bb1732dd11
commit 41f2a80aa8

View file

@ -6,7 +6,7 @@ import { executionWorkspacesApi } from "../api/execution-workspaces";
import { instanceSettingsApi } from "../api/instanceSettings"; import { instanceSettingsApi } from "../api/instanceSettings";
import { useCompany } from "../context/CompanyContext"; import { useCompany } from "../context/CompanyContext";
import { queryKeys } from "../lib/queryKeys"; import { queryKeys } from "../lib/queryKeys";
import { cn } from "../lib/utils"; import { cn, projectWorkspaceUrl } from "../lib/utils";
import { Button } from "@/components/ui/button"; import { Button } from "@/components/ui/button";
import { Check, Copy, GitBranch, FolderOpen, Pencil, X } from "lucide-react"; import { Check, Copy, GitBranch, FolderOpen, Pencil, X } from "lucide-react";
@ -114,6 +114,29 @@ function configuredWorkspaceLabel(
} }
} }
function projectWorkspaceDetailLink(input: {
projectId: string | null | undefined;
projectWorkspaceId: string | null | undefined;
}) {
if (!input.projectId || !input.projectWorkspaceId) return null;
return projectWorkspaceUrl({ id: input.projectId, urlKey: input.projectId }, input.projectWorkspaceId);
}
function workspaceDetailLink(input: {
projectId: string | null | undefined;
issueProjectWorkspaceId: string | null | undefined;
workspace: ExecutionWorkspace | null | undefined;
}) {
const linkedProjectWorkspaceId = input.workspace?.projectWorkspaceId ?? input.issueProjectWorkspaceId ?? null;
if (input.workspace?.mode === "shared_workspace") {
return projectWorkspaceDetailLink({
projectId: input.projectId,
projectWorkspaceId: linkedProjectWorkspaceId,
});
}
return input.workspace ? `/execution-workspaces/${input.workspace.id}` : null;
}
function statusBadge(status: string) { function statusBadge(status: string) {
const colors: Record<string, string> = { const colors: Record<string, string> = {
active: "bg-green-500/15 text-green-700 dark:text-green-400", active: "bg-green-500/15 text-green-700 dark:text-green-400",
@ -209,6 +232,17 @@ export function IssueWorkspaceCard({ issue, project, onUpdate }: IssueWorkspaceC
deduplicatedReusableWorkspaces.find((w) => w.id === draftExecutionWorkspaceId) deduplicatedReusableWorkspaces.find((w) => w.id === draftExecutionWorkspaceId)
?? (draftExecutionWorkspaceId === issue.executionWorkspaceId ? selectedReusableExecutionWorkspace : null); ?? (draftExecutionWorkspaceId === issue.executionWorkspaceId ? selectedReusableExecutionWorkspace : null);
const selectedReusableWorkspaceLink = workspaceDetailLink({
projectId: project?.id,
issueProjectWorkspaceId: issue.projectWorkspaceId,
workspace: selectedReusableExecutionWorkspace,
});
const currentWorkspaceLink = workspaceDetailLink({
projectId: project?.id,
issueProjectWorkspaceId: issue.projectWorkspaceId,
workspace,
});
const canSaveWorkspaceConfig = draftSelection !== "reuse_existing" || draftExecutionWorkspaceId.length > 0; const canSaveWorkspaceConfig = draftSelection !== "reuse_existing" || draftExecutionWorkspaceId.length > 0;
const handleSave = useCallback(() => { const handleSave = useCallback(() => {
@ -317,18 +351,22 @@ export function IssueWorkspaceCard({ issue, project, onUpdate }: IssueWorkspaceC
{currentSelection === "reuse_existing" && selectedReusableExecutionWorkspace && ( {currentSelection === "reuse_existing" && selectedReusableExecutionWorkspace && (
<div className="text-muted-foreground" style={{ overflowWrap: "anywhere" }}> <div className="text-muted-foreground" style={{ overflowWrap: "anywhere" }}>
Reusing:{" "} Reusing:{" "}
<Link {selectedReusableWorkspaceLink ? (
to={`/execution-workspaces/${selectedReusableExecutionWorkspace.id}`} <Link
className="hover:text-foreground hover:underline" to={selectedReusableWorkspaceLink}
> className="hover:text-foreground hover:underline"
>
<BreakablePath text={selectedReusableExecutionWorkspace.name} />
</Link>
) : (
<BreakablePath text={selectedReusableExecutionWorkspace.name} /> <BreakablePath text={selectedReusableExecutionWorkspace.name} />
</Link> )}
</div> </div>
)} )}
{workspace && ( {workspace && currentWorkspaceLink && (
<div className="pt-0.5"> <div className="pt-0.5">
<Link <Link
to={`/execution-workspaces/${workspace.id}`} to={currentWorkspaceLink}
className="text-[11px] text-muted-foreground hover:text-foreground hover:underline" className="text-[11px] text-muted-foreground hover:text-foreground hover:underline"
> >
View workspace details View workspace details
@ -385,12 +423,16 @@ export function IssueWorkspaceCard({ issue, project, onUpdate }: IssueWorkspaceC
<div className="text-[11px] text-muted-foreground space-y-0.5 pt-1 border-t border-border/50"> <div className="text-[11px] text-muted-foreground space-y-0.5 pt-1 border-t border-border/50">
<div style={{ overflowWrap: "anywhere" }}> <div style={{ overflowWrap: "anywhere" }}>
Current:{" "} Current:{" "}
<Link {currentWorkspaceLink ? (
to={`/execution-workspaces/${workspace.id}`} <Link
className="hover:text-foreground hover:underline" to={currentWorkspaceLink}
> className="hover:text-foreground hover:underline"
>
<BreakablePath text={workspace.name} />
</Link>
) : (
<BreakablePath text={workspace.name} /> <BreakablePath text={workspace.name} />
</Link> )}
{" · "} {" · "}
{workspace.status} {workspace.status}
</div> </div>