fix: all functionalities for profile, archived and draft issues (#2922)

* fix profile issue filters and kanban

* fix profile draft and archived issues
This commit is contained in:
rahulramesha 2023-11-28 18:15:46 +05:30 committed by GitHub
parent 62c0615012
commit db510dcfcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 104 additions and 64 deletions

View File

@ -18,6 +18,7 @@ export const ProfileIssuesAppliedFiltersRoot: React.FC = observer(() => {
const { const {
workspace: { workspaceLabels }, workspace: { workspaceLabels },
workspaceProfileIssuesFilter: { issueFilters, updateFilters }, workspaceProfileIssuesFilter: { issueFilters, updateFilters },
projectMember: { projectMembers },
} = useMobxStore(); } = useMobxStore();
const userFilters = issueFilters?.filters; const userFilters = issueFilters?.filters;
@ -64,7 +65,7 @@ export const ProfileIssuesAppliedFiltersRoot: React.FC = observer(() => {
handleClearAllFilters={handleClearAllFilters} handleClearAllFilters={handleClearAllFilters}
handleRemoveFilter={handleRemoveFilter} handleRemoveFilter={handleRemoveFilter}
labels={workspaceLabels ?? []} labels={workspaceLabels ?? []}
members={[]} members={projectMembers?.map((m) => m.member)}
states={[]} states={[]}
/> />
</div> </div>

View File

@ -1,12 +1,8 @@
import React, { ReactElement } from "react"; import React from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import useSWR from "swr"; import useSWR from "swr";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// layouts
import { AppLayout } from "layouts/app-layout";
import { ProfileAuthWrapper } from "layouts/user-profile-layout";
// components // components
import { UserProfileHeader } from "components/headers";
import { ProfileIssuesListLayout } from "components/issues/issue-layouts/list/roots/profile-issues-root"; import { ProfileIssuesListLayout } from "components/issues/issue-layouts/list/roots/profile-issues-root";
import { ProfileIssuesKanBanLayout } from "components/issues/issue-layouts/kanban/roots/profile-issues-root"; import { ProfileIssuesKanBanLayout } from "components/issues/issue-layouts/kanban/roots/profile-issues-root";
import { ProfileIssuesAppliedFiltersRoot } from "components/issues"; import { ProfileIssuesAppliedFiltersRoot } from "components/issues";
@ -31,12 +27,15 @@ export const ProfileIssuesPage = observer((props: IProfileIssuesPage) => {
workspaceProfileIssuesFilter: { issueFilters, fetchFilters }, workspaceProfileIssuesFilter: { issueFilters, fetchFilters },
}: RootStore = useMobxStore(); }: RootStore = useMobxStore();
useSWR(workspaceSlug && userId ? `CURRENT_WORKSPACE_PROFILE_ISSUES_${workspaceSlug}_${userId}` : null, async () => { useSWR(
if (workspaceSlug && userId) { workspaceSlug && userId ? `CURRENT_WORKSPACE_PROFILE_ISSUES_${workspaceSlug}_${userId}_${props.type}` : null,
await fetchFilters(workspaceSlug); async () => {
await fetchIssues(workspaceSlug, userId, getIssues ? "mutation" : "init-loader", props.type); if (workspaceSlug && userId) {
await fetchFilters(workspaceSlug);
await fetchIssues(workspaceSlug, userId, getIssues ? "mutation" : "init-loader", props.type);
}
} }
}); );
const activeLayout = issueFilters?.displayFilters?.layout || undefined; const activeLayout = issueFilters?.displayFilters?.layout || undefined;

View File

@ -5,6 +5,7 @@ import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOption
import { EFilterType } from "store/issues/types"; import { EFilterType } from "store/issues/types";
import { handleIssueQueryParamsByLayout } from "helpers/issue.helper"; import { handleIssueQueryParamsByLayout } from "helpers/issue.helper";
import { IssueFilterBaseStore } from "../project-issues/base-issue-filter.store"; import { IssueFilterBaseStore } from "../project-issues/base-issue-filter.store";
import { isEmpty } from "lodash";
interface IProjectIssuesFiltersOptions { interface IProjectIssuesFiltersOptions {
filters: IIssueFilterOptions; filters: IIssueFilterOptions;
@ -121,12 +122,18 @@ export class GlobalIssuesFilterStore extends IssueFilterBaseStore implements IGl
let _projectIssueFilters = this.projectIssueFilters; let _projectIssueFilters = this.projectIssueFilters;
if (!_projectIssueFilters) _projectIssueFilters = {}; if (!_projectIssueFilters) _projectIssueFilters = {};
if (!_projectIssueFilters[workspaceSlug]) if (!_projectIssueFilters[workspaceSlug]) {
_projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; _projectIssueFilters[workspaceSlug] = { displayProperties: {} } as IProjectIssuesDisplayOptions;
_projectIssueFilters[workspaceSlug] = { }
..._projectIssueFilters[workspaceSlug], if (
...issueFilters, isEmpty(_projectIssueFilters[workspaceSlug].filters) ||
}; isEmpty(_projectIssueFilters[workspaceSlug].displayFilters)
) {
_projectIssueFilters[workspaceSlug] = {
..._projectIssueFilters[workspaceSlug],
...issueFilters,
};
}
runInAction(() => { runInAction(() => {
this.projectIssueFilters = _projectIssueFilters; this.projectIssueFilters = _projectIssueFilters;
@ -192,15 +199,15 @@ export class GlobalIssuesFilterStore extends IssueFilterBaseStore implements IGl
fetchDisplayProperties = async (workspaceSlug: string) => { fetchDisplayProperties = async (workspaceSlug: string) => {
try { try {
const displayProperties: IIssueDisplayProperties = { const displayProperties: IIssueDisplayProperties = {
assignee: false, assignee: true,
start_date: false, start_date: true,
due_date: false, due_date: true,
labels: false, labels: false,
key: false, key: false,
priority: false, priority: true,
state: false, state: false,
sub_issue_count: false, sub_issue_count: true,
link: false, link: true,
attachment_count: false, attachment_count: false,
estimate: false, estimate: false,
created_on: false, created_on: false,
@ -209,12 +216,15 @@ export class GlobalIssuesFilterStore extends IssueFilterBaseStore implements IGl
let _projectIssueFilters = { ...this.projectIssueFilters }; let _projectIssueFilters = { ...this.projectIssueFilters };
if (!_projectIssueFilters) _projectIssueFilters = {}; if (!_projectIssueFilters) _projectIssueFilters = {};
if (!_projectIssueFilters[workspaceSlug]) if (!_projectIssueFilters[workspaceSlug]) {
_projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; _projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {} } as IProjectIssuesDisplayOptions;
_projectIssueFilters[workspaceSlug] = { }
..._projectIssueFilters[workspaceSlug], if (isEmpty(_projectIssueFilters[workspaceSlug].displayProperties)) {
displayProperties: displayProperties, _projectIssueFilters[workspaceSlug] = {
}; ..._projectIssueFilters[workspaceSlug],
displayProperties: displayProperties,
};
}
runInAction(() => { runInAction(() => {
this.projectIssueFilters = _projectIssueFilters; this.projectIssueFilters = _projectIssueFilters;

View File

@ -5,6 +5,7 @@ import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOption
import { EFilterType } from "store/issues/types"; import { EFilterType } from "store/issues/types";
import { handleIssueQueryParamsByLayout } from "helpers/issue.helper"; import { handleIssueQueryParamsByLayout } from "helpers/issue.helper";
import { IssueFilterBaseStore } from "../project-issues/base-issue-filter.store"; import { IssueFilterBaseStore } from "../project-issues/base-issue-filter.store";
import isEmpty from "lodash/isEmpty";
interface IProjectIssuesFiltersOptions { interface IProjectIssuesFiltersOptions {
filters: IIssueFilterOptions; filters: IIssueFilterOptions;
@ -121,12 +122,18 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP
let _projectIssueFilters = this.projectIssueFilters; let _projectIssueFilters = this.projectIssueFilters;
if (!_projectIssueFilters) _projectIssueFilters = {}; if (!_projectIssueFilters) _projectIssueFilters = {};
if (!_projectIssueFilters[workspaceSlug]) if (!_projectIssueFilters[workspaceSlug]) {
_projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; _projectIssueFilters[workspaceSlug] = { displayProperties: {} } as IProjectIssuesDisplayOptions;
_projectIssueFilters[workspaceSlug] = { }
..._projectIssueFilters[workspaceSlug], if (
...issueFilters, isEmpty(_projectIssueFilters[workspaceSlug].filters) ||
}; isEmpty(_projectIssueFilters[workspaceSlug].displayFilters)
) {
_projectIssueFilters[workspaceSlug] = {
..._projectIssueFilters[workspaceSlug],
...issueFilters,
};
}
runInAction(() => { runInAction(() => {
this.projectIssueFilters = _projectIssueFilters; this.projectIssueFilters = _projectIssueFilters;
@ -184,7 +191,6 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP
return _filters; return _filters;
} catch (error) { } catch (error) {
this.fetchDisplayFilters(workspaceSlug);
throw error; throw error;
} }
}; };
@ -192,12 +198,12 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP
fetchDisplayProperties = async (workspaceSlug: string) => { fetchDisplayProperties = async (workspaceSlug: string) => {
try { try {
const displayProperties: IIssueDisplayProperties = { const displayProperties: IIssueDisplayProperties = {
assignee: false, assignee: true,
start_date: false, start_date: false,
due_date: false, due_date: false,
labels: false, labels: true,
key: false, key: true,
priority: false, priority: true,
state: false, state: false,
sub_issue_count: false, sub_issue_count: false,
link: false, link: false,
@ -209,12 +215,15 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP
let _projectIssueFilters = { ...this.projectIssueFilters }; let _projectIssueFilters = { ...this.projectIssueFilters };
if (!_projectIssueFilters) _projectIssueFilters = {}; if (!_projectIssueFilters) _projectIssueFilters = {};
if (!_projectIssueFilters[workspaceSlug]) if (!_projectIssueFilters[workspaceSlug]) {
_projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {}, displayProperties: {} }; _projectIssueFilters[workspaceSlug] = { filters: {}, displayFilters: {} } as IProjectIssuesDisplayOptions;
_projectIssueFilters[workspaceSlug] = { }
..._projectIssueFilters[workspaceSlug], if (isEmpty(_projectIssueFilters[workspaceSlug].displayProperties)) {
displayProperties: displayProperties, _projectIssueFilters[workspaceSlug] = {
}; ..._projectIssueFilters[workspaceSlug],
displayProperties: displayProperties,
};
}
runInAction(() => { runInAction(() => {
this.projectIssueFilters = _projectIssueFilters; this.projectIssueFilters = _projectIssueFilters;
@ -242,7 +251,6 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP
return properties; return properties;
} catch (error) { } catch (error) {
this.fetchDisplayProperties(workspaceSlug);
throw error; throw error;
} }
}; };

View File

@ -19,7 +19,7 @@ export interface IProfileIssuesStore {
loader: TLoader; loader: TLoader;
issues: { [user_id: string]: IProfileIssueTabTypes } | undefined; issues: { [user_id: string]: IProfileIssueTabTypes } | undefined;
currentUserId: string | null; currentUserId: string | null;
currentUserIssueTab: "assigned" | "created" | "subscribed" | null; currentUserIssueTab: "assigned" | "created" | "subscribed" | undefined;
// computed // computed
getIssues: IIssueResponse | undefined; getIssues: IIssueResponse | undefined;
getIssuesIds: IGroupedIssues | ISubGroupedIssues | TUnGroupedIssues | undefined; getIssuesIds: IGroupedIssues | ISubGroupedIssues | TUnGroupedIssues | undefined;
@ -52,7 +52,7 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
loader: TLoader = "init-loader"; loader: TLoader = "init-loader";
issues: { [user_id: string]: IProfileIssueTabTypes } | undefined = undefined; issues: { [user_id: string]: IProfileIssueTabTypes } | undefined = undefined;
currentUserId: string | null = null; currentUserId: string | null = null;
currentUserIssueTab: "assigned" | "created" | "subscribed" | null = null; currentUserIssueTab: "assigned" | "created" | "subscribed" | undefined = undefined;
// root store // root store
rootStore; rootStore;
// service // service
@ -87,7 +87,9 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
if (!workspaceSlug || !this.currentUserId || !this.currentUserIssueTab) return; if (!workspaceSlug || !this.currentUserId || !this.currentUserIssueTab) return;
const userFilters = this.rootStore?.workspaceProfileIssuesFilter?.issueFilters?.filters; const userFilters = this.rootStore?.workspaceProfileIssuesFilter?.issueFilters?.filters;
if (userFilters) this.fetchIssues(workspaceSlug, this.currentUserId, "mutation", this.currentUserIssueTab); if (userFilters) {
this.fetchIssues(workspaceSlug, this.currentUserId, "mutation", this.currentUserIssueTab);
}
}); });
} }
@ -103,6 +105,7 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
const displayFilters = this.rootStore?.workspaceProfileIssuesFilter?.issueFilters?.displayFilters; const displayFilters = this.rootStore?.workspaceProfileIssuesFilter?.issueFilters?.displayFilters;
if (!displayFilters) return undefined; if (!displayFilters) return undefined;
const subGroupBy = displayFilters?.sub_group_by;
const groupBy = displayFilters?.group_by; const groupBy = displayFilters?.group_by;
const orderBy = displayFilters?.order_by; const orderBy = displayFilters?.order_by;
const layout = displayFilters?.layout; const layout = displayFilters?.layout;
@ -114,6 +117,15 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
if (layout === "list" && orderBy) { if (layout === "list" && orderBy) {
if (groupBy) issues = this.groupedIssues(groupBy, orderBy, this.issues[currentUserId][this.currentUserIssueTab]); if (groupBy) issues = this.groupedIssues(groupBy, orderBy, this.issues[currentUserId][this.currentUserIssueTab]);
else issues = this.unGroupedIssues(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; return issues;
@ -188,20 +200,12 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
createIssue = async (workspaceSlug: string, userId: string, data: Partial<IIssue>) => { createIssue = async (workspaceSlug: string, userId: string, data: Partial<IIssue>) => {
try { try {
const projectId = data.project; const projectId = data.project;
const moduleId = data.module_id;
const cycleId = data.cycle_id;
if (!projectId) return; if (!projectId) return;
let response = {} as IIssue; let response = {} as IIssue;
response = await this.rootStore.projectIssues.createIssue(workspaceSlug, projectId, data); response = await this.rootStore.projectIssues.createIssue(workspaceSlug, projectId, data);
// if (moduleId)
// response = await this.rootStore.moduleIssues.addIssueToModule(workspaceSlug, projectId, moduleId, response);
// if (cycleId)
// response = await this.rootStore.cycleIssues.addIssueToCycle(workspaceSlug, projectId, cycleId, response);
let _issues = this.issues; let _issues = this.issues;
if (!_issues) _issues = {}; if (!_issues) _issues = {};
if (!_issues[userId]) _issues[userId] = { assigned: {}, created: {}, subscribed: {} }; if (!_issues[userId]) _issues[userId] = { assigned: {}, created: {}, subscribed: {} };
@ -229,8 +233,8 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
let _issues = { ...this.issues }; let _issues = { ...this.issues };
if (!_issues) _issues = {}; if (!_issues) _issues = {};
if (!_issues[userId]) _issues[userId] = { assigned: {}, created: {}, subscribed: {} }; if (!_issues[userId]) _issues[userId] = { assigned: {}, created: {}, subscribed: {} };
_issues[projectId][this.currentUserIssueTab][userId] = { _issues[userId][this.currentUserIssueTab][userId] = {
..._issues[projectId][this.currentUserIssueTab][userId], ..._issues[userId][this.currentUserIssueTab][userId],
...data, ...data,
}; };

View File

@ -119,8 +119,17 @@ export class ProjectArchivedIssuesStore extends IssueBaseStore implements IProje
removeIssue = async (workspaceSlug: string, projectId: string, issueId: string) => { removeIssue = async (workspaceSlug: string, projectId: string, issueId: string) => {
try { try {
await this.archivedIssueService.unarchiveIssue(workspaceSlug, projectId, issueId); let _issues = { ...this.issues };
return; if (!_issues) _issues = {};
if (!_issues[projectId]) _issues[projectId] = {};
delete _issues?.[projectId]?.[issueId];
runInAction(() => {
this.issues = _issues;
});
const response = await this.archivedIssueService.deleteArchivedIssue(workspaceSlug, projectId, issueId);
return response;
} catch (error) { } catch (error) {
throw error; throw error;
} }
@ -128,8 +137,17 @@ export class ProjectArchivedIssuesStore extends IssueBaseStore implements IProje
removeIssueFromArchived = async (workspaceSlug: string, projectId: string, issueId: string) => { removeIssueFromArchived = async (workspaceSlug: string, projectId: string, issueId: string) => {
try { try {
await this.archivedIssueService.deleteArchivedIssue(workspaceSlug, projectId, issueId); let _issues = { ...this.issues };
return; if (!_issues) _issues = {};
if (!_issues[projectId]) _issues[projectId] = {};
delete _issues?.[projectId]?.[issueId];
runInAction(() => {
this.issues = _issues;
});
const response = await this.archivedIssueService.unarchiveIssue(workspaceSlug, projectId, issueId);
return response;
} catch (error) { } catch (error) {
throw error; throw error;
} }