forked from github/plane
1e152c666c
* chore: moved app & space from apps to root * chore: modified workspace configuration * chore: modified dockerfiles for space and web * chore: modified icons for space * feat: updated files for new svg icons supported by next-images * chore: added /spaces base path for next * chore: added compose config for space * chore: updated husky configuration * chore: updated workflows for new configuration * chore: changed app name to web * fix: resolved build errors with web * chore: reset file tracing root for both projects * chore: added nginx config for deploy * fix: eslint and tsconfig settings for space app * husky setup fixes based on new dir * eslint fixes * prettier formatting --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com>
89 lines
2.5 KiB
TypeScript
89 lines
2.5 KiB
TypeScript
// mobx
|
|
import { observable, action, makeObservable, runInAction } from "mobx";
|
|
// service
|
|
import ProjectService from "services/project.service";
|
|
// types
|
|
import { IWorkspace, IProject, IProjectSettings } from "types/project";
|
|
|
|
export interface IProjectStore {
|
|
loader: boolean;
|
|
error: any | null;
|
|
workspace: IWorkspace | null;
|
|
project: IProject | null;
|
|
deploySettings: IProjectSettings | null;
|
|
viewOptions: any;
|
|
activeBoard: string | null;
|
|
fetchProjectSettings: (workspace_slug: string, project_slug: string) => Promise<void>;
|
|
setActiveBoard: (value: string) => void;
|
|
}
|
|
|
|
class ProjectStore implements IProjectStore {
|
|
loader: boolean = false;
|
|
error: any | null = null;
|
|
// data
|
|
workspace: IWorkspace | null = null;
|
|
project: IProject | null = null;
|
|
deploySettings: IProjectSettings | null = null;
|
|
viewOptions: any = null;
|
|
activeBoard: string | null = null;
|
|
// root store
|
|
rootStore;
|
|
// service
|
|
projectService;
|
|
|
|
constructor(_rootStore: any | null = null) {
|
|
makeObservable(this, {
|
|
// loaders and error observables
|
|
loader: observable,
|
|
error: observable.ref,
|
|
// observable
|
|
workspace: observable.ref,
|
|
project: observable.ref,
|
|
deploySettings: observable.ref,
|
|
viewOptions: observable.ref,
|
|
activeBoard: observable.ref,
|
|
// actions
|
|
fetchProjectSettings: action,
|
|
setActiveBoard: action,
|
|
// computed
|
|
});
|
|
|
|
this.rootStore = _rootStore;
|
|
this.projectService = new ProjectService();
|
|
}
|
|
|
|
fetchProjectSettings = async (workspace_slug: string, project_slug: string) => {
|
|
try {
|
|
this.loader = true;
|
|
this.error = null;
|
|
|
|
const response = await this.projectService.getProjectSettings(workspace_slug, project_slug);
|
|
|
|
if (response) {
|
|
const _project: IProject = { ...response?.project_details };
|
|
const _workspace: IWorkspace = { ...response?.workspace_detail };
|
|
const _viewOptions = { ...response?.views };
|
|
const _deploySettings = { ...response };
|
|
runInAction(() => {
|
|
this.project = _project;
|
|
this.workspace = _workspace;
|
|
this.viewOptions = _viewOptions;
|
|
this.deploySettings = _deploySettings;
|
|
this.loader = false;
|
|
});
|
|
}
|
|
return response;
|
|
} catch (error) {
|
|
this.loader = false;
|
|
this.error = error;
|
|
return error;
|
|
}
|
|
};
|
|
|
|
setActiveBoard = (boardValue: string) => {
|
|
this.activeBoard = boardValue;
|
|
};
|
|
}
|
|
|
|
export default ProjectStore;
|