mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: store fixes
This commit is contained in:
parent
2dcaccd4ec
commit
9b41b5baf5
@ -26,8 +26,7 @@ type Props = {
|
|||||||
|
|
||||||
export type TPeekOverviewModes = "side" | "modal" | "full";
|
export type TPeekOverviewModes = "side" | "modal" | "full";
|
||||||
|
|
||||||
export const IssuePeekOverview: React.FC<Props> = observer(
|
export const IssuePeekOverview: React.FC<Props> = observer(({ handleMutation, projectId, readOnly, workspaceSlug }) => {
|
||||||
({ handleMutation, projectId, readOnly, workspaceSlug }) => {
|
|
||||||
const [isSidePeekOpen, setIsSidePeekOpen] = useState(false);
|
const [isSidePeekOpen, setIsSidePeekOpen] = useState(false);
|
||||||
const [isModalPeekOpen, setIsModalPeekOpen] = useState(false);
|
const [isModalPeekOpen, setIsModalPeekOpen] = useState(false);
|
||||||
const [peekOverviewMode, setPeekOverviewMode] = useState<TPeekOverviewModes>("side");
|
const [peekOverviewMode, setPeekOverviewMode] = useState<TPeekOverviewModes>("side");
|
||||||
@ -36,8 +35,8 @@ export const IssuePeekOverview: React.FC<Props> = observer(
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { peekIssue } = router.query;
|
const { peekIssue } = router.query;
|
||||||
|
|
||||||
const { issues: issuesStore } = useMobxStore();
|
const { issueDetail: issueDetailStore } = useMobxStore();
|
||||||
const { deleteIssue, getIssueById, issues, updateIssue } = issuesStore;
|
const { deleteIssue, getIssueById, issues, updateIssue } = issueDetailStore;
|
||||||
|
|
||||||
const issue = issues[peekIssue?.toString() ?? ""];
|
const issue = issues[peekIssue?.toString() ?? ""];
|
||||||
|
|
||||||
@ -189,5 +188,4 @@ export const IssuePeekOverview: React.FC<Props> = observer(
|
|||||||
</Transition.Root>
|
</Transition.Root>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
@ -3,57 +3,43 @@ import { observable, action, makeObservable, runInAction } from "mobx";
|
|||||||
import { RootStore } from "./root";
|
import { RootStore } from "./root";
|
||||||
// services
|
// services
|
||||||
import { IssueService } from "services/issue.service";
|
import { IssueService } from "services/issue.service";
|
||||||
|
import { IIssue } from "types";
|
||||||
|
|
||||||
export type IPeekMode = "side" | "modal" | "full";
|
export type IPeekMode = "side" | "modal" | "full";
|
||||||
|
|
||||||
export interface IIssueViewDetailStore {
|
export interface IIssueDetailStore {
|
||||||
loader: boolean;
|
loader: boolean;
|
||||||
error: any | null;
|
error: any | null;
|
||||||
|
|
||||||
peekId: string | null;
|
peekId: string | null;
|
||||||
peekMode: IPeekMode | null;
|
peekMode: IPeekMode | null;
|
||||||
|
|
||||||
issue_detail: {
|
|
||||||
workspace: {
|
|
||||||
[key: string]: {
|
|
||||||
issues: {
|
issues: {
|
||||||
[key: string]: any;
|
[key: string]: IIssue;
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
setPeekId: (issueId: string | null) => void;
|
setPeekId: (issueId: string | null) => void;
|
||||||
setPeekMode: (issueId: IPeekMode | null) => void;
|
setPeekMode: (issueId: IPeekMode | null) => void;
|
||||||
|
|
||||||
// fetch issue details
|
// fetch issue details
|
||||||
fetchIssueDetailsAsync: (workspaceId: string, projectId: string, issueId: string) => void;
|
fetchIssueDetails: (workspaceId: string, projectId: string, issueId: string) => void;
|
||||||
// creating issue
|
// creating issue
|
||||||
createIssueAsync: (workspaceId: string, projectId: string, issueId: string, data: any) => void;
|
createIssue: (workspaceId: string, projectId: string, issueId: string, data: any) => void;
|
||||||
// updating issue
|
// updating issue
|
||||||
updateIssueAsync: (workspaceId: string, projectId: string, issueId: string, data: any) => void;
|
updateIssue: (workspaceId: string, projectId: string, issueId: string, data: any) => void;
|
||||||
// deleting issue
|
// deleting issue
|
||||||
deleteIssueAsync: (workspaceId: string, projectId: string, issueId: string) => void;
|
deleteIssue: (workspaceId: string, projectId: string, issueId: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
class IssueViewDetailStore implements IIssueViewDetailStore {
|
class IssueDetailStore implements IIssueDetailStore {
|
||||||
loader: boolean = false;
|
loader: boolean = false;
|
||||||
error: any | null = null;
|
error: any | null = null;
|
||||||
|
|
||||||
peekId: string | null = null;
|
peekId: string | null = null;
|
||||||
peekMode: IPeekMode | null = null;
|
peekMode: IPeekMode | null = null;
|
||||||
|
|
||||||
issue_detail: {
|
|
||||||
workspace: {
|
|
||||||
[key: string]: {
|
|
||||||
issues: {
|
issues: {
|
||||||
[key: string]: any;
|
[key: string]: IIssue;
|
||||||
};
|
} = {};
|
||||||
};
|
|
||||||
};
|
|
||||||
} = {
|
|
||||||
workspace: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// root store
|
// root store
|
||||||
rootStore;
|
rootStore;
|
||||||
@ -63,20 +49,21 @@ class IssueViewDetailStore implements IIssueViewDetailStore {
|
|||||||
constructor(_rootStore: RootStore) {
|
constructor(_rootStore: RootStore) {
|
||||||
makeObservable(this, {
|
makeObservable(this, {
|
||||||
// observable
|
// observable
|
||||||
loader: observable,
|
loader: observable.ref,
|
||||||
error: observable,
|
error: observable.ref,
|
||||||
|
|
||||||
peekId: observable,
|
peekId: observable.ref,
|
||||||
peekMode: observable,
|
peekMode: observable.ref,
|
||||||
issue_detail: observable,
|
|
||||||
|
issues: observable.ref,
|
||||||
|
|
||||||
setPeekId: action,
|
setPeekId: action,
|
||||||
setPeekMode: action,
|
setPeekMode: action,
|
||||||
|
|
||||||
fetchIssueDetailsAsync: action,
|
fetchIssueDetails: action,
|
||||||
createIssueAsync: action,
|
createIssue: action,
|
||||||
updateIssueAsync: action,
|
updateIssue: action,
|
||||||
deleteIssueAsync: action,
|
deleteIssue: action,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.rootStore = _rootStore;
|
this.rootStore = _rootStore;
|
||||||
@ -84,20 +71,22 @@ class IssueViewDetailStore implements IIssueViewDetailStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setPeekId = (issueId: string | null) => (this.peekId = issueId);
|
setPeekId = (issueId: string | null) => (this.peekId = issueId);
|
||||||
|
|
||||||
setPeekMode = (mode: IPeekMode | null) => (this.peekMode = mode);
|
setPeekMode = (mode: IPeekMode | null) => (this.peekMode = mode);
|
||||||
|
|
||||||
fetchIssueDetailsAsync = async (workspaceId: string, projectId: string, issueId: string) => {
|
fetchIssueDetails = async (workspaceId: string, projectId: string, issueId: string) => {
|
||||||
try {
|
try {
|
||||||
this.loader = true;
|
this.loader = true;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
|
|
||||||
console.log("workspaceId", workspaceId);
|
const issueDetailsResponse = await this.issueService.retrieve(workspaceId, projectId, issueId);
|
||||||
console.log("projectId", projectId);
|
|
||||||
console.log("issueId", issueId);
|
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.loader = false;
|
this.loader = false;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
|
this.issues = {
|
||||||
|
[issueId]: issueDetailsResponse,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("error in fetching issue details", error);
|
console.log("error in fetching issue details", error);
|
||||||
@ -107,7 +96,7 @@ class IssueViewDetailStore implements IIssueViewDetailStore {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
createIssueAsync = async (workspaceId: string, projectId: string, issueId: string, data: any) => {
|
createIssue = async (workspaceId: string, projectId: string, issueId: string, data: any) => {
|
||||||
try {
|
try {
|
||||||
this.loader = true;
|
this.loader = true;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
@ -129,12 +118,12 @@ class IssueViewDetailStore implements IIssueViewDetailStore {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
updateIssueAsync = async (workspaceId: string, projectId: string, issueId: string, data: any) => {
|
updateIssue = async (workspaceId: string, projectId: string, issueId: string, data: any) => {
|
||||||
try {
|
try {
|
||||||
this.loader = true;
|
this.loader = true;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
|
|
||||||
const filteredParams = this.rootStore.issueFilters.getComputedFilters(
|
const filteredParams = this.rootStore.issueFilter.getComputedFilters(
|
||||||
workspaceId,
|
workspaceId,
|
||||||
projectId,
|
projectId,
|
||||||
null,
|
null,
|
||||||
@ -161,7 +150,7 @@ class IssueViewDetailStore implements IIssueViewDetailStore {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
deleteIssueAsync = async (workspaceId: string, projectId: string, issueId: string) => {
|
deleteIssue = async (workspaceId: string, projectId: string, issueId: string) => {
|
||||||
try {
|
try {
|
||||||
this.loader = true;
|
this.loader = true;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
@ -183,4 +172,4 @@ class IssueViewDetailStore implements IIssueViewDetailStore {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export default IssueViewDetailStore;
|
export default IssueDetailStore;
|
||||||
|
Loading…
Reference in New Issue
Block a user