import React from "react"; // components import { ListGroupByHeaderRoot } from "./headers/group-by-root"; import { IssueBlocksList, ListQuickAddIssueForm } from "components/issues"; // types import { IIssue, IIssueDisplayProperties, IIssueLabel, IProject, IState, IUserLite } from "types"; import { IIssueResponse, IGroupedIssues, TUnGroupedIssues, ViewFlags } from "store/issues/types"; import { EIssueActions } from "../types"; // constants import { getValueFromObject } from "constants/issue"; import { EProjectStore } from "store/command-palette.store"; export interface IGroupByList { issueIds: IGroupedIssues | TUnGroupedIssues | any; issues: any; group_by: string | null; list: any; listKey: string; states: IState[] | null; is_list?: boolean; handleIssues: (issue: IIssue, action: EIssueActions) => Promise; quickActions: (group_by: string | null, issue: IIssue) => React.ReactNode; displayProperties: IIssueDisplayProperties | undefined; enableIssueQuickAdd: boolean; showEmptyGroup?: boolean; isReadonly: boolean; quickAddCallback?: ( workspaceSlug: string, projectId: string, data: IIssue, viewId?: string ) => Promise; disableIssueCreation?: boolean; currentStore: EProjectStore; viewId?: string; } const GroupByList: React.FC = (props) => { const { issueIds, issues, group_by, list, listKey, is_list = false, states, handleIssues, quickActions, displayProperties, enableIssueQuickAdd, showEmptyGroup, isReadonly, quickAddCallback, viewId, disableIssueCreation, currentStore, } = props; const prePopulateQuickAddData = (groupByKey: string | null, value: any) => { const defaultState = states?.find((state) => state.default); if (groupByKey === null) return { state: defaultState?.id }; else { if (groupByKey === "state") return { state: groupByKey === "state" ? value : defaultState?.id }; else return { state: defaultState?.id, [groupByKey]: value }; } }; const validateEmptyIssueGroups = (issues: IIssue[]) => { const issuesCount = issues?.length || 0; if (!showEmptyGroup && issuesCount <= 0) return false; return true; }; return (
{list && list.length > 0 && list.map( (_list: any) => validateEmptyIssueGroups(is_list ? issueIds : issueIds?.[getValueFromObject(_list, listKey) as string]) && (
{issues && ( )} {enableIssueQuickAdd && (
)}
) )}
); }; export interface IList { issueIds: IGroupedIssues | TUnGroupedIssues | any; issues: IIssueResponse | undefined; group_by: string | null; handleIssues: (issue: IIssue, action: EIssueActions) => Promise; quickActions: (group_by: string | null, issue: IIssue) => React.ReactNode; displayProperties: IIssueDisplayProperties | undefined; showEmptyGroup: boolean; enableIssueQuickAdd: boolean; isReadonly: boolean; states: IState[] | null; labels: IIssueLabel[] | null; members: IUserLite[] | null; projects: IProject[] | null; stateGroups: any; priorities: any; quickAddCallback?: ( workspaceSlug: string, projectId: string, data: IIssue, viewId?: string ) => Promise; viewId?: string; disableIssueCreation?: boolean; currentStore: EProjectStore; } export const List: React.FC = (props) => { const { issueIds, issues, group_by, handleIssues, quickActions, quickAddCallback, viewId, displayProperties, showEmptyGroup, enableIssueQuickAdd, isReadonly, disableIssueCreation, states, stateGroups, priorities, labels, members, projects, currentStore, } = props; return (
{group_by === null && ( )} {group_by && group_by === "project" && projects && ( )} {group_by && group_by === "state" && states && ( )} {group_by && group_by === "state_detail.group" && stateGroups && ( )} {group_by && group_by === "priority" && priorities && ( )} {group_by && group_by === "labels" && labels && ( )} {group_by && group_by === "assignees" && members && ( )} {group_by && group_by === "created_by" && members && ( )}
); };