ФУНКЦИИ - МЕЖПРОЕКТНАЯ КОММУНИКАЦИЯ: web-доступ к внешним контурам и исправление модалки запроса

This commit is contained in:
DCCONSTRUCTIONS
2026-04-19 00:07:10 +03:00
parent 6d67571b27
commit 3fe3539614
21 changed files with 707 additions and 42 deletions
@@ -5,7 +5,13 @@
*/
import { API_BASE_URL } from "@plane/constants";
import type { TExternalContourRequest, TExternalContourRequestResponse, TIssue } from "@plane/types";
import type {
TExternalContourRequest,
TExternalContourRequestResponse,
TExternalContourTargetOptions,
TExternalContourTargetProject,
TIssue,
} from "@plane/types";
import { APIService } from "@/services/api.service";
export class ExternalContourService extends APIService {
@@ -29,6 +35,26 @@ export class ExternalContourService extends APIService {
});
}
async listTargetProjects(workspaceSlug: string, projectId: string): Promise<TExternalContourTargetProject[]> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/external-contours/targets/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async retrieveTargetOptions(
workspaceSlug: string,
projectId: string,
targetProjectId: string
): Promise<TExternalContourTargetOptions> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/external-contours/targets/${targetProjectId}/options/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async create(
workspaceSlug: string,
projectId: string,
@@ -6,7 +6,13 @@
import { set } from "lodash-es";
import { action, computed, makeObservable, observable, runInAction } from "mobx";
import type { TExternalContourRequest, TInboxIssueCurrentTab, TIssue } from "@plane/types";
import type {
TExternalContourRequest,
TExternalContourTargetOptions,
TExternalContourTargetProject,
TInboxIssueCurrentTab,
TIssue,
} from "@plane/types";
import { EInboxIssueCurrentTab } from "@plane/types";
import { ExternalContourService } from "@/services/external-contours";
import type { CoreRootStore } from "../root.store";
@@ -20,15 +26,22 @@ export interface IProjectExternalContoursStore {
loader: TLoader;
requestIds: string[];
requests: Record<string, TExternalContourRequest>;
targetProjectIds: string[];
targetProjects: Record<string, TExternalContourTargetProject>;
targetOptionsMap: Record<string, TExternalContourTargetOptions>;
createRequest: (
workspaceSlug: string,
projectId: string,
data: Partial<TIssue> & { target_project_id?: string | null }
) => Promise<TExternalContourRequest | undefined>;
fetchTargetProjects: (workspaceSlug: string, projectId: string) => Promise<void>;
fetchTargetOptions: (workspaceSlug: string, projectId: string, targetProjectId: string) => Promise<TExternalContourTargetOptions | undefined>;
fetchRequestById: (workspaceSlug: string, projectId: string, requestId: string) => Promise<TExternalContourRequest | undefined>;
fetchRequests: (workspaceSlug: string, projectId: string, tab?: TInboxIssueCurrentTab) => Promise<void>;
getIsRequestAvailable: (requestId: string) => boolean;
getRequestById: (requestId: string) => TExternalContourRequest | undefined;
getTargetProjectById: (projectId: string | null | undefined) => TExternalContourTargetProject | undefined;
getTargetOptionsByProjectId: (projectId: string | null | undefined) => TExternalContourTargetOptions | undefined;
handleCurrentTab: (workspaceSlug: string, projectId: string, tab: TInboxIssueCurrentTab) => Promise<void>;
openRequestIds: string[];
closedRequestIds: string[];
@@ -44,6 +57,9 @@ export class ProjectExternalContoursStore implements IProjectExternalContoursSto
loader: TLoader = "init-loading";
requestIds: string[] = [];
requests: Record<string, TExternalContourRequest> = {};
targetProjectIds: string[] = [];
targetProjects: Record<string, TExternalContourTargetProject> = {};
targetOptionsMap: Record<string, TExternalContourTargetOptions> = {};
externalContourService;
@@ -55,9 +71,14 @@ export class ProjectExternalContoursStore implements IProjectExternalContoursSto
loader: observable.ref,
requestIds: observable.shallow,
requests: observable,
targetProjectIds: observable.shallow,
targetProjects: observable,
targetOptionsMap: observable,
openRequestIds: computed,
closedRequestIds: computed,
filteredRequestIds: computed,
fetchTargetProjects: action,
fetchTargetOptions: action,
fetchRequests: action,
fetchRequestById: action,
createRequest: action,
@@ -82,6 +103,9 @@ export class ProjectExternalContoursStore implements IProjectExternalContoursSto
}
getRequestById = (requestId: string) => this.requests[requestId];
getTargetProjectById = (projectId: string | null | undefined) => (projectId ? this.targetProjects[projectId] : undefined);
getTargetOptionsByProjectId = (projectId: string | null | undefined) =>
projectId ? this.targetOptionsMap[projectId] : undefined;
getIsRequestAvailable = (requestId: string) => this.requestIds.includes(requestId);
@@ -97,6 +121,40 @@ export class ProjectExternalContoursStore implements IProjectExternalContoursSto
});
};
fetchTargetProjects = async (workspaceSlug: string, projectId: string) => {
try {
const projects = await this.externalContourService.listTargetProjects(workspaceSlug, projectId);
runInAction(() => {
this.targetProjectIds = [];
this.targetProjects = {};
projects.forEach((project) => {
set(this.targetProjects, project.id, project);
this.targetProjectIds.push(project.id);
});
});
} catch (error) {
runInAction(() => {
this.targetProjectIds = [];
this.targetProjects = {};
});
throw error;
}
};
fetchTargetOptions = async (workspaceSlug: string, projectId: string, targetProjectId: string) => {
try {
const options = await this.externalContourService.retrieveTargetOptions(workspaceSlug, projectId, targetProjectId);
runInAction(() => {
set(this.targetOptionsMap, targetProjectId, options);
set(this.targetProjects, targetProjectId, options.project);
if (!this.targetProjectIds.includes(targetProjectId)) this.targetProjectIds.push(targetProjectId);
});
return options;
} catch (error) {
throw error;
}
};
handleCurrentTab = async (workspaceSlug: string, projectId: string, tab: TInboxIssueCurrentTab) => {
this.currentTab = tab;
await this.fetchRequests(workspaceSlug, projectId, tab);