From c67f08fca4387f1b72d2a2169b9bbd9c92ec6a28 Mon Sep 17 00:00:00 2001 From: gurusainath Date: Thu, 14 Sep 2023 16:03:35 +0530 Subject: [PATCH] chore: filter, layout, display filters, extra filters and display properties render validation --- .../display-filters/extra-options.tsx | 46 ++++--- .../issue-layouts/display-filters/index.tsx | 103 ++++++++++----- .../issue-layouts/filters/index.tsx | 123 +++++++++++------- .../issue-layouts/filters/labels.tsx | 13 +- .../issue-layouts/layout-selection.tsx | 60 +++++---- web/store/issue-views/issue_data.ts | 67 +++++++++- 6 files changed, 290 insertions(+), 122 deletions(-) diff --git a/web/components/issue-layouts/display-filters/extra-options.tsx b/web/components/issue-layouts/display-filters/extra-options.tsx index 15450a24f..11ef74a94 100644 --- a/web/components/issue-layouts/display-filters/extra-options.tsx +++ b/web/components/issue-layouts/display-filters/extra-options.tsx @@ -7,6 +7,8 @@ import { observer } from "mobx-react-lite"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; import { RootStore } from "store/root"; +// default data +import { issueFilterVisibilityData } from "store/issue-views/issue_data"; export const FilterExtraOptions = observer(() => { const store: RootStore = useMobxStore(); @@ -18,6 +20,13 @@ export const FilterExtraOptions = observer(() => { issueFilterStore.handleUserFilter("display_filters", key, !value); }; + const handleExtraOptionsSectionVisibility = (key: string) => + issueFilterStore?.issueView && + issueFilterStore?.issueLayout && + issueFilterVisibilityData[ + issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others" + ]?.extra_options?.[issueFilterStore?.issueLayout].values?.includes(key); + return (
{
{issueFilterStore?.issueRenderFilters?.extra_properties && issueFilterStore?.issueRenderFilters?.extra_properties.length > 0 && - issueFilterStore?.issueRenderFilters?.extra_properties.map((_extraProperties) => ( - - handleExtraOptions( - _extraProperties?.key, - issueFilterStore?.userFilters?.display_filters?.[_extraProperties?.key] - ) - } - title={_extraProperties.title} - /> - ))} + issueFilterStore?.issueRenderFilters?.extra_properties.map( + (_extraProperties) => + handleExtraOptionsSectionVisibility(_extraProperties?.key) && ( + + handleExtraOptions( + _extraProperties?.key, + issueFilterStore?.userFilters?.display_filters?.[_extraProperties?.key] + ) + } + title={_extraProperties.title} + /> + ) + )}
)}
diff --git a/web/components/issue-layouts/display-filters/index.tsx b/web/components/issue-layouts/display-filters/index.tsx index 5a3fb3a08..d629327af 100644 --- a/web/components/issue-layouts/display-filters/index.tsx +++ b/web/components/issue-layouts/display-filters/index.tsx @@ -5,41 +5,78 @@ import { FilterGroupBy } from "./group-by"; import { FilterOrderBy } from "./order-by"; import { FilterIssueType } from "./issue-type"; import { FilterExtraOptions } from "./extra-options"; -// // mobx react lite -// import { observer } from "mobx-react-lite"; -// // mobx store -// import { useMobxStore } from "lib/mobx/store-provider"; -// import { RootStore } from "store/root"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; +// default data +import { issueFilterVisibilityData } from "store/issue-views/issue_data"; -// const store: RootStore = useMobxStore(); -// const { issueFilters: issueFilterStore, issueView: issueViewStore } = store; +export const DisplayFiltersSelection = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore } = store; -export const DisplayFiltersSelection = () => ( -
-
- Search container -
-
- {/* display properties */} -
- + const handleDisplayPropertiesSectionVisibility = + issueFilterStore?.issueView && + issueFilterStore?.issueLayout && + issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others"] + ?.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); + + const handleExtraOptionsSectionVisibility = + issueFilterStore?.issueView && + issueFilterStore?.issueLayout && + issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others"] + ?.extra_options?.[issueFilterStore?.issueLayout].access; + + return ( +
+
+ Search container
- {/* group by */} -
- -
- {/* order by */} -
- -
- {/* issue type */} -
- -
- {/* Options */} -
- +
+ {/* display properties */} + {handleDisplayPropertiesSectionVisibility && ( +
+ +
+ )} + + {/* group by */} + {handleDisplayFilterSectionVisibility("group_by") && ( +
+ +
+ )} + + {/* order by */} + {handleDisplayFilterSectionVisibility("order_by") && ( +
+ +
+ )} + + {/* issue type */} + {handleDisplayFilterSectionVisibility("issue_type") && ( +
+ +
+ )} + + {/* Options */} + {handleExtraOptionsSectionVisibility && ( +
+ +
+ )}
-
-); + ); +}); diff --git a/web/components/issue-layouts/filters/index.tsx b/web/components/issue-layouts/filters/index.tsx index 4376f2d33..2ad446eb3 100644 --- a/web/components/issue-layouts/filters/index.tsx +++ b/web/components/issue-layouts/filters/index.tsx @@ -8,53 +8,86 @@ 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"; +// mobx react lite +import { observer } from "mobx-react-lite"; +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +import { RootStore } from "store/root"; +// default data +import { issueFilterVisibilityData } from "store/issue-views/issue_data"; -// const store: RootStore = useMobxStore(); -// const { issueFilters: issueFilterStore, issueView: issueViewStore } = store; +export const FilterSelection = observer(() => { + const store: RootStore = useMobxStore(); + const { issueFilters: issueFilterStore } = store; -export const FilterSelection = () => ( -
-
- Search container -
-
- {/* priority */} -
- + const handleFilterSectionVisibility = (section_key: string) => + issueFilterStore?.issueView && + issueFilterVisibilityData[ + issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others" + ].filters.includes(section_key); + + return ( +
+
+ Search container
- {/* state group */} -
- -
- {/* state */} -
- -
- {/* assignees */} -
- -
- {/* created_by */} -
- -
- {/* labels */} -
- -
- {/* start_date */} -
- -
- {/* due_date */} -
- +
+ {/* 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/labels.tsx b/web/components/issue-layouts/filters/labels.tsx index 61ba8d182..6b38ff123 100644 --- a/web/components/issue-layouts/filters/labels.tsx +++ b/web/components/issue-layouts/filters/labels.tsx @@ -32,18 +32,23 @@ export const FilterLabels = observer(() => { issueFilterStore.handleUserFilter("filters", key, _value); }; + const handleLabels = + issueFilterStore.issueView && issueFilterStore.issueView === "my_issues" + ? issueFilterStore?.workspaceLabels + : issueFilterStore?.projectLabels; + return (
setPreviewEnabled(!previewEnabled)} /> {previewEnabled && (
- {issueFilterStore?.projectLabels && - issueFilterStore?.projectLabels.length > 0 && - issueFilterStore?.projectLabels.map((_label) => ( + {handleLabels && + handleLabels.length > 0 && + handleLabels.map((_label) => ( { const store: RootStore = useMobxStore(); @@ -40,11 +42,18 @@ export const LayoutSelection = observer(() => { }, ]; + const handleLayoutSectionVisibility = (layout_key: string) => + issueFilterStore?.issueView && + issueFilterVisibilityData[ + issueFilterStore?.issueView === "my_issues" ? "my_issues" : "others" + ].layout.includes(layout_key); + const handleLayoutSelection = (_layoutKey: string) => { issueFilterStore.handleUserFilter("display_filters", "layout", _layoutKey); }; console.log("----"); + console.log("my_user_id", issueFilterStore.myUserId); console.log("workspace_id", issueFilterStore.workspaceId); console.log("project_id", issueFilterStore.projectId); console.log("module_id", issueFilterStore.moduleId); @@ -54,31 +63,38 @@ export const LayoutSelection = observer(() => { console.log("issue_view", issueFilterStore.issueView); console.log("issue_layout", issueFilterStore.issueLayout); + console.log("user_filters", issueFilterStore.userFilters); + console.log("issues", issueStore.issues); + console.log("issues", issueStore.getIssues); + console.log("----"); return (
- {layoutSelectionFilters.map((_layout) => ( -
handleLayoutSelection(_layout?.key)} - > - <_layout.icon - size={14} - strokeWidth={2} - className={`${ - issueFilterStore?.issueLayout == _layout?.key - ? `text-custom-text-100` - : `text-custom-text-100 group-hover:text-custom-text-200` - }`} - /> -
- ))} + {layoutSelectionFilters.map( + (_layout) => + handleLayoutSectionVisibility(_layout?.key) && ( +
handleLayoutSelection(_layout?.key)} + > + <_layout.icon + size={14} + strokeWidth={2} + className={`${ + issueFilterStore?.issueLayout == _layout?.key + ? `text-custom-text-100` + : `text-custom-text-100 group-hover:text-custom-text-200` + }`} + /> +
+ ) + )}
); }); diff --git a/web/store/issue-views/issue_data.ts b/web/store/issue-views/issue_data.ts index ab369f732..eff9a13db 100644 --- a/web/store/issue-views/issue_data.ts +++ b/web/store/issue-views/issue_data.ts @@ -78,8 +78,73 @@ export const displayProperties: { key: string; title: string }[] = [ ]; export const extraProperties: { key: string; title: string }[] = [ - { key: "sub_issues", title: "Show sub-issues" }, // in spreadsheet its always false + { key: "sub_issue", title: "Show sub-issues" }, // in spreadsheet its always false { key: "show_empty_groups", title: "Show empty states" }, // filter on front-end { key: "calendar_date_range", title: "Calendar Date Range" }, // calendar date range yyyy-mm-dd;before range yyyy-mm-dd;after { key: "start_target_date", title: "Start target Date" }, // gantt always be true ]; + +export const issueFilterVisibilityData: any = { + my_issues: { + layout: ["list", "kanban"], + filters: ["priority", "state_group", "labels", "start_date", "due_date"], + display_properties: { + list: true, + kanban: true, + }, + display_filters: { + list: ["group_by", "order_by", "issue_type"], + kanban: ["group_by", "order_by", "issue_type"], + }, + extra_options: { + list: { + access: true, + values: ["show_empty_groups"], + }, + kanban: { + access: true, + values: ["show_empty_groups"], + }, + }, + }, + others: { + layout: ["list", "kanban", "calendar", "spreadsheet", "gantt"], + filters: ["priority", "state", "assignees", "created_by", "labels", "start_date", "due_date"], + display_properties: { + list: true, + kanban: true, + calendar: true, + spreadsheet: true, + gantt: false, + }, + display_filters: { + list: ["group_by", "order_by", "issue_type", "sub_issue", "show_empty_groups"], + kanban: ["group_by", "order_by", "issue_type", "sub_issue", "show_empty_groups"], + calendar: ["issue_type"], + spreadsheet: ["issue_type"], + gantt: ["order_by", "issue_type", "sub_issue"], + }, + extra_options: { + list: { + access: true, + values: ["show_empty_groups", "sub_issue"], + }, + kanban: { + access: true, + values: ["show_empty_groups", "sub_issue"], + }, + calendar: { + access: false, + values: [], + }, + spreadsheet: { + access: false, + values: [], + }, + gantt: { + access: true, + values: ["sub_issue"], + }, + }, + }, +};