@@ -11,16 +11,15 @@ import { ProjectService, ProjectStateService, ProjectArchiveService } from "@/se
1111// store
1212import { CoreRootStore } from "../root.store" ;
1313
14+ type ProjectOverviewCollapsible = "links" | "attachments" ;
15+
1416export interface IProjectStore {
1517 // observables
1618 isUpdatingProject : boolean ;
1719 loader : boolean ;
1820 projectMap : {
1921 [ projectId : string ] : TProject ; // projectId: project Info
2022 } ;
21- projectEpicPropertiesMap : {
22- [ projectId : string ] : any ;
23- } ;
2423 // computed
2524 filteredProjectIds : string [ ] | undefined ;
2625 workspaceProjectIds : string [ ] | undefined ;
@@ -32,9 +31,15 @@ export interface IProjectStore {
3231 // actions
3332 getProjectById : ( projectId : string | undefined | null ) => TProject | undefined ;
3433 getProjectIdentifierById : ( projectId : string | undefined | null ) => string ;
35- getProjectEpicPropertiesById : ( projectId : string | undefined | null ) => any ;
34+ // collapsible
35+ openCollapsibleSection : ProjectOverviewCollapsible [ ] ;
36+ lastCollapsibleAction : ProjectOverviewCollapsible | null ;
37+
38+ setOpenCollapsibleSection : ( section : ProjectOverviewCollapsible [ ] ) => void ;
39+ setLastCollapsibleAction : ( section : ProjectOverviewCollapsible ) => void ;
40+ toggleOpenCollapsibleSection : ( section : ProjectOverviewCollapsible ) => void ;
41+
3642 // fetch actions
37- fetchProjectEpicProperties : ( workspaceSlug : string , projectId : string ) => Promise < any > ;
3843 fetchProjects : ( workspaceSlug : string ) => Promise < TProject [ ] > ;
3944 fetchProjectDetails : ( workspaceSlug : string , projectId : string ) => Promise < TProject > ;
4045 // favorites actions
@@ -58,9 +63,9 @@ export class ProjectStore implements IProjectStore {
5863 projectMap : {
5964 [ projectId : string ] : TProject ; // projectId: project Info
6065 } = { } ;
61- projectEpicPropertiesMap : {
62- [ projectId : string ] : any ;
63- } = { } ;
66+ openCollapsibleSection : ProjectOverviewCollapsible [ ] = [ ] ;
67+ lastCollapsibleAction : ProjectOverviewCollapsible | null = null ;
68+
6469 // root store
6570 rootStore : CoreRootStore ;
6671 // service
@@ -76,6 +81,8 @@ export class ProjectStore implements IProjectStore {
7681 isUpdatingProject : observable ,
7782 loader : observable . ref ,
7883 projectMap : observable ,
84+ openCollapsibleSection : observable . ref ,
85+ lastCollapsibleAction : observable . ref ,
7986 // computed
8087 filteredProjectIds : computed ,
8188 workspaceProjectIds : computed ,
@@ -85,7 +92,6 @@ export class ProjectStore implements IProjectStore {
8592 joinedProjectIds : computed ,
8693 favoriteProjectIds : computed ,
8794 // fetch actions
88- fetchProjectEpicProperties : action ,
8995 fetchProjects : action ,
9096 fetchProjectDetails : action ,
9197 // favorites actions
@@ -96,6 +102,10 @@ export class ProjectStore implements IProjectStore {
96102 // CRUD actions
97103 createProject : action ,
98104 updateProject : action ,
105+ // collapsible actions
106+ setOpenCollapsibleSection : action ,
107+ setLastCollapsibleAction : action ,
108+ toggleOpenCollapsibleSection : action ,
99109 } ) ;
100110 // root store
101111 this . rootStore = _rootStore ;
@@ -214,23 +224,22 @@ export class ProjectStore implements IProjectStore {
214224 return projectIds ;
215225 }
216226
217- fetchProjectEpicProperties = async ( workspaceSlug : string , projectId : string ) => {
218- try {
219- const response = await this . projectService . fetchProjectEpicProperties ( workspaceSlug , projectId ) ;
220- runInAction ( ( ) => {
221- set ( this . projectEpicPropertiesMap , [ projectId ] , response ) ;
222- } ) ;
223- return response ;
224- } catch ( error ) {
225- console . log ( "Failed to fetch epic properties from project store" ) ;
226- throw error ;
227- }
227+ setOpenCollapsibleSection = ( section : ProjectOverviewCollapsible [ ] ) => {
228+ this . openCollapsibleSection = section ;
229+ if ( this . lastCollapsibleAction ) this . lastCollapsibleAction = null ;
228230 } ;
229231
230- getProjectEpicPropertiesById = computedFn ( ( projectId : string | undefined | null ) => {
231- const projectEpicProperties = this . projectEpicPropertiesMap [ projectId ?? "" ] ;
232- return projectEpicProperties ;
233- } ) ;
232+ setLastCollapsibleAction = ( section : ProjectOverviewCollapsible ) => {
233+ this . openCollapsibleSection = [ section ] ;
234+ } ;
235+
236+ toggleOpenCollapsibleSection = ( section : ProjectOverviewCollapsible ) => {
237+ if ( this . openCollapsibleSection && this . openCollapsibleSection . includes ( section ) ) {
238+ this . openCollapsibleSection = this . openCollapsibleSection . filter ( ( s ) => s !== section ) ;
239+ } else {
240+ this . openCollapsibleSection = [ ...this . openCollapsibleSection , section ] ;
241+ }
242+ } ;
234243
235244 /**
236245 * get Workspace projects using workspace slug
0 commit comments