diff --git a/web/components/issue-layouts/header/display-filters/index.tsx b/web/components/issue-layouts/header/display-filters/index.tsx new file mode 100644 index 000000000..33561c0ae --- /dev/null +++ b/web/components/issue-layouts/header/display-filters/index.tsx @@ -0,0 +1,15 @@ +import React from "react"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; + +export const DisplayPropertiesSelection = () => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + return ( +
+
Filter Selection
+
+ ); +}; diff --git a/web/components/issue-layouts/header/filters/assignees.tsx b/web/components/issue-layouts/header/filters/assignees.tsx new file mode 100644 index 000000000..66aa66e79 --- /dev/null +++ b/web/components/issue-layouts/header/filters/assignees.tsx @@ -0,0 +1,90 @@ +import React from "react"; +// lucide icons +import { + AlertCircleIcon, + SignalHighIcon, + SignalMediumIcon, + SignalLowIcon, + BanIcon, + CheckIcon, + ChevronDown, + ChevronUp, +} from "lucide-react"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; + +export const FilterAssignees = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + const [allFiltersToggle, setAllFiltersToggle] = React.useState(false); + + const PriorityIcons = ({ priority }: { priority: string }) => { + if (priority === "urgent") + return ( +
+ +
+ ); + if (priority === "high") + return ( +
+ +
+ ); + if (priority === "medium") + return ( +
+ +
+ ); + if (priority === "low") + return ( +
+ +
+ ); + return ( +
+ +
+ ); + }; + + return ( +
+
+
Assignees
+
setAllFiltersToggle(!allFiltersToggle)} + > + {allFiltersToggle ? : } +
+
+
+ {issueFilterStore?.issueRenderFilters?.priority && + issueFilterStore?.issueRenderFilters?.priority.length > 0 && + issueFilterStore?.issueRenderFilters?.priority.map((priority) => ( +
+ +
+ {priority.title} +
+
+ +
+
+ ))} +
+
+ ); +}); diff --git a/web/components/issue-layouts/header/filters/created-by.tsx b/web/components/issue-layouts/header/filters/created-by.tsx new file mode 100644 index 000000000..f1d28dad5 --- /dev/null +++ b/web/components/issue-layouts/header/filters/created-by.tsx @@ -0,0 +1,90 @@ +import React from "react"; +// lucide icons +import { + AlertCircleIcon, + SignalHighIcon, + SignalMediumIcon, + SignalLowIcon, + BanIcon, + CheckIcon, + ChevronDown, + ChevronUp, +} from "lucide-react"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; + +export const FilterCreatedBy = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + const [allFiltersToggle, setAllFiltersToggle] = React.useState(false); + + const PriorityIcons = ({ priority }: { priority: string }) => { + if (priority === "urgent") + return ( +
+ +
+ ); + if (priority === "high") + return ( +
+ +
+ ); + if (priority === "medium") + return ( +
+ +
+ ); + if (priority === "low") + return ( +
+ +
+ ); + return ( +
+ +
+ ); + }; + + return ( +
+
+
Created By
+
setAllFiltersToggle(!allFiltersToggle)} + > + {allFiltersToggle ? : } +
+
+
+ {issueFilterStore?.issueRenderFilters?.priority && + issueFilterStore?.issueRenderFilters?.priority.length > 0 && + issueFilterStore?.issueRenderFilters?.priority.map((priority) => ( +
+ +
+ {priority.title} +
+
+ +
+
+ ))} +
+
+ ); +}); diff --git a/web/components/issue-layouts/header/filters/index.tsx b/web/components/issue-layouts/header/filters/index.tsx new file mode 100644 index 000000000..0913ed033 --- /dev/null +++ b/web/components/issue-layouts/header/filters/index.tsx @@ -0,0 +1,57 @@ +import React from "react"; +// components +import { FilterPriority } from "./priority"; +import { FilterState } from "./state"; +import { FilterStateGroup } from "./state-group"; +import { FilterAssignees } from "./assignees"; +import { FilterCreatedBy } from "./created-by"; +import { FilterLabels } from "./labels"; +import { FilterStartDate } from "./start-date"; +import { FilterTargetDate } from "./target-date"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; + +export const FilterSelection = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + return ( +
+ {/* priority */} +
+ +
+ {/* state group */} +
+ +
+ {/* state */} +
+ +
+ {/* assignees */} +
+ +
+ {/* created_by */} +
+ +
+ {/* labels */} +
+ +
+ {/* start_date */} +
+ +
+ {/* due_date */} +
+ +
+
+ ); +}); diff --git a/web/components/issue-layouts/header/filters/labels.tsx b/web/components/issue-layouts/header/filters/labels.tsx new file mode 100644 index 000000000..6d8eed30a --- /dev/null +++ b/web/components/issue-layouts/header/filters/labels.tsx @@ -0,0 +1,90 @@ +import React from "react"; +// lucide icons +import { + AlertCircleIcon, + SignalHighIcon, + SignalMediumIcon, + SignalLowIcon, + BanIcon, + CheckIcon, + ChevronDown, + ChevronUp, +} from "lucide-react"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; + +export const FilterLabels = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + const [allFiltersToggle, setAllFiltersToggle] = React.useState(false); + + const PriorityIcons = ({ priority }: { priority: string }) => { + if (priority === "urgent") + return ( +
+ +
+ ); + if (priority === "high") + return ( +
+ +
+ ); + if (priority === "medium") + return ( +
+ +
+ ); + if (priority === "low") + return ( +
+ +
+ ); + return ( +
+ +
+ ); + }; + + return ( +
+
+
Labels
+
setAllFiltersToggle(!allFiltersToggle)} + > + {allFiltersToggle ? : } +
+
+
+ {issueFilterStore?.issueRenderFilters?.priority && + issueFilterStore?.issueRenderFilters?.priority.length > 0 && + issueFilterStore?.issueRenderFilters?.priority.map((priority) => ( +
+ +
+ {priority.title} +
+
+ +
+
+ ))} +
+
+ ); +}); diff --git a/web/components/issue-layouts/header/filters/priority.tsx b/web/components/issue-layouts/header/filters/priority.tsx new file mode 100644 index 000000000..4615fbfc4 --- /dev/null +++ b/web/components/issue-layouts/header/filters/priority.tsx @@ -0,0 +1,90 @@ +import React from "react"; +// lucide icons +import { + AlertCircle, + SignalHigh, + SignalMedium, + SignalLow, + Ban, + Check, + ChevronDown, + ChevronUp, +} from "lucide-react"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; + +const PriorityIcons = ({ priority }: { priority: string }) => { + if (priority === "urgent") + return ( +
+ +
+ ); + if (priority === "high") + return ( +
+ +
+ ); + if (priority === "medium") + return ( +
+ +
+ ); + if (priority === "low") + return ( +
+ +
+ ); + return ( +
+ +
+ ); +}; + +export const FilterPriority = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + const [allFiltersToggle, setAllFiltersToggle] = React.useState(false); + + return ( +
+
+
Priority
+
setAllFiltersToggle(!allFiltersToggle)} + > + {allFiltersToggle ? : } +
+
+
+ {issueFilterStore?.issueRenderFilters?.priority && + issueFilterStore?.issueRenderFilters?.priority.length > 0 && + issueFilterStore?.issueRenderFilters?.priority.map((_priority) => ( +
+ +
+ {_priority.title} +
+
+ {false && } +
+
+ ))} +
+
+ ); +}); diff --git a/web/components/issue-layouts/header/filters/start-date.tsx b/web/components/issue-layouts/header/filters/start-date.tsx new file mode 100644 index 000000000..b35d5f30f --- /dev/null +++ b/web/components/issue-layouts/header/filters/start-date.tsx @@ -0,0 +1,90 @@ +import React from "react"; +// lucide icons +import { + AlertCircleIcon, + SignalHighIcon, + SignalMediumIcon, + SignalLowIcon, + BanIcon, + CheckIcon, + ChevronDown, + ChevronUp, +} from "lucide-react"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; + +export const FilterStartDate = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + const [allFiltersToggle, setAllFiltersToggle] = React.useState(false); + + const PriorityIcons = ({ priority }: { priority: string }) => { + if (priority === "urgent") + return ( +
+ +
+ ); + if (priority === "high") + return ( +
+ +
+ ); + if (priority === "medium") + return ( +
+ +
+ ); + if (priority === "low") + return ( +
+ +
+ ); + return ( +
+ +
+ ); + }; + + return ( +
+
+
Start Date
+
setAllFiltersToggle(!allFiltersToggle)} + > + {allFiltersToggle ? : } +
+
+
+ {issueFilterStore?.issueRenderFilters?.priority && + issueFilterStore?.issueRenderFilters?.priority.length > 0 && + issueFilterStore?.issueRenderFilters?.priority.map((priority) => ( +
+ +
+ {priority.title} +
+
+ +
+
+ ))} +
+
+ ); +}); diff --git a/web/components/issue-layouts/header/filters/state-group.tsx b/web/components/issue-layouts/header/filters/state-group.tsx new file mode 100644 index 000000000..15049650a --- /dev/null +++ b/web/components/issue-layouts/header/filters/state-group.tsx @@ -0,0 +1,90 @@ +import React from "react"; +// lucide icons +import { + AlertCircleIcon, + SignalHighIcon, + SignalMediumIcon, + SignalLowIcon, + BanIcon, + CheckIcon, + ChevronDown, + ChevronUp, +} from "lucide-react"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; + +export const StateGroupIcons = ({ stateGroup }: { stateGroup: string }) => { + if (stateGroup === "cancelled") + return ( +
+ +
+ ); + if (stateGroup === "completed") + return ( +
+ +
+ ); + if (stateGroup === "started") + return ( +
+ +
+ ); + if (stateGroup === "unstarted") + return ( +
+ +
+ ); + return ( +
+ +
+ ); +}; + +export const FilterStateGroup = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + const [allFiltersToggle, setAllFiltersToggle] = React.useState(false); + + return ( +
+
+
State Group
+
setAllFiltersToggle(!allFiltersToggle)} + > + {allFiltersToggle ? : } +
+
+
+ {issueFilterStore?.issueRenderFilters?.state_group && + issueFilterStore?.issueRenderFilters?.state_group.length > 0 && + issueFilterStore?.issueRenderFilters?.state_group.map((_stateGroup) => ( +
+ +
+ {_stateGroup.title} +
+
+ +
+
+ ))} +
+
+ ); +}); diff --git a/web/components/issue-layouts/header/filters/state.tsx b/web/components/issue-layouts/header/filters/state.tsx new file mode 100644 index 000000000..a2b29fbee --- /dev/null +++ b/web/components/issue-layouts/header/filters/state.tsx @@ -0,0 +1,51 @@ +import React from "react"; +// lucide icons +import { CheckIcon, ChevronDown, ChevronUp } from "lucide-react"; +// components +import { StateGroupIcons } from "./state-group"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; + +export const FilterState = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + const [allFiltersToggle, setAllFiltersToggle] = React.useState(false); + + return ( +
+
+
State
+
setAllFiltersToggle(!allFiltersToggle)} + > + {allFiltersToggle ? : } +
+
+
+ {issueFilterStore?.projectStates && + issueFilterStore?.projectStates.length > 0 && + issueFilterStore?.projectStates.map((_state) => ( +
+ +
+ {_state?.name} +
+
+ +
+
+ ))} +
+
+ ); +}); diff --git a/web/components/issue-layouts/header/filters/target-date.tsx b/web/components/issue-layouts/header/filters/target-date.tsx new file mode 100644 index 000000000..8d5af198d --- /dev/null +++ b/web/components/issue-layouts/header/filters/target-date.tsx @@ -0,0 +1,90 @@ +import React from "react"; +// lucide icons +import { + AlertCircleIcon, + SignalHighIcon, + SignalMediumIcon, + SignalLowIcon, + BanIcon, + CheckIcon, + ChevronDown, + ChevronUp, +} from "lucide-react"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; + +export const FilterTargetDate = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + const [allFiltersToggle, setAllFiltersToggle] = React.useState(false); + + const PriorityIcons = ({ priority }: { priority: string }) => { + if (priority === "urgent") + return ( +
+ +
+ ); + if (priority === "high") + return ( +
+ +
+ ); + if (priority === "medium") + return ( +
+ +
+ ); + if (priority === "low") + return ( +
+ +
+ ); + return ( +
+ +
+ ); + }; + + return ( +
+
+
Target Date
+
setAllFiltersToggle(!allFiltersToggle)} + > + {allFiltersToggle ? : } +
+
+
+ {issueFilterStore?.issueRenderFilters?.priority && + issueFilterStore?.issueRenderFilters?.priority.length > 0 && + issueFilterStore?.issueRenderFilters?.priority.map((priority) => ( +
+ +
+ {priority.title} +
+
+ +
+
+ ))} +
+
+ ); +}); diff --git a/web/components/issue-layouts/header/layout-filter/index.tsx b/web/components/issue-layouts/header/layout-filter/index.tsx new file mode 100644 index 000000000..ce0410f75 --- /dev/null +++ b/web/components/issue-layouts/header/layout-filter/index.tsx @@ -0,0 +1,115 @@ +import React from "react"; +// lucide icons +import { Columns, Grid3x3, Calendar, GanttChart, List } from "lucide-react"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { RootStore } from "store/root"; +import { TIssueLayouts } from "store/issue-views/issue_filters"; +import { useMobxStore } from "lib/mobx/store-provider"; + +export const LayoutSelection = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + const layoutSelectionFilters: { key: TIssueLayouts; title: string; icon: any }[] = [ + { + key: "list", + title: "List", + icon: List, + }, + { + key: "kanban", + title: "Kanban", + icon: Grid3x3, + }, + { + key: "calendar", + title: "Calendar", + icon: Calendar, + }, + { + key: "spreadsheet", + title: "Spreadsheet", + icon: Columns, + }, + { + key: "gantt", + title: "Gantt", + icon: GanttChart, + }, + ]; + + const handleLayoutSelection = (layout: TIssueLayouts) => { + if (!issueFilterStore.workspaceId) return; + if (issueFilterStore.issueView === "my_issues") { + issueStore.getMyIssuesAsync(issueFilterStore.workspaceId, issueFilterStore.issueView, layout); + return; + } + + if (!issueFilterStore.projectId) return; + if (issueFilterStore.issueView === "issues") { + issueStore.getProjectIssuesAsync( + issueFilterStore.workspaceId, + issueFilterStore.projectId, + issueFilterStore.issueView, + layout + ); + return; + } + if (issueFilterStore.issueView === "modules" && issueFilterStore.moduleId) { + issueStore.getIssuesForModulesAsync( + issueFilterStore.workspaceId, + issueFilterStore.projectId, + issueFilterStore.moduleId, + issueFilterStore.issueView, + layout + ); + return; + } + if (issueFilterStore.issueView === "cycles" && issueFilterStore.cycleId) { + issueStore.getIssuesForCyclesAsync( + issueFilterStore.workspaceId, + issueFilterStore.projectId, + issueFilterStore.cycleId, + issueFilterStore.issueView, + layout + ); + return; + } + if (issueFilterStore.issueView === "views" && issueFilterStore.viewId) { + issueStore.getIssuesForViewsAsync( + issueFilterStore.workspaceId, + issueFilterStore.projectId, + issueFilterStore.viewId, + issueFilterStore.issueView, + layout + ); + return; + } + }; + + return ( +
+ {layoutSelectionFilters.map((_layout) => ( +
handleLayoutSelection(_layout?.key)} + > + <_layout.icon + size={15} + strokeWidth={2} + className={`${ + issueFilterStore?.issueLayout == _layout?.key + ? `text-gray-900` + : `text-gray-700 group-hover:text-gray-900` + }`} + /> +
+ ))} +
+ ); +}); diff --git a/web/components/issue-layouts/kanban/index.tsx b/web/components/issue-layouts/kanban/index.tsx index 27d7fcbc0..51828ae99 100644 --- a/web/components/issue-layouts/kanban/index.tsx +++ b/web/components/issue-layouts/kanban/index.tsx @@ -12,7 +12,7 @@ import { RootStore } from "store/root"; export const IssueKanBanViewRoot = observer(() => { const store: RootStore = useMobxStore(); - const { issueView: issueViewStore } = store; + const { issueFilters: issueFilterStore, issueView: issueViewStore } = store; const onDragEnd = (result: any) => { if (!result) return; @@ -28,9 +28,31 @@ export const IssueKanBanViewRoot = observer(() => { console.log("result", result); }; + console.log("------"); + console.log("workspace id -->", issueFilterStore?.workspaceId); + console.log("project id -->", issueFilterStore?.projectId); + console.log("module id -->", issueFilterStore?.moduleId); + console.log("cycle id -->", issueFilterStore?.cycleId); + console.log("view id -->", issueFilterStore?.viewId); + + console.log("<-- workspace level -->"); + console.log("workspace projects -->", issueFilterStore?.workspaceProjects); + console.log("workspace labels -->", issueFilterStore?.workspaceLabels); + + console.log("<-- project level -->"); + console.log("project states -->", issueFilterStore?.projectStates); + console.log("project labels -->", issueFilterStore?.projectLabels); + console.log("project members -->", issueFilterStore?.projectMembers); + + console.log("project display properties -->", issueFilterStore?.projectDisplayProperties); + + console.log("issue layout -->", issueFilterStore?.issueLayout); + console.log("issues -->", issueViewStore?.getIssues); + console.log("------"); + return (
- {issueViewStore.loader && issueViewStore?.issues === null ? ( + {issueViewStore.loader || issueViewStore?.getIssues === null ? (
Loading...
) : ( <> diff --git a/web/components/issue-layouts/root.tsx b/web/components/issue-layouts/root.tsx new file mode 100644 index 000000000..23752fe49 --- /dev/null +++ b/web/components/issue-layouts/root.tsx @@ -0,0 +1,14 @@ +import React from "react"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { RootStore } from "store/root"; +import { TIssueLayouts } from "store/issue-views/issue_filters"; +import { useMobxStore } from "lib/mobx/store-provider"; + +export const IssuesRoot = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore, issueView: issueStore } = store; + + return
issue root
; +}); diff --git a/web/pages/kanban.tsx b/web/pages/kanban.tsx index 8e0312dd9..a31d39bfc 100644 --- a/web/pages/kanban.tsx +++ b/web/pages/kanban.tsx @@ -3,6 +3,8 @@ import React from "react"; import useSWR from "swr"; // components import { IssueKanBanViewRoot } from "components/issue-layouts/kanban"; +import { LayoutSelection } from "components/issue-layouts/header/layout-filter"; +import { FilterSelection } from "components/issue-layouts/header/filters"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; import { RootStore } from "store/root"; @@ -15,21 +17,20 @@ const KanBanViewRoot = () => { const viewSlug: string = "1f66a767-00d1-422c-8f8f-6925282b7249"; const store: RootStore = useMobxStore(); - const { issueView: issueViewStore } = store; + const { issueFilters: issueFilterStore, issueView: issueViewStore } = store; React.useEffect(() => { const init = async () => { // my issues under a workspace - console.log("started--->"); + // console.log("started--->"); // await issueViewStore.getMyIssuesAsync(workspaceSlug, "my_issues", "list"); // await issueViewStore.getMyIssuesAsync(workspaceSlug, "my_issues", "kanban"); // await issueViewStore.getMyIssuesAsync(workspaceSlug, "my_issues", "calendar"); // await issueViewStore.getMyIssuesAsync(workspaceSlug, "my_issues", "spreadsheet"); // await issueViewStore.getMyIssuesAsync(workspaceSlug, "my_issues", "gantt"); - // project issues under and workspace and project - // await issueViewStore.getProjectIssuesAsync(workspaceSlug, projectSlug, "issues", "list"); - await issueViewStore.getProjectIssuesAsync(workspaceSlug, projectSlug, "issues", "kanban"); + await issueViewStore.getProjectIssuesAsync(workspaceSlug, projectSlug, "issues", "list"); + // await issueViewStore.getProjectIssuesAsync(workspaceSlug, projectSlug, "issues", "kanban"); // await issueViewStore.getProjectIssuesAsync(workspaceSlug, projectSlug, "issues", "calendar"); // await issueViewStore.getProjectIssuesAsync( // workspaceSlug, @@ -38,7 +39,6 @@ const KanBanViewRoot = () => { // "spreadsheet" // ); // await issueViewStore.getProjectIssuesAsync(workspaceSlug, projectSlug, "issues", "gantt"); - // module issues under and workspace and project // await issueViewStore.getIssuesForModulesAsync( // workspaceSlug, @@ -75,7 +75,6 @@ const KanBanViewRoot = () => { // "modules", // "gantt" // ); - // cycle issues under and workspace and project // await issueViewStore.getIssuesForCyclesAsync( // workspaceSlug, @@ -112,7 +111,6 @@ const KanBanViewRoot = () => { // "cycles", // "gantt" // ); - // cycle issues under and workspace and project // await issueViewStore.getIssuesForViewsAsync( // workspaceSlug, @@ -149,8 +147,7 @@ const KanBanViewRoot = () => { // "views", // "gantt" // ); - - console.log("ended--->"); + // console.log("ended--->"); }; init(); @@ -163,10 +160,21 @@ const KanBanViewRoot = () => { className="flex-shrink-0 h-[60px] border-b border-gray-200" // style={{ writingMode: "vertical-lr" }} > - Filter Header +
+
+
Filter Header
+
+
+
{/* */}
+
+ +
+
+
- + + {/* */}
diff --git a/web/services/state.service.ts b/web/services/state.service.ts index 52481f8bb..a0d2c34fd 100644 --- a/web/services/state.service.ts +++ b/web/services/state.service.ts @@ -10,7 +10,7 @@ const trackEvent = // types import type { ICurrentUserResponse, IState, IStateResponse } from "types"; -class ProjectStateServices extends APIService { +export class ProjectStateServices extends APIService { constructor() { super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); } diff --git a/web/services/workspace.service.ts b/web/services/workspace.service.ts index 8097253e6..47d6b329e 100644 --- a/web/services/workspace.service.ts +++ b/web/services/workspace.service.ts @@ -20,7 +20,7 @@ import { const trackEvent = process.env.NEXT_PUBLIC_TRACK_EVENTS === "true" || process.env.NEXT_PUBLIC_TRACK_EVENTS === "1"; -class WorkspaceService extends APIService { +export class WorkspaceService extends APIService { constructor() { super(NEXT_PUBLIC_API_BASE_URL || "http://localhost:8000"); } diff --git a/web/store/issue-views/Issues.ts b/web/store/issue-views/Issues.ts index 817eb7c23..b839cfeec 100644 --- a/web/store/issue-views/Issues.ts +++ b/web/store/issue-views/Issues.ts @@ -121,14 +121,19 @@ class IssueViewStore implements IIssueViewStore { get getIssues() { if (this.issues != null) { const currentView: TIssueViews | null = this.rootStore.issueFilters.issueView; - const currentLayout: TIssueLayouts | null = this.rootStore.issueFilters.issueLayout; const currentWorkspaceId: string | null = this.rootStore.issueFilters.workspaceId; const currentProjectId: string | null = this.rootStore.issueFilters.projectId; const currentModuleId: string | null = this.rootStore.issueFilters.moduleId; const currentCycleId: string | null = this.rootStore.issueFilters.cycleId; const currentViewId: string | null = this.rootStore.issueFilters.viewId; - if (!currentView || !currentLayout || !currentWorkspaceId) return null; + if (!currentView || !currentWorkspaceId) return null; + + const currentLayout: TIssueLayouts = currentProjectId + ? this.rootStore.issueFilters.issueFilters?.[currentWorkspaceId] + ?.project_issue_properties?.[currentProjectId]?.renderLayout + : this.rootStore.issueFilters.issueFilters?.[currentWorkspaceId]?.my_issue_properties + ?.renderLayout; if (currentView === "my_issues") return this.issues?.[currentWorkspaceId]?.my_issues?.[currentLayout]; @@ -149,6 +154,8 @@ class IssueViewStore implements IIssueViewStore { currentViewId ]?.[currentLayout]; } + + return null; } // fetching my issues @@ -157,6 +164,7 @@ class IssueViewStore implements IIssueViewStore { this.loader = true; this.error = null; + await this.rootStore.issueFilters.getWorkspaceMyIssuesFilters(workspaceId); const filteredParams = this.rootStore.issueFilters.getComputedFilters( workspaceId, null, @@ -189,7 +197,7 @@ class IssueViewStore implements IIssueViewStore { return issuesResponse; } catch (error) { - console.warn("error", error); + console.warn("error in fetching the my issues", error); this.loader = false; this.error = null; return error; @@ -207,6 +215,7 @@ class IssueViewStore implements IIssueViewStore { this.loader = true; this.error = null; + await this.rootStore.issueFilters.getProjectIssueFilters(workspaceId, projectId); const filteredParams = this.rootStore.issueFilters.getComputedFilters( workspaceId, projectId, @@ -249,7 +258,7 @@ class IssueViewStore implements IIssueViewStore { return issuesResponse; } catch (error) { - console.warn("error", error); + console.warn("error in fetching the project issues", error); this.loader = false; this.error = null; return error; @@ -268,6 +277,11 @@ class IssueViewStore implements IIssueViewStore { this.loader = true; this.error = null; + await this.rootStore.issueFilters.getProjectIssueModuleFilters( + workspaceId, + projectId, + moduleId + ); const filteredParams = this.rootStore.issueFilters.getComputedFilters( workspaceId, projectId, @@ -314,7 +328,7 @@ class IssueViewStore implements IIssueViewStore { return issuesResponse; } catch (error) { - console.warn("error", error); + console.warn("error in fetching the project module issues", error); this.loader = false; this.error = null; return error; @@ -333,6 +347,11 @@ class IssueViewStore implements IIssueViewStore { this.loader = true; this.error = null; + await this.rootStore.issueFilters.getProjectIssueCyclesFilters( + workspaceId, + projectId, + cycleId + ); const filteredParams = this.rootStore.issueFilters.getComputedFilters( workspaceId, projectId, @@ -379,7 +398,7 @@ class IssueViewStore implements IIssueViewStore { return issuesResponse; } catch (error) { - console.warn("error", error); + console.warn("error in fetching the project cycles issues", error); this.loader = false; this.error = null; return error; @@ -398,6 +417,7 @@ class IssueViewStore implements IIssueViewStore { this.loader = true; this.error = null; + await this.rootStore.issueFilters.getProjectIssueViewsFilters(workspaceId, projectId, viewId); const filteredParams = this.rootStore.issueFilters.getComputedFilters( workspaceId, projectId, @@ -443,7 +463,7 @@ class IssueViewStore implements IIssueViewStore { return issuesResponse; } catch (error) { - console.warn("error", error); + console.warn("error in fetching the project view issues", error); this.loader = false; this.error = null; return error; diff --git a/web/store/issue-views/issue_data.ts b/web/store/issue-views/issue_data.ts index 939967023..d5efa6e7e 100644 --- a/web/store/issue-views/issue_data.ts +++ b/web/store/issue-views/issue_data.ts @@ -6,7 +6,15 @@ export const filtersPriority: { key: string; title: string }[] = [ { key: "null", title: "None" }, ]; -export const filtersStartDate = [ +export const filterStateGroup: { key: string; title: string }[] = [ + { key: "backlog", title: "Backlog" }, + { key: "unstarted", title: "Unstarted" }, + { key: "started", title: "Started" }, + { key: "completed", title: "Completed" }, + { key: "cancelled", title: "Cancelled" }, +]; + +export const filtersStartDate: { key: string; title: string }[] = [ { key: "last_week", title: "Last Week" }, { key: "2_weeks_from_now", title: "2 weeks from now" }, { key: "1_month_from_now", title: "1 month from now" }, @@ -14,7 +22,7 @@ export const filtersStartDate = [ { key: "custom", title: "Custom" }, ]; -export const filtersDueDate = [ +export const filtersDueDate: { key: string; title: string }[] = [ { key: "last_week", title: "Last Week" }, { key: "2_weeks_from_now", title: "2 weeks from now" }, { key: "1_month_from_now", title: "1 month from now" }, @@ -22,16 +30,17 @@ export const filtersDueDate = [ { key: "custom", title: "Custom" }, ]; -export const displayPropertyGroupBy = [ +export const displayPropertyGroupBy: { key: string; title: string }[] = [ { key: "state", title: "States" }, { key: "state_detail.group", title: "State Groups" }, { key: "priority", title: "Priority" }, + { key: "Project", title: "project" }, // required this on my issues { key: "labels", title: "Labels" }, { key: "assignees", title: "Assignees" }, { key: "created_by", title: "Created By" }, ]; -export const displayPropertyOrderBy = [ +export const displayPropertyOrderBy: { key: string; title: string }[] = [ { key: "sort_order", title: "Manual" }, { key: "created_at", title: "Last Created" }, { key: "updated_at", title: "Last Updated" }, @@ -39,13 +48,13 @@ export const displayPropertyOrderBy = [ { key: "priority", title: "Priority" }, ]; -export const displayPropertyIssueType = [ +export const displayPropertyIssueType: { key: string; title: string }[] = [ { key: "all", title: "All" }, { key: "active", title: "Active Issues" }, { key: "backlog", title: "Backlog Issues" }, ]; -export const displayProperties = [ +export const displayProperties: { key: string; title: string }[] = [ { key: "assignee", title: "Assignee" }, { key: "start_date", title: "Start Date" }, { key: "due_date", title: "Due Date" }, diff --git a/web/store/issue-views/issue_filters.ts b/web/store/issue-views/issue_filters.ts index 9cb21817e..102f15193 100644 --- a/web/store/issue-views/issue_filters.ts +++ b/web/store/issue-views/issue_filters.ts @@ -2,10 +2,14 @@ import { observable, action, computed, makeObservable, runInAction } from "mobx" // types import { RootStore } from "../root"; // services -import {} from "services/issues.service"; +import { WorkspaceService } from "services/workspace.service"; +import { ProjectIssuesServices } from "services/issues.service"; +import { ProjectStateServices } from "services/state.service"; +import { ProjectServices } from "services/project.service"; // default data import { filtersPriority, + filterStateGroup, filtersStartDate, filtersDueDate, displayPropertyGroupBy, @@ -15,8 +19,98 @@ import { } from "./issue_data"; export type TIssueViews = "my_issues" | "issues" | "modules" | "views" | "cycles"; + export type TIssueLayouts = "list" | "kanban" | "calendar" | "spreadsheet" | "gantt"; +export interface IIssueFilter { + priority: string[] | undefined; + state: string[] | undefined; + state_group: string[] | undefined; + assignees: string[] | undefined; + created_by: string[] | undefined; + labels: string[] | undefined; + start_date: string[] | undefined; + target_date: string[] | undefined; + [key: string]: any; +} + +export interface IIssueDisplayFilters { + group_by: undefined | string; + order_by: undefined | string; + type: string | undefined; + sub_issue: boolean; + show_empty_groups: boolean; + layout: TIssueLayouts; + calendar_date_range: string | undefined; // only for calendar + start_target_date: boolean; + [key: string]: any; +} + +export interface IIssueDisplayProperties { + assignee: boolean; + attachment_count: boolean; + created_on: boolean; + due_date: boolean; + estimate: boolean; + key: boolean; + labels: boolean; + link: boolean; + priority: boolean; + start_date: boolean; + state: boolean; + sub_issue_count: boolean; + updated_on: boolean; + [key: string]: any; +} + +export interface IIssueRenderFilters { + priority: { key: string; title: string }[]; + state_group: { key: string; title: string }[]; + start_date: { key: string; title: string }[]; + due_date: { key: string; title: string }[]; + group_by: { key: string; title: string }[]; + order_by: { key: string; title: string }[]; + issue_type: { key: string; title: string }[]; + display_properties: { key: string; title: string }[]; + workspace_properties: { + [key: string]: { + projects: any[]; + labels: any[]; + project_properties: { + [key: string]: { + states: any[] | null; + labels: any[] | null; + members: any[] | null; + }; + }; + }; + }; +} + +export interface IIssueFilters { + [key: string]: { + my_issue_properties: { + filters: IIssueFilter; + display_filters: IIssueDisplayFilters; + display_properties: IIssueDisplayProperties; + renderLayout: TIssueLayouts; + }; + project_issue_properties: { + [key: string]: { + issues: { + filters: IIssueFilter; + display_filters: IIssueDisplayFilters; + }; + cycles: { filters: IIssueFilter; display_filters: IIssueDisplayFilters }; + modules: { filters: IIssueFilter; display_filters: IIssueDisplayFilters }; + views: { filters: IIssueFilter; display_filters: IIssueDisplayFilters }; + display_properties: IIssueDisplayProperties; + renderLayout: TIssueLayouts; + }; + }; + }; +} + export interface IIssueFilterStore { loader: boolean; error: any | null; @@ -27,68 +121,37 @@ export interface IIssueFilterStore { moduleId: string | null; cycleId: string | null; viewId: string | null; - // current issue layout:TIssueLayouts and view:TIssueViews issueView: TIssueViews | null; - issueLayout: TIssueLayouts | null; - // filters - // static filters data - priority: { key: string; title: string }[]; - startDate: { key: string; title: string }[]; - dueDate: { key: string; title: string }[]; - issueType: { key: string; title: string }[]; - - // static display filters data - groupBy: { key: string; title: string }[]; - orderBy: { key: string; title: string }[]; - - // dynamic filters data - state: { [key: string]: { key: string; title: string }[] } | null; - members: { [key: string]: { key: string; title: string }[] } | null; // members are used for both assignees and crated_by - labels: { [key: string]: { key: string; title: string }[] } | null; - - userSelectedFilters: { - priority: string[] | null; - state: string[] | null; - assignees: string[] | null; - created_by: string[] | null; - labels: string[] | null; - start_date: string[] | null; - target_date: string[] | null; - type: string; - }; - - userSelectedDisplayFilters?: { - group_by: undefined | string; - order_by: undefined | string; - sub_issue: boolean; - showEmptyGroups: boolean; - }; - - // static display properties data - displayProperties?: { key: string; title: string }[] | null; - userSelectedDisplayProperties?: { - assignee: boolean; - attachment_count: boolean; - created_on: boolean; - due_date: boolean; - estimate: boolean; - key: boolean; - labels: boolean; - link: boolean; - priority: boolean; - start_date: boolean; - state: boolean; - sub_issue_count: boolean; - updated_on: boolean; - }; + issueRenderFilters: IIssueRenderFilters; + issueFilters: IIssueFilters; // actions - getProjectIssueFilterProperties: () => any | Promise; - getProjectIssueDisplayProperties: () => any | Promise; - getProjectMembers: () => any | Promise; - getProjectStates: () => any | Promise; - getProjectLabels: () => any | Promise; + getWorkspaceMyIssuesFilters: (workspaceId: string) => Promise; + updateWorkspaceMyIssuesFilters: () => any | Promise; + + getProjectLevelMembers: (workspaceId: string, projectId: string) => any | Promise; + getProjectLevelStates: (workspaceId: string, projectId: string) => any | Promise; + getProjectLevelLabels: (workspaceId: string, projectId: string) => any | Promise; + getProjectDisplayFilters: (workspaceId: string, projectId: string) => any | Promise; + getProjectDisplayProperties: (workspaceId: string, projectId: string) => any | Promise; + + getProjectIssueFilters: (workspaceId: string, projectId: string) => any | Promise; + getProjectIssueModuleFilters: ( + workspaceId: string, + projectId: string, + moduleId: string + ) => any | Promise; + getProjectIssueCyclesFilters: ( + workspaceId: string, + projectId: string, + cycleId: string + ) => any | Promise; + getProjectIssueViewsFilters: ( + workspaceId: string, + projectId: string, + viewId: string + ) => any | Promise; } class IssueFilterStore implements IIssueFilterStore { @@ -101,46 +164,28 @@ class IssueFilterStore implements IIssueFilterStore { cycleId: string | null = null; viewId: string | null = null; - issueLayout: TIssueLayouts | null = null; issueView: TIssueViews | null = null; - priority: { key: string; title: string }[] = filtersPriority; - startDate: { key: string; title: string }[] = filtersStartDate; - dueDate: { key: string; title: string }[] = filtersDueDate; - issueType: { key: string; title: string }[] = displayPropertyIssueType; - - // static display filters data - groupBy: { key: string; title: string }[] = displayPropertyGroupBy; - orderBy: { key: string; title: string }[] = displayPropertyOrderBy; - - state: { [key: string]: { key: string; title: string }[] } | null = null; - members: { [key: string]: { key: string; title: string }[] } | null = null; - labels: { [key: string]: { key: string; title: string }[] } | null = null; - - userSelectedFilters: { - priority: string[] | null; - state: string[] | null; - assignees: string[] | null; - created_by: string[] | null; - labels: string[] | null; - start_date: string[] | null; - target_date: string[] | null; - type: string; - } = { - priority: null, - state: null, - assignees: null, - created_by: null, - labels: null, - start_date: null, - target_date: null, - type: "all", + issueRenderFilters: IIssueRenderFilters = { + priority: filtersPriority, + state_group: filterStateGroup, + start_date: filtersStartDate, + due_date: filtersDueDate, + group_by: displayPropertyGroupBy, + order_by: displayPropertyOrderBy, + issue_type: displayPropertyIssueType, + display_properties: displayProperties, + workspace_properties: {}, }; + issueFilters: IIssueFilters = {}; // root store rootStore; // service - projectPublishService = null; + workspaceService; + issueService; + stateService; + projectService; constructor(_rootStore: RootStore) { makeObservable(this, { @@ -154,14 +199,19 @@ class IssueFilterStore implements IIssueFilterStore { cycleId: observable, viewId: observable, - issueLayout: observable, issueView: observable, - state: observable.ref, - members: observable.ref, - labels: observable.ref, + issueRenderFilters: observable.ref, + issueFilters: observable.ref, - userSelectedFilters: observable.ref, + // computed + issueLayout: computed, + workspaceProjects: computed, + workspaceLabels: computed, + projectStates: computed, + projectLabels: computed, + projectMembers: computed, + projectDisplayProperties: computed, // action setWorkspaceId: action, @@ -169,20 +219,30 @@ class IssueFilterStore implements IIssueFilterStore { setModuleId: action, setCycleId: action, setViewId: action, - - setIssueLayout: action, setIssueView: action, - getProjectIssueFilterProperties: action, - getProjectIssueDisplayProperties: action, - getProjectMembers: action, - getProjectStates: action, - getProjectLabels: action, - // computed + getComputedFilters: action, + + getWorkspaceMyIssuesFilters: action, + updateWorkspaceMyIssuesFilters: action, + + getProjectLevelMembers: action, + getProjectLevelStates: action, + getProjectLevelLabels: action, + getProjectDisplayFilters: action, + getProjectDisplayProperties: action, + + getProjectIssueFilters: action, + getProjectIssueModuleFilters: action, + getProjectIssueCyclesFilters: action, + getProjectIssueViewsFilters: action, }); this.rootStore = _rootStore; - this.projectPublishService = null; + this.workspaceService = new WorkspaceService(); + this.issueService = new ProjectIssuesServices(); + this.stateService = new ProjectStateServices(); + this.projectService = new ProjectServices(); } setWorkspaceId = (_workspaceId: string | null) => (this.workspaceId = _workspaceId); @@ -190,9 +250,52 @@ class IssueFilterStore implements IIssueFilterStore { setModuleId = (_moduleId: string | null) => (this.moduleId = _moduleId); setCycleId = (_cycleId: string | null) => (this.cycleId = _cycleId); setViewId = (_viewId: string | null) => (this.viewId = _viewId); - setIssueLayout = (_layout: TIssueLayouts | null) => (this.issueLayout = _layout); setIssueView = (_view: TIssueViews | null) => (this.issueView = _view); + // computed + get issueLayout() { + if (!this.workspaceId) return null; + + if (!this.projectId) + return this.issueFilters?.[this.workspaceId]?.my_issue_properties?.renderLayout; + if (this.projectId) + return this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId] + ?.renderLayout; + } + + get workspaceProjects() { + if (!this.workspaceId) return null; + return this.issueRenderFilters?.workspace_properties?.[this.workspaceId]?.projects; + } + get workspaceLabels() { + if (!this.workspaceId) return null; + return this.issueRenderFilters?.workspace_properties?.[this.workspaceId]?.labels; + } + + get projectStates() { + if (!this.workspaceId || !this.projectId) return null; + return this.issueRenderFilters?.workspace_properties?.[this.workspaceId]?.project_properties?.[ + this.projectId + ]?.states; + } + get projectLabels() { + if (!this.workspaceId || !this.projectId) return null; + return this.issueRenderFilters?.workspace_properties?.[this.workspaceId]?.project_properties?.[ + this.projectId + ]?.labels; + } + get projectMembers() { + if (!this.workspaceId || !this.projectId) return null; + return this.issueRenderFilters?.workspace_properties?.[this.workspaceId]?.project_properties?.[ + this.projectId + ]?.members; + } + get projectDisplayProperties() { + if (!this.workspaceId || !this.projectId) return null; + return this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId] + ?.display_properties; + } + computedFilter = (filters: any, filteredParams: any) => { const computedFilters: any = {}; Object.keys(filters).map((key) => { @@ -205,8 +308,6 @@ class IssueFilterStore implements IIssueFilterStore { return computedFilters; }; - - // computed functions starts getComputedFilters = ( _workspaceId: string | null, _projectId: string | null, @@ -222,17 +323,44 @@ class IssueFilterStore implements IIssueFilterStore { this.setCycleId(_cycleId); this.setViewId(_viewId); this.setIssueView(_issueView); - this.setIssueLayout(_issueLayout); + + if (_workspaceId) { + if (!_projectId) + this.issueFilters = { + ...this.issueFilters, + [_workspaceId]: { + ...this.issueFilters[_workspaceId], + my_issue_properties: { + ...this.issueFilters[_workspaceId]?.my_issue_properties, + renderLayout: _issueLayout, + }, + }, + }; + else + this.issueFilters = { + ...this.issueFilters, + [_workspaceId]: { + ...this.issueFilters[_workspaceId], + project_issue_properties: { + ...this.issueFilters[_workspaceId]?.project_issue_properties, + [_projectId]: { + ...this.issueFilters[_workspaceId]?.project_issue_properties?.[_projectId], + renderLayout: _issueLayout, + }, + }, + }, + }; + } let filteredRouteParams: any = { - priority: this.userSelectedFilters?.priority || undefined, - state: this.userSelectedFilters?.state || undefined, - assignees: this.userSelectedFilters?.assignees || undefined, // ['user_id', 'user_id'] - created_by: this.userSelectedFilters?.created_by || undefined, // ['user_id', 'user_id'] - labels: this.userSelectedFilters?.labels || undefined, // ['label_id', 'label_id'] - start_date: this.userSelectedFilters?.start_date || undefined, // ['yyyy-mm-dd:after/before', 'yyyy-mm-dd:after/before'] - target_date: this.userSelectedFilters?.target_date || undefined, // [yyyy-mm-dd:after, yyyy-mm-dd:before] - type: this.userSelectedFilters?.type || undefined, // 'active' (started, un_started) || 'backlog' || 'null' (all_the_issues) + priority: [] || undefined, + state: [] || undefined, + assignees: [] || undefined, // ['user_id', 'user_id'] + created_by: [] || undefined, // ['user_id', 'user_id'] + labels: [] || undefined, // ['label_id', 'label_id'] + start_date: [] || undefined, // ['yyyy-mm-dd:after/before', 'yyyy-mm-dd:after/before'] + target_date: [] || undefined, // [yyyy-mm-dd:after, yyyy-mm-dd:before] + type: "" || undefined, // 'active' (started, un_started) || 'backlog' || 'null' (all_the_issues) group_by: "state", // TIssueGroupByOptions order_by: "-created_at", // TIssueOrderByOptions sub_issue: true, // true for all other views except spreadsheet @@ -240,7 +368,7 @@ class IssueFilterStore implements IIssueFilterStore { let filteredParams: any = {}; - if (this.issueLayout === "list") + if (_issueLayout === "list") filteredParams = [ "priority", "state", @@ -254,7 +382,7 @@ class IssueFilterStore implements IIssueFilterStore { "order_by", "sub_issue", ]; - if (this.issueLayout === "kanban") + if (_issueLayout === "kanban") filteredParams = [ "priority", "state", @@ -268,7 +396,7 @@ class IssueFilterStore implements IIssueFilterStore { "order_by", "sub_issue", ]; - if (this.issueLayout === "calendar") + if (_issueLayout === "calendar") filteredParams = [ "priority", "state", @@ -279,7 +407,7 @@ class IssueFilterStore implements IIssueFilterStore { "target_date", "type", ]; - if (this.issueLayout === "spreadsheet") + if (_issueLayout === "spreadsheet") filteredParams = [ "priority", "state", @@ -290,7 +418,7 @@ class IssueFilterStore implements IIssueFilterStore { "target_date", "type", ]; - if (this.issueLayout === "gantt") + if (_issueLayout === "gantt") filteredParams = [ "priority", "state", @@ -309,22 +437,794 @@ class IssueFilterStore implements IIssueFilterStore { return filteredRouteParams; }; - // computed functions ends + // services + getWorkspaceMyIssuesProjects = async (workspaceId: string) => { + try { + this.loader = true; + this.error = null; - // fetching current user project issue filter and display settings - getProjectIssueFilterProperties = () => {}; + const params = { is_favorite: false }; + const issuesProjectsResponse = await this.projectService.getProjects(workspaceId, params); - // fetching display properties - getProjectIssueDisplayProperties = () => {}; + if (issuesProjectsResponse) { + const _issuesProjectsResponse = { + ...this.issueRenderFilters, + workspace_properties: { + ...this.issueRenderFilters?.workspace_properties, + [workspaceId]: { + ...this.issueRenderFilters?.workspace_properties?.[workspaceId], + projects: issuesProjectsResponse, + }, + }, + }; - // fetching project members - getProjectMembers = () => {}; + runInAction(() => { + this.issueRenderFilters = _issuesProjectsResponse; + this.loader = false; + this.error = null; + }); + } + return issuesProjectsResponse; + } catch (error) { + console.warn("error in fetching workspace level projects", error); + this.loader = false; + this.error = null; + return error; + } + }; - // fetching project state <-> groups - getProjectStates = () => {}; + getWorkspaceMyIssuesLabels = async (workspaceId: string) => { + try { + this.loader = true; + this.error = null; - // fetching project labels - getProjectLabels = () => {}; + const issuesLabelsResponse = await this.issueService.getWorkspaceLabels(workspaceId); + + if (issuesLabelsResponse) { + const _issuesLabelsResponse = { + ...this.issueRenderFilters, + workspace_properties: { + ...this.issueRenderFilters?.workspace_properties, + [workspaceId]: { + ...this.issueRenderFilters?.workspace_properties?.[workspaceId], + labels: issuesLabelsResponse, + }, + }, + }; + + runInAction(() => { + this.issueRenderFilters = _issuesLabelsResponse; + this.loader = false; + this.error = null; + }); + } + return issuesLabelsResponse; + } catch (error) { + console.warn("error in fetching workspace level labels", error); + this.loader = false; + this.error = null; + return error; + } + }; + + getWorkspaceMyIssuesFilters = async (workspaceId: string) => { + try { + this.loader = true; + this.error = null; + + // fetching workspace level issue filters + await this.getWorkspaceMyIssuesProjects(workspaceId); + await this.getWorkspaceMyIssuesLabels(workspaceId); + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + if (issuesFiltersResponse) { + const _issuesFiltersResponse: any = { + ...this.issueFilters, + [workspaceId]: { + ...this?.issueFilters?.[workspaceId], + my_issue_properties: { + ...this?.issueFilters?.[workspaceId]?.my_issue_properties, + filters: { + priority: undefined, + state: undefined, + state_group: undefined, + assignees: undefined, + created_by: undefined, + labels: undefined, + start_date: undefined, + target_date: undefined, + subscriber: undefined, + }, + display_filters: { + group_by: undefined, + order_by: undefined, + type: undefined, + sub_issue: undefined, + show_empty_groups: undefined, + layout: undefined, + calendar_date_range: undefined, + start_target_date: undefined, + }, + display_properties: { + assignee: false, + attachment_count: false, + created_on: false, + due_date: false, + estimate: false, + key: false, + labels: false, + link: false, + priority: false, + start_date: false, + state: false, + sub_issue_count: false, + updated_on: false, + }, + }, + }, + }; + runInAction(() => { + this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + return issuesFiltersResponse; + } catch (error) { + console.warn("error in fetching workspace level filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + updateWorkspaceMyIssuesFilters = async () => { + try { + this.loader = true; + this.error = null; + + const workspaceId = "1"; + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + + if (issuesFiltersResponse) { + // const _issuesFiltersResponse = this.issueFilters; + // const _issuesFiltersResponse: any = { + // ...this.issues, + // [workspaceId]: { + // ...this?.issues[workspaceId], + // my_issues: { + // ...this?.issues[workspaceId]?.my_issues, + // [_layout as string]: issuesResponse, + // }, + // }, + // }; + + runInAction(() => { + // this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + + // return issuesResponse; + } catch (error) { + console.warn("error in fetching workspace level issue filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + + getProjectLevelStates = async (workspaceId: string, projectId: string) => { + try { + this.loader = true; + this.error = null; + + const issuesStateResponse = await this.stateService.getStates(workspaceId, projectId); + if (issuesStateResponse) { + const _states: any[] = []; + Object.keys(issuesStateResponse).map((state) => { + _states.push(...issuesStateResponse[state]); + }); + + const _issuesStateResponse = { + ...this.issueRenderFilters, + workspace_properties: { + ...this.issueRenderFilters?.workspace_properties, + [workspaceId]: { + ...this.issueRenderFilters?.workspace_properties?.[workspaceId], + project_properties: { + ...this.issueRenderFilters?.workspace_properties?.[workspaceId]?.project_properties, + [projectId]: { + ...this.issueRenderFilters?.workspace_properties?.[workspaceId] + ?.project_properties?.[projectId], + states: _states, + }, + }, + }, + }, + }; + + runInAction(() => { + this.issueRenderFilters = _issuesStateResponse; + this.loader = false; + this.error = null; + }); + } + return issuesStateResponse; + } catch (error) { + console.warn("error in fetching project level states", error); + this.loader = false; + this.error = null; + return error; + } + }; + + getProjectLevelLabels = async (workspaceId: string, projectId: string) => { + try { + this.loader = true; + this.error = null; + + const issuesLabelsResponse = await this.issueService.getIssueLabels(workspaceId, projectId); + if (issuesLabelsResponse) { + const _issuesLabelsResponse = { + ...this.issueRenderFilters, + workspace_properties: { + ...this.issueRenderFilters?.workspace_properties, + [workspaceId]: { + ...this.issueRenderFilters?.workspace_properties?.[workspaceId], + project_properties: { + ...this.issueRenderFilters?.workspace_properties?.[workspaceId]?.project_properties, + [projectId]: { + ...this.issueRenderFilters?.workspace_properties?.[workspaceId] + ?.project_properties?.[projectId], + labels: issuesLabelsResponse, + }, + }, + }, + }, + }; + + runInAction(() => { + this.issueRenderFilters = _issuesLabelsResponse; + this.loader = false; + this.error = null; + }); + } + return issuesLabelsResponse; + } catch (error) { + console.warn("error in fetching project level labels", error); + this.loader = false; + this.error = null; + return error; + } + }; + + getProjectLevelMembers = async (workspaceId: string, projectId: string) => { + try { + this.loader = true; + this.error = null; + + const issuesMembersResponse = await this.projectService.projectMembers( + workspaceId, + projectId + ); + if (issuesMembersResponse) { + const _issuesMembersResponse = { + ...this.issueRenderFilters, + workspace_properties: { + ...this.issueRenderFilters?.workspace_properties, + [workspaceId]: { + ...this.issueRenderFilters?.workspace_properties?.[workspaceId], + project_properties: { + ...this.issueRenderFilters?.workspace_properties?.[workspaceId]?.project_properties, + [projectId]: { + ...this.issueRenderFilters?.workspace_properties?.[workspaceId] + ?.project_properties?.[projectId], + members: issuesMembersResponse, + }, + }, + }, + }, + }; + + runInAction(() => { + this.issueRenderFilters = _issuesMembersResponse; + this.loader = false; + this.error = null; + }); + } + return issuesMembersResponse; + } catch (error) { + console.warn("error in fetching project level members", error); + this.loader = false; + this.error = null; + return error; + } + }; + + getProjectDisplayProperties = async (workspaceId: string, projectId: string) => { + try { + this.loader = true; + this.error = null; + + const issuesDisplayPropertiesResponse = await this.issueService.getIssueProperties( + workspaceId, + projectId + ); + + if (issuesDisplayPropertiesResponse) { + const _issuesDisplayPropertiesResponse: any = { + ...this.issueFilters, + [workspaceId]: { + ...this?.issueFilters[workspaceId], + project_issue_properties: { + ...this?.issueFilters[workspaceId]?.project_issue_properties, + [projectId]: { + ...this?.issueFilters[workspaceId]?.project_issue_properties?.[projectId], + display_properties: issuesDisplayPropertiesResponse, + }, + }, + }, + }; + + runInAction(() => { + this.issueFilters = _issuesDisplayPropertiesResponse; + this.loader = false; + this.error = null; + }); + } + + return issuesDisplayPropertiesResponse; + } catch (error) { + console.warn("error in fetching project level display properties", error); + this.loader = false; + this.error = null; + return error; + } + }; + updateProjectDisplayProperties = async (workspaceId: string, projectId: string, data: any) => { + try { + this.loader = true; + this.error = null; + + const issuesDisplayPropertiesResponse = await this.issueService.getIssueProperties( + workspaceId, + projectId + ); + + if (issuesDisplayPropertiesResponse) { + const _issuesDisplayPropertiesResponse: any = { + ...this.issueFilters, + [workspaceId]: { + ...this?.issueFilters[workspaceId], + project_issue_properties: { + ...this?.issueFilters[workspaceId]?.project_issue_properties, + [projectId]: { + ...this?.issueFilters[workspaceId]?.project_issue_properties?.[projectId], + display_properties: issuesDisplayPropertiesResponse, + }, + }, + }, + }; + + runInAction(() => { + this.issueFilters = _issuesDisplayPropertiesResponse; + this.loader = false; + this.error = null; + }); + } + + return issuesDisplayPropertiesResponse; + } catch (error) { + console.warn("error in fetching project level display properties", error); + this.loader = false; + this.error = null; + return error; + } + }; + + getProjectDisplayFilters = async (workspaceId: string, projectId: string) => { + try { + this.loader = true; + this.error = null; + + const workspaceId = "1"; + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + + if (issuesFiltersResponse) { + // const _issuesFiltersResponse = this.issueFilters; + // const _issuesFiltersResponse: any = { + // ...this.issues, + // [workspaceId]: { + // ...this?.issues[workspaceId], + // my_issues: { + // ...this?.issues[workspaceId]?.my_issues, + // [_layout as string]: issuesResponse, + // }, + // }, + // }; + + runInAction(() => { + // this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + + // return issuesResponse; + } catch (error) { + console.warn("error in fetching workspace level issue filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + updateProjectDisplayFilters = async (workspaceId: string, projectId: string) => { + try { + this.loader = true; + this.error = null; + + const workspaceId = "1"; + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + + if (issuesFiltersResponse) { + // const _issuesFiltersResponse = this.issueFilters; + // const _issuesFiltersResponse: any = { + // ...this.issues, + // [workspaceId]: { + // ...this?.issues[workspaceId], + // my_issues: { + // ...this?.issues[workspaceId]?.my_issues, + // [_layout as string]: issuesResponse, + // }, + // }, + // }; + + runInAction(() => { + // this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + + // return issuesResponse; + } catch (error) { + console.warn("error in fetching workspace level issue filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + + getProjectIssueFilters = async (workspaceId: string, projectId: string) => { + try { + this.loader = true; + this.error = null; + + await this.getProjectLevelStates(workspaceId, projectId); + await this.getProjectLevelLabels(workspaceId, projectId); + await this.getProjectLevelMembers(workspaceId, projectId); + await this.getProjectDisplayProperties(workspaceId, projectId); + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + + if (issuesFiltersResponse) { + // const _issuesFiltersResponse = this.issueFilters; + // const _issuesFiltersResponse: any = { + // ...this.issues, + // [workspaceId]: { + // ...this?.issues[workspaceId], + // my_issues: { + // ...this?.issues[workspaceId]?.my_issues, + // [_layout as string]: issuesResponse, + // }, + // }, + // }; + + runInAction(() => { + // this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + + // return issuesResponse; + } catch (error) { + console.warn("error in fetching workspace level issue filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + updateProjectIssueFilters = async (workspaceId: string, projectId: string) => { + try { + this.loader = true; + this.error = null; + + await this.getProjectLevelStates(workspaceId, projectId); + await this.getProjectLevelLabels(workspaceId, projectId); + await this.getProjectLevelMembers(workspaceId, projectId); + // await this.getProjectDisplayProperties(workspaceId, projectId); + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + + if (issuesFiltersResponse) { + // const _issuesFiltersResponse = this.issueFilters; + // const _issuesFiltersResponse: any = { + // ...this.issues, + // [workspaceId]: { + // ...this?.issues[workspaceId], + // my_issues: { + // ...this?.issues[workspaceId]?.my_issues, + // [_layout as string]: issuesResponse, + // }, + // }, + // }; + + runInAction(() => { + // this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + + // return issuesResponse; + } catch (error) { + console.warn("error in fetching workspace level issue filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + + getProjectIssueModuleFilters = async ( + workspaceId: string, + projectId: string, + moduleId: string + ) => { + try { + this.loader = true; + this.error = null; + + const workspaceId = "1"; + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + + if (issuesFiltersResponse) { + // const _issuesFiltersResponse = this.issueFilters; + // const _issuesFiltersResponse: any = { + // ...this.issues, + // [workspaceId]: { + // ...this?.issues[workspaceId], + // my_issues: { + // ...this?.issues[workspaceId]?.my_issues, + // [_layout as string]: issuesResponse, + // }, + // }, + // }; + + runInAction(() => { + // this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + + // return issuesResponse; + } catch (error) { + console.warn("error in fetching workspace level issue filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + updateProjectIssueModuleFilters = async ( + workspaceId: string, + projectId: string, + moduleId: string + ) => { + try { + this.loader = true; + this.error = null; + + const workspaceId = "1"; + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + + if (issuesFiltersResponse) { + // const _issuesFiltersResponse = this.issueFilters; + // const _issuesFiltersResponse: any = { + // ...this.issues, + // [workspaceId]: { + // ...this?.issues[workspaceId], + // my_issues: { + // ...this?.issues[workspaceId]?.my_issues, + // [_layout as string]: issuesResponse, + // }, + // }, + // }; + + runInAction(() => { + // this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + + // return issuesResponse; + } catch (error) { + console.warn("error in fetching workspace level issue filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + + getProjectIssueCyclesFilters = async ( + workspaceId: string, + projectId: string, + cycleId: string + ) => { + try { + this.loader = true; + this.error = null; + + const workspaceId = "1"; + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + + if (issuesFiltersResponse) { + // const _issuesFiltersResponse = this.issueFilters; + // const _issuesFiltersResponse: any = { + // ...this.issues, + // [workspaceId]: { + // ...this?.issues[workspaceId], + // my_issues: { + // ...this?.issues[workspaceId]?.my_issues, + // [_layout as string]: issuesResponse, + // }, + // }, + // }; + + runInAction(() => { + // this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + + // return issuesResponse; + } catch (error) { + console.warn("error in fetching workspace level issue filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + updateProjectIssueCyclesFilters = async ( + workspaceId: string, + projectId: string, + cycleId: string + ) => { + try { + this.loader = true; + this.error = null; + + const workspaceId = "1"; + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + + if (issuesFiltersResponse) { + // const _issuesFiltersResponse = this.issueFilters; + // const _issuesFiltersResponse: any = { + // ...this.issues, + // [workspaceId]: { + // ...this?.issues[workspaceId], + // my_issues: { + // ...this?.issues[workspaceId]?.my_issues, + // [_layout as string]: issuesResponse, + // }, + // }, + // }; + + runInAction(() => { + // this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + + // return issuesResponse; + } catch (error) { + console.warn("error in fetching workspace level issue filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + + getProjectIssueViewsFilters = async (workspaceId: string, projectId: string, viewId: string) => { + try { + this.loader = true; + this.error = null; + + const workspaceId = "1"; + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + + if (issuesFiltersResponse) { + // const _issuesFiltersResponse = this.issueFilters; + // const _issuesFiltersResponse: any = { + // ...this.issues, + // [workspaceId]: { + // ...this?.issues[workspaceId], + // my_issues: { + // ...this?.issues[workspaceId]?.my_issues, + // [_layout as string]: issuesResponse, + // }, + // }, + // }; + + runInAction(() => { + // this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + + // return issuesResponse; + } catch (error) { + console.warn("error in fetching workspace level issue filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + updateProjectIssueViewsFilters = async ( + workspaceId: string, + projectId: string, + viewId: string + ) => { + try { + this.loader = true; + this.error = null; + + const workspaceId = "1"; + + const issuesFiltersResponse = await this.workspaceService.workspaceMemberMe(workspaceId); + + if (issuesFiltersResponse) { + // const _issuesFiltersResponse = this.issueFilters; + // const _issuesFiltersResponse: any = { + // ...this.issues, + // [workspaceId]: { + // ...this?.issues[workspaceId], + // my_issues: { + // ...this?.issues[workspaceId]?.my_issues, + // [_layout as string]: issuesResponse, + // }, + // }, + // }; + + runInAction(() => { + // this.issueFilters = _issuesFiltersResponse; + this.loader = false; + this.error = null; + }); + } + + // return issuesResponse; + } catch (error) { + console.warn("error in fetching workspace level issue filters", error); + this.loader = false; + this.error = null; + return error; + } + }; + // project level filters ends } export default IssueFilterStore;