From 2891ed1c3af11cb68ba36c37a82d64f2c1151dee Mon Sep 17 00:00:00 2001 From: dakshesh14 Date: Mon, 6 Nov 2023 21:34:39 +0530 Subject: [PATCH] fix: build errors --- .../kanban/roots/project-draft-issue-root.tsx | 3 + .../list/roots/project-draft-issue-root.tsx | 2 +- web/store/draft-issues/index.ts | 1 - .../draft-issues/issue_kanban_view.store.ts | 448 ------------------ .../project-view/project_view_issues.store.ts | 8 +- web/store/root.ts | 11 +- 6 files changed, 7 insertions(+), 466 deletions(-) delete mode 100644 web/store/draft-issues/issue_kanban_view.store.ts diff --git a/web/components/issues/issue-layouts/kanban/roots/project-draft-issue-root.tsx b/web/components/issues/issue-layouts/kanban/roots/project-draft-issue-root.tsx index ca0d81549..34da6c3b2 100644 --- a/web/components/issues/issue-layouts/kanban/roots/project-draft-issue-root.tsx +++ b/web/components/issues/issue-layouts/kanban/roots/project-draft-issue-root.tsx @@ -81,6 +81,7 @@ export const DraftIssueKanBanLayout: React.FC = observer(() => { const members = projectStore?.projectMembers || null; const stateGroups = ISSUE_STATE_GROUPS || null; const projects = workspaceSlug ? projectStore?.projects[workspaceSlug.toString()] || null : null; + const orderBy = draftIssueFiltersStore?.userDisplayFilters?.order_by || null; return (
@@ -102,6 +103,7 @@ export const DraftIssueKanBanLayout: React.FC = observer(() => { handleKanBanToggle={handleKanBanToggle} states={states} stateGroups={stateGroups} + order_by={orderBy} priorities={priorities} labels={labels} members={members?.map((m) => m.member) ?? null} @@ -113,6 +115,7 @@ export const DraftIssueKanBanLayout: React.FC = observer(() => { issues={issues} sub_group_by={sub_group_by} group_by={group_by} + order_by={orderBy} handleIssues={handleIssues} quickActions={(sub_group_by, group_by, issue) => ( { handleUpdate={(issue: any, action: any) => handleIssues(group_by, issue, action)} /> )} - display_properties={display_properties} + displayProperties={display_properties} states={states} stateGroups={stateGroups} priorities={priorities} diff --git a/web/store/draft-issues/index.ts b/web/store/draft-issues/index.ts index 071dd6ee3..abfd52768 100644 --- a/web/store/draft-issues/index.ts +++ b/web/store/draft-issues/index.ts @@ -1,3 +1,2 @@ export * from "./issue.store"; export * from "./issue_filters.store"; -export * from "./issue_kanban_view.store"; diff --git a/web/store/draft-issues/issue_kanban_view.store.ts b/web/store/draft-issues/issue_kanban_view.store.ts deleted file mode 100644 index b730b31d7..000000000 --- a/web/store/draft-issues/issue_kanban_view.store.ts +++ /dev/null @@ -1,448 +0,0 @@ -import { action, computed, makeObservable, observable, runInAction } from "mobx"; -// types -import { RootStore } from "../root"; -import { IIssueType } from "./issue.store"; - -export interface IDraftIssueKanBanViewStore { - kanBanToggle: { - groupByHeaderMinMax: string[]; - subgroupByIssuesVisibility: string[]; - }; - // computed - canUserDragDrop: boolean; - canUserDragDropVertically: boolean; - canUserDragDropHorizontally: boolean; - // actions - handleKanBanToggle: (toggle: "groupByHeaderMinMax" | "subgroupByIssuesVisibility", value: string) => void; - handleSwimlaneDragDrop: (source: any, destination: any) => void; - handleDragDrop: (source: any, destination: any) => void; -} - -// TODO: change implementation for draft issues -export class DraftIssueKanBanViewStore implements IDraftIssueKanBanViewStore { - kanBanToggle: { - groupByHeaderMinMax: string[]; - subgroupByIssuesVisibility: string[]; - } = { groupByHeaderMinMax: [], subgroupByIssuesVisibility: [] }; - // root store - rootStore; - - constructor(_rootStore: RootStore) { - makeObservable(this, { - kanBanToggle: observable, - // computed - canUserDragDrop: computed, - canUserDragDropVertically: computed, - canUserDragDropHorizontally: computed, - - // actions - handleKanBanToggle: action, - handleSwimlaneDragDrop: action, - handleDragDrop: action, - }); - - this.rootStore = _rootStore; - } - - get canUserDragDrop() { - if ( - this.rootStore?.issueFilter?.userDisplayFilters?.order_by && - this.rootStore?.issueFilter?.userDisplayFilters?.order_by === "sort_order" && - this.rootStore?.issueFilter?.userDisplayFilters?.group_by && - ["state", "priority"].includes(this.rootStore?.issueFilter?.userDisplayFilters?.group_by) - ) { - if (!this.rootStore?.issueFilter?.userDisplayFilters?.sub_group_by) return true; - if ( - this.rootStore?.issueFilter?.userDisplayFilters?.sub_group_by && - ["state", "priority"].includes(this.rootStore?.issueFilter?.userDisplayFilters?.sub_group_by) - ) - return true; - } - return false; - } - - get canUserDragDropVertically() { - return false; - } - - get canUserDragDropHorizontally() { - return false; - } - - handleKanBanToggle = (toggle: "groupByHeaderMinMax" | "subgroupByIssuesVisibility", value: string) => { - this.kanBanToggle = { - ...this.kanBanToggle, - [toggle]: this.kanBanToggle[toggle].includes(value) - ? this.kanBanToggle[toggle].filter((v) => v !== value) - : [...this.kanBanToggle[toggle], value], - }; - }; - - handleSwimlaneDragDrop = async (source: any, destination: any) => { - const workspaceSlug = this.rootStore?.workspace?.workspaceSlug; - const projectId = this.rootStore?.project?.projectId; - const issueType: IIssueType | null = this.rootStore?.issue?.getIssueType; - const issueLayout = this.rootStore?.issueFilter?.userDisplayFilters?.layout || null; - const currentIssues: any = this.rootStore.issue.getIssues; - - const sortOrderDefaultValue = 65535; - - if (workspaceSlug && projectId && issueType && issueLayout === "kanban" && currentIssues) { - // update issue payload - let updateIssue: any = { - workspaceSlug: workspaceSlug, - projectId: projectId, - }; - - // source, destination group and sub group id - let droppableSourceColumnId = source.droppableId; - droppableSourceColumnId = droppableSourceColumnId ? droppableSourceColumnId.split("__") : null; - let droppableDestinationColumnId = destination.droppableId; - droppableDestinationColumnId = droppableDestinationColumnId ? droppableDestinationColumnId.split("__") : null; - if (!droppableSourceColumnId || !droppableDestinationColumnId) return null; - - const source_group_id: string = droppableSourceColumnId[0]; - const source_sub_group_id: string = droppableSourceColumnId[1] === "null" ? null : droppableSourceColumnId[1]; - - const destination_group_id: string = droppableDestinationColumnId[0]; - const destination_sub_group_id: string = - droppableDestinationColumnId[1] === "null" ? null : droppableDestinationColumnId[1]; - - if (source_sub_group_id === destination_sub_group_id) { - if (source_group_id === destination_group_id) { - const _issues = currentIssues[source_sub_group_id][source_group_id]; - - // update the sort order - if (destination.index === 0) { - updateIssue = { - ...updateIssue, - sort_order: _issues[destination.index].sort_order - sortOrderDefaultValue, - }; - } else if (destination.index === _issues.length - 1) { - updateIssue = { - ...updateIssue, - sort_order: _issues[destination.index].sort_order + sortOrderDefaultValue, - }; - } else { - updateIssue = { - ...updateIssue, - sort_order: (_issues[destination.index - 1].sort_order + _issues[destination.index].sort_order) / 2, - }; - } - - const [removed] = _issues.splice(source.index, 1); - _issues.splice(destination.index, 0, { ...removed, sort_order: updateIssue.sort_order }); - updateIssue = { ...updateIssue, issueId: removed?.id }; - currentIssues[source_sub_group_id][source_group_id] = _issues; - } - - if (source_group_id != destination_group_id) { - const _sourceIssues = currentIssues[source_sub_group_id][source_group_id]; - let _destinationIssues = currentIssues[destination_sub_group_id][destination_group_id] || []; - - if (_destinationIssues && _destinationIssues.length > 0) { - if (destination.index === 0) { - updateIssue = { - ...updateIssue, - sort_order: _destinationIssues[destination.index].sort_order - sortOrderDefaultValue, - }; - } else if (destination.index === _destinationIssues.length) { - updateIssue = { - ...updateIssue, - sort_order: _destinationIssues[destination.index - 1].sort_order + sortOrderDefaultValue, - }; - } else { - updateIssue = { - ...updateIssue, - sort_order: - (_destinationIssues[destination.index - 1].sort_order + - _destinationIssues[destination.index].sort_order) / - 2, - }; - } - } else { - updateIssue = { - ...updateIssue, - sort_order: sortOrderDefaultValue, - }; - } - - let issueStatePriority = {}; - if (this.rootStore.issueFilter?.userDisplayFilters?.group_by === "state") { - updateIssue = { ...updateIssue, state: destination_group_id }; - issueStatePriority = { ...issueStatePriority, state: destination_group_id }; - } - if (this.rootStore.issueFilter?.userDisplayFilters?.group_by === "priority") { - updateIssue = { ...updateIssue, priority: destination_group_id }; - issueStatePriority = { ...issueStatePriority, priority: destination_group_id }; - } - - const [removed] = _sourceIssues.splice(source.index, 1); - if (_destinationIssues && _destinationIssues.length > 0) - _destinationIssues.splice(destination.index, 0, { - ...removed, - sort_order: updateIssue.sort_order, - ...issueStatePriority, - }); - else - _destinationIssues = [ - ..._destinationIssues, - { ...removed, sort_order: updateIssue.sort_order, ...issueStatePriority }, - ]; - updateIssue = { ...updateIssue, issueId: removed?.id }; - - currentIssues[source_sub_group_id][source_group_id] = _sourceIssues; - currentIssues[destination_sub_group_id][destination_group_id] = _destinationIssues; - } - } - - if (source_sub_group_id != destination_sub_group_id) { - const _sourceIssues = currentIssues[source_sub_group_id][source_group_id]; - let _destinationIssues = currentIssues[destination_sub_group_id][destination_group_id] || []; - - if (_destinationIssues && _destinationIssues.length > 0) { - if (destination.index === 0) { - updateIssue = { - ...updateIssue, - sort_order: _destinationIssues[destination.index].sort_order - sortOrderDefaultValue, - }; - } else if (destination.index === _destinationIssues.length) { - updateIssue = { - ...updateIssue, - sort_order: _destinationIssues[destination.index - 1].sort_order + sortOrderDefaultValue, - }; - } else { - updateIssue = { - ...updateIssue, - sort_order: - (_destinationIssues[destination.index - 1].sort_order + - _destinationIssues[destination.index].sort_order) / - 2, - }; - } - } else { - updateIssue = { - ...updateIssue, - sort_order: sortOrderDefaultValue, - }; - } - - let issueStatePriority = {}; - if (source_group_id === destination_group_id) { - if (this.rootStore.issueFilter?.userDisplayFilters?.sub_group_by === "state") { - updateIssue = { ...updateIssue, state: destination_sub_group_id }; - issueStatePriority = { ...issueStatePriority, state: destination_sub_group_id }; - } - if (this.rootStore.issueFilter?.userDisplayFilters?.sub_group_by === "priority") { - updateIssue = { ...updateIssue, priority: destination_sub_group_id }; - issueStatePriority = { ...issueStatePriority, priority: destination_sub_group_id }; - } - } else { - if (this.rootStore.issueFilter?.userDisplayFilters?.sub_group_by === "state") { - updateIssue = { ...updateIssue, state: destination_sub_group_id, priority: destination_group_id }; - issueStatePriority = { - ...issueStatePriority, - state: destination_sub_group_id, - priority: destination_group_id, - }; - } - if (this.rootStore.issueFilter?.userDisplayFilters?.sub_group_by === "priority") { - updateIssue = { ...updateIssue, state: destination_group_id, priority: destination_sub_group_id }; - issueStatePriority = { - ...issueStatePriority, - state: destination_group_id, - priority: destination_sub_group_id, - }; - } - } - - const [removed] = _sourceIssues.splice(source.index, 1); - if (_destinationIssues && _destinationIssues.length > 0) - _destinationIssues.splice(destination.index, 0, { - ...removed, - sort_order: updateIssue.sort_order, - ...issueStatePriority, - }); - else - _destinationIssues = [ - ..._destinationIssues, - { ...removed, sort_order: updateIssue.sort_order, ...issueStatePriority }, - ]; - - updateIssue = { ...updateIssue, issueId: removed?.id }; - currentIssues[source_sub_group_id][source_group_id] = _sourceIssues; - currentIssues[destination_sub_group_id][destination_group_id] = _destinationIssues; - } - - const reorderedIssues = { - ...this.rootStore?.issue.issues, - [projectId]: { - ...this.rootStore?.issue.issues?.[projectId], - [issueType]: { - ...this.rootStore?.issue.issues?.[projectId]?.[issueType], - [issueType]: currentIssues, - }, - }, - }; - - runInAction(() => { - this.rootStore.issue.issues = { ...reorderedIssues }; - }); - - this.rootStore.issueDetail?.updateIssue( - updateIssue.workspaceSlug, - updateIssue.projectId, - updateIssue.issueId, - updateIssue - ); - } - }; - - handleDragDrop = async (source: any, destination: any) => { - const workspaceSlug = this.rootStore?.workspace?.workspaceSlug; - const projectId = this.rootStore?.project?.projectId; - const issueType: IIssueType | null = this.rootStore?.issue?.getIssueType; - const issueLayout = this.rootStore?.issueFilter?.userDisplayFilters?.layout || null; - const currentIssues: any = this.rootStore.issue.getIssues; - - const sortOrderDefaultValue = 65535; - - if (workspaceSlug && projectId && issueType && issueLayout === "kanban" && currentIssues) { - // update issue payload - let updateIssue: any = { - workspaceSlug: workspaceSlug, - projectId: projectId, - }; - - // source, destination group and sub group id - let droppableSourceColumnId = source.droppableId; - droppableSourceColumnId = droppableSourceColumnId ? droppableSourceColumnId.split("__") : null; - let droppableDestinationColumnId = destination.droppableId; - droppableDestinationColumnId = droppableDestinationColumnId ? droppableDestinationColumnId.split("__") : null; - if (!droppableSourceColumnId || !droppableDestinationColumnId) return null; - - const source_group_id: string = droppableSourceColumnId[0]; - const destination_group_id: string = droppableDestinationColumnId[0]; - - if (this.canUserDragDrop) { - // vertical - if (source_group_id === destination_group_id) { - const _issues = currentIssues[source_group_id]; - - // update the sort order - if (destination.index === 0) { - updateIssue = { - ...updateIssue, - sort_order: _issues[destination.index].sort_order - sortOrderDefaultValue, - }; - } else if (destination.index === _issues.length - 1) { - updateIssue = { - ...updateIssue, - sort_order: _issues[destination.index].sort_order + sortOrderDefaultValue, - }; - } else { - updateIssue = { - ...updateIssue, - sort_order: (_issues[destination.index - 1].sort_order + _issues[destination.index].sort_order) / 2, - }; - } - - const [removed] = _issues.splice(source.index, 1); - _issues.splice(destination.index, 0, { ...removed, sort_order: updateIssue.sort_order }); - updateIssue = { ...updateIssue, issueId: removed?.id }; - currentIssues[source_group_id] = _issues; - } - - // horizontal - if (source_group_id != destination_group_id) { - const _sourceIssues = currentIssues[source_group_id]; - let _destinationIssues = currentIssues[destination_group_id] || []; - - if (_destinationIssues && _destinationIssues.length > 0) { - if (destination.index === 0) { - updateIssue = { - ...updateIssue, - sort_order: _destinationIssues[destination.index].sort_order - sortOrderDefaultValue, - }; - } else if (destination.index === _destinationIssues.length) { - updateIssue = { - ...updateIssue, - sort_order: _destinationIssues[destination.index - 1].sort_order + sortOrderDefaultValue, - }; - } else { - updateIssue = { - ...updateIssue, - sort_order: - (_destinationIssues[destination.index - 1].sort_order + - _destinationIssues[destination.index].sort_order) / - 2, - }; - } - } else { - updateIssue = { - ...updateIssue, - sort_order: sortOrderDefaultValue, - }; - } - - let issueStatePriority = {}; - if (this.rootStore.issueFilter?.userDisplayFilters?.group_by === "state") { - updateIssue = { ...updateIssue, state: destination_group_id }; - issueStatePriority = { ...issueStatePriority, state: destination_group_id }; - } - if (this.rootStore.issueFilter?.userDisplayFilters?.group_by === "priority") { - updateIssue = { ...updateIssue, priority: destination_group_id }; - issueStatePriority = { ...issueStatePriority, priority: destination_group_id }; - } - - const [removed] = _sourceIssues.splice(source.index, 1); - if (_destinationIssues && _destinationIssues.length > 0) - _destinationIssues.splice(destination.index, 0, { - ...removed, - sort_order: updateIssue.sort_order, - ...issueStatePriority, - }); - else - _destinationIssues = [ - ..._destinationIssues, - { ...removed, sort_order: updateIssue.sort_order, ...issueStatePriority }, - ]; - updateIssue = { ...updateIssue, issueId: removed?.id }; - - currentIssues[source_group_id] = _sourceIssues; - currentIssues[destination_group_id] = _destinationIssues; - } - } - - // user can drag the issues only vertically - if (this.canUserDragDropVertically && destination_group_id === destination_group_id) { - } - - // user can drag the issues only horizontally - if (this.canUserDragDropHorizontally && destination_group_id != destination_group_id) { - } - - const reorderedIssues = { - ...this.rootStore?.issue.issues, - [projectId]: { - ...this.rootStore?.issue.issues?.[projectId], - [issueType]: { - ...this.rootStore?.issue.issues?.[projectId]?.[issueType], - [issueType]: currentIssues, - }, - }, - }; - - runInAction(() => { - this.rootStore.issue.issues = { ...reorderedIssues }; - }); - - this.rootStore.issueDetail?.updateIssue( - updateIssue.workspaceSlug, - updateIssue.projectId, - updateIssue.issueId, - updateIssue - ); - } - }; -} diff --git a/web/store/project-view/project_view_issues.store.ts b/web/store/project-view/project_view_issues.store.ts index c28f7e9de..11a6ccfc4 100644 --- a/web/store/project-view/project_view_issues.store.ts +++ b/web/store/project-view/project_view_issues.store.ts @@ -347,11 +347,7 @@ export class ProjectViewIssuesStore implements IProjectViewIssuesStore { if (displayFilters.layout === "calendar") filteredRouteParams.group_by = "target_date"; if (displayFilters.layout === "gantt_chart") filteredRouteParams.start_target_date = true; - const issueResponse: any = await this.issueService.getIssuesWithParams( - workspaceSlug, - projectId, - filteredRouteParams - ); + const response: any = await this.issueService.getIssuesWithParams(workspaceSlug, projectId, filteredRouteParams); const issueType = this.rootStore.issue.getIssueType; @@ -360,7 +356,7 @@ export class ProjectViewIssuesStore implements IProjectViewIssuesStore { ...this.viewIssues, [viewId]: { ...this.viewIssues[viewId], - [issueType]: issueResponse?.["data"], + [issueType]: response, }, }; diff --git a/web/store/root.ts b/web/store/root.ts index 19099259f..65a5087f1 100644 --- a/web/store/root.ts +++ b/web/store/root.ts @@ -87,14 +87,7 @@ import { ArchivedIssueDetailStore, IArchivedIssueDetailStore, } from "store/archived-issues"; -import { - DraftIssueFilterStore, - IDraftIssueFilterStore, - IssueDraftStore, - IIssueDraftStore, - DraftIssueKanBanViewStore, - IDraftIssueKanBanViewStore, -} from "store/draft-issues"; +import { DraftIssueFilterStore, IDraftIssueFilterStore, IssueDraftStore, IIssueDraftStore } from "store/draft-issues"; import { IInboxFiltersStore, IInboxIssueDetailsStore, @@ -163,7 +156,6 @@ export class RootStore { draftIssues: IIssueDraftStore; draftIssueFilters: IDraftIssueFilterStore; - draftIssueKanBanView: IDraftIssueKanBanViewStore; inbox: IInboxStore; inboxIssues: IInboxIssuesStore; @@ -225,7 +217,6 @@ export class RootStore { this.draftIssues = new IssueDraftStore(this); this.draftIssueFilters = new DraftIssueFilterStore(this); - this.draftIssueKanBanView = new DraftIssueKanBanViewStore(this); this.inbox = new InboxStore(this); this.inboxIssues = new InboxIssuesStore(this);