Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

feat(web): filter subtasks by state and change state from issue rows (#443)

Croff08647f4c1b90
diff --git a/apps/web/messages/ar/issue.json b/apps/web/messages/ar/issue.json
index 03984ef3..7d34c821 100644
--- a/apps/web/messages/ar/issue.json
+++ b/apps/web/messages/ar/issue.json
@@ -198,7 +198,11 @@
"detachFromParent": "الفصل عن {parent}",
"subtaskOf": "مهمة فرعية من {issue}",
"existingIssue": "مهمة موجودة",
- "searchPrompt": "ابحث عن مهام لإضافتها كمهمة فرعية…"
+ "searchPrompt": "ابحث عن مهام لإضافتها كمهمة فرعية…",
+ "filter": "التصفية حسب الحالة",
+ "hiding": "مخفية: {states}",
+ "clearFilter": "مسح التصفية",
+ "allHidden": "كل المهام الفرعية مخفية بالتصفية."
},
"subtaskDisposal": {
"intro": "{issues, plural, zero {لا مهام} one {هذه المهمة لديها} two {هاتان المهمتان لديهما} few {هذه المهام لديها} many {هذه المهام لديها} other {هذه المهام لديها}} {count, plural, zero {لا مهام فرعية} one {مهمة فرعية واحدة} two {مهمتان فرعيتان} few {# مهام فرعية} many {# مهمة فرعية} other {# مهمة فرعية}}.",
diff --git a/apps/web/messages/en/issue.json b/apps/web/messages/en/issue.json
index eae187b0..6a421597 100644
--- a/apps/web/messages/en/issue.json
+++ b/apps/web/messages/en/issue.json
@@ -198,7 +198,11 @@
"detachFromParent": "Detach from {parent}",
"subtaskOf": "Subtask of {issue}",
"existingIssue": "Existing issue",
- "searchPrompt": "Search issues to add as a subtask…"
+ "searchPrompt": "Search issues to add as a subtask…",
+ "filter": "Filter by state",
+ "hiding": "Hiding {states}",
+ "clearFilter": "Clear filter",
+ "allHidden": "All subtasks are hidden by the filter."
},
"subtaskDisposal": {
"intro": "{issues, plural, one {This issue has} other {These issues have}} {count, plural, one {# subtask} other {# subtasks}}.",
diff --git a/apps/web/messages/es-ES/issue.json b/apps/web/messages/es-ES/issue.json
index 3913de64..9bd6089f 100644
--- a/apps/web/messages/es-ES/issue.json
+++ b/apps/web/messages/es-ES/issue.json
@@ -198,7 +198,11 @@
"detachFromParent": "Desvincar de {parent}",
"subtaskOf": "Subtarea de {issue}",
"existingIssue": "Ticket existente",
- "searchPrompt": "Buscar tickets para añadir como subtarea…"
+ "searchPrompt": "Buscar tickets para añadir como subtarea…",
+ "filter": "Filtrar por estado",
+ "hiding": "Ocultando {states}",
+ "clearFilter": "Quitar filtro",
+ "allHidden": "El filtro oculta todas las subtareas."
},
"subtaskDisposal": {
"intro": "{issues, plural, one {Este ticket tiene} other {Estos tickets tienen}} {count, plural, one {# subtarea} other {# subtareas}}.",
diff --git a/apps/web/messages/fr/issue.json b/apps/web/messages/fr/issue.json
index 9fcf643f..7e11a911 100644
--- a/apps/web/messages/fr/issue.json
+++ b/apps/web/messages/fr/issue.json
@@ -198,7 +198,11 @@
"detachFromParent": "Détacher de {parent}",
"subtaskOf": "Sous-tâche de {issue}",
"existingIssue": "Ticket existant",
- "searchPrompt": "Rechercher un ticket à ajouter comme sous-tâche…"
+ "searchPrompt": "Rechercher un ticket à ajouter comme sous-tâche…",
+ "filter": "Filtrer par état",
+ "hiding": "Masqués : {states}",
+ "clearFilter": "Effacer le filtre",
+ "allHidden": "Le filtre masque toutes les sous-tâches."
},
"subtaskDisposal": {
"intro": "{issues, plural, one {Ce ticket a} other {Ces tickets ont}} {count, plural, one {# sous-tâche} other {# sous-tâches}}.",
diff --git a/apps/web/messages/id/issue.json b/apps/web/messages/id/issue.json
index 388999eb..c79927b8 100644
--- a/apps/web/messages/id/issue.json
+++ b/apps/web/messages/id/issue.json
@@ -198,7 +198,11 @@
"detachFromParent": "Lepaskan dari {parent}",
"subtaskOf": "Subtugas dari {issue}",
"existingIssue": "Issue yang ada",
- "searchPrompt": "Cari issue untuk ditambahkan sebagai subtugas…"
+ "searchPrompt": "Cari issue untuk ditambahkan sebagai subtugas…",
+ "filter": "Filter menurut status",
+ "hiding": "Menyembunyikan {states}",
+ "clearFilter": "Hapus filter",
+ "allHidden": "Semua subtugas disembunyikan oleh filter."
},
"subtaskDisposal": {
"intro": "{issues, plural, one {Issue ini memiliki} other {Issue tersebut memiliki}} {count, plural, one {# subtugas} other {# subtugas}}.",
diff --git a/apps/web/messages/pt-BR/issue.json b/apps/web/messages/pt-BR/issue.json
index aa03cfe5..3629c140 100644
--- a/apps/web/messages/pt-BR/issue.json
+++ b/apps/web/messages/pt-BR/issue.json
@@ -198,7 +198,11 @@
"detachFromParent": "Desvincular de {parent}",
"subtaskOf": "Subtarefa de {issue}",
"existingIssue": "Issue existente",
- "searchPrompt": "Buscar issues para adicionar como subtarefa…"
+ "searchPrompt": "Buscar issues para adicionar como subtarefa…",
+ "filter": "Filtrar por status",
+ "hiding": "Ocultando {states}",
+ "clearFilter": "Limpar filtro",
+ "allHidden": "Todas as subtarefas estão ocultas pelo filtro."
},
"subtaskDisposal": {
"intro": "{issues, plural, one {Esta issue tem} other {Estas issues têm}} {count, plural, one {# subtarefa} other {# subtarefas}}.",
diff --git a/apps/web/messages/ru/issue.json b/apps/web/messages/ru/issue.json
index 9481e290..13148107 100644
--- a/apps/web/messages/ru/issue.json
+++ b/apps/web/messages/ru/issue.json
@@ -198,7 +198,11 @@
"detachFromParent": "Отвязать от {parent}",
"subtaskOf": "Подзадача {issue}",
"existingIssue": "Существующая задача",
- "searchPrompt": "Поиск задач, чтобы добавить подзадачей…"
+ "searchPrompt": "Поиск задач, чтобы добавить подзадачей…",
+ "filter": "Фильтр по статусу",
+ "hiding": "Скрыто: {states}",
+ "clearFilter": "Сбросить фильтр",
+ "allHidden": "Все подзадачи скрыты фильтром."
},
"subtaskDisposal": {
"intro": "{issues, plural, one {У этой задачи} other {У этих задач}} {count, plural, one {# подзадача} few {# подзадачи} many {# подзадач} other {# подзадачи}}.",
diff --git a/apps/web/messages/uk/issue.json b/apps/web/messages/uk/issue.json
index 3517af14..342ec2d6 100644
--- a/apps/web/messages/uk/issue.json
+++ b/apps/web/messages/uk/issue.json
@@ -198,7 +198,11 @@
"detachFromParent": "Відв'язати від {parent}",
"subtaskOf": "Підзадача {issue}",
"existingIssue": "Наявна задача",
- "searchPrompt": "Пошук задач, щоб додати підзадачею…"
+ "searchPrompt": "Пошук задач, щоб додати підзадачею…",
+ "filter": "Фільтр за статусом",
+ "hiding": "Приховано: {states}",
+ "clearFilter": "Скинути фільтр",
+ "allHidden": "Усі підзадачі приховані фільтром."
},
"subtaskDisposal": {
"intro": "{issues, plural, one {Ця задача має} other {Ці задачі мають}} {count, plural, one {# підзадачу} few {# підзадачі} many {# підзадач} other {# підзадачі}}.",
diff --git a/apps/web/messages/zh-CN/issue.json b/apps/web/messages/zh-CN/issue.json
index 49c5b710..5bafc756 100644
--- a/apps/web/messages/zh-CN/issue.json
+++ b/apps/web/messages/zh-CN/issue.json
@@ -198,7 +198,11 @@
"detachFromParent": "从 {parent} 分离",
"subtaskOf": "{issue} 的子任务",
"existingIssue": "现有工作项",
- "searchPrompt": "搜索要添加为子任务的工作项…"
+ "searchPrompt": "搜索要添加为子任务的工作项…",
+ "filter": "按状态筛选",
+ "hiding": "已隐藏:{states}",
+ "clearFilter": "清除筛选",
+ "allHidden": "所有子任务都被筛选隐藏了。"
},
"subtaskDisposal": {
"intro": "{issues, plural, other {这些工作项包含}} {count, plural, other {# 个子任务}}。",
diff --git a/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsx b/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsx
index 0d4eed13..0c0598eb 100644
--- a/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsx
+++ b/apps/web/src/features/issue/components/detail/IssueLinksPanel.tsx
@@ -6,10 +6,12 @@ import { LINK_RELATIONS, inverseRelation, linkRelation, storedKind } from '@/uti
import { useLinkRelationLabel } from '@/hooks/useLinkRelationLabel';
import { usePersistedOpen } from '../../hooks/usePersistedOpen';
import { useLinkIssues, useUnlinkIssues } from '../../services/links.service';
+import { useSetRelatedIssueState } from '../../services/relatedIssues.service';
import NewIssueModal from '../create/NewIssueModal';
import IssueLinkDialog from './IssueLinkDialog';
import IssueLinksAddMenu from './IssueLinksAddMenu';
import IssueRefRow from './IssueRefRow';
+import IssueRefList from './IssueRefList';
import IssueSectionHeading from './IssueSectionHeading';
import { useTranslations } from 'next-intl';
@@ -44,6 +46,7 @@ export default function IssueLinksPanel({
const { open, toggle } = usePersistedOpen('issue-links-open');
const linkIssues = useLinkIssues();
const unlinkIssues = useUnlinkIssues();
+ const setState = useSetRelatedIssueState(project.project.ref, issue.id);
const links = issue.links;
if (readOnly && links.length === 0) return null;
@@ -77,10 +80,10 @@ export default function IssueLinksPanel({
{t('emptyHint')}
</p>
) : (
- <div className="flex flex-col gap-3">
+ <IssueRefList className="gap-y-3">
{groups.map((group) => (
- <div key={group.relation}>
- <h4 className="mb-1 px-2 text-xs font-medium text-muted-foreground">
+ <div key={group.relation} className="col-span-full grid grid-cols-subgrid">
+ <h4 className="col-span-full mb-1 px-2 text-xs font-medium text-muted-foreground">
{relationLabel(group.relation)}
</h4>
{group.links.map((link) => (
@@ -92,6 +95,9 @@ export default function IssueLinksPanel({
removeLabel={t('remove', { issue: link.issue.identifier })}
readOnly={readOnly}
onOpen={onOpenIssue && (() => onOpenIssue(link.issue.id))}
+ onChangeState={
+ canEdit ? (columnId) => setState(link.issue.id, columnId) : undefined
+ }
onRemove={
canEdit
? () =>
@@ -107,7 +113,7 @@ export default function IssueLinksPanel({
))}
</div>
))}
- </div>
+ </IssueRefList>
))}
{adding && (
diff --git a/apps/web/src/features/issue/components/detail/IssueRefList.tsx b/apps/web/src/features/issue/components/detail/IssueRefList.tsx
new file mode 100644
index 00000000..abd689c6
--- /dev/null
+++ b/apps/web/src/features/issue/components/detail/IssueRefList.tsx
@@ -0,0 +1,19 @@
+import type { ReactNode } from 'react';
+import { cn } from '@/lib/utils';
+
+// The grid IssueRefRows share, so the identifiers, titles and statuses of all rows
+// line up: each column takes the width of its widest cell, whatever the project
+// names its columns.
+export default function IssueRefList({
+ children,
+ className,
+}: {
+ children: ReactNode;
+ className?: string;
+}) {
+ return (
+ <div className={cn('grid grid-cols-[auto_auto_minmax(0,1fr)_auto_auto] gap-x-2', className)}>
+ {children}
+ </div>
+ );
+}
diff --git a/apps/web/src/features/issue/components/detail/IssueRefRow.tsx b/apps/web/src/features/issue/components/detail/IssueRefRow.tsx
index f3553d35..db185337 100644
--- a/apps/web/src/features/issue/components/detail/IssueRefRow.tsx
+++ b/apps/web/src/features/issue/components/detail/IssueRefRow.tsx
@@ -4,16 +4,18 @@ import type { ProjectDetail } from '@/lib/api/endpoints/projects';
import type { IssueRef } from '@/lib/api/endpoints/issues';
import { issuePath } from '@/utils/paths';
import { Button } from '@/components/ui/button';
+import PopoverPick from '@/components/common/fields/PopoverPick';
import ArchivedBadge from '@/components/common/ArchivedBadge';
import {
historyScrollRestorationAnchorProps,
historyScrollRestorationLinkProps,
} from '@/hooks/useHistoryScrollRestoration';
import { StateIcon } from '../shared/IssueIcons';
+import { useTranslations } from 'next-intl';
// One other issue in the Links or Subtasks panel — the far end of a relation, a
// subtask, or the parent an issue hangs under — with its status, opening its page
-// on click. onRemove is absent when the member cannot edit; removeLabel names what
+// on click. onRemove and onChangeState are absent when the member cannot edit; removeLabel names what
// removing it does, for the screen reader. A public share has no issue pages to
// link to, so it passes onOpen and the row opens the issue where it stands; a
// share that cannot open it at all (a single shared issue) passes neither and the
@@ -24,6 +26,7 @@ export default function IssueRefRow({
scrollAnchorKey,
removeLabel,
onRemove,
+ onChangeState,
onOpen,
readOnly,
}: {
@@ -32,22 +35,27 @@ export default function IssueRefRow({
scrollAnchorKey: string;
removeLabel: string;
onRemove?: () => void;
+ onChangeState?: (columnId: number) => void;
onOpen?: () => void;
readOnly?: boolean;
}) {
+ const t = useTranslations('issue.fieldSelects');
const column = project.columns.find((c) => c.id === issue.columnId);
const label = (
<>
- <span className="shrink-0 font-mono text-xs text-muted-foreground">{issue.identifier}</span>
- <span className="truncate text-sm">{issue.title}</span>
+ <span className="font-mono text-xs text-muted-foreground">{issue.identifier}</span>
+ <span className="flex min-w-0 items-center gap-2">
+ <span className="truncate text-sm">{issue.title}</span>
+ {issue.archived && <ArchivedBadge />}
+ </span>
</>
);
- const labelClass = 'flex min-w-0 flex-1 items-center gap-2';
+ const labelClass = 'col-span-2 col-start-2 grid grid-cols-subgrid items-center';
function renderName() {
if (onOpen)
return (
- <button type="button" onClick={onOpen} className={`${labelClass} text-left`}>
+ <button type="button" onClick={onOpen} className={`${labelClass} text-start`}>
{label}
</button>
);
@@ -65,16 +73,42 @@ export default function IssueRefRow({
}
return (
- <div className="group flex items-center gap-2 rounded-md px-2 py-1.5 hover:bg-accent/50">
- {column && <StateIcon stateType={column.stateType} color={column.color} />}
+ <div className="group col-span-full grid grid-cols-subgrid items-center rounded-md px-2 py-1.5 hover:bg-accent/50">
+ {column && (
+ <StateIcon className="col-start-1" stateType={column.stateType} color={column.color} />
+ )}
{renderName()}
- {issue.archived && <ArchivedBadge />}
- {column && <span className="shrink-0 text-xs text-muted-foreground">{column.name}</span>}
+ {column &&
+ (onChangeState ? (
+ <PopoverPick
+ align="end"
+ inputPlaceholder={t('changeState')}
+ emptyText={t('noState')}
+ trigger={
+ <button
+ type="button"
+ className="col-start-4 text-start text-xs text-muted-foreground hover:text-foreground"
+ >
+ {column.name}
+ </button>
+ }
+ items={project.columns.map((c) => ({
+ key: String(c.id),
+ search: c.name,
+ icon: <StateIcon stateType={c.stateType} color={c.color} />,
+ label: c.name,
+ selected: c.id === column.id,
+ onSelect: () => onChangeState(c.id),
+ }))}
+ />
+ ) : (
+ <span className="col-start-4 text-xs text-muted-foreground">{column.name}</span>
+ ))}
{onRemove && (
<Button
variant="ghost"
size="icon"
- className="size-6 shrink-0 opacity-0 group-hover:opacity-100 hover:text-destructive"
+ className="col-start-5 size-6 opacity-0 group-hover:opacity-100 hover:text-destructive"
aria-label={removeLabel}
onClick={onRemove}
>
diff --git a/apps/web/src/features/issue/components/detail/IssueSubtasksFilterChip.tsx b/apps/web/src/features/issue/components/detail/IssueSubtasksFilterChip.tsx
new file mode 100644
index 00000000..25ba963d
--- /dev/null
+++ b/apps/web/src/features/issue/components/detail/IssueSubtasksFilterChip.tsx
@@ -0,0 +1,23 @@
+import { X } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import type { SubtaskStateFilter } from '../../hooks/useSubtaskStateFilter';
+
+export default function IssueSubtasksFilterChip({ filter }: { filter: SubtaskStateFilter }) {
+ const t = useTranslations('issue.subtasks');
+ if (filter.hidden.length === 0) return null;
+ return (
+ <span className="flex min-w-0 items-center gap-0.5 rounded-full bg-primary/10 py-0.5 ps-2 pe-0.5 text-xs text-primary">
+ <span className="truncate">
+ {t('hiding', { states: filter.hidden.map((c) => c.name).join(', ') })}
+ </span>
+ <button
+ type="button"
+ className="flex size-4 shrink-0 items-center justify-center rounded-full hover:bg-primary/20"
+ aria-label={t('clearFilter')}
+ onClick={filter.showAll}
+ >
+ <X className="size-3" />
+ </button>
+ </span>
+ );
+}
diff --git a/apps/web/src/features/issue/components/detail/IssueSubtasksFilterMenu.tsx b/apps/web/src/features/issue/components/detail/IssueSubtasksFilterMenu.tsx
new file mode 100644
index 00000000..642d7b00
--- /dev/null
+++ b/apps/web/src/features/issue/components/detail/IssueSubtasksFilterMenu.tsx
@@ -0,0 +1,45 @@
+import { ListFilter } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import { Button } from '@/components/ui/button';
+import {
+ DropdownMenu,
+ DropdownMenuCheckboxItem,
+ DropdownMenuContent,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu';
+import type { SubtaskStateFilter } from '../../hooks/useSubtaskStateFilter';
+import { StateIcon } from '../shared/IssueIcons';
+
+export default function IssueSubtasksFilterMenu({ filter }: { filter: SubtaskStateFilter }) {
+ const t = useTranslations('issue.subtasks');
+ if (filter.columns.length === 0) return null;
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon"
+ className={`size-7 ${filter.hidden.length > 0 ? 'text-primary' : ''}`}
+ title={t('filter')}
+ aria-label={t('filter')}
+ >
+ <ListFilter className="size-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-52">
+ {filter.columns.map(({ column, count }) => (
+ <DropdownMenuCheckboxItem
+ key={column.id}
+ checked={filter.isShown(column.id)}
+ onCheckedChange={() => filter.toggle(column.id)}
+ onSelect={(e) => e.preventDefault()}
+ >
+ <StateIcon stateType={column.stateType} color={column.color} />
+ <span className="flex-1 truncate">{column.name}</span>
+ <span className="text-xs text-muted-foreground tabular-nums">{count}</span>
+ </DropdownMenuCheckboxItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
diff --git a/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsx b/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsx
index cc060a11..2cc83178 100644
--- a/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsx
+++ b/apps/web/src/features/issue/components/detail/IssueSubtasksPanel.tsx
@@ -14,9 +14,14 @@ import {
import IssuePickerDialog from '@/components/common/overlay/IssuePickerDialog';
import NewIssueModal from '../create/NewIssueModal';
import { usePersistedOpen } from '../../hooks/usePersistedOpen';
+import { useSubtaskStateFilter } from '../../hooks/useSubtaskStateFilter';
import { useSetIssueParent } from '../../services/subtasks.service';
+import { useSetRelatedIssueState } from '../../services/relatedIssues.service';
import IssueSectionHeading from './IssueSectionHeading';
import IssueRefRow from './IssueRefRow';
+import IssueRefList from './IssueRefList';
+import IssueSubtasksFilterChip from './IssueSubtasksFilterChip';
+import IssueSubtasksFilterMenu from './IssueSubtasksFilterMenu';
import { useTranslations } from 'next-intl';
// The issue's place in the subtask hierarchy: the parent it hangs under, or the
@@ -46,7 +51,9 @@ export default function IssueSubtasksPanel({
const [attaching, setAttaching] = useState(false);
const [creating, setCreating] = useState(false);
const { open, toggle } = usePersistedOpen('issue-subtasks-open');
+ const filter = useSubtaskStateFilter(project, issue.subtasks);
const setParent = useSetIssueParent();
+ const setState = useSetRelatedIssueState(project.project.ref, issue.id);
const parent = issue.parent;
if (readOnly && !parent && issue.subtasks.length === 0) return null;
@@ -65,15 +72,18 @@ export default function IssueSubtasksPanel({
function body() {
if (parent)
return (
- <IssueRefRow
- project={project}
- issue={parent}
- scrollAnchorKey={`parent:${parent.id}`}
- removeLabel={t('detachFromParent', { parent: parent.identifier })}
- readOnly={readOnly}
- onOpen={onOpenIssue && (() => onOpenIssue(parent.id))}
- onRemove={canEdit ? () => detach(issue.id, parent.id) : undefined}
- />
+ <IssueRefList>
+ <IssueRefRow
+ project={project}
+ issue={parent}
+ scrollAnchorKey={`parent:${parent.id}`}
+ removeLabel={t('detachFromParent', { parent: parent.identifier })}
+ readOnly={readOnly}
+ onOpen={onOpenIssue && (() => onOpenIssue(parent.id))}
+ onRemove={canEdit ? () => detach(issue.id, parent.id) : undefined}
+ onChangeState={canEdit ? (columnId) => setState(parent.id, columnId) : undefined}
+ />
+ </IssueRefList>
);
if (issue.subtasks.length === 0)
return (
@@ -81,53 +91,75 @@ export default function IssueSubtasksPanel({
{canEdit ? t('emptyHint') : t('empty')}
</p>
);
- return issue.subtasks.map((subtask) => (
- <IssueRefRow
- key={subtask.id}
- project={project}
- issue={subtask}
- scrollAnchorKey={`subtask:${subtask.id}`}
- removeLabel={t('detach', { subtask: subtask.identifier })}
- readOnly={readOnly}
- onOpen={onOpenIssue && (() => onOpenIssue(subtask.id))}
- onRemove={canEdit ? () => detach(subtask.id, issue.id) : undefined}
- />
- ));
+ if (filter.shownSubtasks.length === 0)
+ return (
+ <p className="rounded-md border border-dashed p-4 text-center text-sm text-muted-foreground">
+ {t('allHidden')}
+ </p>
+ );
+ return (
+ <IssueRefList>
+ {filter.shownSubtasks.map((subtask) => (
+ <IssueRefRow
+ key={subtask.id}
+ project={project}
+ issue={subtask}
+ scrollAnchorKey={`subtask:${subtask.id}`}
+ removeLabel={t('detach', { subtask: subtask.identifier })}
+ readOnly={readOnly}
+ onOpen={onOpenIssue && (() => onOpenIssue(subtask.id))}
+ onRemove={canEdit ? () => detach(subtask.id, issue.id) : undefined}
+ onChangeState={canEdit ? (columnId) => setState(subtask.id, columnId) : undefined}
+ />
+ ))}
+ </IssueRefList>
+ );
}
return (
// Collapsed, the heading row is all there is, so the section pulls itself up
// against the section below it.
<div className={`mt-6 border-t pt-5 ${open ? '' : '-mb-2'}`}>
- {/* Fixed height: the Add button only renders while the section is open, and
+ {/* Fixed height: the buttons only render while the section is open, and
without it the row would shrink to the height of the heading text. */}
<div className={`flex h-7 items-center justify-between gap-3 ${open ? 'mb-3' : ''}`}>
- <IssueSectionHeading
- label={parent ? t('parent') : t('title')}
- open={open}
- onToggle={toggle}
- tally={done}
- />
- {open && !parent && canEdit && (
- <DropdownMenu>
- <DropdownMenuTrigger asChild>
- <Button variant="ghost" size="sm" className="h-7 gap-1.5">
- <Plus className="size-4" />
- {tCommon('add')}
- </Button>
- </DropdownMenuTrigger>
- <DropdownMenuContent align="end" className="w-44">
- {canCreate && (
- <DropdownMenuItem onSelect={() => setCreating(true)}>
- {t('newSubtask')}
+ <div className="flex min-w-0 items-center gap-2">
+ <IssueSectionHeading
+ label={parent ? t('parent') : t('title')}
+ open={open}
+ onToggle={toggle}
+ tally={done}
+ />
+ {open && !parent && <IssueSubtasksFilterChip filter={filter} />}
+ </div>
+ <div className="flex shrink-0 items-center gap-1">
+ {open && !parent && <IssueSubtasksFilterMenu filter={filter} />}
+ {open && !parent && canEdit && (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="ghost"
+ size="icon"
+ className="size-7"
+ title={tCommon('add')}
+ aria-label={tCommon('add')}
+ >
+ <Plus className="size-4" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" className="w-44">
+ {canCreate && (
+ <DropdownMenuItem onSelect={() => setCreating(true)}>
+ {t('newSubtask')}
+ </DropdownMenuItem>
+ )}
+ <DropdownMenuItem onSelect={() => setAttaching(true)}>
+ {t('existingIssue')}
</DropdownMenuItem>
- )}
- <DropdownMenuItem onSelect={() => setAttaching(true)}>
- {t('existingIssue')}
- </DropdownMenuItem>
- </DropdownMenuContent>
- </DropdownMenu>
- )}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )}
+ </div>
</div>
{open && body()}
diff --git a/apps/web/src/features/issue/hooks/usePersistedOpen.ts b/apps/web/src/features/issue/hooks/usePersistedOpen.ts
index 6b7b2db2..dddd123b 100644
--- a/apps/web/src/features/issue/hooks/usePersistedOpen.ts
+++ b/apps/web/src/features/issue/hooks/usePersistedOpen.ts
@@ -62,5 +62,14 @@ export function usePersistedOpenGroups(storageKey: string) {
[storageKey],
);
- return { isOpen: (key: string) => !closed.includes(key), toggle };
+ const openAll = useCallback(() => {
+ setClosed([]);
+ try {
+ localStorage.removeItem(storageKey);
+ } catch {
+ // Ignore write failures (private mode / quota); the state still updates.
+ }
+ }, [storageKey]);
+
+ return { isOpen: (key: string) => !closed.includes(key), toggle, openAll };
}
diff --git a/apps/web/src/features/issue/hooks/useSubtaskStateFilter.ts b/apps/web/src/features/issue/hooks/useSubtaskStateFilter.ts
new file mode 100644
index 00000000..5d288f17
--- /dev/null
+++ b/apps/web/src/features/issue/hooks/useSubtaskStateFilter.ts
@@ -0,0 +1,27 @@
+import type { ProjectDetail } from '@/lib/api/endpoints/projects';
+import type { IssueRef } from '@/lib/api/endpoints/issues';
+import { usePersistedOpenGroups } from './usePersistedOpen';
+
+// Which states the Subtasks panel hides, remembered per project. Only the states
+// the subtasks are in are offered, each with how many subtasks it holds.
+export function useSubtaskStateFilter(project: ProjectDetail, subtasks: IssueRef[]) {
+ const shown = usePersistedOpenGroups(`issue-subtasks-hidden-states:${project.project.id}`);
+
+ const columns = project.columns
+ .map((column) => ({
+ column,
+ count: subtasks.filter((s) => s.columnId === column.id).length,
+ }))
+ .filter((entry) => entry.count > 0);
+
+ return {
+ columns,
+ hidden: columns.filter(({ column }) => !shown.isOpen(String(column.id))).map((e) => e.column),
+ shownSubtasks: subtasks.filter((s) => shown.isOpen(String(s.columnId))),
+ isShown: (columnId: number) => shown.isOpen(String(columnId)),
+ toggle: (columnId: number) => shown.toggle(String(columnId)),
+ showAll: shown.openAll,
+ };
+}
+
+export type SubtaskStateFilter = ReturnType<typeof useSubtaskStateFilter>;
diff --git a/apps/web/src/features/issue/services/relatedIssues.service.ts b/apps/web/src/features/issue/services/relatedIssues.service.ts
new file mode 100644
index 00000000..6bb7a8cc
--- /dev/null
+++ b/apps/web/src/features/issue/services/relatedIssues.service.ts
@@ -0,0 +1,23 @@
+// Changing the state of an issue listed on another issue's page: a subtask, the
+// parent, a linked issue. The list is read from the viewed issue's detail, so that
+// detail and its feed refresh too, besides what useUpdateIssue refreshes for the
+// changed issue.
+
+import { useQueryClient } from '@tanstack/react-query';
+import { useUpdateIssue } from '@/services/issues.service';
+import { qk } from '@/services/queryKeys';
+
+export function useSetRelatedIssueState(projectKey: string, viewedIssueId: number) {
+ const qc = useQueryClient();
+ const updateIssue = useUpdateIssue(projectKey);
+ return (issueId: number, columnId: number) =>
+ updateIssue.mutate(
+ { id: issueId, patch: { columnId } },
+ {
+ onSettled: () => {
+ void qc.invalidateQueries({ queryKey: qk.issue(viewedIssueId) });
+ void qc.invalidateQueries({ queryKey: qk.feed(viewedIssueId) });
+ },
+ },
+ );
+}