feat: hydrate persisted PR details on task disclosure (#3055)
This commit is contained in:
@@ -92,6 +92,7 @@ const TEST_TIMESTAMP = "2026-07-31T00:00:00Z";
|
||||
function makePR(id: string, number: number, repo = "kandev"): TaskPR {
|
||||
return {
|
||||
id,
|
||||
workspace_id: "workspace-1",
|
||||
task_id: "task-1",
|
||||
owner: "acme",
|
||||
repo,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import { IconGitPullRequest } from "@tabler/icons-react";
|
||||
import { getPRAggregateStatusColor, PRTaskIcon } from "@/components/github/pr-task-icon";
|
||||
import { MRTaskIcon } from "@/components/gitlab/mr-task-icon";
|
||||
import { useAppStore } from "@/components/state-provider";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/** Shows PR icon from store (real data) or from prInfo prop (prototype/mock). */
|
||||
@@ -14,8 +13,7 @@ function TaskPRIcon({
|
||||
taskId?: string;
|
||||
prInfo?: { number: number; state: string; aggregateState?: string };
|
||||
}) {
|
||||
const hasStorePR = useAppStore((s) => !!taskId && (s.taskPRs.byTaskId[taskId]?.length ?? 0) > 0);
|
||||
if (hasStorePR) return <PRTaskIcon taskId={taskId!} />;
|
||||
if (taskId) return <PRTaskIcon taskId={taskId} prInfo={prInfo} />;
|
||||
if (!prInfo) return null;
|
||||
const color = getPRAggregateStatusColor(prInfo.aggregateState ?? prInfo.state);
|
||||
return (
|
||||
@@ -31,9 +29,8 @@ function TaskPRIcon({
|
||||
|
||||
/**
|
||||
* PR badge (store or prInfo fallback) and MR badge as siblings, PR first. The
|
||||
* MR branch needs its own taskId guard: hasStorePR inside TaskPRIcon is false
|
||||
* both when taskId is absent and when it's present with no PRs, so it can't
|
||||
* gate the MRTaskIcon call.
|
||||
* MR branch needs its own taskId guard because MRTaskIcon reads task-scoped
|
||||
* store data and cannot render without a task identity.
|
||||
*/
|
||||
export function TaskContributionIcons({
|
||||
taskId,
|
||||
|
||||
@@ -47,6 +47,7 @@ function renderTaskItem(
|
||||
function makePR(overrides: Partial<TaskPR> = {}): TaskPR {
|
||||
return {
|
||||
id: "id",
|
||||
workspace_id: "workspace-1",
|
||||
task_id: "t1",
|
||||
owner: "o",
|
||||
repo: "r",
|
||||
@@ -647,6 +648,7 @@ describe("TaskItem contribution badges", () => {
|
||||
|
||||
const prIcon = screen.getByTestId(PR_ICON_TEST_ID);
|
||||
const mrIcon = screen.getByTestId(MR_ICON_TEST_ID);
|
||||
expect(prIcon.getAttribute("role")).toBe("img");
|
||||
expect(prIcon.compareDocumentPosition(mrIcon) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import type { TaskMR } from "@/lib/types/gitlab";
|
||||
function makePR(overrides: Partial<TaskPR>): TaskPR {
|
||||
return {
|
||||
id: "pr-1",
|
||||
workspace_id: "workspace-1",
|
||||
task_id: "task-1",
|
||||
owner: "kdlbs",
|
||||
repo: "kandev",
|
||||
|
||||
@@ -35,6 +35,7 @@ import { TaskPRShortcut } from "./task-pr-shortcut";
|
||||
function makePR(id: string, number: number): TaskPR {
|
||||
return {
|
||||
id,
|
||||
workspace_id: "workspace-1",
|
||||
task_id: "task-1",
|
||||
owner: "acme",
|
||||
repo: "kandev",
|
||||
|
||||
@@ -25,6 +25,7 @@ function makeTask(overrides: Partial<KanbanState["tasks"][number]>): KanbanState
|
||||
|
||||
function makePR(overrides: Pick<TaskPR, "id" | "task_id">): TaskPR {
|
||||
return {
|
||||
workspace_id: "workspace-1",
|
||||
owner: "o",
|
||||
repo: "r",
|
||||
pr_number: 1,
|
||||
|
||||
Reference in New Issue
Block a user