Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

feat(issues): add blocker entry to the Relations submenu (MUL-10053) (#11394)

Bohan Jiangc07e5efdf23d
diff --git a/packages/core/modals/store.ts b/packages/core/modals/store.ts
index 7c31c64d1f..7922084338 100644
--- a/packages/core/modals/store.ts
+++ b/packages/core/modals/store.ts
@@ -11,6 +11,7 @@ type ModalType =
| "issue-set-parent"
| "issue-mark-duplicate"
| "issue-add-child"
+ | "issue-add-blocker"
| "project-add-issue"
| "project-rename"
| "issue-rename"
diff --git a/packages/views/issues/actions/__tests__/use-issue-actions.test.tsx b/packages/views/issues/actions/__tests__/use-issue-actions.test.tsx
index 3f4400284c..bc9e885e43 100644
--- a/packages/views/issues/actions/__tests__/use-issue-actions.test.tsx
+++ b/packages/views/issues/actions/__tests__/use-issue-actions.test.tsx
@@ -358,6 +358,13 @@ describe("useIssueActions", () => {
issueId: "issue-1",
});
+ act(() => {
+ result.current.openAddBlocker();
+ });
+ expect(mockOpenModal).toHaveBeenLastCalledWith("issue-add-blocker", {
+ issueId: "issue-1",
+ });
+
act(() => {
result.current.openCreateSubIssue();
});
diff --git a/packages/views/issues/actions/issue-actions-menu-items.tsx b/packages/views/issues/actions/issue-actions-menu-items.tsx
index 78967f2561..528ea80e6e 100644
--- a/packages/views/issues/actions/issue-actions-menu-items.tsx
+++ b/packages/views/issues/actions/issue-actions-menu-items.tsx
@@ -13,6 +13,7 @@ import {
CircleDot,
CircleEqual,
ExternalLink,
+ Flag,
FolderOpen,
Hash,
Link2,
@@ -144,6 +145,7 @@ export function IssueActionsMenuItems({
removeParent,
openAddChild,
openMarkDuplicate,
+ openAddBlocker,
openDeleteConfirm,
} = actions;
@@ -473,7 +475,7 @@ export function IssueActionsMenuItems({
{/* Relationship actions live under "Relations" — a semantically
explicit label (unlike the old "More") so the first level tells
you what the submenu does. Holds parent/sub-issue links today,
- and will grow (blocks, duplicates, related) as we add more
+ blockers and duplicates, and will grow (related) as we add more
relation types. */}
<P.Sub>
<P.SubTrigger>
@@ -495,6 +497,10 @@ export function IssueActionsMenuItems({
<ArrowDown className="h-3.5 w-3.5" />
{t(($) => $.actions.add_sub_issue)}
</P.Item>
+ <P.Item onClick={openAddBlocker}>
+ <Flag className="h-3.5 w-3.5" />
+ {t(($) => $.actions.add_blocker)}
+ </P.Item>
{/* Marking a duplicate cancels the issue. (MUL-7420) */}
{workflowAllowsStatus(workflow, "cancelled") && (
<P.Item onClick={openMarkDuplicate}>
diff --git a/packages/views/issues/actions/use-issue-actions.ts b/packages/views/issues/actions/use-issue-actions.ts
index de09716747..58a4e64307 100644
--- a/packages/views/issues/actions/use-issue-actions.ts
+++ b/packages/views/issues/actions/use-issue-actions.ts
@@ -40,6 +40,7 @@ export interface UseIssueActionsResult {
removeParent: () => void;
openAddChild: () => void;
openMarkDuplicate: () => void;
+ openAddBlocker: () => void;
openDeleteConfirm: (opts?: { onDeletedFallbackPath?: string }) => void;
}
@@ -320,6 +321,11 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {
openModal("issue-add-child", { issueId });
}, [openModal, issueId]);
+ const openAddBlocker = useCallback(() => {
+ if (!issueId) return;
+ openModal("issue-add-blocker", { issueId });
+ }, [openModal, issueId]);
+
const openDeleteConfirm = useCallback(
(opts?: { onDeletedFallbackPath?: string }) => {
if (!issueId) return;
@@ -348,6 +354,7 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {
removeParent,
openAddChild,
openMarkDuplicate,
+ openAddBlocker,
openDeleteConfirm,
};
}
diff --git a/packages/views/issues/components/issue-blockers.test.tsx b/packages/views/issues/components/issue-blockers.test.tsx
index bf60e77871..bd74ae51be 100644
--- a/packages/views/issues/components/issue-blockers.test.tsx
+++ b/packages/views/issues/components/issue-blockers.test.tsx
@@ -16,7 +16,6 @@ vi.mock("@multica/core/issues/blockers", () => ({
vi.mock("../../navigation", () => ({
AppLink: ({ children, href }: { children: React.ReactNode; href: string }) => <a href={href}>{children}</a>,
}));
-vi.mock("../../modals/issue-picker-modal", () => ({ IssuePickerModal: () => null }));
import { IssueBlockersSection } from "./issue-blockers";
diff --git a/packages/views/issues/components/issue-blockers.tsx b/packages/views/issues/components/issue-blockers.tsx
index 887f8cee2e..a081357f34 100644
--- a/packages/views/issues/components/issue-blockers.tsx
+++ b/packages/views/issues/components/issue-blockers.tsx
@@ -6,10 +6,10 @@ import { Button } from "@multica/ui/components/ui/button";
import { useWorkspaceId } from "@multica/core/hooks";
import { issueRouteRef, useWorkspacePaths } from "@multica/core/paths";
import { useUpdateIssueBlockers } from "@multica/core/issues/blockers";
+import { useModalStore } from "@multica/core/modals";
import type { Issue } from "@multica/core/types";
import { AppLink } from "../../navigation";
import { useT } from "../../i18n";
-import { IssuePickerModal } from "../../modals/issue-picker-modal";
import { IssueSidebarSectionHeader } from "./issue-sidebar-section";
export function IssueBlockedMarker({ issue }: { issue: Issue }) {
@@ -27,7 +27,7 @@ export function IssueBlockersSection({ issue }: { issue: Issue }) {
const wsId = useWorkspaceId();
const paths = useWorkspacePaths();
const [open, setOpen] = useState(true);
- const [pickerOpen, setPickerOpen] = useState(false);
+ const openModal = useModalStore((s) => s.open);
const mutation = useUpdateIssueBlockers(wsId, issue.id);
if (issue.blocked_by === undefined) return null;
const blockers = issue.blocked_by;
@@ -38,7 +38,7 @@ export function IssueBlockersSection({ issue }: { issue: Issue }) {
const restrictedCount = Math.max(0, (issue.blocked_count ?? 0) - blockers.filter((b) => !b.closed).length);
return <div>
<IssueSidebarSectionHeader title={t(($) => $.waiting.title)} open={open} onOpenChange={setOpen} count={issue.blocked_count}
- actions={<Button variant="ghost" size="icon-xs" aria-label={t(($) => $.waiting.add)} onClick={() => { mutation.reset(); setPickerOpen(true); }}><Plus /></Button>} />
+ actions={<Button variant="ghost" size="icon-xs" aria-label={t(($) => $.waiting.add)} onClick={() => openModal("issue-add-blocker", { issueId: issue.id })}><Plus /></Button>} />
{open && <div className="px-4 space-y-2 text-caption">
{manual.map((blocker) => <div key={blocker.id} className="flex min-w-0 items-center gap-1">
<Flag className={blocker.closed ? "size-3.5 shrink-0 text-muted-foreground" : "size-3.5 shrink-0 text-destructive"} aria-hidden="true" />
@@ -62,9 +62,5 @@ export function IssueBlockersSection({ issue }: { issue: Issue }) {
{blockers.length === 0 && !restrictedCount && <p className="text-muted-foreground">{t(($) => $.waiting.empty)}</p>}
{mutation.isError && <p role="alert" className="text-destructive">{mutation.error.message}</p>}
</div>}
- <IssuePickerModal error={mutation.isError ? mutation.error.message : undefined} pending={mutation.isPending} closeOnSelect={false} open={pickerOpen} onOpenChange={setPickerOpen} title={t(($) => $.waiting.add)} description={t(($) => $.waiting.picker_hint)}
- excludeIds={[issue.id, ...(issue.parent_issue_id ? [issue.parent_issue_id] : []), ...manual.map((b) => b.id)]}
- isSelectable={(candidate) => candidate.parent_issue_id !== issue.id}
- onSelect={(candidate) => mutation.mutate({ blocked_by: [candidate.id] }, { onSuccess: () => setPickerOpen(false) })} />
</div>;
}
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index 77979cdfcb..a2630b05e3 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -1134,6 +1134,7 @@
"remove_parent_issue": "Remove parent issue",
"remove_parent_issue_success": "Removed parent issue",
"add_sub_issue": "Add sub-issue...",
+ "add_blocker": "Add blocker...",
"delete_issue": "Delete issue",
"mark_duplicate": "Mark as duplicate...",
"open_in_new_window": "Open in new window"
diff --git a/packages/views/locales/es/issues.json b/packages/views/locales/es/issues.json
index 8b17141140..108a616160 100644
--- a/packages/views/locales/es/issues.json
+++ b/packages/views/locales/es/issues.json
@@ -1041,6 +1041,7 @@
"remove_parent_issue": "Quitar tarea principal",
"remove_parent_issue_success": "Tarea principal quitada",
"add_sub_issue": "Añadir subtarea...",
+ "add_blocker": "Añadir requisito...",
"delete_issue": "Eliminar tarea",
"mark_duplicate": "Marcar como duplicada...",
"rename_issue": "Renombrar tarea",
diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.json
index 0dd72a50ce..c93686ee50 100644
--- a/packages/views/locales/fr/issues.json
+++ b/packages/views/locales/fr/issues.json
@@ -1134,6 +1134,7 @@
"remove_parent_issue": "Retirer la tâche parente",
"remove_parent_issue_success": "Tâche parente retirée",
"add_sub_issue": "Ajouter une sous-tâche...",
+ "add_blocker": "Ajouter un prérequis...",
"delete_issue": "Supprimer la tâche",
"mark_duplicate": "Marquer comme doublon...",
"open_in_new_window": "Ouvrir dans une nouvelle fenêtre"
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index 4737fdb94f..1e1c63af60 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -1076,6 +1076,7 @@
"remove_parent_issue": "親タスクを解除",
"remove_parent_issue_success": "親タスクを解除しました",
"add_sub_issue": "サブタスクを追加...",
+ "add_blocker": "先行タスクを追加...",
"delete_issue": "タスクを削除",
"mark_duplicate": "重複としてマーク...",
"open_in_new_window": "新しいウィンドウで開く"
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index 70dcd38d25..68f4a3c744 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -1076,6 +1076,7 @@
"remove_parent_issue": "상위 태스크 제거",
"remove_parent_issue_success": "상위 태스크를 제거했습니다",
"add_sub_issue": "하위 태스크 추가...",
+ "add_blocker": "선행 작업 추가...",
"delete_issue": "태스크 삭제",
"mark_duplicate": "중복으로 표시...",
"open_in_new_window": "새 창에서 열기"
diff --git a/packages/views/locales/ru/issues.json b/packages/views/locales/ru/issues.json
index 843ee09936..c0e28f4b08 100644
--- a/packages/views/locales/ru/issues.json
+++ b/packages/views/locales/ru/issues.json
@@ -1247,6 +1247,7 @@
"remove_parent_issue": "Убрать родительскую задачу",
"remove_parent_issue_success": "Родительская задача убрана",
"add_sub_issue": "Добавить подзадачу...",
+ "add_blocker": "Добавить зависимость...",
"delete_issue": "Удалить задачу",
"mark_duplicate": "Отметить как дубликат...",
"locate_in_sidebar": "Показать на боковой панели",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index 6be6fbdf3b..d10d63f831 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -1076,6 +1076,7 @@
"remove_parent_issue": "移除父任务",
"remove_parent_issue_success": "已移除父任务",
"add_sub_issue": "添加子任务...",
+ "add_blocker": "添加前置任务...",
"delete_issue": "删除任务",
"mark_duplicate": "标记为重复...",
"open_in_new_window": "在新窗口中打开"
diff --git a/packages/views/locales/zh-Hant/issues.json b/packages/views/locales/zh-Hant/issues.json
index b98b9a22f7..52c660cef3 100644
--- a/packages/views/locales/zh-Hant/issues.json
+++ b/packages/views/locales/zh-Hant/issues.json
@@ -1076,6 +1076,7 @@
"remove_parent_issue": "移除父任務",
"remove_parent_issue_success": "已移除父任務",
"add_sub_issue": "新增子任務...",
+ "add_blocker": "新增前置任務...",
"delete_issue": "刪除任務",
"mark_duplicate": "標記為重複...",
"open_in_new_window": "在新視窗中開啟"
diff --git a/packages/views/modals/add-blocker-issue.test.tsx b/packages/views/modals/add-blocker-issue.test.tsx
new file mode 100644
index 0000000000..0966ef84be
--- /dev/null
+++ b/packages/views/modals/add-blocker-issue.test.tsx
@@ -0,0 +1,85 @@
+import { fireEvent, render, screen } from "@testing-library/react";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import { AddBlockerIssueModal } from "./add-blocker-issue";
+
+type PickerProps = {
+ excludeIds: string[];
+ isSelectable: (issue: { parent_issue_id: string | null }) => boolean;
+ onSelect: (issue: { id: string }) => void;
+ error?: string;
+ pending: boolean;
+ closeOnSelect: boolean;
+};
+
+const mocks = vi.hoisted(() => ({
+ mutate: vi.fn(),
+ mutation: { isError: false, isPending: false, error: null as Error | null },
+ picker: null as PickerProps | null,
+}));
+
+vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws-1" }));
+vi.mock("@multica/core/issues/blockers", () => ({
+ useUpdateIssueBlockers: () => ({ ...mocks.mutation, mutate: mocks.mutate }),
+}));
+vi.mock("@multica/core/issues/queries", () => ({
+ issueDetailOptions: (_wsId: string, issueId: string) => ({ queryKey: ["issues", "detail", issueId] }),
+}));
+vi.mock("@tanstack/react-query", () => ({
+ useQuery: () => ({
+ data: {
+ id: "issue-1",
+ parent_issue_id: "parent-1",
+ blocked_by: [
+ { id: "manual-1", via: "manual" },
+ { id: "stage-1", via: "stage" },
+ ],
+ },
+ }),
+}));
+vi.mock("./issue-picker-modal", () => ({
+ IssuePickerModal: (props: PickerProps) => {
+ mocks.picker = props;
+ return (
+ <button type="button" onClick={() => props.onSelect({ id: "blocker-1" })}>
+ Select issue
+ </button>
+ );
+ },
+}));
+vi.mock("../i18n", () => ({
+ useT: () => ({
+ t: (selector: (labels: Record<string, Record<string, string>>) => string) =>
+ selector({ waiting: { add: "Add blocker", picker_hint: "Pick a blocker" } }),
+ }),
+}));
+
+beforeEach(() => {
+ mocks.mutate.mockReset();
+ mocks.mutation = { isError: false, isPending: false, error: null };
+ mocks.picker = null;
+});
+
+describe("AddBlockerIssueModal", () => {
+ it("excludes the issue, its parent and existing manual blockers, and its own sub-issues", () => {
+ render(<AddBlockerIssueModal onClose={vi.fn()} data={{ issueId: "issue-1" }} />);
+ expect(mocks.picker?.excludeIds).toEqual(["issue-1", "parent-1", "manual-1"]);
+ expect(mocks.picker?.isSelectable({ parent_issue_id: "issue-1" })).toBe(false);
+ expect(mocks.picker?.isSelectable({ parent_issue_id: null })).toBe(true);
+ });
+
+ it("adds the picked blocker and closes only once the write succeeds", () => {
+ const onClose = vi.fn();
+ render(<AddBlockerIssueModal onClose={onClose} data={{ issueId: "issue-1" }} />);
+ expect(mocks.picker?.closeOnSelect).toBe(false);
+
+ fireEvent.click(screen.getByText("Select issue"));
+ expect(mocks.mutate).toHaveBeenCalledWith({ blocked_by: ["blocker-1"] }, { onSuccess: onClose });
+ expect(onClose).not.toHaveBeenCalled();
+ });
+
+ it("shows the server's rejection inside the picker", () => {
+ mocks.mutation = { isError: true, isPending: false, error: new Error("would create a cycle") };
+ render(<AddBlockerIssueModal onClose={vi.fn()} data={{ issueId: "issue-1" }} />);
+ expect(mocks.picker?.error).toBe("would create a cycle");
+ });
+});
diff --git a/packages/views/modals/add-blocker-issue.tsx b/packages/views/modals/add-blocker-issue.tsx
new file mode 100644
index 0000000000..0ab637d356
--- /dev/null
+++ b/packages/views/modals/add-blocker-issue.tsx
@@ -0,0 +1,64 @@
+"use client";
+
+import { useQuery } from "@tanstack/react-query";
+import { useWorkspaceId } from "@multica/core/hooks";
+import { issueDetailOptions } from "@multica/core/issues/queries";
+import { useUpdateIssueBlockers } from "@multica/core/issues/blockers";
+import { IssuePickerModal } from "./issue-picker-modal";
+import { useT } from "../i18n";
+
+/**
+ * Adds a manual blocker to an issue (MUL-8860). Shared by the sidebar's
+ * Waiting section and the Relations submenu of the issue actions menu, so
+ * both entry points write through the same path. The picker stays open while
+ * the write is in flight and shows the server's error in place (a cycle, a
+ * blocker the caller can't see), closing only once the blocker is saved.
+ */
+export function AddBlockerIssueModal({
+ open = true,
+ onClose,
+ onOpenChangeComplete,
+ data,
+}: {
+ open?: boolean;
+ onClose: () => void;
+ onOpenChangeComplete?: (open: boolean) => void;
+ data: Record<string, unknown> | null;
+}) {
+ const { t } = useT("issues");
+ const issueId = (data?.issueId as string) || "";
+ const wsId = useWorkspaceId();
+ const mutation = useUpdateIssueBlockers(wsId, issueId);
+
+ // List rows don't carry blocked_by, so read the detail for what to exclude.
+ const { data: issue } = useQuery({
+ ...issueDetailOptions(wsId, issueId),
+ enabled: !!issueId,
+ });
+ const excludeIds = [
+ issueId,
+ ...(issue?.parent_issue_id ? [issue.parent_issue_id] : []),
+ ...(issue?.blocked_by ?? []).filter((b) => b.via === "manual").map((b) => b.id),
+ ];
+
+ return (
+ <IssuePickerModal
+ open={open}
+ onOpenChange={(v) => {
+ if (!v) onClose();
+ }}
+ onOpenChangeComplete={onOpenChangeComplete}
+ title={t(($) => $.waiting.add)}
+ description={t(($) => $.waiting.picker_hint)}
+ error={mutation.isError ? mutation.error.message : undefined}
+ pending={mutation.isPending}
+ closeOnSelect={false}
+ excludeIds={excludeIds}
+ // A sub-issue can't block its own parent.
+ isSelectable={(candidate) => candidate.parent_issue_id !== issueId}
+ onSelect={(candidate) =>
+ mutation.mutate({ blocked_by: [candidate.id] }, { onSuccess: onClose })
+ }
+ />
+ );
+}
diff --git a/packages/views/modals/registry.tsx b/packages/views/modals/registry.tsx
index da4cf7e075..03e8f08f50 100644
--- a/packages/views/modals/registry.tsx
+++ b/packages/views/modals/registry.tsx
@@ -9,6 +9,7 @@ import { FeedbackModal } from "./feedback";
import { SetParentIssueModal } from "./set-parent-issue";
import { MarkDuplicateIssueModal } from "./mark-duplicate-issue";
import { AddChildIssueModal } from "./add-child-issue";
+import { AddBlockerIssueModal } from "./add-blocker-issue";
import { AddProjectIssueModal } from "./add-project-issue";
import { RenameIssueModal } from "./rename-issue";
import { RenameProjectModal } from "./rename-project";
@@ -173,6 +174,17 @@ export function ModalRegistry() {
/>
);
break;
+ case "issue-add-blocker":
+ activeModal = (
+ <AddBlockerIssueModal
+ key={sessionKey}
+ open={isOpen}
+ onClose={close}
+ onOpenChangeComplete={handleOpenChangeComplete}
+ data={currentData}
+ />
+ );
+ break;
case "project-add-issue":
activeModal = (
<AddProjectIssueModal