Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Calendar layout to Global Issues page #4511

Open
wants to merge 3 commits into
base: preview
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add Calendar layout to Global Issues page
vinhloc30796 committed May 18, 2024
commit 8bfdd948b2877746e192d152fd1370d161a56818
27 changes: 24 additions & 3 deletions web/components/headers/global-issues.tsx
Original file line number Diff line number Diff line change
@@ -4,12 +4,12 @@ import { useRouter } from "next/router";
// icons
import { PlusIcon } from "lucide-react";
// types
import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOptions } from "@plane/types";
import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOptions, TIssueLayouts } from "@plane/types";
// ui
import { Breadcrumbs, Button, LayersIcon } from "@plane/ui";
// components
import { BreadcrumbLink } from "@/components/common";
import { DisplayFiltersSelection, FiltersDropdown, FilterSelection } from "@/components/issues";
import { DisplayFiltersSelection, FiltersDropdown, FilterSelection, LayoutSelection } from "@/components/issues";
import { CreateUpdateWorkspaceViewModal } from "@/components/workspace";
// constants
import { EIssueFilterType, EIssuesStoreType, ISSUE_DISPLAY_FILTERS_BY_LAYOUT } from "@/constants/issue";
@@ -22,7 +22,7 @@ export const GlobalIssuesHeader: React.FC = observer(() => {
const [createViewModal, setCreateViewModal] = useState(false);
// router
const router = useRouter();
const { workspaceSlug, globalViewId } = router.query;
const { workspaceSlug, globalViewId, projectId } = router.query;
// store hooks
const {
issuesFilter: { filters, updateFilters },
@@ -36,6 +36,22 @@ export const GlobalIssuesHeader: React.FC = observer(() => {
} = useMember();

const issueFilters = globalViewId ? filters[globalViewId.toString()] : undefined;
const activeLayout = issueFilters?.displayFilters?.layout;

const handleLayoutChange = useCallback(
(layout: TIssueLayouts) => {
// (updatedDisplayFilter: Partial<IIssueDisplayFilterOptions>) => {
if (!workspaceSlug) return;
updateFilters(
workspaceSlug.toString(),
undefined,
EIssueFilterType.DISPLAY_FILTERS,
{ layout: layout },
globalViewId.toString(),
);
},
[workspaceSlug, updateFilters, globalViewId]
);

const handleFiltersUpdate = useCallback(
(key: keyof IIssueFilterOptions, value: string | string[]) => {
@@ -110,6 +126,11 @@ export const GlobalIssuesHeader: React.FC = observer(() => {
</div>
<div className="flex items-center gap-2">
<>
<LayoutSelection
layouts={["calendar", "spreadsheet"]}
onChange={(layout) => handleLayoutChange(layout)}
selectedLayout={activeLayout}
/>
<FiltersDropdown title="Filters" placement="bottom-end">
<FilterSelection
layoutDisplayFiltersOptions={ISSUE_DISPLAY_FILTERS_BY_LAYOUT.my_issues.spreadsheet}
151 changes: 151 additions & 0 deletions web/components/issues/issue-layouts/calendar/calendar-view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import React, { useRef } from "react";
import { DraggableLocation, DragDropContext, DropResult } from "@hello-pangea/dnd";
import { observer } from "mobx-react-lite";
import { EIssueFilterType, EIssuesStoreType } from "@/constants/issue";

Check warning on line 4 in web/components/issues/issue-layouts/calendar/calendar-view.tsx

Codacy Production / Codacy Static Code Analysis

web/components/issues/issue-layouts/calendar/calendar-view.tsx#L4

`@/constants/issue` import should occur after import of `@/components/issues`
import {
TIssue,
IIssueDisplayFilterOptions,
IIssueDisplayProperties,
IIssueMap,
TGroupedIssues,
IIssueFilterOptions,
TIssueMap,
TIssueKanbanFilters,
} from "@plane/types";
// components
import { Spinner, TOAST_TYPE, setToast } from "@plane/ui";
import { CalendarChart } from "@/components/issues";
import { useProject } from "@/hooks/store";
import { TRenderQuickActions } from "../list/list-view-types";

Check warning on line 19 in web/components/issues/issue-layouts/calendar/calendar-view.tsx

Codacy Production / Codacy Static Code Analysis

web/components/issues/issue-layouts/calendar/calendar-view.tsx#L19

`../list/list-view-types` import should occur after import of `@/store/issue/workspace`
import { handleDragDrop } from "./utils";

Check warning on line 20 in web/components/issues/issue-layouts/calendar/calendar-view.tsx

Codacy Production / Codacy Static Code Analysis

web/components/issues/issue-layouts/calendar/calendar-view.tsx#L20

`./utils` import should occur after import of `@/store/issue/workspace`
import { IWorkspaceIssuesFilter } from "@/store/issue/workspace";
// types
//hooks

type Props = {
// displayProperties: IIssueDisplayProperties;
// displayFilters: IIssueDisplayFilterOptions;
// handleDisplayFilterUpdate: (data: Partial<IIssueDisplayFilterOptions>) => void;
// issueIds: string[] | undefined;
// quickActions: TRenderQuickActions;
// updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
// openIssuesListModal?: (() => void) | null;
// quickAddCallback?: (
// workspaceSlug: string,
// projectId: string,
// data: TIssue,
// viewId?: string
// ) => Promise<TIssue | undefined>;
// viewId?: string;
// canEditProperties: (projectId: string | undefined) => boolean;
// enableQuickCreateIssue?: boolean;
// disableIssueCreation?: boolean;
// isWorkspaceLevel?: boolean;

// issues
issuesFilterStore: IWorkspaceIssuesFilter,
issues: TIssueMap,
// issueIds: string[],
groupedIssueIds: TGroupedIssues,
// Layout
// layout: "month" | "week" | undefined;
// showWeekends: boolean;
// handlers
quickActions: TRenderQuickActions;
quickAddIssues?: (
// quickAddCallback?: (
workspaceSlug: string,
projectId: string,
data: TIssue,
viewId?: string
) => Promise<TIssue | undefined>;
addIssuesToView?: (issueIds: string[]) => Promise<any>;
// handleDisplayFilterUpdate?: (
// projectId: string,
// filterType: EIssueFilterType,
// filters: IIssueFilterOptions | IIssueDisplayFilterOptions | IIssueDisplayProperties | TIssueKanbanFilters
// ) => Promise<void>;
// updateIssue?: (projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>;
viewId?: string;
readOnly?: boolean;
updateFilters?: (
projectId: string,
filterType: EIssueFilterType,
filters: IIssueFilterOptions | IIssueDisplayFilterOptions | IIssueDisplayProperties | TIssueKanbanFilters
) => Promise<void>
isWorkspaceLevel?: boolean;
// handleDragDrop?: (
// source: DraggableLocation,
// destination: DraggableLocation,
// workspaceSlug: string | undefined,
// projectId: string | undefined,
// issueMap: IIssueMap,
// issueWithIds: TGroupedIssues,
// updateIssue?: ((projectId: string, issueId: string, data: TIssue) => Promise<void>) | undefined
// ) => Promise<void>
};

export const CalendarView: React.FC<Props> = observer((props: Props) => {
const {
issuesFilterStore,
issues,
groupedIssueIds,
// layout,
// showWeekends,
quickActions,
quickAddIssues,
// updateIssue,
addIssuesToView,
viewId,
readOnly,
updateFilters,
isWorkspaceLevel = true
} = props;
// refs
const containerRef = useRef<HTMLTableElement | null>(null);
const portalRef = useRef<HTMLDivElement | null>(null);

const { currentProjectDetails } = useProject();

const isEstimateEnabled: boolean = currentProjectDetails?.estimate !== null;

const displayFilters = issuesFilterStore.issueFilters.displayFilters;
console.log("CalendarView.displayFilters", displayFilters)

const onDragEnd = async (result: DropResult) => {
if (!result) return;

// return if not dropped on the correct place
if (!result.destination) return;

// return if dropped on the same date
if (result.destination.droppableId === result.source.droppableId) return;

if (handleDragDrop) {
await handleDragDrop
}
};

return (
<div className="relative flex flex-col h-full w-full overflow-x-hidden whitespace-nowrap rounded-lg bg-custom-background-200 text-custom-text-200">
<div ref={containerRef} className="vertical-scrollbar horizontal-scrollbar scrollbar-lg h-full w-full bg-custom-background-100 pt-4">
<DragDropContext onDragEnd={onDragEnd}>
<CalendarChart
issuesFilterStore={issuesFilterStore}
issues={issues}
groupedIssueIds={groupedIssueIds}
layout={displayFilters?.calendar?.layout}
showWeekends={displayFilters?.calendar?.show_weekends ?? false}
quickActions={quickActions}
quickAddIssue={quickAddIssues}
addIssuesToView={addIssuesToView}
viewId={viewId}
// readOnly={!isEditingAllowed || isCompletedCycle}
readOnly={readOnly}
updateFilters={updateFilters}
/>
</DragDropContext>
</div>
</div>
);
});
1 change: 1 addition & 0 deletions web/components/issues/issue-layouts/calendar/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./dropdowns";
export * from "./roots";
export * from "./calendar-view";
export * from "./calendar";
export * from "./types.d";
export * from "./day-tile";
Loading