chore: store setup for build fixes

This commit is contained in:
sriram veeraghanta 2023-09-21 15:00:19 +05:30
parent 6d52801ea7
commit f69d34698a
13 changed files with 123 additions and 58 deletions

View File

@ -14,18 +14,19 @@ import { observer } from "mobx-react-lite";
import { useMobxStore } from "lib/mobx/store-provider";
import { RootStore } from "store/root";
// default data
import { issueFilterVisibilityData } from "store/helpers/issue-data";
// import { issueFilterVisibilityData } from "store/helpers/issue-data";
export const FilterPreview = observer(() => {
const store: RootStore = useMobxStore();
const { issueFilters: issueFilterStore } = store;
const { issueFilter: issueFilterStore } = store;
const handleFilterSectionVisibility = (section_key: string) =>
issueFilterStore?.issueView &&
issueFilterStore?.issueLayout &&
issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "issues"]?.filters?.[
issueFilterStore?.issueLayout
]?.includes(section_key);
const handleFilterSectionVisibility = (section_key: string) => {
// issueFilterStore?.issueView &&
// issueFilterStore?.issueLayout &&
// issueFilterVisibilityData[issueFilterStore?.issueView === "my_issues" ? "my_issues" : "issues"]?.filters?.[
// issueFilterStore?.issueLayout
// ]?.includes(section_key);
};
const validateFiltersAvailability =
issueFilterStore?.userFilters?.filters != null &&

View File

@ -6,6 +6,7 @@ import { IssuesRoot } from "components/issue-layouts/root";
// mobx store
import { useMobxStore } from "lib/mobx/store-provider";
import { RootStore } from "store/root";
import useSWR from "swr";
const KanBanViewRoot = () => {
const router = useRouter();
@ -14,32 +15,41 @@ const KanBanViewRoot = () => {
project_slug: string;
};
const { issue: issueViewStore, workspace: workspaceStore, project: projectStore }: RootStore = useMobxStore();
const {
issue: issueViewStore,
workspace: workspaceStore,
project: projectStore,
issueFilter: issueFilterStore,
}: RootStore = useMobxStore();
useSWR(
workspace_slug && project_slug ? "USER_FILTERS" : null,
workspace_slug && project_slug
? () => {
console.log("sdad");
issueFilterStore.fetchUserFilters(workspace_slug.toString(), project_slug.toString());
}
: null
);
React.useEffect(() => {
console.log("request init--->");
const init = async () => {
workspaceStore.setWorkspaceId(workspace_slug);
await workspaceStore.getWorkspaces();
await workspaceStore.getWorkspaceLabels(workspace_slug);
projectStore.setProject(project_slug);
await projectStore.getWorkspaceProjects(workspace_slug);
await projectStore.getProjectStates(workspace_slug, project_slug);
await projectStore.getProjectLabels(workspace_slug, project_slug);
await projectStore.getProjectMembers(workspace_slug, project_slug);
await issueViewStore.getProjectIssuesAsync(workspace_slug, project_slug);
// workspaceStore.setWorkspaceId(workspace_slug);
// await workspaceStore.getWorkspaces();
// await workspaceStore.getWorkspaceLabels(workspace_slug);
// projectStore.setProject(project_slug);
// await projectStore.getWorkspaceProjects(workspace_slug);
// await projectStore.getProjectStates(workspace_slug, project_slug);
// await projectStore.getProjectLabels(workspace_slug, project_slug);
// await projectStore.getProjectMembers(workspace_slug, project_slug);
// await issueViewStore.getProjectIssuesAsync(workspace_slug, project_slug);
};
if (workspace_slug && project_slug) init();
console.log("request completed--->");
}, [workspace_slug, project_slug, issueViewStore, workspaceStore, projectStore]);
return (
<div className="w-screen min-h-[600px] h-screen">
<IssuesRoot />
</div>
);
return <div className="w-screen min-h-[600px] h-screen">{/* <IssuesRoot /> */}</div>;
};
export default KanBanViewRoot;

View File

@ -12,7 +12,7 @@ import type {
} from "types";
import { API_BASE_URL } from "helpers/common.helper";
export class IssueServices extends APIService {
export class IssueService extends APIService {
constructor() {
super(API_BASE_URL);
}
@ -607,6 +607,6 @@ export class IssueServices extends APIService {
}
}
const issuesServices = new IssueServices();
const issueService = new IssueService();
export default issuesServices;
export default issueService;

View File

@ -16,7 +16,7 @@ import type {
TProjectIssuesSearchParams,
} from "types";
export class ProjectServices extends APIService {
export class ProjectService extends APIService {
constructor() {
super(API_BASE_URL);
}
@ -336,4 +336,4 @@ export class ProjectServices extends APIService {
}
}
export default new ProjectServices();
export default new ProjectService();

View File

@ -6,7 +6,7 @@ import trackEventServices from "services/track_event.service";
import { ICurrentUserResponse } from "types";
import { IProjectPublishSettings } from "store/project_publish";
class ProjectServices extends APIService {
export class ProjectPublishServices extends APIService {
constructor() {
super(API_BASE_URL);
}
@ -98,4 +98,4 @@ class ProjectServices extends APIService {
}
}
export default ProjectServices;
export default new ProjectPublishServices();

View File

@ -2,8 +2,8 @@ import { action, computed, observable, makeObservable, runInAction } from "mobx"
// types
import { RootStore } from "./root";
// services
import { ProjectServices } from "services/project.service";
import { IssueServices } from "services/issue.service";
import { ProjectService } from "services/project.service";
import { IssueService } from "services/issue.service";
export interface ICycleStore {
loader: boolean;
@ -40,8 +40,8 @@ class CycleStore implements ICycleStore {
});
this.rootStore = _rootStore;
this.projectService = new ProjectServices();
this.issueService = new IssueServices();
this.projectService = new ProjectService();
this.issueService = new IssueService();
}
// computed

View File

@ -2,7 +2,7 @@ import { observable, action, makeObservable, runInAction } from "mobx";
// types
import { RootStore } from "./root";
// services
import { IssueServices } from "services/issue.service";
import { IssueService } from "services/issue.service";
export type IPeekMode = "side" | "modal" | "full";
@ -80,7 +80,7 @@ class IssueViewDetailStore implements IIssueViewDetailStore {
});
this.rootStore = _rootStore;
this.issueService = new IssueServices();
this.issueService = new IssueService();
}
setPeekId = (issueId: string | null) => (this.peekId = issueId);

View File

@ -1,12 +1,19 @@
import { observable, action, computed, makeObservable, runInAction } from "mobx";
// types
import { RootStore } from "./root";
import { ProjectService } from "services/project.service";
import { IssueService } from "services/issue.service";
export interface IIssueFilterStore {
loader: boolean;
error: any | null;
userDisplayProperties: any;
userDisplayFilters: any;
userFilters: any;
defaultDisplayFilters: any;
defaultFilters: any;
fetchUserFilters: (workspaceSlug: string, projectSlug: string) => void;
}
class IssueFilterStore implements IIssueFilterStore {
@ -15,19 +22,64 @@ class IssueFilterStore implements IIssueFilterStore {
// observables
userDisplayProperties: any = {};
userDisplayFilters: any = {};
userFilters: any = {};
defaultDisplayFilters: any = {};
defaultFilters: any = {};
defaultDisplayProperties: any = {
assignee: true,
due_date: true,
key: true,
labels: true,
priority: true,
start_date: true,
state: true,
sub_issue_count: true,
};
// root store
rootStore;
projectService;
issueService;
constructor(_rootStore: RootStore) {
makeObservable(this, {
loader: observable.ref,
error: observable.ref,
defaultDisplayFilters: observable.ref,
defaultFilters: observable.ref,
userDisplayProperties: observable.ref,
userDisplayFilters: observable.ref,
userFilters: observable.ref,
fetchUserFilters: action,
});
this.rootStore = _rootStore;
this.projectService = new ProjectService();
this.issueService = new IssueService();
}
fetchUserFilters = async (workspaceSlug: string, projectId: string) => {
try {
const memberResponse = await this.projectService.projectMemberMe(workspaceSlug, projectId);
const issueProperties = await this.issueService.getIssueProperties(workspaceSlug, projectId);
console.log("memberResponse", memberResponse);
console.log("issueProperties", issueProperties);
runInAction(() => {
this.userFilters = memberResponse?.view_props?.filters;
this.userDisplayFilters = memberResponse?.view_props?.display_filters;
this.userDisplayProperties = issueProperties?.properties || this.defaultDisplayProperties;
// default props from api
this.defaultFilters = memberResponse.default_props.filters;
this.defaultDisplayFilters = memberResponse.default_props.display_filters;
});
} catch (error) {
console.log("Failed to fetch user filters in issue filter store", error);
}
};
}
export default IssueFilterStore;

View File

@ -2,8 +2,8 @@ import { action, computed, observable, makeObservable, runInAction } from "mobx"
// types
import { RootStore } from "./root";
// services
import { ProjectServices } from "services/project.service";
import { IssueServices } from "services/issue.service";
import { ProjectService } from "services/project.service";
import { IssueService } from "services/issue.service";
export interface IModuleStore {
loader: boolean;
@ -40,8 +40,8 @@ class ModuleStore implements IModuleStore {
});
this.rootStore = _rootStore;
this.projectService = new ProjectServices();
this.issueService = new IssueServices();
this.projectService = new ProjectService();
this.issueService = new IssueService();
}
// computed

View File

@ -3,10 +3,10 @@ import { observable, action, computed, makeObservable, runInAction } from "mobx"
import { RootStore } from "./root";
import { IProject, IIssueLabels, IProjectMember, IStateResponse, IState, ICycle, IModule, IView, IPage } from "types";
// services
import { ProjectServices } from "services/project.service";
import { IssueServices } from "services/issue.service";
import { ProjectService } from "services/project.service";
import { IssueService } from "services/issue.service";
import { ProjectStateServices } from "services/project_state.service";
import CycleService from "services/cycles.service";
import { CycleService } from "services/cycles.service";
import { ModuleService } from "services/modules.service";
import { ViewService } from "services/views.service";
import { PageService } from "services/page.service";
@ -110,6 +110,7 @@ class ProjectStore implements IProjectStore {
moduleService;
viewService;
pageService;
cycleService;
constructor(_rootStore: RootStore) {
makeObservable(this, {
@ -148,12 +149,13 @@ class ProjectStore implements IProjectStore {
});
this.rootStore = _rootStore;
this.projectService = new ProjectServices();
this.issueService = new IssueServices();
this.projectService = new ProjectService();
this.issueService = new IssueService();
this.stateService = new ProjectStateServices();
this.moduleService = new ModuleService();
this.viewService = new ViewService();
this.pageService = new PageService();
this.cycleService = new CycleService();
}
get projectStatesByGroups() {
@ -307,7 +309,7 @@ class ProjectStore implements IProjectStore {
this.loader = true;
this.error = null;
const cyclesResponse = await CycleService.getCyclesWithParams(workspaceSlug, projectSlug, "all");
const cyclesResponse = await this.cycleService.getCyclesWithParams(workspaceSlug, projectSlug, "all");
runInAction(() => {
this.cycles = {

View File

@ -2,7 +2,7 @@ import { observable, action, computed, makeObservable, runInAction } from "mobx"
// types
import { RootStore } from "./root";
// services
import ProjectServices from "services/project_publish.service";
import { ProjectPublishServices } from "services/project_publish.service";
export type TProjectPublishViews = "list" | "gantt" | "kanban" | "calendar" | "spreadsheet";
@ -87,7 +87,7 @@ class ProjectPublishStore implements IProjectPublishStore {
});
this.rootStore = _rootStore;
this.projectPublishService = new ProjectServices();
this.projectPublishService = new ProjectPublishServices();
}
handleProjectModal = (project_id: string | null = null) => {

View File

@ -2,8 +2,8 @@ import { action, computed, observable, makeObservable, runInAction } from "mobx"
// types
import { RootStore } from "./root";
// services
import { ProjectServices } from "services/project.service";
import { IssueServices } from "services/issue.service";
import { ProjectService } from "services/project.service";
import { IssueService } from "services/issue.service";
export interface IViewStore {
loader: boolean;
@ -40,8 +40,8 @@ class ViewStore implements IViewStore {
});
this.rootStore = _rootStore;
this.projectService = new ProjectServices();
this.issueService = new IssueServices();
this.projectService = new ProjectService();
this.issueService = new IssueService();
}
// computed

View File

@ -4,8 +4,8 @@ import { RootStore } from "./root";
import { IIssueLabels, IProject, IWorkspace } from "types";
// services
import { WorkspaceService } from "services/workspace.service";
import { ProjectServices } from "services/project.service";
import { IssueServices } from "services/issue.service";
import { ProjectService } from "services/project.service";
import { IssueService } from "services/issue.service";
export interface IWorkspaceStore {
loader: boolean;
@ -64,8 +64,8 @@ class WorkspaceStore implements IWorkspaceStore {
this.rootStore = _rootStore;
this.workspaceService = new WorkspaceService();
this.projectService = new ProjectServices();
this.issueService = new IssueServices();
this.projectService = new ProjectService();
this.issueService = new IssueService();
}
/**