-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: add remaining layouts to cycle (#2413)
- Loading branch information
Showing
17 changed files
with
401 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { useCallback } from "react"; | ||
import { useRouter } from "next/router"; | ||
import { observer } from "mobx-react-lite"; | ||
|
||
// mobx store | ||
import { useMobxStore } from "lib/mobx/store-provider"; | ||
// components | ||
import { DisplayFiltersSelection, FiltersDropdown, FilterSelection, LayoutSelection } from "components/issues"; | ||
// types | ||
import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOptions, TIssueLayouts } from "types"; | ||
// constants | ||
import { ISSUE_DISPLAY_FILTERS_BY_LAYOUT } from "constants/issue"; | ||
|
||
export const CycleIssuesHeader: React.FC = observer(() => { | ||
const router = useRouter(); | ||
const { workspaceSlug, projectId, cycleId } = router.query; | ||
|
||
const { | ||
issueFilter: issueFilterStore, | ||
cycleIssueFilter: cycleIssueFilterStore, | ||
project: projectStore, | ||
} = useMobxStore(); | ||
|
||
const activeLayout = issueFilterStore.userDisplayFilters.layout; | ||
|
||
const handleLayoutChange = useCallback( | ||
(layout: TIssueLayouts) => { | ||
if (!workspaceSlug || !projectId) return; | ||
|
||
issueFilterStore.updateUserFilters(workspaceSlug.toString(), projectId.toString(), { | ||
display_filters: { | ||
layout, | ||
}, | ||
}); | ||
}, | ||
[issueFilterStore, projectId, workspaceSlug] | ||
); | ||
|
||
const handleFiltersUpdate = useCallback( | ||
(key: keyof IIssueFilterOptions, value: string | string[]) => { | ||
if (!workspaceSlug || !projectId || !cycleId) return; | ||
|
||
const newValues = cycleIssueFilterStore.cycleFilters?.[key] ?? []; | ||
|
||
if (Array.isArray(value)) { | ||
value.forEach((val) => { | ||
if (!newValues.includes(val)) newValues.push(val); | ||
}); | ||
} else { | ||
if (cycleIssueFilterStore.cycleFilters?.[key]?.includes(value)) newValues.splice(newValues.indexOf(value), 1); | ||
else newValues.push(value); | ||
} | ||
|
||
cycleIssueFilterStore.updateCycleFilters(workspaceSlug.toString(), projectId.toString(), cycleId.toString(), { | ||
[key]: newValues, | ||
}); | ||
}, | ||
[cycleId, cycleIssueFilterStore, projectId, workspaceSlug] | ||
); | ||
|
||
const handleDisplayFiltersUpdate = useCallback( | ||
(updatedDisplayFilter: Partial<IIssueDisplayFilterOptions>) => { | ||
if (!workspaceSlug || !projectId) return; | ||
|
||
issueFilterStore.updateUserFilters(workspaceSlug.toString(), projectId.toString(), { | ||
display_filters: { | ||
...updatedDisplayFilter, | ||
}, | ||
}); | ||
}, | ||
[issueFilterStore, projectId, workspaceSlug] | ||
); | ||
|
||
const handleDisplayPropertiesUpdate = useCallback( | ||
(property: Partial<IIssueDisplayProperties>) => { | ||
if (!workspaceSlug || !projectId) return; | ||
|
||
issueFilterStore.updateDisplayProperties(workspaceSlug.toString(), projectId.toString(), property); | ||
}, | ||
[issueFilterStore, projectId, workspaceSlug] | ||
); | ||
|
||
return ( | ||
<div className="flex items-center gap-2"> | ||
<LayoutSelection | ||
layouts={["list", "kanban", "calendar", "spreadsheet", "gantt_chart"]} | ||
onChange={(layout) => handleLayoutChange(layout)} | ||
selectedLayout={activeLayout} | ||
/> | ||
<FiltersDropdown title="Filters"> | ||
<FilterSelection | ||
filters={cycleIssueFilterStore.cycleFilters} | ||
handleFiltersUpdate={handleFiltersUpdate} | ||
layoutDisplayFiltersOptions={activeLayout ? ISSUE_DISPLAY_FILTERS_BY_LAYOUT.issues[activeLayout] : undefined} | ||
labels={projectStore.labels?.[projectId?.toString() ?? ""] ?? undefined} | ||
members={projectStore.members?.[projectId?.toString() ?? ""]?.map((m) => m.member)} | ||
states={projectStore.states?.[projectId?.toString() ?? ""] ?? undefined} | ||
/> | ||
</FiltersDropdown> | ||
<FiltersDropdown title="View"> | ||
<DisplayFiltersSelection | ||
displayFilters={issueFilterStore.userDisplayFilters} | ||
displayProperties={issueFilterStore.userDisplayProperties} | ||
handleDisplayFiltersUpdate={handleDisplayFiltersUpdate} | ||
handleDisplayPropertiesUpdate={handleDisplayPropertiesUpdate} | ||
layoutDisplayFiltersOptions={activeLayout ? ISSUE_DISPLAY_FILTERS_BY_LAYOUT.issues[activeLayout] : undefined} | ||
/> | ||
</FiltersDropdown> | ||
</div> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
web/components/issues/issue-layouts/calendar/cycle-root.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { observer } from "mobx-react-lite"; | ||
import { DragDropContext, DropResult } from "@hello-pangea/dnd"; | ||
|
||
// mobx store | ||
import { useMobxStore } from "lib/mobx/store-provider"; | ||
// components | ||
import { CalendarChart } from "components/issues"; | ||
// types | ||
import { IIssueGroupedStructure } from "store/issue"; | ||
|
||
export const CycleCalendarLayout: React.FC = observer(() => { | ||
const { cycleIssue: cycleIssueStore, issueFilter: issueFilterStore } = useMobxStore(); | ||
|
||
// TODO: add drag and drop functionality | ||
const onDragEnd = (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; | ||
|
||
// issueKanBanViewStore?.handleDragDrop(result.source, result.destination); | ||
}; | ||
|
||
const issues = cycleIssueStore.getIssues; | ||
|
||
return ( | ||
<div className="h-full w-full pt-4 bg-custom-background-100 overflow-hidden"> | ||
<DragDropContext onDragEnd={onDragEnd}> | ||
<CalendarChart | ||
issues={issues as IIssueGroupedStructure | null} | ||
layout={issueFilterStore.userDisplayFilters.calendar?.layout} | ||
/> | ||
</DragDropContext> | ||
</div> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { useRouter } from "next/router"; | ||
import { observer } from "mobx-react-lite"; | ||
|
||
// mobx store | ||
import { useMobxStore } from "lib/mobx/store-provider"; | ||
// hooks | ||
import useProjectDetails from "hooks/use-project-details"; | ||
// components | ||
import { GanttChartRoot, renderIssueBlocksStructure } from "components/gantt-chart"; | ||
import { IssueGanttBlock, IssueGanttSidebarBlock, IssuePeekOverview } from "components/issues"; | ||
// types | ||
import { IIssueUnGroupedStructure } from "store/issue"; | ||
|
||
export const CycleGanttLayout: React.FC = observer(() => { | ||
const router = useRouter(); | ||
const { workspaceSlug, projectId } = router.query; | ||
|
||
const { projectDetails } = useProjectDetails(); | ||
|
||
const { cycleIssue: cycleIssueStore, issueFilter: issueFilterStore } = useMobxStore(); | ||
|
||
const appliedDisplayFilters = issueFilterStore.userDisplayFilters; | ||
|
||
const issues = cycleIssueStore.getIssues; | ||
|
||
const isAllowed = projectDetails?.member_role === 20 || projectDetails?.member_role === 15; | ||
|
||
return ( | ||
<> | ||
<IssuePeekOverview | ||
projectId={projectId?.toString() ?? ""} | ||
workspaceSlug={workspaceSlug?.toString() ?? ""} | ||
readOnly={!isAllowed} | ||
/> | ||
<div className="w-full h-full"> | ||
<GanttChartRoot | ||
border={false} | ||
title="Issues" | ||
loaderTitle="Issues" | ||
blocks={issues ? renderIssueBlocksStructure(issues as IIssueUnGroupedStructure) : null} | ||
blockUpdateHandler={(block, payload) => { | ||
// TODO: update mutation logic | ||
// updateGanttIssue(block, payload, mutateGanttIssues, user, workspaceSlug?.toString()) | ||
}} | ||
BlockRender={IssueGanttBlock} | ||
SidebarBlockRender={IssueGanttSidebarBlock} | ||
enableBlockLeftResize={isAllowed} | ||
enableBlockRightResize={isAllowed} | ||
enableBlockMove={isAllowed} | ||
enableReorder={appliedDisplayFilters.order_by === "sort_order" && isAllowed} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from "./blocks"; | ||
export * from "./cycle-root"; | ||
export * from "./module-root"; | ||
export * from "./project-view-root"; | ||
export * from "./root"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.