[WEB-2943] chore: issue reaction and code refactor (#6350)
* chore: issue reaction component updated * chore: project store updated
This commit is contained in:
parent
c2d8703acf
commit
3691cef351
2 changed files with 36 additions and 26 deletions
|
|
@ -20,10 +20,11 @@ export type TIssueReaction = {
|
||||||
issueId: string;
|
issueId: string;
|
||||||
currentUser: IUser;
|
currentUser: IUser;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const IssueReaction: FC<TIssueReaction> = observer((props) => {
|
export const IssueReaction: FC<TIssueReaction> = observer((props) => {
|
||||||
const { workspaceSlug, projectId, issueId, currentUser, disabled = false } = props;
|
const { workspaceSlug, projectId, issueId, currentUser, disabled = false, className = "" } = props;
|
||||||
// hooks
|
// hooks
|
||||||
const {
|
const {
|
||||||
reaction: { getReactionsByIssueId, reactionsByUser, getReactionById },
|
reaction: { getReactionsByIssueId, reactionsByUser, getReactionById },
|
||||||
|
|
@ -92,7 +93,7 @@ export const IssueReaction: FC<TIssueReaction> = observer((props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative mt-4 flex items-center gap-1.5">
|
<div className={cn("relative mt-4 flex items-center gap-1.5", className)}>
|
||||||
{!disabled && (
|
{!disabled && (
|
||||||
<ReactionSelector size="md" position="top" value={userReactions} onSelect={issueReactionOperations.react} />
|
<ReactionSelector size="md" position="top" value={userReactions} onSelect={issueReactionOperations.react} />
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,8 @@ import { ProjectService, ProjectStateService, ProjectArchiveService } from "@/se
|
||||||
// store
|
// store
|
||||||
import { CoreRootStore } from "../root.store";
|
import { CoreRootStore } from "../root.store";
|
||||||
|
|
||||||
|
type ProjectOverviewCollapsible = "links" | "attachments";
|
||||||
|
|
||||||
export interface IProjectStore {
|
export interface IProjectStore {
|
||||||
// observables
|
// observables
|
||||||
isUpdatingProject: boolean;
|
isUpdatingProject: boolean;
|
||||||
|
|
@ -18,9 +20,6 @@ export interface IProjectStore {
|
||||||
projectMap: {
|
projectMap: {
|
||||||
[projectId: string]: TProject; // projectId: project Info
|
[projectId: string]: TProject; // projectId: project Info
|
||||||
};
|
};
|
||||||
projectEpicPropertiesMap: {
|
|
||||||
[projectId: string]: any;
|
|
||||||
};
|
|
||||||
// computed
|
// computed
|
||||||
filteredProjectIds: string[] | undefined;
|
filteredProjectIds: string[] | undefined;
|
||||||
workspaceProjectIds: string[] | undefined;
|
workspaceProjectIds: string[] | undefined;
|
||||||
|
|
@ -32,9 +31,15 @@ export interface IProjectStore {
|
||||||
// actions
|
// actions
|
||||||
getProjectById: (projectId: string | undefined | null) => TProject | undefined;
|
getProjectById: (projectId: string | undefined | null) => TProject | undefined;
|
||||||
getProjectIdentifierById: (projectId: string | undefined | null) => string;
|
getProjectIdentifierById: (projectId: string | undefined | null) => string;
|
||||||
getProjectEpicPropertiesById: (projectId: string | undefined | null) => any;
|
// collapsible
|
||||||
|
openCollapsibleSection: ProjectOverviewCollapsible[];
|
||||||
|
lastCollapsibleAction: ProjectOverviewCollapsible | null;
|
||||||
|
|
||||||
|
setOpenCollapsibleSection: (section: ProjectOverviewCollapsible[]) => void;
|
||||||
|
setLastCollapsibleAction: (section: ProjectOverviewCollapsible) => void;
|
||||||
|
toggleOpenCollapsibleSection: (section: ProjectOverviewCollapsible) => void;
|
||||||
|
|
||||||
// fetch actions
|
// fetch actions
|
||||||
fetchProjectEpicProperties: (workspaceSlug: string, projectId: string) => Promise<any>;
|
|
||||||
fetchProjects: (workspaceSlug: string) => Promise<TProject[]>;
|
fetchProjects: (workspaceSlug: string) => Promise<TProject[]>;
|
||||||
fetchProjectDetails: (workspaceSlug: string, projectId: string) => Promise<TProject>;
|
fetchProjectDetails: (workspaceSlug: string, projectId: string) => Promise<TProject>;
|
||||||
// favorites actions
|
// favorites actions
|
||||||
|
|
@ -58,9 +63,9 @@ export class ProjectStore implements IProjectStore {
|
||||||
projectMap: {
|
projectMap: {
|
||||||
[projectId: string]: TProject; // projectId: project Info
|
[projectId: string]: TProject; // projectId: project Info
|
||||||
} = {};
|
} = {};
|
||||||
projectEpicPropertiesMap: {
|
openCollapsibleSection: ProjectOverviewCollapsible[] = [];
|
||||||
[projectId: string]: any;
|
lastCollapsibleAction: ProjectOverviewCollapsible | null = null;
|
||||||
} = {};
|
|
||||||
// root store
|
// root store
|
||||||
rootStore: CoreRootStore;
|
rootStore: CoreRootStore;
|
||||||
// service
|
// service
|
||||||
|
|
@ -76,6 +81,8 @@ export class ProjectStore implements IProjectStore {
|
||||||
isUpdatingProject: observable,
|
isUpdatingProject: observable,
|
||||||
loader: observable.ref,
|
loader: observable.ref,
|
||||||
projectMap: observable,
|
projectMap: observable,
|
||||||
|
openCollapsibleSection: observable.ref,
|
||||||
|
lastCollapsibleAction: observable.ref,
|
||||||
// computed
|
// computed
|
||||||
filteredProjectIds: computed,
|
filteredProjectIds: computed,
|
||||||
workspaceProjectIds: computed,
|
workspaceProjectIds: computed,
|
||||||
|
|
@ -85,7 +92,6 @@ export class ProjectStore implements IProjectStore {
|
||||||
joinedProjectIds: computed,
|
joinedProjectIds: computed,
|
||||||
favoriteProjectIds: computed,
|
favoriteProjectIds: computed,
|
||||||
// fetch actions
|
// fetch actions
|
||||||
fetchProjectEpicProperties: action,
|
|
||||||
fetchProjects: action,
|
fetchProjects: action,
|
||||||
fetchProjectDetails: action,
|
fetchProjectDetails: action,
|
||||||
// favorites actions
|
// favorites actions
|
||||||
|
|
@ -96,6 +102,10 @@ export class ProjectStore implements IProjectStore {
|
||||||
// CRUD actions
|
// CRUD actions
|
||||||
createProject: action,
|
createProject: action,
|
||||||
updateProject: action,
|
updateProject: action,
|
||||||
|
// collapsible actions
|
||||||
|
setOpenCollapsibleSection: action,
|
||||||
|
setLastCollapsibleAction: action,
|
||||||
|
toggleOpenCollapsibleSection: action,
|
||||||
});
|
});
|
||||||
// root store
|
// root store
|
||||||
this.rootStore = _rootStore;
|
this.rootStore = _rootStore;
|
||||||
|
|
@ -214,23 +224,22 @@ export class ProjectStore implements IProjectStore {
|
||||||
return projectIds;
|
return projectIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchProjectEpicProperties = async (workspaceSlug: string, projectId: string) => {
|
setOpenCollapsibleSection = (section: ProjectOverviewCollapsible[]) => {
|
||||||
try {
|
this.openCollapsibleSection = section;
|
||||||
const response = await this.projectService.fetchProjectEpicProperties(workspaceSlug, projectId);
|
if (this.lastCollapsibleAction) this.lastCollapsibleAction = null;
|
||||||
runInAction(() => {
|
|
||||||
set(this.projectEpicPropertiesMap, [projectId], response);
|
|
||||||
});
|
|
||||||
return response;
|
|
||||||
} catch (error) {
|
|
||||||
console.log("Failed to fetch epic properties from project store");
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
getProjectEpicPropertiesById = computedFn((projectId: string | undefined | null) => {
|
setLastCollapsibleAction = (section: ProjectOverviewCollapsible) => {
|
||||||
const projectEpicProperties = this.projectEpicPropertiesMap[projectId ?? ""];
|
this.openCollapsibleSection = [section];
|
||||||
return projectEpicProperties;
|
};
|
||||||
});
|
|
||||||
|
toggleOpenCollapsibleSection = (section: ProjectOverviewCollapsible) => {
|
||||||
|
if (this.openCollapsibleSection && this.openCollapsibleSection.includes(section)) {
|
||||||
|
this.openCollapsibleSection = this.openCollapsibleSection.filter((s) => s !== section);
|
||||||
|
} else {
|
||||||
|
this.openCollapsibleSection = [...this.openCollapsibleSection, section];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get Workspace projects using workspace slug
|
* get Workspace projects using workspace slug
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue