From edd1f6e42388f970674855863d121fe258e1e561 Mon Sep 17 00:00:00 2001 From: rahulramesha Date: Mon, 27 Nov 2023 17:05:08 +0530 Subject: [PATCH] fix profile issue filters and kanban --- .../roots/profile-issues-root.tsx | 3 +- web/store/issues/global/filter.store.ts | 46 +++++++++++------- web/store/issues/profile/filter.store.ts | 48 +++++++++++-------- web/store/issues/profile/issue.store.ts | 10 ++++ 4 files changed, 68 insertions(+), 39 deletions(-) diff --git a/web/components/issues/issue-layouts/filters/applied-filters/roots/profile-issues-root.tsx b/web/components/issues/issue-layouts/filters/applied-filters/roots/profile-issues-root.tsx index 80354b749..89870d98a 100644 --- a/web/components/issues/issue-layouts/filters/applied-filters/roots/profile-issues-root.tsx +++ b/web/components/issues/issue-layouts/filters/applied-filters/roots/profile-issues-root.tsx @@ -18,6 +18,7 @@ export const ProfileIssuesAppliedFiltersRoot: React.FC = observer(() => { const { workspace: { workspaceLabels }, workspaceProfileIssuesFilter: { issueFilters, updateFilters }, + projectMember: { projectMembers }, } = useMobxStore(); const userFilters = issueFilters?.filters; @@ -64,7 +65,7 @@ export const ProfileIssuesAppliedFiltersRoot: React.FC = observer(() => { handleClearAllFilters={handleClearAllFilters} handleRemoveFilter={handleRemoveFilter} labels={workspaceLabels ?? []} - members={[]} + members={projectMembers?.map((m) => m.member)} states={[]} /> diff --git a/web/store/issues/global/filter.store.ts b/web/store/issues/global/filter.store.ts index a2304f36d..81d661972 100644 --- a/web/store/issues/global/filter.store.ts +++ b/web/store/issues/global/filter.store.ts @@ -5,6 +5,7 @@ import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOption import { EFilterType } from "store/issues/types"; import { handleIssueQueryParamsByLayout } from "helpers/issue.helper"; import { IssueFilterBaseStore } from "../project-issues/base-issue-filter.store"; +import { isEmpty } from "lodash"; interface IProjectIssuesFiltersOptions { filters: IIssueFilterOptions; @@ -121,12 +122,18 @@ export class GlobalIssuesFilterStore extends IssueFilterBaseStore implements IGl let _projectIssueFilters = this.projectIssueFilters; if (!_projectIssueFilters) _projectIssueFilters = {}; - if (!_projectIssueFilters[workspaceSlug]) - _projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; - _projectIssueFilters[workspaceSlug] = { - ..._projectIssueFilters[workspaceSlug], - ...issueFilters, - }; + if (!_projectIssueFilters[workspaceSlug]) { + _projectIssueFilters[workspaceSlug] = { displayProperties: {} } as IProjectIssuesDisplayOptions; + } + if ( + isEmpty(_projectIssueFilters[workspaceSlug].filters) || + isEmpty(_projectIssueFilters[workspaceSlug].displayFilters) + ) { + _projectIssueFilters[workspaceSlug] = { + ..._projectIssueFilters[workspaceSlug], + ...issueFilters, + }; + } runInAction(() => { this.projectIssueFilters = _projectIssueFilters; @@ -192,15 +199,15 @@ export class GlobalIssuesFilterStore extends IssueFilterBaseStore implements IGl fetchDisplayProperties = async (workspaceSlug: string) => { try { const displayProperties: IIssueDisplayProperties = { - assignee: false, - start_date: false, - due_date: false, + assignee: true, + start_date: true, + due_date: true, labels: false, key: false, - priority: false, + priority: true, state: false, - sub_issue_count: false, - link: false, + sub_issue_count: true, + link: true, attachment_count: false, estimate: false, created_on: false, @@ -209,12 +216,15 @@ export class GlobalIssuesFilterStore extends IssueFilterBaseStore implements IGl let _projectIssueFilters = { ...this.projectIssueFilters }; if (!_projectIssueFilters) _projectIssueFilters = {}; - if (!_projectIssueFilters[workspaceSlug]) - _projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; - _projectIssueFilters[workspaceSlug] = { - ..._projectIssueFilters[workspaceSlug], - displayProperties: displayProperties, - }; + if (!_projectIssueFilters[workspaceSlug]) { + _projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {} } as IProjectIssuesDisplayOptions; + } + if (isEmpty(_projectIssueFilters[workspaceSlug].displayProperties)) { + _projectIssueFilters[workspaceSlug] = { + ..._projectIssueFilters[workspaceSlug], + displayProperties: displayProperties, + }; + } runInAction(() => { this.projectIssueFilters = _projectIssueFilters; diff --git a/web/store/issues/profile/filter.store.ts b/web/store/issues/profile/filter.store.ts index 3fb82d9e5..a947b8d23 100644 --- a/web/store/issues/profile/filter.store.ts +++ b/web/store/issues/profile/filter.store.ts @@ -5,6 +5,7 @@ import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOption import { EFilterType } from "store/issues/types"; import { handleIssueQueryParamsByLayout } from "helpers/issue.helper"; import { IssueFilterBaseStore } from "../project-issues/base-issue-filter.store"; +import { isEmpty } from "lodash"; interface IProjectIssuesFiltersOptions { filters: IIssueFilterOptions; @@ -121,12 +122,18 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP let _projectIssueFilters = this.projectIssueFilters; if (!_projectIssueFilters) _projectIssueFilters = {}; - if (!_projectIssueFilters[workspaceSlug]) - _projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; - _projectIssueFilters[workspaceSlug] = { - ..._projectIssueFilters[workspaceSlug], - ...issueFilters, - }; + if (!_projectIssueFilters[workspaceSlug]) { + _projectIssueFilters[workspaceSlug] = { displayProperties: {} } as IProjectIssuesDisplayOptions; + } + if ( + isEmpty(_projectIssueFilters[workspaceSlug].filters) || + isEmpty(_projectIssueFilters[workspaceSlug].displayFilters) + ) { + _projectIssueFilters[workspaceSlug] = { + ..._projectIssueFilters[workspaceSlug], + ...issueFilters, + }; + } runInAction(() => { this.projectIssueFilters = _projectIssueFilters; @@ -184,7 +191,6 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP return _filters; } catch (error) { - this.fetchDisplayFilters(workspaceSlug); throw error; } }; @@ -192,15 +198,15 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP fetchDisplayProperties = async (workspaceSlug: string) => { try { const displayProperties: IIssueDisplayProperties = { - assignee: false, - start_date: false, - due_date: false, + assignee: true, + start_date: true, + due_date: true, labels: false, key: false, - priority: false, + priority: true, state: false, - sub_issue_count: false, - link: false, + sub_issue_count: true, + link: true, attachment_count: false, estimate: false, created_on: false, @@ -209,12 +215,15 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP let _projectIssueFilters = { ...this.projectIssueFilters }; if (!_projectIssueFilters) _projectIssueFilters = {}; - if (!_projectIssueFilters[workspaceSlug]) - _projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; - _projectIssueFilters[workspaceSlug] = { - ..._projectIssueFilters[workspaceSlug], - displayProperties: displayProperties, - }; + if (!_projectIssueFilters[workspaceSlug]) { + _projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {} } as IProjectIssuesDisplayOptions; + } + if (isEmpty(_projectIssueFilters[workspaceSlug].displayProperties)) { + _projectIssueFilters[workspaceSlug] = { + ..._projectIssueFilters[workspaceSlug], + displayProperties: displayProperties, + }; + } runInAction(() => { this.projectIssueFilters = _projectIssueFilters; @@ -242,7 +251,6 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP return properties; } catch (error) { - this.fetchDisplayProperties(workspaceSlug); throw error; } }; diff --git a/web/store/issues/profile/issue.store.ts b/web/store/issues/profile/issue.store.ts index 71a2938cd..911096324 100644 --- a/web/store/issues/profile/issue.store.ts +++ b/web/store/issues/profile/issue.store.ts @@ -102,6 +102,7 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues const displayFilters = this.rootStore?.workspaceProfileIssuesFilter?.issueFilters?.displayFilters; if (!displayFilters) return undefined; + const subGroupBy = displayFilters?.sub_group_by; const groupBy = displayFilters?.group_by; const orderBy = displayFilters?.order_by; const layout = displayFilters?.layout; @@ -113,6 +114,15 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues if (layout === "list" && orderBy) { if (groupBy) issues = this.groupedIssues(groupBy, orderBy, this.issues[currentUserId][this.currentUserIssueTab]); else issues = this.unGroupedIssues(orderBy, this.issues[currentUserId][this.currentUserIssueTab]); + } else if (layout === "kanban" && groupBy && orderBy) { + if (subGroupBy) + issues = this.subGroupedIssues( + subGroupBy, + groupBy, + orderBy, + this.issues[currentUserId][this.currentUserIssueTab] + ); + else issues = this.groupedIssues(groupBy, orderBy, this.issues[currentUserId][this.currentUserIssueTab]); } return issues;