diff --git a/web/components/issue-layouts/display-filters/extra-options.tsx b/web/components/issue-layouts/display-filters/extra-options.tsx index 100a6cfd7..58cbf193f 100644 --- a/web/components/issue-layouts/display-filters/extra-options.tsx +++ b/web/components/issue-layouts/display-filters/extra-options.tsx @@ -23,9 +23,9 @@ export const FilterExtraOptions = observer(() => { const handleExtraOptionsSectionVisibility = (key: string) => issueFilterStore?.issueView && issueFilterStore?.issueLayout && - issueFilterVisibilityData[ - issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others" - ]?.extra_options?.[issueFilterStore?.issueLayout].values?.includes(key); + issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "issues"]?.extra_options?.[ + issueFilterStore?.issueLayout + ].values?.includes(key); return (
@@ -43,11 +43,7 @@ export const FilterExtraOptions = observer(() => { handleExtraOptionsSectionVisibility(_extraProperties?.key) && ( handleExtraOptions( _extraProperties?.key, diff --git a/web/components/issue-layouts/display-filters/group-by.tsx b/web/components/issue-layouts/display-filters/group-by.tsx index 93e297803..026ad68da 100644 --- a/web/components/issue-layouts/display-filters/group-by.tsx +++ b/web/components/issue-layouts/display-filters/group-by.tsx @@ -32,11 +32,7 @@ export const FilterGroupBy = observer(() => { issueFilterStore?.issueRenderFilters?.group_by.map((_groupBy) => ( handleGroupBy("group_by", _groupBy?.key)} title={_groupBy.title} multiple={false} diff --git a/web/components/issue-layouts/display-filters/index.tsx b/web/components/issue-layouts/display-filters/index.tsx index 0c7ff05fd..c4a81bc3c 100644 --- a/web/components/issue-layouts/display-filters/index.tsx +++ b/web/components/issue-layouts/display-filters/index.tsx @@ -20,21 +20,22 @@ export const DisplayFiltersSelection = observer(() => { const handleDisplayPropertiesSectionVisibility = issueFilterStore?.issueView && issueFilterStore?.issueLayout && - issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others"] + issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "issues"] ?.display_properties?.[issueFilterStore?.issueLayout]; const handleDisplayFilterSectionVisibility = (section_key: string) => issueFilterStore?.issueView && issueFilterStore?.issueLayout && - issueFilterVisibilityData[ - issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others" - ]?.display_filters?.[issueFilterStore?.issueLayout].includes(section_key); + issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "issues"]?.display_filters?.[ + issueFilterStore?.issueLayout + ].includes(section_key); const handleExtraOptionsSectionVisibility = issueFilterStore?.issueView && issueFilterStore?.issueLayout && - issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others"] - ?.extra_options?.[issueFilterStore?.issueLayout].access; + issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "issues"]?.extra_options?.[ + issueFilterStore?.issueLayout + ].access; return (
diff --git a/web/components/issue-layouts/display-filters/issue-type.tsx b/web/components/issue-layouts/display-filters/issue-type.tsx index 10f50800b..cdf5dd342 100644 --- a/web/components/issue-layouts/display-filters/issue-type.tsx +++ b/web/components/issue-layouts/display-filters/issue-type.tsx @@ -32,11 +32,7 @@ export const FilterIssueType = observer(() => { issueFilterStore?.issueRenderFilters?.issue_type.map((_issueType) => ( handleIssueType("type", _issueType?.key)} title={_issueType.title} multiple={false} diff --git a/web/components/issue-layouts/display-filters/order-by.tsx b/web/components/issue-layouts/display-filters/order-by.tsx index c7c3f2ebb..b575ed45e 100644 --- a/web/components/issue-layouts/display-filters/order-by.tsx +++ b/web/components/issue-layouts/display-filters/order-by.tsx @@ -32,11 +32,7 @@ export const FilterOrderBy = observer(() => { issueFilterStore?.issueRenderFilters?.order_by.map((_orderBy) => ( handleOrderBy("order_by", _orderBy?.key)} title={_orderBy.title} multiple={false} diff --git a/web/components/issue-layouts/filters-preview/assignees.tsx b/web/components/issue-layouts/filters-preview/assignees.tsx index 80bfbc084..be91064a9 100644 --- a/web/components/issue-layouts/filters-preview/assignees.tsx +++ b/web/components/issue-layouts/filters-preview/assignees.tsx @@ -9,13 +9,7 @@ import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; import { RootStore } from "store/root"; -export const MemberIcons = ({ - display_name, - avatar, -}: { - display_name: string; - avatar: string | null; -}) => ( +export const MemberIcons = ({ display_name, avatar }: { display_name: string; avatar: string | null }) => (
{avatar ? ( {display_name @@ -49,9 +43,7 @@ export const FilterAssignees = observer(() => {
@@ -60,17 +52,10 @@ export const FilterAssignees = observer(() => { issueFilterStore?.projectMembers.map( (_member) => issueFilterStore?.userFilters?.filters?.assignees != null && - issueFilterStore?.userFilters?.filters?.assignees.includes( - _member?.member?.id - ) && ( + issueFilterStore?.userFilters?.filters?.assignees.includes(_member?.member?.id) && ( - } + icon={} title={`${_member?.member?.display_name}`} onClick={() => handleFilter("assignees", _member?.member?.id)} className="border border-custom-border-100 bg-custom-background-100" diff --git a/web/components/issue-layouts/filters-preview/created-by.tsx b/web/components/issue-layouts/filters-preview/created-by.tsx index c69234b7c..c32b7fcb6 100644 --- a/web/components/issue-layouts/filters-preview/created-by.tsx +++ b/web/components/issue-layouts/filters-preview/created-by.tsx @@ -32,9 +32,7 @@ export const FilterCreatedBy = observer(() => {
@@ -44,18 +42,11 @@ export const FilterCreatedBy = observer(() => { issueFilterStore?.projectMembers.map( (_member) => issueFilterStore?.userFilters?.filters?.created_by != null && - issueFilterStore?.userFilters?.filters?.created_by.includes( - _member?.member?.id - ) && ( + issueFilterStore?.userFilters?.filters?.created_by.includes(_member?.member?.id) && ( - } + icon={} onClick={() => handleFilter("created_by", _member?.member?.id)} className="border border-custom-border-100 bg-custom-background-100" /> diff --git a/web/components/issue-layouts/filters-preview/helpers/content.tsx b/web/components/issue-layouts/filters-preview/helpers/content.tsx index dc56bc391..4838c9319 100644 --- a/web/components/issue-layouts/filters-preview/helpers/content.tsx +++ b/web/components/issue-layouts/filters-preview/helpers/content.tsx @@ -8,13 +8,7 @@ interface IFilterPreviewContent { style?: any; } -export const FilterPreviewContent = ({ - icon, - title, - onClick, - className, - style, -}: IFilterPreviewContent) => ( +export const FilterPreviewContent = ({ icon, title, onClick, className, style }: IFilterPreviewContent) => (
{ - const store: RootStore = useMobxStore(); - const { issueFilters: issueFilterStore } = store; - - const handleFilterSectionVisibility = (section_key: string) => - issueFilterStore?.issueView && - issueFilterStore?.issueLayout && - issueFilterVisibilityData[ - issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others" - ]?.filters?.[issueFilterStore?.issueLayout]?.includes(section_key); - - return ( -
-
Search container
-
- {/* priority */} - {handleFilterSectionVisibility("priority") && ( -
- -
- )} - - {/* state group */} - {handleFilterSectionVisibility("state_group") && ( -
- -
- )} - - {/* state */} - {handleFilterSectionVisibility("state") && ( -
- -
- )} - - {/* assignees */} - {handleFilterSectionVisibility("assignees") && ( -
- -
- )} - - {/* created_by */} - {handleFilterSectionVisibility("created_by") && ( -
- -
- )} - - {/* labels */} - {handleFilterSectionVisibility("labels") && ( -
- -
- )} - - {/* start_date */} - {handleFilterSectionVisibility("start_date") && ( -
- -
- )} - - {/* due_date */} - {handleFilterSectionVisibility("due_date") && ( -
- -
- )} -
-
- ); -}); diff --git a/web/components/issue-layouts/filters-preview/index.tsx b/web/components/issue-layouts/filters-preview/index.tsx index fd202e11b..03aac5b66 100644 --- a/web/components/issue-layouts/filters-preview/index.tsx +++ b/web/components/issue-layouts/filters-preview/index.tsx @@ -23,9 +23,9 @@ export const FilterPreview = observer(() => { const handleFilterSectionVisibility = (section_key: string) => issueFilterStore?.issueView && issueFilterStore?.issueLayout && - issueFilterVisibilityData[ - issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others" - ]?.filters?.[issueFilterStore?.issueLayout]?.includes(section_key); + issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "issues"]?.filters?.[ + issueFilterStore?.issueLayout + ]?.includes(section_key); const validateFiltersAvailability = issueFilterStore?.userFilters?.filters != null && diff --git a/web/components/issue-layouts/filters-preview/labels.tsx b/web/components/issue-layouts/filters-preview/labels.tsx index dbe825a7c..2542b2ac8 100644 --- a/web/components/issue-layouts/filters-preview/labels.tsx +++ b/web/components/issue-layouts/filters-preview/labels.tsx @@ -43,9 +43,7 @@ export const FilterLabels = observer(() => { {issueFilterStore?.userFilters?.filters?.labels != null && (
- +
diff --git a/web/components/issue-layouts/filters-preview/state-group.tsx b/web/components/issue-layouts/filters-preview/state-group.tsx index e461f2eb0..cffaf6de8 100644 --- a/web/components/issue-layouts/filters-preview/state-group.tsx +++ b/web/components/issue-layouts/filters-preview/state-group.tsx @@ -18,53 +18,27 @@ import { RootStore } from "store/root"; // constants import { STATE_GROUP_COLORS } from "constants/state"; -export const StateGroupIcons = ({ - stateGroup, - color = null, -}: { - stateGroup: string; - color?: string | null; -}) => { +export const StateGroupIcons = ({ stateGroup, color = null }: { stateGroup: string; color?: string | null }) => { if (stateGroup === "cancelled") return ( - + ); if (stateGroup === "completed") return ( - + ); if (stateGroup === "started") return ( - + ); if (stateGroup === "unstarted") return ( - + ); if (stateGroup === "backlog") return (
- +
); return <>; @@ -125,9 +99,7 @@ export const FilterStateGroup = observer(() => {
@@ -136,9 +108,7 @@ export const FilterStateGroup = observer(() => { issueFilterStore?.issueRenderFilters?.state_group.map( (_stateGroup) => issueFilterStore?.userFilters?.filters?.state_group != null && - issueFilterStore?.userFilters?.filters?.state_group.includes( - _stateGroup?.key - ) && ( + issueFilterStore?.userFilters?.filters?.state_group.includes(_stateGroup?.key) && ( } diff --git a/web/components/issue-layouts/filters-preview/state.tsx b/web/components/issue-layouts/filters-preview/state.tsx index 3e4088974..f81e6e29f 100644 --- a/web/components/issue-layouts/filters-preview/state.tsx +++ b/web/components/issue-layouts/filters-preview/state.tsx @@ -10,7 +10,7 @@ import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; import { RootStore } from "store/root"; // store default data -import { issueStateGroupKeys } from "store/issue-views/issue_data"; +import { stateGroups } from "store/issue-views/issue_data"; export const FilterState = observer(() => { const store: RootStore = useMobxStore(); @@ -33,23 +33,21 @@ export const FilterState = observer(() => { {issueFilterStore?.userFilters?.filters?.state != null && (
- +
- {issueStateGroupKeys.map( + {stateGroups.map( (_stateGroup) => issueFilterStore?.projectStates && - issueFilterStore?.projectStates[_stateGroup] && - issueFilterStore?.projectStates[_stateGroup].length > 0 && - issueFilterStore?.projectStates[_stateGroup].map( + issueFilterStore?.projectStates[_stateGroup?.key] && + issueFilterStore?.projectStates[_stateGroup?.key].length > 0 && + issueFilterStore?.projectStates[_stateGroup?.key].map( (_state: any) => issueFilterStore?.userFilters?.filters?.state != null && issueFilterStore?.userFilters?.filters?.state.includes(_state?.id) && ( } + icon={} title={_state?.name} style={stateStyles(_state?.group, _state?.color)} onClick={() => handleFilter("state", _state?.id)} diff --git a/web/components/issue-layouts/filters/assignees.tsx b/web/components/issue-layouts/filters/assignees.tsx index 422318ec1..f5f49eee7 100644 --- a/web/components/issue-layouts/filters/assignees.tsx +++ b/web/components/issue-layouts/filters/assignees.tsx @@ -8,13 +8,7 @@ import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; import { RootStore } from "store/root"; -export const MemberIcons = ({ - display_name, - avatar, -}: { - display_name: string; - avatar: string | null; -}) => ( +export const MemberIcons = ({ display_name, avatar }: { display_name: string; avatar: string | null }) => (
{avatar ? ( {display_name @@ -64,12 +58,7 @@ export const FilterAssignees = observer(() => { : false } onClick={() => handleFilter("assignees", _member?.member?.id)} - icon={ - - } + icon={} title={`${_member?.member?.display_name} (${_member?.member?.first_name} ${_member?.member?.last_name})`} /> ))} diff --git a/web/components/issue-layouts/filters/created-by.tsx b/web/components/issue-layouts/filters/created-by.tsx index e2353d32c..35693de2f 100644 --- a/web/components/issue-layouts/filters/created-by.tsx +++ b/web/components/issue-layouts/filters/created-by.tsx @@ -47,12 +47,7 @@ export const FilterCreatedBy = observer(() => { : false } onClick={() => handleFilter("created_by", _member?.member?.id)} - icon={ - - } + icon={} title={`${_member?.member?.display_name} (${_member?.member?.first_name} ${_member?.member?.last_name})`} /> ))} diff --git a/web/components/issue-layouts/filters/index.tsx b/web/components/issue-layouts/filters/index.tsx index 89fbcdd91..2512ae042 100644 --- a/web/components/issue-layouts/filters/index.tsx +++ b/web/components/issue-layouts/filters/index.tsx @@ -23,7 +23,7 @@ export const FilterSelection = observer(() => { const handleFilterSectionVisibility = (section_key: string) => issueFilterStore?.issueView && issueFilterStore?.issueLayout && - issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others"]?.filters?.[ + issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "issues"]?.filters?.[ issueFilterStore?.issueLayout ]?.includes(section_key); diff --git a/web/components/issue-layouts/filters/state-group.tsx b/web/components/issue-layouts/filters/state-group.tsx index e9ea5c6fa..dcfd71cbf 100644 --- a/web/components/issue-layouts/filters/state-group.tsx +++ b/web/components/issue-layouts/filters/state-group.tsx @@ -31,51 +31,31 @@ export const StateGroupIcons = ({ if (stateGroup === "cancelled") return (
- +
); if (stateGroup === "completed") return (
- +
); if (stateGroup === "started") return (
- +
); if (stateGroup === "unstarted") return (
- +
); if (stateGroup === "backlog") return (
- +
); return <>; diff --git a/web/components/issue-layouts/filters/state.tsx b/web/components/issue-layouts/filters/state.tsx index bb56c2f72..02c1d745e 100644 --- a/web/components/issue-layouts/filters/state.tsx +++ b/web/components/issue-layouts/filters/state.tsx @@ -9,7 +9,7 @@ import { observer } from "mobx-react-lite"; import { useMobxStore } from "lib/mobx/store-provider"; import { RootStore } from "store/root"; // store default data -import { issueStateGroupKeys } from "store/issue-views/issue_data"; +import { stateGroups } from "store/issue-views/issue_data"; export const FilterState = observer(() => { const store: RootStore = useMobxStore(); @@ -28,8 +28,8 @@ export const FilterState = observer(() => { issueFilterStore.handleUserFilter("filters", key, _value); }; - const countAllState = issueStateGroupKeys - .map((_stateGroup) => issueFilterStore?.projectStates?.[_stateGroup].length || 0) + const countAllState = stateGroups + .map((_stateGroup) => issueFilterStore?.projectStates?.[_stateGroup?.key].length || 0) .reduce((sum: number, currentValue: number) => sum + currentValue, 0); console.log("countAllState", countAllState); @@ -43,12 +43,12 @@ export const FilterState = observer(() => { /> {previewEnabled && (
- {issueStateGroupKeys.map( + {stateGroups.map( (_stateGroup) => issueFilterStore?.projectStates && - issueFilterStore?.projectStates[_stateGroup] && - issueFilterStore?.projectStates[_stateGroup].length > 0 && - issueFilterStore?.projectStates[_stateGroup].map((_state: any) => ( + issueFilterStore?.projectStates[_stateGroup?.key] && + issueFilterStore?.projectStates[_stateGroup?.key].length > 0 && + issueFilterStore?.projectStates[_stateGroup?.key].map((_state: any) => ( { : false } onClick={() => handleFilter("state", _state?.id)} - icon={} + icon={} title={_state?.name} /> )) diff --git a/web/components/issue-layouts/helpers/dropdown.tsx b/web/components/issue-layouts/helpers/dropdown.tsx index 988f1050e..4e12c2bc0 100644 --- a/web/components/issue-layouts/helpers/dropdown.tsx +++ b/web/components/issue-layouts/helpers/dropdown.tsx @@ -21,11 +21,7 @@ export const IssueDropdown = ({ children, title = "Dropdown" }: IIssueDropdown) >
{title}
- {open ? ( - - ) : ( - - )} + {open ? : }
void; } -export const FilterHeader = ({ - title, - isPreviewEnabled, - handleIsPreviewEnabled, -}: IFilterHeader) => ( +export const FilterHeader = ({ title, isPreviewEnabled, handleIsPreviewEnabled }: IFilterHeader) => (
{title}
void; } -export const FilterOption = ({ - isChecked, - icon, - title, - multiple = true, - onClick, -}: IFilterOption) => ( +export const FilterOption = ({ isChecked, icon, title, multiple = true, onClick }: IFilterOption) => (
{ const handleLayoutSectionVisibility = (layout_key: string) => issueFilterStore?.issueView && - issueFilterVisibilityData[ - issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others" - ].layout.includes(layout_key); + issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "issues"].layout.includes( + layout_key + ); const handleLayoutSelection = (_layoutKey: string) => { issueFilterStore.handleUserFilter("display_filters", "layout", _layoutKey); @@ -76,9 +76,7 @@ export const LayoutSelection = observer(() => {
handleLayoutSelection(_layout?.key)} > diff --git a/web/components/issue-layouts/list/group-header.tsx b/web/components/issue-layouts/list/group-header.tsx index 9091ef851..ca9ecb1f2 100644 --- a/web/components/issue-layouts/list/group-header.tsx +++ b/web/components/issue-layouts/list/group-header.tsx @@ -11,30 +11,20 @@ export interface IIssueListGroupHeader { export const IssueListGroupHeader: FC = (props) => { const { groupId, groupBy } = props; - const { issueView: issueViewStore, issueFilters: issueFilterStore }: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore }: RootStore = useMobxStore(); return (
{groupBy === "state" && <>{issueFilterStore.getProjectStateById(groupId)?.name}} {groupBy === "state_detail.group" && <>{groupId}} {groupBy === "priority" && <>{groupId}} - {groupBy === "project" && ( - <>{issueFilterStore.workspaceProjects?.find((p) => (p.id = groupId))} - )} - {groupBy === "labels" && ( - <>{issueFilterStore.projectLabels?.find((p) => p.id === groupId)?.name || " None"} - )} + {groupBy === "project" && <>{issueFilterStore.workspaceProjects?.find((p) => (p.id = groupId))}} + {groupBy === "labels" && <>{issueFilterStore.projectLabels?.find((p) => p.id === groupId)?.name || " None"}} {groupBy === "assignees" && ( - <> - {issueFilterStore.projectMembers?.find((p) => p?.member?.id === groupId)?.member - ?.display_name || " None"} - + <>{issueFilterStore.projectMembers?.find((p) => p?.member?.id === groupId)?.member?.display_name || " None"} )} {groupBy === "created_by" && ( - <> - {issueFilterStore.projectMembers?.find((p) => p?.member?.id === groupId)?.member - ?.display_name || " None"} - + <>{issueFilterStore.projectMembers?.find((p) => p?.member?.id === groupId)?.member?.display_name || " None"} )}
); diff --git a/web/components/issue-layouts/list/list.tsx b/web/components/issue-layouts/list/list.tsx index 8a858ee6a..f06c6234d 100644 --- a/web/components/issue-layouts/list/list.tsx +++ b/web/components/issue-layouts/list/list.tsx @@ -4,17 +4,11 @@ import { IssueListItem } from "./item"; import { observer } from "mobx-react-lite"; export interface IIssueListView { - issues: IIssue[]; + issues: IIssue[] | null; groupId: string; } export const IssueListView: FC = observer((props) => { const { issues = [], groupId } = props; - return ( -
- {issues.map((issue) => ( - - ))} -
- ); + return
{issues && issues.map((issue) => )}
; }); diff --git a/web/components/issue-layouts/list/root.tsx b/web/components/issue-layouts/list/root.tsx index 5649a522b..389c13fa1 100644 --- a/web/components/issue-layouts/list/root.tsx +++ b/web/components/issue-layouts/list/root.tsx @@ -20,7 +20,7 @@ export const IssueListViewRoot = observer(() => {
Loading...
) : ( <> - {Object.keys(issueViewStore?.getIssues).map((groupId) => ( + {Object.keys(issueViewStore?.getIssues).map((groupId: any) => ( {({ open }) => ( <> @@ -31,7 +31,10 @@ export const IssueListViewRoot = observer(() => { /> - + )} diff --git a/web/store/issue-views/Issues.ts b/web/store/issue-views/Issues.ts index b7aede2a9..7303245fc 100644 --- a/web/store/issue-views/Issues.ts +++ b/web/store/issue-views/Issues.ts @@ -14,11 +14,11 @@ export interface IIssues { } export interface IIssuesLayout { - list: IIssues; - kanban: IIssues; - calendar: IIssues; - spreadsheet: IIssues; - gantt_chart: IIssues; + list: IIssues[]; + kanban: IIssues[]; + calendar: IIssues[]; + spreadsheet: IIssues[]; + gantt_chart: IIssues[]; } export interface IIssueState { @@ -143,14 +143,14 @@ class IssueViewStore implements IIssueViewStore { return null; } - updateIssues = (group_id: string | null, issue_id: string | null, data: any) => { + updateIssues = (group_id: any = null, issue_id: string | null, data: any) => { 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; + // const currentModuleId: string | null = this.rootStore.issueFilters.moduleId; + // const currentCycleId: string | null = this.rootStore.issueFilters.cycleId; + // const currentViewId: string | null = this.rootStore.issueFilters.viewId; const currentView: TIssueViews | null = this.rootStore.issueFilters.issueView; - const currentLayout: TIssueLayouts | null | undefined = this.rootStore.issueFilters.issueLayout; + const currentLayout: TIssueLayouts | null = this.rootStore.issueFilters.issueLayout; if (!currentView || !currentWorkspaceId || !currentLayout || !issue_id) return null; @@ -170,7 +170,7 @@ class IssueViewStore implements IIssueViewStore { }, }, }, - }; + } as any; } else { this.issues = { ...this.issues, @@ -183,7 +183,7 @@ class IssueViewStore implements IIssueViewStore { ), }, }, - }; + } as any; } } @@ -210,7 +210,7 @@ class IssueViewStore implements IIssueViewStore { }, }, }, - }; + } as any; } else { this.issues = { ...this.issues, @@ -229,7 +229,7 @@ class IssueViewStore implements IIssueViewStore { }, }, }, - }; + } as any; } } }; diff --git a/web/store/issue-views/issue_data.ts b/web/store/issue-views/issue_data.ts index 11edc4e0b..3b127a272 100644 --- a/web/store/issue-views/issue_data.ts +++ b/web/store/issue-views/issue_data.ts @@ -1,4 +1,6 @@ import { renderDateFormat } from "helpers/date-time.helper"; +// types +import { TIssueLayouts, TIssueParams } from "./issue_filters"; export type TStateGroup = "backlog" | "unstarted" | "started" | "completed" | "cancelled"; @@ -153,6 +155,83 @@ export const issueFilterVisibilityData: any = { }, }; +export const handleIssueQueryParamsByLayout = (_layout: TIssueLayouts | undefined): TIssueParams[] | null => { + if (_layout === "list") + return [ + "priority", + "state_group", + "state", + "assignees", + "created_by", + "labels", + "start_date", + "target_date", + "group_by", + "order_by", + "type", + "sub_issue", + "show_empty_groups", + ]; + if (_layout === "kanban") + return [ + "priority", + "state_group", + "state", + "assignees", + "created_by", + "labels", + "start_date", + "target_date", + "group_by", + "order_by", + "type", + "sub_issue", + "show_empty_groups", + ]; + if (_layout === "calendar") + return [ + "priority", + "state_group", + "state", + "assignees", + "created_by", + "labels", + "start_date", + "target_date", + "type", + "calendar_date_range", + ]; + if (_layout === "spreadsheet") + return [ + "priority", + "state_group", + "state", + "assignees", + "created_by", + "labels", + "start_date", + "target_date", + "type", + "sub_issue", + ]; + if (_layout === "gantt_chart") + return [ + "priority", + "state", + "assignees", + "created_by", + "labels", + "start_date", + "target_date", + "order_by", + "type", + "sub_issue", + "start_target_date", + ]; + + return null; +}; + export const handleIssueParamsDateFormat = (key: string, start_date: any | null, target_date: any | null) => { if (key === "last_week") return `${renderDateFormat(new Date(new Date().getTime() - 7 * 24 * 60 * 60 * 1000))};after,${renderDateFormat( diff --git a/web/store/issue-views/issue_detail.ts b/web/store/issue-views/issue_detail.ts index cda0b7bc9..c1dae8222 100644 --- a/web/store/issue-views/issue_detail.ts +++ b/web/store/issue-views/issue_detail.ts @@ -143,7 +143,7 @@ class IssueViewDetailStore implements IIssueViewDetailStore { this.rootStore.issueFilters.issueView || "issues" ); const issueResponse = await this.issueService.patchIssue(workspaceId, projectId, issueId, data, undefined); - const issueList = await this.issueService.getIssuesWithParams(workspaceId, projectId, filteredParams); + const issueList = (await this.issueService.getIssuesWithParams(workspaceId, projectId, filteredParams)) as any; console.log("issueList", issueList); if (issueResponse) { diff --git a/web/store/issue-views/issue_filters.ts b/web/store/issue-views/issue_filters.ts index 17beb0108..bfe971b27 100644 --- a/web/store/issue-views/issue_filters.ts +++ b/web/store/issue-views/issue_filters.ts @@ -1,4 +1,4 @@ -import { observable, action, computed, makeObservable, runInAction, autorun } from "mobx"; +import { observable, action, computed, makeObservable, runInAction } from "mobx"; // types import { RootStore } from "../root"; // services @@ -11,20 +11,22 @@ import { ProjectCycleServices } from "services/cycles.service"; import { ViewServices as ProjectViewServices } from "services/views.service"; // default data import { - filtersPriority, - filterStateGroup, - filtersStartDate, - filtersDueDate, - displayPropertyGroupBy, - displayPropertyOrderBy, - displayPropertyIssueType, + priorities, + stateGroups, + startDateOptions, + dueDateOptions, + groupByOptions, + orderByOptions, + issueTypes, displayProperties, extraProperties, + handleIssueQueryParamsByLayout, } from "./issue_data"; -import { IIssueState } from "./Issues"; export type TIssueViews = "my_issues" | "issues" | "modules" | "views" | "cycles"; + export type TIssueLayouts = "list" | "kanban" | "calendar" | "spreadsheet" | "gantt_chart"; + export type TIssueParams = | "priority" | "state_group" @@ -149,7 +151,6 @@ export interface IIssueFilterStore { error: any | null; // current workspace and project id - myUserId: string | null; workspaceId: string | null; projectId: string | null; moduleId: string | null; @@ -205,13 +206,13 @@ class IssueFilterStore implements IIssueFilterStore { issueView: TIssueViews | null = null; issueRenderFilters: IIssueRenderFilters = { - priority: filtersPriority, - state_group: filterStateGroup, - start_date: filtersStartDate, - due_date: filtersDueDate, - group_by: displayPropertyGroupBy, - order_by: displayPropertyOrderBy, - issue_type: displayPropertyIssueType, + priority: priorities, + state_group: stateGroups, + start_date: startDateOptions, + due_date: dueDateOptions, + group_by: groupByOptions, + order_by: orderByOptions, + issue_type: issueTypes, display_properties: displayProperties, extra_properties: extraProperties, workspace_properties: {}, @@ -235,7 +236,6 @@ class IssueFilterStore implements IIssueFilterStore { loader: observable, error: observable, - myUserId: observable, workspaceId: observable, projectId: observable, moduleId: observable, @@ -311,6 +311,8 @@ class IssueFilterStore implements IIssueFilterStore { this.issueFilters?.[this.workspaceId]?.project_issue_properties?.[this.projectId]?.issues?.display_filters ?.layout || null ); + + return null; } get workspaceProjects() { @@ -692,81 +694,8 @@ class IssueFilterStore implements IIssueFilterStore { // in spreadsheet sub issue is false for sure // in gantt start_target_date is true for sure - let filteredParams: TIssueParams[] = []; - if (_layout === "list") - filteredParams = [ - "priority", - "state_group", - "state", - "assignees", - "created_by", - "labels", - "start_date", - "target_date", - "group_by", - "order_by", - "type", - "sub_issue", - "show_empty_groups", - ]; - if (_layout === "kanban") - filteredParams = [ - "priority", - "state_group", - "state", - "assignees", - "created_by", - "labels", - "start_date", - "target_date", - "group_by", - "order_by", - "type", - "sub_issue", - "show_empty_groups", - ]; - if (_layout === "calendar") - filteredParams = [ - "priority", - "state_group", - "state", - "assignees", - "created_by", - "labels", - "start_date", - "target_date", - "type", - "calendar_date_range", - ]; - if (_layout === "spreadsheet") - filteredParams = [ - "priority", - "state_group", - "state", - "assignees", - "created_by", - "labels", - "start_date", - "target_date", - "type", - "sub_issue", - ]; - if (_layout === "gantt_chart") - filteredParams = [ - "priority", - "state", - "assignees", - "created_by", - "labels", - "start_date", - "target_date", - "order_by", - "type", - "sub_issue", - "start_target_date", - ]; - - filteredRouteParams = this.computedFilter(filteredRouteParams, filteredParams); + const filteredParams: TIssueParams[] | null = handleIssueQueryParamsByLayout(_layout); + if (filteredParams) filteredRouteParams = this.computedFilter(filteredRouteParams, filteredParams); return filteredRouteParams; }; @@ -1054,10 +983,10 @@ class IssueFilterStore implements IIssueFilterStore { this.loader = true; this.error = null; + await this.rootStore.user.setCurrentUser(); const issuesDisplayPropertiesResponse = await this.issueService.getIssueProperties(workspaceId, projectId); if (issuesDisplayPropertiesResponse) { - const _myUserId: string = issuesDisplayPropertiesResponse?.user; const _issuesDisplayPropertiesResponse: any = { ...this.issueFilters, [workspaceId]: { @@ -1076,7 +1005,6 @@ class IssueFilterStore implements IIssueFilterStore { }; runInAction(() => { - this.myUserId = _myUserId; this.issueFilters = _issuesDisplayPropertiesResponse; this.loader = false; this.error = null; @@ -1103,7 +1031,7 @@ class IssueFilterStore implements IIssueFilterStore { const payload = { properties: data, - user: this.myUserId, + user: this.rootStore?.user?.currentUser?.id, }; const issuesDisplayPropertiesResponse = await this.issueService.patchIssueProperties( workspaceId, diff --git a/web/store/issue-views/project.ts b/web/store/issue-views/project.ts new file mode 100644 index 000000000..ad7c72b84 --- /dev/null +++ b/web/store/issue-views/project.ts @@ -0,0 +1,21 @@ +import { action, computed, makeObservable } from "mobx"; +// types +import { RootStore } from "../root"; + +export interface IIssueProject {} + +class IssueProject implements IIssueProject { + // root store + rootStore; + + constructor(_rootStore: RootStore) { + makeObservable(this, { + // computed + // actions + }); + + this.rootStore = _rootStore; + } +} + +export default IssueProject; diff --git a/web/store/issue-views/workspace.ts b/web/store/issue-views/workspace.ts new file mode 100644 index 000000000..0203e6cfd --- /dev/null +++ b/web/store/issue-views/workspace.ts @@ -0,0 +1,21 @@ +import { action, computed, makeObservable } from "mobx"; +// types +import { RootStore } from "../root"; + +export interface IIssueWorkspace {} + +class IssueWorkspace implements IIssueWorkspace { + // root store + rootStore; + + constructor(_rootStore: RootStore) { + makeObservable(this, { + // computed + // actions + }); + + this.rootStore = _rootStore; + } +} + +export default IssueWorkspace; diff --git a/web/store/root.ts b/web/store/root.ts index 90a9ef870..763ac5e31 100644 --- a/web/store/root.ts +++ b/web/store/root.ts @@ -7,6 +7,8 @@ import ProjectStore, { IProjectStore } from "./project"; import ProjectPublishStore, { IProjectPublishStore } from "./project-publish"; import IssuesStore from "./issues"; // issues views and filters +import IssueWorkspace from "./issue-views/workspace"; +import IssueProject from "./issue-views/project"; import IssueFilterStore from "./issue-views/issue_filters"; import IssueViewStore from "./issue-views/Issues"; import IssueViewDetailStore from "./issue-views/issue_detail"; @@ -20,6 +22,9 @@ export class RootStore { project: IProjectStore; projectPublish: IProjectPublishStore; issues: IssuesStore; + // issues views and filters + issueWorkspace: IssueWorkspace; + issueProject: IssueProject; issueFilters: IssueFilterStore; issueView: IssueViewStore; issueDetail: IssueViewDetailStore; @@ -31,6 +36,9 @@ export class RootStore { this.project = new ProjectStore(this); this.projectPublish = new ProjectPublishStore(this); this.issues = new IssuesStore(this); + // issues views and filters + this.issueWorkspace = new IssueWorkspace(this); + this.issueProject = new IssueProject(this); this.issueFilters = new IssueFilterStore(this); this.issueView = new IssueViewStore(this); this.issueDetail = new IssueViewDetailStore(this);