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; loadMoreIssues: (() => void) | undefined; 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; } 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, loadMoreIssues, viewId, disableIssueCreation, storeType, addIssuesToView, canEditProperties, scrollableContainerRef, isDragStarted, showEmptyGroup = true, } = 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 groupWithIssues = list.filter((_list) => (issueIds as TGroupedIssues)?.[_list.id]?.issueCount > 0); const groupList = showEmptyGroup ? list : groupWithIssues; const visibilityGroupBy = (_list: IGroupByColumn) => { if (sub_group_by) { if (kanbanFilters?.sub_group_by.includes(_list.id)) return true; return false; } else { if (kanbanFilters?.group_by.includes(_list.id)) return true; return false; } }; const isGroupByCreatedBy = group_by === "created_by"; return (
{groupList && groupList.length > 0 && groupList.map((_list: IGroupByColumn) => { const groupByVisibilityToggle = visibilityGroupBy(_list); return (
{sub_group_by === null && (
)} {!groupByVisibilityToggle && ( )}
); })}
); }); export interface IKanBan { issuesMap: IIssueMap; issueIds: TGroupedIssues | TSubGroupedIssues; 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; loadMoreIssues: (() => void) | undefined; 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; } export const KanBan: React.FC = observer((props) => { const { issuesMap, issueIds, displayProperties, sub_group_by, group_by, sub_group_id = "null", updateIssue, quickActions, kanbanFilters, handleKanbanFilters, loadMoreIssues, enableQuickIssueCreate, quickAddCallback, viewId, disableIssueCreation, storeType, addIssuesToView, canEditProperties, scrollableContainerRef, isDragStarted, showEmptyGroup, } = props; const issueKanBanView = useKanbanView(); return ( ); });