import { MutableRefObject } from "react"; import { observer } from "mobx-react-lite"; // constants // hooks import { useCycle, useIssueDetail, useKanbanView, useLabel, useMember, useModule, useProject, useProjectState, } from "hooks/store"; // types import { GroupByColumnTypes, IGroupByColumn, TGroupedIssues, TIssue, IIssueDisplayProperties, IIssueMap, TSubGroupedIssues, TUnGroupedIssues, TIssueKanbanFilters, } from "@plane/types"; // parent components import { getGroupByColumns } from "../utils"; // components import { HeaderGroupByCard } from "./headers/group-by-card"; import { KanbanGroup } from "./kanban-group"; import { KanbanStoreType } from "./base-kanban-root"; export interface IGroupByKanBan { issuesMap: IIssueMap; issueIds: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues; displayProperties: IIssueDisplayProperties | undefined; sub_group_by: string | null; group_by: string | null; sub_group_id: string; isDragDisabled: boolean; updateIssue: ((projectId: string, issueId: string, data: Partial) => Promise) | undefined; quickActions: (issue: TIssue, customActionButton?: React.ReactElement) => React.ReactNode; kanbanFilters: TIssueKanbanFilters; handleKanbanFilters: any; enableQuickIssueCreate?: boolean; quickAddCallback?: ( workspaceSlug: string, projectId: string, data: TIssue, viewId?: string ) => Promise; viewId?: string; disableIssueCreation?: boolean; storeType: KanbanStoreType; addIssuesToView?: (issueIds: string[]) => Promise; canEditProperties: (projectId: string | undefined) => boolean; scrollableContainerRef?: MutableRefObject; isDragStarted?: boolean; showEmptyGroup?: boolean; subGroupIssueHeaderCount?: (listId: string) => number; } const GroupByKanBan: React.FC = observer((props) => { const { issuesMap, issueIds, displayProperties, sub_group_by, group_by, sub_group_id = "null", isDragDisabled, updateIssue, quickActions, kanbanFilters, handleKanbanFilters, enableQuickIssueCreate, quickAddCallback, viewId, disableIssueCreation, storeType, addIssuesToView, canEditProperties, scrollableContainerRef, isDragStarted, showEmptyGroup = true, subGroupIssueHeaderCount, } = props; const member = useMember(); const project = useProject(); const label = useLabel(); const cycle = useCycle(); const moduleInfo = useModule(); const projectState = useProjectState(); const { peekIssue } = useIssueDetail(); const list = getGroupByColumns( group_by as GroupByColumnTypes, project, cycle, moduleInfo, label, projectState, member ); if (!list) return null; const visibilityGroupBy = (_list: IGroupByColumn): { showGroup: boolean; showIssues: boolean } => { if (sub_group_by) { const groupVisibility = { showGroup: true, showIssues: true, }; if (!showEmptyGroup) { groupVisibility.showGroup = subGroupIssueHeaderCount ? subGroupIssueHeaderCount(_list.id) > 0 : true; } return groupVisibility; } else { const groupVisibility = { showGroup: true, showIssues: true, }; if (!showEmptyGroup) { if ((issueIds as TGroupedIssues)?.[_list.id]?.length > 0) groupVisibility.showGroup = true; else groupVisibility.showGroup = false; } if (kanbanFilters?.group_by.includes(_list.id)) groupVisibility.showIssues = false; return groupVisibility; } }; const isGroupByCreatedBy = group_by === "created_by"; return (
{list && list.length > 0 && list.map((subList: IGroupByColumn) => { const groupByVisibilityToggle = visibilityGroupBy(subList); if (groupByVisibilityToggle.showGroup === false) return <>; return (
{sub_group_by === null && (
)} {groupByVisibilityToggle.showIssues && ( )}
); })}
); }); export interface IKanBan { issuesMap: IIssueMap; issueIds: TGroupedIssues | TSubGroupedIssues | TUnGroupedIssues; displayProperties: IIssueDisplayProperties | undefined; sub_group_by: string | null; group_by: string | null; sub_group_id?: string; updateIssue: ((projectId: string, issueId: string, data: Partial) => Promise) | undefined; quickActions: (issue: TIssue, customActionButton?: React.ReactElement) => React.ReactNode; kanbanFilters: TIssueKanbanFilters; handleKanbanFilters: (toggle: "group_by" | "sub_group_by", value: string) => void; showEmptyGroup: boolean; enableQuickIssueCreate?: boolean; quickAddCallback?: ( workspaceSlug: string, projectId: string, data: TIssue, viewId?: string ) => Promise; viewId?: string; disableIssueCreation?: boolean; storeType: KanbanStoreType; addIssuesToView?: (issueIds: string[]) => Promise; canEditProperties: (projectId: string | undefined) => boolean; scrollableContainerRef?: MutableRefObject; isDragStarted?: boolean; subGroupIssueHeaderCount?: (listId: string) => number; } export const KanBan: React.FC = observer((props) => { const { issuesMap, issueIds, displayProperties, sub_group_by, group_by, sub_group_id = "null", updateIssue, quickActions, kanbanFilters, handleKanbanFilters, enableQuickIssueCreate, quickAddCallback, viewId, disableIssueCreation, storeType, addIssuesToView, canEditProperties, scrollableContainerRef, isDragStarted, showEmptyGroup, subGroupIssueHeaderCount, } = props; const issueKanBanView = useKanbanView(); return ( ); });