fix: calendar filters and handled kanban issue empty state dnd error

This commit is contained in:
gurusainath 2023-12-08 12:45:08 +05:30
parent 9147b58b99
commit 0611ff221f
11 changed files with 127 additions and 59 deletions

View File

@ -16,7 +16,6 @@ import {
IViewIssuesFilterStore, IViewIssuesFilterStore,
IViewIssuesStore, IViewIssuesStore,
} from "store/issues"; } from "store/issues";
import { IIssueCalendarViewStore } from "store/issue";
import { IQuickActionProps } from "../list/list-view-types"; import { IQuickActionProps } from "../list/list-view-types";
import { EIssueActions } from "../types"; import { EIssueActions } from "../types";
import { IGroupedIssues } from "store/issues/types"; import { IGroupedIssues } from "store/issues/types";
@ -28,7 +27,6 @@ interface IBaseCalendarRoot {
| IModuleIssuesFilterStore | IModuleIssuesFilterStore
| ICycleIssuesFilterStore | ICycleIssuesFilterStore
| IViewIssuesFilterStore; | IViewIssuesFilterStore;
calendarViewStore: IIssueCalendarViewStore;
QuickActions: FC<IQuickActionProps>; QuickActions: FC<IQuickActionProps>;
issueActions: { issueActions: {
[EIssueActions.DELETE]: (issue: IIssue) => Promise<void>; [EIssueActions.DELETE]: (issue: IIssue) => Promise<void>;
@ -77,13 +75,14 @@ export const BaseCalendarRoot = observer((props: IBaseCalendarRoot) => {
<div className="h-full w-full pt-4 bg-custom-background-100 overflow-hidden"> <div className="h-full w-full pt-4 bg-custom-background-100 overflow-hidden">
<DragDropContext onDragEnd={onDragEnd}> <DragDropContext onDragEnd={onDragEnd}>
<CalendarChart <CalendarChart
issuesFilterStore={issuesFilterStore}
issues={issues} issues={issues}
groupedIssueIds={groupedIssueIds} groupedIssueIds={groupedIssueIds}
layout={displayFilters?.calendar?.layout} layout={displayFilters?.calendar?.layout}
showWeekends={displayFilters?.calendar?.show_weekends ?? false} showWeekends={displayFilters?.calendar?.show_weekends ?? false}
quickActions={(issue, customActionButton) => ( quickActions={(issue, customActionButton) => (
<QuickActions <QuickActions
customActionButton={customActionButton} customActionButton={customActionButton}
issue={issue} issue={issue}
handleDelete={async () => handleIssues(issue.target_date ?? "", issue, EIssueActions.DELETE)} handleDelete={async () => handleIssues(issue.target_date ?? "", issue, EIssueActions.DELETE)}
handleUpdate={ handleUpdate={

View File

@ -10,8 +10,19 @@ import { Spinner } from "@plane/ui";
import { ICalendarWeek } from "./types"; import { ICalendarWeek } from "./types";
import { IIssue } from "types"; import { IIssue } from "types";
import { IGroupedIssues, IIssueResponse } from "store/issues/types"; import { IGroupedIssues, IIssueResponse } from "store/issues/types";
import {
ICycleIssuesFilterStore,
IModuleIssuesFilterStore,
IProjectIssuesFilterStore,
IViewIssuesFilterStore,
} from "store/issues";
type Props = { type Props = {
issuesFilterStore:
| IProjectIssuesFilterStore
| IModuleIssuesFilterStore
| ICycleIssuesFilterStore
| IViewIssuesFilterStore;
issues: IIssueResponse | undefined; issues: IIssueResponse | undefined;
groupedIssueIds: IGroupedIssues; groupedIssueIds: IGroupedIssues;
layout: "month" | "week" | undefined; layout: "month" | "week" | undefined;
@ -27,7 +38,8 @@ type Props = {
}; };
export const CalendarChart: React.FC<Props> = observer((props) => { export const CalendarChart: React.FC<Props> = observer((props) => {
const { issues, groupedIssueIds, layout, showWeekends, quickActions, quickAddCallback, viewId } = props; const { issuesFilterStore, issues, groupedIssueIds, layout, showWeekends, quickActions, quickAddCallback, viewId } =
props;
const { calendar: calendarStore } = useMobxStore(); const { calendar: calendarStore } = useMobxStore();
@ -45,7 +57,7 @@ export const CalendarChart: React.FC<Props> = observer((props) => {
return ( return (
<> <>
<div className="h-full w-full flex flex-col overflow-hidden"> <div className="h-full w-full flex flex-col overflow-hidden">
<CalendarHeader /> <CalendarHeader issuesFilterStore={issuesFilterStore} />
<CalendarWeekHeader isLoading={!issues} showWeekends={showWeekends} /> <CalendarWeekHeader isLoading={!issues} showWeekends={showWeekends} />
<div className="h-full w-full overflow-y-auto"> <div className="h-full w-full overflow-y-auto">
{layout === "month" && ( {layout === "month" && (
@ -53,6 +65,7 @@ export const CalendarChart: React.FC<Props> = observer((props) => {
{allWeeksOfActiveMonth && {allWeeksOfActiveMonth &&
Object.values(allWeeksOfActiveMonth).map((week: ICalendarWeek, weekIndex) => ( Object.values(allWeeksOfActiveMonth).map((week: ICalendarWeek, weekIndex) => (
<CalendarWeekDays <CalendarWeekDays
issuesFilterStore={issuesFilterStore}
key={weekIndex} key={weekIndex}
week={week} week={week}
issues={issues} issues={issues}
@ -67,6 +80,7 @@ export const CalendarChart: React.FC<Props> = observer((props) => {
)} )}
{layout === "week" && ( {layout === "week" && (
<CalendarWeekDays <CalendarWeekDays
issuesFilterStore={issuesFilterStore}
week={calendarStore.allDaysOfActiveWeek} week={calendarStore.allDaysOfActiveWeek}
issues={issues} issues={issues}
groupedIssueIds={groupedIssueIds} groupedIssueIds={groupedIssueIds}

View File

@ -11,8 +11,19 @@ import { renderDateFormat } from "helpers/date-time.helper";
import { MONTHS_LIST } from "constants/calendar"; import { MONTHS_LIST } from "constants/calendar";
import { IIssue } from "types"; import { IIssue } from "types";
import { IGroupedIssues, IIssueResponse } from "store/issues/types"; import { IGroupedIssues, IIssueResponse } from "store/issues/types";
import {
ICycleIssuesFilterStore,
IModuleIssuesFilterStore,
IProjectIssuesFilterStore,
IViewIssuesFilterStore,
} from "store/issues";
type Props = { type Props = {
issuesFilterStore:
| IProjectIssuesFilterStore
| IModuleIssuesFilterStore
| ICycleIssuesFilterStore
| IViewIssuesFilterStore;
date: ICalendarDate; date: ICalendarDate;
issues: IIssueResponse | undefined; issues: IIssueResponse | undefined;
groupedIssueIds: IGroupedIssues; groupedIssueIds: IGroupedIssues;
@ -28,11 +39,18 @@ type Props = {
}; };
export const CalendarDayTile: React.FC<Props> = observer((props) => { export const CalendarDayTile: React.FC<Props> = observer((props) => {
const { date, issues, groupedIssueIds, quickActions, enableQuickIssueCreate, quickAddCallback, viewId } = props; const {
issuesFilterStore,
date,
issues,
groupedIssueIds,
quickActions,
enableQuickIssueCreate,
quickAddCallback,
viewId,
} = props;
const { issueFilter: issueFilterStore } = useMobxStore(); const calendarLayout = issuesFilterStore?.issueFilters?.displayFilters?.calendar?.layout ?? "month";
const calendarLayout = issueFilterStore.userDisplayFilters.calendar?.layout ?? "month";
const issueIdList = groupedIssueIds ? groupedIssueIds[renderDateFormat(date.date)] : null; const issueIdList = groupedIssueIds ? groupedIssueIds[renderDateFormat(date.date)] : null;

View File

@ -13,12 +13,29 @@ import { Check, ChevronUp } from "lucide-react";
import { TCalendarLayouts } from "types"; import { TCalendarLayouts } from "types";
// constants // constants
import { CALENDAR_LAYOUTS } from "constants/calendar"; import { CALENDAR_LAYOUTS } from "constants/calendar";
import { EFilterType } from "store/issues/types";
import {
ICycleIssuesFilterStore,
IModuleIssuesFilterStore,
IProjectIssuesFilterStore,
IViewIssuesFilterStore,
} from "store/issues";
interface ICalendarHeader {
issuesFilterStore:
| IProjectIssuesFilterStore
| IModuleIssuesFilterStore
| ICycleIssuesFilterStore
| IViewIssuesFilterStore;
}
export const CalendarOptionsDropdown: React.FC<ICalendarHeader> = observer((props) => {
const { issuesFilterStore } = props;
export const CalendarOptionsDropdown: React.FC = observer(() => {
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query; const { workspaceSlug, projectId } = router.query;
const { issueFilter: issueFilterStore, calendar: calendarStore } = useMobxStore(); const { calendar: calendarStore } = useMobxStore();
const [referenceElement, setReferenceElement] = useState<HTMLButtonElement | null>(null); const [referenceElement, setReferenceElement] = useState<HTMLButtonElement | null>(null);
const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null); const [popperElement, setPopperElement] = useState<HTMLDivElement | null>(null);
@ -35,18 +52,16 @@ export const CalendarOptionsDropdown: React.FC = observer(() => {
], ],
}); });
const calendarLayout = issueFilterStore.userDisplayFilters.calendar?.layout ?? "month"; const calendarLayout = issuesFilterStore.issueFilters?.displayFilters?.calendar?.layout ?? "month";
const showWeekends = issueFilterStore.userDisplayFilters.calendar?.show_weekends ?? false; const showWeekends = issuesFilterStore.issueFilters?.displayFilters?.calendar?.show_weekends ?? false;
const handleLayoutChange = (layout: TCalendarLayouts) => { const handleLayoutChange = (layout: TCalendarLayouts) => {
if (!workspaceSlug || !projectId) return; if (!workspaceSlug || !projectId) return;
issueFilterStore.updateUserFilters(workspaceSlug.toString(), projectId.toString(), { issuesFilterStore.updateFilters(workspaceSlug.toString(), projectId.toString(), EFilterType.DISPLAY_FILTERS, {
display_filters: { calendar: {
calendar: { ...issuesFilterStore.issueFilters?.displayFilters?.calendar,
...issueFilterStore.userDisplayFilters.calendar, layout,
layout,
},
}, },
}); });
@ -56,16 +71,14 @@ export const CalendarOptionsDropdown: React.FC = observer(() => {
}; };
const handleToggleWeekends = () => { const handleToggleWeekends = () => {
const showWeekends = issueFilterStore.userDisplayFilters.calendar?.show_weekends ?? false; const showWeekends = issuesFilterStore.issueFilters?.displayFilters?.calendar?.show_weekends ?? false;
if (!workspaceSlug || !projectId) return; if (!workspaceSlug || !projectId) return;
issueFilterStore.updateUserFilters(workspaceSlug.toString(), projectId.toString(), { issuesFilterStore.updateFilters(workspaceSlug.toString(), projectId.toString(), EFilterType.DISPLAY_FILTERS, {
display_filters: { calendar: {
calendar: { ...issuesFilterStore.issueFilters?.displayFilters?.calendar,
...issueFilterStore.userDisplayFilters.calendar, show_weekends: !showWeekends,
show_weekends: !showWeekends,
},
}, },
}); });
}; };

View File

@ -6,8 +6,24 @@ import { useMobxStore } from "lib/mobx/store-provider";
import { CalendarMonthsDropdown, CalendarOptionsDropdown } from "components/issues"; import { CalendarMonthsDropdown, CalendarOptionsDropdown } from "components/issues";
// icons // icons
import { ChevronLeft, ChevronRight } from "lucide-react"; import { ChevronLeft, ChevronRight } from "lucide-react";
import {
ICycleIssuesFilterStore,
IModuleIssuesFilterStore,
IProjectIssuesFilterStore,
IViewIssuesFilterStore,
} from "store/issues";
interface ICalendarHeader {
issuesFilterStore:
| IProjectIssuesFilterStore
| IModuleIssuesFilterStore
| ICycleIssuesFilterStore
| IViewIssuesFilterStore;
}
export const CalendarHeader: React.FC<ICalendarHeader> = observer((props) => {
const { issuesFilterStore } = props;
export const CalendarHeader: React.FC = observer(() => {
const { issueFilter: issueFilterStore, calendar: calendarStore } = useMobxStore(); const { issueFilter: issueFilterStore, calendar: calendarStore } = useMobxStore();
const calendarLayout = issueFilterStore.userDisplayFilters.calendar?.layout ?? "month"; const calendarLayout = issueFilterStore.userDisplayFilters.calendar?.layout ?? "month";
@ -91,7 +107,7 @@ export const CalendarHeader: React.FC = observer(() => {
> >
Today Today
</button> </button>
<CalendarOptionsDropdown /> <CalendarOptionsDropdown issuesFilterStore={issuesFilterStore} />
</div> </div>
</div> </div>
); );

View File

@ -13,7 +13,6 @@ export const CycleCalendarLayout: React.FC = observer(() => {
const { const {
cycleIssues: cycleIssueStore, cycleIssues: cycleIssueStore,
cycleIssuesFilter: cycleIssueFilterStore, cycleIssuesFilter: cycleIssueFilterStore,
cycleIssueCalendarView: cycleIssueCalendarViewStore,
calendarHelpers: { handleDragDrop: handleCalenderDragDrop }, calendarHelpers: { handleDragDrop: handleCalenderDragDrop },
} = useMobxStore(); } = useMobxStore();
@ -62,7 +61,6 @@ export const CycleCalendarLayout: React.FC = observer(() => {
<BaseCalendarRoot <BaseCalendarRoot
issueStore={cycleIssueStore} issueStore={cycleIssueStore}
issuesFilterStore={cycleIssueFilterStore} issuesFilterStore={cycleIssueFilterStore}
calendarViewStore={cycleIssueCalendarViewStore}
QuickActions={CycleIssueQuickActions} QuickActions={CycleIssueQuickActions}
issueActions={issueActions} issueActions={issueActions}
viewId={cycleId.toString()} viewId={cycleId.toString()}

View File

@ -13,7 +13,6 @@ export const ModuleCalendarLayout: React.FC = observer(() => {
const { const {
moduleIssues: moduleIssueStore, moduleIssues: moduleIssueStore,
moduleIssuesFilter: moduleIssueFilterStore, moduleIssuesFilter: moduleIssueFilterStore,
moduleIssueCalendarView: moduleIssueCalendarViewStore,
calendarHelpers: { handleDragDrop: handleCalenderDragDrop }, calendarHelpers: { handleDragDrop: handleCalenderDragDrop },
} = useMobxStore(); } = useMobxStore();
@ -56,7 +55,6 @@ export const ModuleCalendarLayout: React.FC = observer(() => {
<BaseCalendarRoot <BaseCalendarRoot
issueStore={moduleIssueStore} issueStore={moduleIssueStore}
issuesFilterStore={moduleIssueFilterStore} issuesFilterStore={moduleIssueFilterStore}
calendarViewStore={moduleIssueCalendarViewStore}
QuickActions={ModuleIssueQuickActions} QuickActions={ModuleIssueQuickActions}
issueActions={issueActions} issueActions={issueActions}
viewId={moduleId} viewId={moduleId}

View File

@ -14,7 +14,6 @@ export const CalendarLayout: React.FC = observer(() => {
const { const {
projectIssues: issueStore, projectIssues: issueStore,
issueCalendarView: issueCalendarViewStore,
projectIssuesFilter: projectIssueFiltersStore, projectIssuesFilter: projectIssueFiltersStore,
calendarHelpers: { handleDragDrop: handleCalenderDragDrop }, calendarHelpers: { handleDragDrop: handleCalenderDragDrop },
} = useMobxStore(); } = useMobxStore();
@ -49,7 +48,6 @@ export const CalendarLayout: React.FC = observer(() => {
<BaseCalendarRoot <BaseCalendarRoot
issueStore={issueStore} issueStore={issueStore}
issuesFilterStore={projectIssueFiltersStore} issuesFilterStore={projectIssueFiltersStore}
calendarViewStore={issueCalendarViewStore}
QuickActions={ProjectIssueQuickActions} QuickActions={ProjectIssueQuickActions}
issueActions={issueActions} issueActions={issueActions}
handleDragDrop={handleDragDrop} handleDragDrop={handleDragDrop}

View File

@ -13,7 +13,6 @@ export const ProjectViewCalendarLayout: React.FC = observer(() => {
const { const {
viewIssues: projectViewIssuesStore, viewIssues: projectViewIssuesStore,
viewIssuesFilter: projectIssueViewFiltersStore, viewIssuesFilter: projectIssueViewFiltersStore,
projectViewIssueCalendarView: projectViewIssueCalendarViewStore,
calendarHelpers: { handleDragDrop: handleCalenderDragDrop }, calendarHelpers: { handleDragDrop: handleCalenderDragDrop },
} = useMobxStore(); } = useMobxStore();
@ -50,7 +49,6 @@ export const ProjectViewCalendarLayout: React.FC = observer(() => {
<BaseCalendarRoot <BaseCalendarRoot
issueStore={projectViewIssuesStore} issueStore={projectViewIssuesStore}
issuesFilterStore={projectIssueViewFiltersStore} issuesFilterStore={projectIssueViewFiltersStore}
calendarViewStore={projectViewIssueCalendarViewStore}
QuickActions={ProjectIssueQuickActions} QuickActions={ProjectIssueQuickActions}
issueActions={issueActions} issueActions={issueActions}
handleDragDrop={handleDragDrop} handleDragDrop={handleDragDrop}

View File

@ -1,7 +1,4 @@
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";
// components // components
import { CalendarDayTile } from "components/issues"; import { CalendarDayTile } from "components/issues";
// helpers // helpers
@ -10,8 +7,19 @@ import { renderDateFormat } from "helpers/date-time.helper";
import { ICalendarDate, ICalendarWeek } from "./types"; import { ICalendarDate, ICalendarWeek } from "./types";
import { IIssue } from "types"; import { IIssue } from "types";
import { IGroupedIssues, IIssueResponse } from "store/issues/types"; import { IGroupedIssues, IIssueResponse } from "store/issues/types";
import {
ICycleIssuesFilterStore,
IModuleIssuesFilterStore,
IProjectIssuesFilterStore,
IViewIssuesFilterStore,
} from "store/issues";
type Props = { type Props = {
issuesFilterStore:
| IProjectIssuesFilterStore
| IModuleIssuesFilterStore
| ICycleIssuesFilterStore
| IViewIssuesFilterStore;
issues: IIssueResponse | undefined; issues: IIssueResponse | undefined;
groupedIssueIds: IGroupedIssues; groupedIssueIds: IGroupedIssues;
week: ICalendarWeek | undefined; week: ICalendarWeek | undefined;
@ -27,12 +35,19 @@ type Props = {
}; };
export const CalendarWeekDays: React.FC<Props> = observer((props) => { export const CalendarWeekDays: React.FC<Props> = observer((props) => {
const { issues, groupedIssueIds, week, quickActions, enableQuickIssueCreate, quickAddCallback, viewId } = props; const {
issuesFilterStore,
issues,
groupedIssueIds,
week,
quickActions,
enableQuickIssueCreate,
quickAddCallback,
viewId,
} = props;
const { issueFilter: issueFilterStore } = useMobxStore(); const calendarLayout = issuesFilterStore?.issueFilters?.displayFilters?.calendar?.layout ?? "month";
const showWeekends = issuesFilterStore?.issueFilters?.displayFilters?.calendar?.show_weekends ?? false;
const calendarLayout = issueFilterStore.userDisplayFilters.calendar?.layout ?? "month";
const showWeekends = issueFilterStore.userDisplayFilters.calendar?.show_weekends ?? false;
if (!week) return null; if (!week) return null;
@ -47,6 +62,7 @@ export const CalendarWeekDays: React.FC<Props> = observer((props) => {
return ( return (
<CalendarDayTile <CalendarDayTile
issuesFilterStore={issuesFilterStore}
key={renderDateFormat(date.date)} key={renderDateFormat(date.date)}
date={date} date={date}
issues={issues} issues={issues}

View File

@ -147,22 +147,22 @@ const GroupByKanBan: React.FC<IGroupByKanBan> = observer((props) => {
</div> </div>
)} )}
</Droppable> </Droppable>
</div>
<div className="flex-shrink-0 w-full bg-custom-background-90 py-1 sticky bottom-0 z-[0]"> <div className="flex-shrink-0 w-full bg-custom-background-90 py-1 sticky bottom-0 z-[0]">
{enableQuickIssueCreate && ( {enableQuickIssueCreate && (
<KanBanQuickAddIssueForm <KanBanQuickAddIssueForm
formKey="name" formKey="name"
groupId={getValueFromObject(_list, listKey) as string} groupId={getValueFromObject(_list, listKey) as string}
subGroupId={sub_group_id} subGroupId={sub_group_id}
prePopulatedData={{ prePopulatedData={{
...(group_by && { [group_by]: getValueFromObject(_list, listKey) }), ...(group_by && { [group_by]: getValueFromObject(_list, listKey) }),
...(sub_group_by && sub_group_id !== "null" && { [sub_group_by]: sub_group_id }), ...(sub_group_by && sub_group_id !== "null" && { [sub_group_by]: sub_group_id }),
}} }}
quickAddCallback={quickAddCallback} quickAddCallback={quickAddCallback}
viewId={viewId} viewId={viewId}
/> />
)} )}
</div>
</div> </div>
{/* {isDragStarted && isDragDisabled && ( {/* {isDragStarted && isDragDisabled && (