mirror of
https://github.com/makeplane/plane.git
synced 2026-01-27 16:49:09 -06:00
[WEB-3066] refactor: replace Space Services with Services Package (#6353)
* [WEB-3066] refactor: replace Space Services with Services Package * chore: minor improvements * fix: type --------- Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
This commit is contained in:
@@ -34,7 +34,19 @@ export abstract class APIService {
|
||||
(error) => {
|
||||
if (error.response && error.response.status === 401) {
|
||||
const currentPath = window.location.pathname;
|
||||
window.location.replace(`/${currentPath ? `?next_path=${currentPath}` : ``}`);
|
||||
let prefix = "";
|
||||
let updatedPath = currentPath;
|
||||
|
||||
// Check for special path prefixes
|
||||
if (currentPath.startsWith("/god-mode")) {
|
||||
prefix = "/god-mode";
|
||||
updatedPath = currentPath.replace("/god-mode", "");
|
||||
} else if (currentPath.startsWith("/spaces")) {
|
||||
prefix = "/spaces";
|
||||
updatedPath = currentPath.replace("/spaces", "");
|
||||
}
|
||||
|
||||
window.location.replace(`${prefix}${updatedPath ? `?next_path=${updatedPath}` : ""}`);
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./auth.service";
|
||||
export * from "./sites-auth.service";
|
||||
|
||||
49
packages/services/src/auth/sites-auth.service.ts
Normal file
49
packages/services/src/auth/sites-auth.service.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
// types
|
||||
import { IEmailCheckData, IEmailCheckResponse } from "@plane/types";
|
||||
// services
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
/**
|
||||
* Service class for handling authentication-related operations for Plane space application
|
||||
* Provides methods for user authentication, password management, and session handling
|
||||
* @extends {APIService}
|
||||
* @remarks This service is only available for plane sites
|
||||
*/
|
||||
export class SitesAuthService extends APIService {
|
||||
/**
|
||||
* Creates an instance of SitesAuthService
|
||||
* Initializes with the base API URL
|
||||
*/
|
||||
constructor(BASE_URL?: string) {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an email exists in the system
|
||||
* @param {IEmailCheckData} data - Email data to verify
|
||||
* @returns {Promise<IEmailCheckResponse>} Response indicating email status
|
||||
* @throws {Error} Throws response data if the request fails
|
||||
*/
|
||||
async emailCheck(data: IEmailCheckData): Promise<IEmailCheckResponse> {
|
||||
return this.post("/auth/spaces/email-check/", data, { headers: {} })
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique code for magic link authentication
|
||||
* @param {{ email: string }} data - Object containing the email address
|
||||
* @returns {Promise<any>} Response containing the generated unique code
|
||||
* @throws {Error} Throws response data if the request fails
|
||||
*/
|
||||
async generateUniqueCode(data: { email: string }): Promise<any> {
|
||||
return this.post("/auth/spaces/magic-generate/", data, { headers: {} })
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2,3 +2,4 @@ export * from "./cycle-analytics.service";
|
||||
export * from "./cycle-archive.service";
|
||||
export * from "./cycle-operations.service";
|
||||
export * from "./cycle.service";
|
||||
export * from "./sites-cycle.service";
|
||||
|
||||
31
packages/services/src/cycle/sites-cycle.service.ts
Normal file
31
packages/services/src/cycle/sites-cycle.service.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { TPublicCycle } from "@plane/types";
|
||||
// api service
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
/**
|
||||
* Service class for managing cycles within plane sites application.
|
||||
* Extends APIService to handle HTTP requests to the cycle-related endpoints.
|
||||
* @extends {APIService}
|
||||
* @remarks This service is only available for plane sites
|
||||
*/
|
||||
export class SitesCycleService extends APIService {
|
||||
constructor(BASE_URL?: string) {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves list of cycles for a specific anchor.
|
||||
* @param anchor - The anchor identifier for the published entity
|
||||
* @returns {Promise<TPublicCycle[]>} The list of cycles
|
||||
* @throws {Error} If the request fails
|
||||
*/
|
||||
async list(anchor: string): Promise<TPublicCycle[]> {
|
||||
return this.get(`/api/public/anchor/${anchor}/cycles/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
import axios from "axios";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
// api service
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
/**
|
||||
* Service class for handling file upload operations
|
||||
* Handles file uploads
|
||||
* @extends {APIService}
|
||||
*/
|
||||
export class FileUploadService extends APIService {
|
||||
private cancelSource: any;
|
||||
|
||||
@@ -9,7 +14,17 @@ export class FileUploadService extends APIService {
|
||||
super("");
|
||||
}
|
||||
|
||||
async uploadFile(url: string, data: FormData): Promise<void> {
|
||||
/**
|
||||
* Uploads a file to the specified signed URL
|
||||
* @param {string} url - The URL to upload the file to
|
||||
* @param {FormData} data - The form data to upload
|
||||
* @returns {Promise<void>} Promise resolving to void
|
||||
* @throws {Error} If the request fails
|
||||
*/
|
||||
async uploadFile(
|
||||
url: string,
|
||||
data: FormData,
|
||||
): Promise<void> {
|
||||
this.cancelSource = axios.CancelToken.source();
|
||||
return this.post(url, data, {
|
||||
headers: {
|
||||
@@ -28,7 +43,10 @@ export class FileUploadService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the upload
|
||||
*/
|
||||
cancelUpload() {
|
||||
this.cancelSource.cancel("Upload canceled");
|
||||
}
|
||||
}
|
||||
}
|
||||
67
packages/services/src/file/file.service.ts
Normal file
67
packages/services/src/file/file.service.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
// api service
|
||||
import { APIService } from "../api.service";
|
||||
// helpers
|
||||
import { getAssetIdFromUrl } from "./helper";
|
||||
|
||||
/**
|
||||
* Service class for managing file operations within plane applications.
|
||||
* Extends APIService to handle HTTP requests to the file-related endpoints.
|
||||
* @extends {APIService}
|
||||
*/
|
||||
export class FileService extends APIService {
|
||||
/**
|
||||
* Creates an instance of FileService
|
||||
* @param {string} BASE_URL - The base URL for API requests
|
||||
*/
|
||||
constructor(BASE_URL?: string) {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a new asset
|
||||
* @param {string} assetPath - The asset path
|
||||
* @returns {Promise<void>} Promise resolving to void
|
||||
* @throws {Error} If the request fails
|
||||
*/
|
||||
async deleteNewAsset(assetPath: string): Promise<void> {
|
||||
return this.delete(assetPath)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an old editor asset
|
||||
* @param {string} workspaceId - The workspace identifier
|
||||
* @param {string} src - The asset source
|
||||
* @returns {Promise<any>} Promise resolving to void
|
||||
* @throws {Error} If the request fails
|
||||
*/
|
||||
async deleteOldEditorAsset(workspaceId: string, src: string): Promise<any> {
|
||||
const assetKey = getAssetIdFromUrl(src);
|
||||
return this.delete(`/api/workspaces/file-assets/${workspaceId}/${assetKey}/`)
|
||||
.then((response) => response?.status)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores an old editor asset
|
||||
* @param {string} workspaceId - The workspace identifier
|
||||
* @param {string} src - The asset source
|
||||
* @returns {Promise<void>} Promise resolving to void
|
||||
* @throws {Error} If the request fails
|
||||
*/
|
||||
async restoreOldEditorAsset(workspaceId: string, src: string): Promise<void> {
|
||||
const assetKey = getAssetIdFromUrl(src);
|
||||
return this.post(`/api/workspaces/file-assets/${workspaceId}/${assetKey}/restore/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
36
packages/services/src/file/helper.ts
Normal file
36
packages/services/src/file/helper.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { TFileMetaDataLite, TFileSignedURLResponse } from "@plane/types";
|
||||
|
||||
/**
|
||||
* @description from the provided signed URL response, generate a payload to be used to upload the file
|
||||
* @param {TFileSignedURLResponse} signedURLResponse
|
||||
* @param {File} file
|
||||
* @returns {FormData} file upload request payload
|
||||
*/
|
||||
export const generateFileUploadPayload = (signedURLResponse: TFileSignedURLResponse, file: File): FormData => {
|
||||
const formData = new FormData();
|
||||
Object.entries(signedURLResponse.upload_data.fields).forEach(([key, value]) => formData.append(key, value));
|
||||
formData.append("file", file);
|
||||
return formData;
|
||||
};
|
||||
|
||||
/**
|
||||
* @description returns the necessary file meta data to upload a file
|
||||
* @param {File} file
|
||||
* @returns {TFileMetaDataLite} payload with file info
|
||||
*/
|
||||
export const getFileMetaDataForUpload = (file: File): TFileMetaDataLite => ({
|
||||
name: file.name,
|
||||
size: file.size,
|
||||
type: file.type,
|
||||
});
|
||||
|
||||
/**
|
||||
* @description this function returns the assetId from the asset source
|
||||
* @param {string} src
|
||||
* @returns {string} assetId
|
||||
*/
|
||||
export const getAssetIdFromUrl = (src: string): string => {
|
||||
const sourcePaths = src.split("/");
|
||||
const assetUrl = sourcePaths[sourcePaths.length - 1];
|
||||
return assetUrl;
|
||||
};
|
||||
3
packages/services/src/file/index.ts
Normal file
3
packages/services/src/file/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from "./file-upload.service";
|
||||
export * from "./sites-file.service";
|
||||
export * from "./file.service";
|
||||
@@ -1,22 +1,40 @@
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
// local services
|
||||
import { TFileEntityInfo, TFileSignedURLResponse } from "@plane/types";
|
||||
import { FileUploadService } from "./file-upload.service";
|
||||
// helpers
|
||||
import { generateFileUploadPayload, getAssetIdFromUrl, getFileMetaDataForUpload } from "@/helpers/file.helper";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
import { FileUploadService } from "@/services/file-upload.service";
|
||||
import { FileService } from "./file.service";
|
||||
import { generateFileUploadPayload, getAssetIdFromUrl, getFileMetaDataForUpload } from "./helper";
|
||||
|
||||
export class FileService extends APIService {
|
||||
/**
|
||||
* Service class for managing file operations within plane sites application.
|
||||
* Extends FileService to manage file-related operations.
|
||||
* @extends {FileService}
|
||||
* @remarks This service is only available for plane sites
|
||||
*/
|
||||
export class SitesFileService extends FileService {
|
||||
private cancelSource: any;
|
||||
fileUploadService: FileUploadService;
|
||||
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
/**
|
||||
* Creates an instance of SitesFileService
|
||||
* @param {string} BASE_URL - The base URL for API requests
|
||||
*/
|
||||
constructor(BASE_URL?: string) {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
this.cancelUpload = this.cancelUpload.bind(this);
|
||||
// services
|
||||
this.fileUploadService = new FileUploadService();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the upload status of an asset
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} assetId - The asset identifier
|
||||
* @returns {Promise<void>} Promise resolving to void
|
||||
* @throws {Error} If the request fails
|
||||
*/
|
||||
private async updateAssetUploadStatus(anchor: string, assetId: string): Promise<void> {
|
||||
return this.patch(`/api/public/assets/v2/anchor/${anchor}/${assetId}/`)
|
||||
.then((response) => response?.data)
|
||||
@@ -25,6 +43,14 @@ export class FileService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the upload status of multiple assets
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} entityId - The entity identifier
|
||||
* @param {Object} data - The data payload
|
||||
* @returns {Promise<void>} Promise resolving to void
|
||||
* @throws {Error} If the request fails
|
||||
*/
|
||||
async updateBulkAssetsUploadStatus(
|
||||
anchor: string,
|
||||
entityId: string,
|
||||
@@ -39,6 +65,14 @@ export class FileService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads a file to the specified anchor
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {TFileEntityInfo} data - The data payload
|
||||
* @param {File} file - The file to upload
|
||||
* @returns {Promise<TFileSignedURLResponse>} Promise resolving to the signed URL response
|
||||
* @throws {Error} If the request fails
|
||||
*/
|
||||
async uploadAsset(anchor: string, data: TFileEntityInfo, file: File): Promise<TFileSignedURLResponse> {
|
||||
const fileMetaData = getFileMetaDataForUpload(file);
|
||||
return this.post(`/api/public/assets/v2/anchor/${anchor}/`, {
|
||||
@@ -57,23 +91,13 @@ export class FileService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async deleteNewAsset(assetPath: string): Promise<void> {
|
||||
return this.delete(assetPath)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async deleteOldEditorAsset(workspaceId: string, src: string): Promise<any> {
|
||||
const assetKey = getAssetIdFromUrl(src);
|
||||
return this.delete(`/api/workspaces/file-assets/${workspaceId}/${assetKey}/`)
|
||||
.then((response) => response?.status)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores a new asset
|
||||
* @param {string} workspaceSlug - The workspace slug
|
||||
* @param {string} src - The asset source
|
||||
* @returns {Promise<void>} Promise resolving to void
|
||||
* @throws {Error} If the request fails
|
||||
*/
|
||||
async restoreNewAsset(workspaceSlug: string, src: string): Promise<void> {
|
||||
// remove the last slash and get the asset id
|
||||
const assetId = getAssetIdFromUrl(src);
|
||||
@@ -84,16 +108,10 @@ export class FileService extends APIService {
|
||||
});
|
||||
}
|
||||
|
||||
async restoreOldEditorAsset(workspaceId: string, src: string): Promise<void> {
|
||||
const assetKey = getAssetIdFromUrl(src);
|
||||
return this.post(`/api/workspaces/file-assets/${workspaceId}/${assetKey}/restore/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the upload
|
||||
*/
|
||||
cancelUpload() {
|
||||
this.cancelSource.cancel("Upload cancelled");
|
||||
this.cancelSource.cancelUpload();
|
||||
}
|
||||
}
|
||||
@@ -10,3 +10,7 @@ export * from "./module";
|
||||
export * from "./user";
|
||||
export * from "./project";
|
||||
export * from "./workspace";
|
||||
export * from "./file";
|
||||
export * from "./label";
|
||||
export * from "./state";
|
||||
export * from "./issue";
|
||||
|
||||
1
packages/services/src/issue/index.ts
Normal file
1
packages/services/src/issue/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./sites-issue.service";
|
||||
244
packages/services/src/issue/sites-issue.service.ts
Normal file
244
packages/services/src/issue/sites-issue.service.ts
Normal file
@@ -0,0 +1,244 @@
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { IPublicIssue, TIssuePublicComment, TPublicIssuesResponse } from "@plane/types";
|
||||
// api service
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
/**
|
||||
* Service class for managing issues within plane sites application
|
||||
* Extends the APIService class to handle HTTP requests to the issue-related endpoints
|
||||
* @extends {APIService}
|
||||
* @remarks This service is only available for plane sites
|
||||
*/
|
||||
export class SitesIssueService extends APIService {
|
||||
constructor(BASE_URL?: string) {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a paginated list of issues for a specific anchor
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {any} params - Optional query parameters
|
||||
* @returns {Promise<TPublicIssuesResponse>} Promise resolving to a paginated list of issues
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async list(anchor: string, params: any): Promise<TPublicIssuesResponse> {
|
||||
return this.get(`/api/public/anchor/${anchor}/issues/`, {
|
||||
params,
|
||||
})
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves details of a specific issue
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} issueID - The issue identifier
|
||||
* @returns {Promise<IPublicIssue>} Promise resolving to the issue details
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async retrieve(anchor: string, issueID: string): Promise<IPublicIssue> {
|
||||
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the votes associated with a specific issue
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} issueID - The issue identifier
|
||||
* @returns {Promise<any>} Promise resolving to the votes
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async listVotes(anchor: string, issueID: string): Promise<any> {
|
||||
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new vote for a specific issue
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} issueID - The issue identifier
|
||||
* @param {any} data - The vote data
|
||||
* @returns {Promise<any>} Promise resolving to the created vote
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async addVote(anchor: string, issueID: string, data: any): Promise<any> {
|
||||
return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a vote for a specific issue
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} issueID - The issue identifier
|
||||
* @returns {Promise<any>} Promise resolving to the deletion response
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async removeVote(anchor: string, issueID: string): Promise<any> {
|
||||
return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the reactions associated with a specific issue
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} issueID - The issue identifier
|
||||
* @returns {Promise<any>} Promise resolving to the reactions
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async listReactions(anchor: string, issueID: string): Promise<any> {
|
||||
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new reaction for a specific issue
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} issueID - The issue identifier
|
||||
* @param {any} data - The reaction data
|
||||
* @returns {Promise<any>} Promise resolving to the created reaction
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async addReaction(anchor: string, issueID: string, data: any): Promise<any> {
|
||||
return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a reaction for a specific issue
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} issueID - The issue identifier
|
||||
* @param {string} reactionId - The reaction identifier
|
||||
* @returns {Promise<any>} Promise resolving to the deletion response
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async removeReaction(anchor: string, issueID: string, reactionId: string): Promise<any> {
|
||||
return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/${reactionId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the comments associated with a specific issue
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} issueID - The issue identifier
|
||||
* @returns {Promise<any>} Promise resolving to the comments
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async listComments(anchor: string, issueID: string): Promise<any> {
|
||||
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/comments/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new comment for a specific issue
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} issueID - The issue identifier
|
||||
* @param {any} data - The comment data
|
||||
* @returns {Promise<TIssuePublicComment>} Promise resolving to the created comment
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async addComment(anchor: string, issueID: string, data: any): Promise<TIssuePublicComment> {
|
||||
return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/comments/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a comment for a specific issue
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} issueID - The issue identifier
|
||||
* @param {string} commentId - The comment identifier
|
||||
* @param {any} data - The updated comment data
|
||||
* @returns {Promise<any>} Promise resolving to the updated comment
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async updateComment(anchor: string, issueID: string, commentId: string, data: any): Promise<any> {
|
||||
return this.patch(`/api/public/anchor/${anchor}/issues/${issueID}/comments/${commentId}/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a comment for a specific issue
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} issueID - The issue identifier
|
||||
* @param {string} commentId - The comment identifier
|
||||
* @returns {Promise<any>} Promise resolving to the deletion response
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async removeComment(anchor: string, issueID: string, commentId: string): Promise<any> {
|
||||
return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/comments/${commentId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new reaction for a specific comment
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} commentId - The comment identifier
|
||||
* @param {any} data - The reaction data
|
||||
* @returns {Promise<any>} Promise resolving to the created reaction
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async addCommentReaction(
|
||||
anchor: string,
|
||||
commentId: string,
|
||||
data: {
|
||||
reaction: string;
|
||||
}
|
||||
): Promise<any> {
|
||||
return this.post(`/api/public/anchor/${anchor}/comments/${commentId}/reactions/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a reaction for a specific comment
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @param {string} commentId - The comment identifier
|
||||
* @param {string} reactionHex - The reaction identifier
|
||||
* @returns {Promise<any>} Promise resolving to the deletion response
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async removeCommentReaction(anchor: string, commentId: string, reactionHex: string): Promise<any> {
|
||||
return this.delete(`/api/public/anchor/${anchor}/comments/${commentId}/reactions/${reactionHex}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
}
|
||||
1
packages/services/src/label/index.ts
Normal file
1
packages/services/src/label/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./sites-label.service";
|
||||
31
packages/services/src/label/sites-label.service.ts
Normal file
31
packages/services/src/label/sites-label.service.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { IIssueLabel } from "@plane/types";
|
||||
// api service
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
/**
|
||||
* Service class for managing labels within plane sites application.
|
||||
* Extends APIService to handle HTTP requests to the label-related endpoints.
|
||||
* @extends {APIService}
|
||||
* @remarks This service is only available for plane sites
|
||||
*/
|
||||
export class SitesLabelService extends APIService {
|
||||
constructor(BASE_URL?: string) {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of labels for a specific anchor.
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @returns {Promise<IIssueLabel[]>} The list of labels
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async list(anchor: string): Promise<IIssueLabel[]> {
|
||||
return this.get(`/api/public/anchor/${anchor}/labels/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./link.service";
|
||||
export * from "./module.service";
|
||||
export * from "./operations.service";
|
||||
export * from "./sites-module.service";
|
||||
|
||||
31
packages/services/src/module/sites-module.service.ts
Normal file
31
packages/services/src/module/sites-module.service.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
// api service
|
||||
import { TPublicModule } from "@plane/types";
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
/**
|
||||
* Service class for managing modules within plane sites application.
|
||||
* Extends APIService to handle HTTP requests to the module-related endpoints.
|
||||
* @extends {APIService}
|
||||
* @remarks This service is only available for plane sites
|
||||
*/
|
||||
export class SitesModuleService extends APIService {
|
||||
constructor(BASE_URL?: string) {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of modules for a specific anchor.
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @returns {Promise<TPublicModule[]>} The list of modules
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async list(anchor: string): Promise<TPublicModule[]> {
|
||||
return this.get(`/api/public/anchor/${anchor}/modules/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./view.service";
|
||||
export * from "./view.service";
|
||||
export * from "./sites-publish.service";
|
||||
|
||||
46
packages/services/src/project/sites-publish.service.ts
Normal file
46
packages/services/src/project/sites-publish.service.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { TProjectPublishSettings } from "@plane/types";
|
||||
// api service
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
/**
|
||||
* Service class for managing project publish operations within plane sites application.
|
||||
* Extends APIService to handle HTTP requests to the project publish-related endpoints.
|
||||
* @extends {APIService}
|
||||
* @remarks This service is only available for plane sites
|
||||
*/
|
||||
export class SitesProjectPublishService extends APIService {
|
||||
constructor(BASE_URL?: string) {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves publish settings for a specific anchor.
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @returns {Promise<TProjectPublishSettings>} The publish settings
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async retrieveSettingsByAnchor(anchor: string): Promise<TProjectPublishSettings> {
|
||||
return this.get(`/api/public/anchor/${anchor}/settings/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves publish settings for a specific project.
|
||||
* @param {string} workspaceSlug - The workspace slug
|
||||
* @param {string} projectID - The project identifier
|
||||
* @returns {Promise<TProjectPublishSettings>} The publish settings
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async retrieveSettingsByProjectId(workspaceSlug: string, projectID: string): Promise<TProjectPublishSettings> {
|
||||
return this.get(`/api/public/workspaces/${workspaceSlug}/projects/${projectID}/anchor/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
}
|
||||
1
packages/services/src/state/index.ts
Normal file
1
packages/services/src/state/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./sites-state.service";
|
||||
31
packages/services/src/state/sites-state.service.ts
Normal file
31
packages/services/src/state/sites-state.service.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { IState } from "@plane/types";
|
||||
// api service
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
/**
|
||||
* Service class for managing states within plane sites application.
|
||||
* Extends APIService to handle HTTP requests to the state-related endpoints.
|
||||
* @extends {APIService}
|
||||
* @remarks This service is only available for plane sites
|
||||
*/
|
||||
export class SitesStateService extends APIService {
|
||||
constructor(BASE_URL?: string) {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of states for a specific anchor.
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @returns {Promise<IState[]>} The list of states
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async list(anchor: string): Promise<IState[]> {
|
||||
return this.get(`/api/public/anchor/${anchor}/states/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from "./favorite.service";
|
||||
export * from "./user.service";
|
||||
export * from "./sites-member.service";
|
||||
|
||||
31
packages/services/src/user/sites-member.service.ts
Normal file
31
packages/services/src/user/sites-member.service.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { TPublicMember } from "@plane/types";
|
||||
// api service
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
/**
|
||||
* Service class for managing members operations within plane sites application.
|
||||
* Extends APIService to handle HTTP requests to the member-related endpoints.
|
||||
* @extends {APIService}
|
||||
* @remarks This service is only available for plane sites
|
||||
*/
|
||||
export class SitesMemberService extends APIService {
|
||||
constructor(BASE_URL?: string) {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of members for a specific anchor.
|
||||
* @param {string} anchor - The anchor identifier
|
||||
* @returns {Promise<TPublicMember[]>} The list of members
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async list(anchor: string): Promise<TPublicMember[]> {
|
||||
return this.get(`/api/public/anchor/${anchor}/members/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import type { IUser } from "@plane/types";
|
||||
import type { IUser, TUserProfile } from "@plane/types";
|
||||
// api service
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
@@ -18,6 +18,60 @@ export class UserService extends APIService {
|
||||
super(BASE_URL || API_BASE_URL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current user details
|
||||
* @returns {Promise<IUser>} Promise resolving to the current user details\
|
||||
* @remarks This method uses the validateStatus: null option to bypass interceptors for unauthorized errors.
|
||||
*/
|
||||
async me(): Promise<IUser> {
|
||||
return this.get("/api/users/me/", { validateStatus: null })
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current user details
|
||||
* @param {Partial<IUser>} data Data to update the user with
|
||||
* @returns {Promise<IUser>} Promise resolving to the updated user details
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async update(data: Partial<IUser>): Promise<IUser> {
|
||||
return this.patch("/api/users/me/", data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current user's profile details
|
||||
* @returns {Promise<TUserProfile>} Promise resolving to the current user's profile details
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async profile(): Promise<TUserProfile> {
|
||||
return this.get("/api/users/me/profile/")
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the current user's profile details
|
||||
* @param {Partial<TUserProfile>} data Data to update the user's profile with
|
||||
* @returns {Promise<TUserProfile>} Promise resolving to the updated user's profile details
|
||||
* @throws {Error} If the API request fails
|
||||
*/
|
||||
async updateProfile(data: Partial<TUserProfile>): Promise<TUserProfile> {
|
||||
return this.patch("/api/users/me/profile/", data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the current instance admin details
|
||||
* @returns {Promise<IUser>} Promise resolving to the current instance admin details
|
||||
|
||||
1
packages/types/src/auth.d.ts
vendored
1
packages/types/src/auth.d.ts
vendored
@@ -7,6 +7,7 @@ export interface IEmailCheckData {
|
||||
export interface IEmailCheckResponse {
|
||||
status: "MAGIC_CODE" | "CREDENTIAL";
|
||||
existing: boolean;
|
||||
is_password_autoset: boolean;
|
||||
}
|
||||
|
||||
export interface ILoginTokenResponse {
|
||||
|
||||
6
packages/types/src/cycle/cycle.d.ts
vendored
6
packages/types/src/cycle/cycle.d.ts
vendored
@@ -132,3 +132,9 @@ export type CycleDateCheckData = {
|
||||
|
||||
export type TCycleEstimateType = "issues" | "points";
|
||||
export type TCyclePlotType = "burndown" | "burnup";
|
||||
|
||||
export type TPublicCycle = {
|
||||
id: string;
|
||||
name: string;
|
||||
status: string;
|
||||
};
|
||||
|
||||
@@ -37,3 +37,30 @@ export type TIssueCommentMap = {
|
||||
export type TIssueCommentIdMap = {
|
||||
[issue_id: string]: string[];
|
||||
};
|
||||
|
||||
export type TIssuePublicComment = {
|
||||
actor_detail: ActorDetail;
|
||||
access: string;
|
||||
actor: string;
|
||||
attachments: any[];
|
||||
comment_html: string;
|
||||
comment_reactions: {
|
||||
actor_detail: ActorDetail;
|
||||
comment: string;
|
||||
id: string;
|
||||
reaction: string;
|
||||
}[];
|
||||
comment_stripped: string;
|
||||
created_at: Date;
|
||||
created_by: string;
|
||||
id: string;
|
||||
is_member: boolean;
|
||||
issue: string;
|
||||
issue_detail: IssueDetail;
|
||||
project: string;
|
||||
project_detail: ProjectDetail;
|
||||
updated_at: Date;
|
||||
updated_by: string;
|
||||
workspace: string;
|
||||
workspace_detail: IWorkspaceLite;
|
||||
};
|
||||
|
||||
73
packages/types/src/issues/issue.d.ts
vendored
73
packages/types/src/issues/issue.d.ts
vendored
@@ -2,8 +2,8 @@ import { EIssueServiceType } from "@plane/constants";
|
||||
import { TIssuePriorities } from "../issues";
|
||||
import { TIssueAttachment } from "./issue_attachment";
|
||||
import { TIssueLink } from "./issue_link";
|
||||
import { TIssueReaction } from "./issue_reaction";
|
||||
import { TIssueRelationTypes } from "@/plane-web/types";
|
||||
import { TIssueReaction, IIssuePublicReaction, IPublicVote } from "./issue_reaction";
|
||||
import { TIssueRelationTypes, TIssuePublicComment } from "@/plane-web/types";
|
||||
|
||||
// new issue structure types
|
||||
|
||||
@@ -118,12 +118,65 @@ export type TBulkOperationsPayload = {
|
||||
properties: Partial<TBulkIssueProperties>;
|
||||
};
|
||||
|
||||
export type TIssueDetailWidget =
|
||||
| "sub-issues"
|
||||
| "relations"
|
||||
| "links"
|
||||
| "attachments";
|
||||
export type TIssueDetailWidget = "sub-issues" | "relations" | "links" | "attachments";
|
||||
|
||||
export type TIssueServiceType =
|
||||
| EIssueServiceType.ISSUES
|
||||
| EIssueServiceType.EPICS;
|
||||
export type TIssueServiceType = EIssueServiceType.ISSUES | EIssueServiceType.EPICS;
|
||||
|
||||
export interface IPublicIssue
|
||||
extends Pick<
|
||||
TIssue,
|
||||
| "description_html"
|
||||
| "created_at"
|
||||
| "updated_at"
|
||||
| "created_by"
|
||||
| "id"
|
||||
| "name"
|
||||
| "priority"
|
||||
| "state_id"
|
||||
| "project_id"
|
||||
| "sequence_id"
|
||||
| "sort_order"
|
||||
| "start_date"
|
||||
| "target_date"
|
||||
| "cycle_id"
|
||||
| "module_ids"
|
||||
| "label_ids"
|
||||
| "assignee_ids"
|
||||
| "attachment_count"
|
||||
| "sub_issues_count"
|
||||
| "link_count"
|
||||
| "estimate_point"
|
||||
> {
|
||||
comments: TIssuePublicComment[];
|
||||
reaction_items: IIssuePublicReaction[];
|
||||
vote_items: IPublicVote[];
|
||||
}
|
||||
|
||||
type TPublicIssueResponseResults =
|
||||
| IPublicIssue[]
|
||||
| {
|
||||
[key: string]: {
|
||||
results:
|
||||
| IPublicIssue[]
|
||||
| {
|
||||
[key: string]: {
|
||||
results: IPublicIssue[];
|
||||
total_results: number;
|
||||
};
|
||||
};
|
||||
total_results: number;
|
||||
};
|
||||
};
|
||||
|
||||
export type TPublicIssuesResponse = {
|
||||
grouped_by: string;
|
||||
next_cursor: string;
|
||||
prev_cursor: string;
|
||||
next_page_results: boolean;
|
||||
prev_page_results: boolean;
|
||||
total_count: number;
|
||||
count: number;
|
||||
total_pages: number;
|
||||
extra_stats: null;
|
||||
results: TPublicIssueResponseResults;
|
||||
};
|
||||
|
||||
12
packages/types/src/issues/issue_reaction.d.ts
vendored
12
packages/types/src/issues/issue_reaction.d.ts
vendored
@@ -1,3 +1,5 @@
|
||||
import { IUserLite } from "../users";
|
||||
|
||||
export type TIssueReaction = {
|
||||
actor: string;
|
||||
id: string;
|
||||
@@ -5,6 +7,11 @@ export type TIssueReaction = {
|
||||
reaction: string;
|
||||
};
|
||||
|
||||
export interface IIssuePublicReaction {
|
||||
actor_details: IUserLite;
|
||||
reaction: string;
|
||||
}
|
||||
|
||||
export type TIssueReactionMap = {
|
||||
[reaction_id: string]: TIssueReaction;
|
||||
};
|
||||
@@ -12,3 +19,8 @@ export type TIssueReactionMap = {
|
||||
export type TIssueReactionIdMap = {
|
||||
[issue_id: string]: { [reaction: string]: string[] };
|
||||
};
|
||||
|
||||
export interface IPublicVote {
|
||||
vote: -1 | 1;
|
||||
actor_details: IUserLite;
|
||||
}
|
||||
|
||||
5
packages/types/src/module/modules.d.ts
vendored
5
packages/types/src/module/modules.d.ts
vendored
@@ -117,3 +117,8 @@ export type SelectModuleType =
|
||||
| undefined;
|
||||
|
||||
export type TModulePlotType = "burndown" | "points";
|
||||
|
||||
export type TPublicModule = {
|
||||
id: string;
|
||||
name: string;
|
||||
};
|
||||
|
||||
11
packages/types/src/users.d.ts
vendored
11
packages/types/src/users.d.ts
vendored
@@ -182,6 +182,17 @@ export interface IUserEmailNotificationSettings {
|
||||
|
||||
export type TProfileViews = "assigned" | "created" | "subscribed";
|
||||
|
||||
export type TPublicMember = {
|
||||
id: string;
|
||||
member: string;
|
||||
member__avatar: string;
|
||||
member__first_name: string;
|
||||
member__last_name: string;
|
||||
member__display_name: string;
|
||||
project: string;
|
||||
workspace: string;
|
||||
};
|
||||
|
||||
// export interface ICurrentUser {
|
||||
// id: readonly string;
|
||||
// avatar: string;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { notFound, redirect } from "next/navigation";
|
||||
// types
|
||||
// plane imports
|
||||
import { SitesProjectPublishService } from "@plane/services";
|
||||
import { TProjectPublishSettings } from "@plane/types";
|
||||
// services
|
||||
import PublishService from "@/services/publish.service";
|
||||
|
||||
const publishService = new PublishService();
|
||||
const publishService = new SitesProjectPublishService();
|
||||
|
||||
type Props = {
|
||||
params: {
|
||||
@@ -22,7 +21,7 @@ export default async function IssuesPage(props: Props) {
|
||||
|
||||
let response: TProjectPublishSettings | undefined = undefined;
|
||||
try {
|
||||
response = await publishService.fetchAnchorFromProjectDetails(workspaceSlug, projectId);
|
||||
response = await publishService.retrieveSettingsByProjectId(workspaceSlug, projectId);
|
||||
} catch (error) {
|
||||
// redirect to 404 page on error
|
||||
notFound();
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
import React, { FC, useEffect, useState } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
// plane imports
|
||||
import { SitesAuthService } from "@plane/services";
|
||||
import { IEmailCheckData } from "@plane/types";
|
||||
// components
|
||||
import {
|
||||
@@ -23,12 +25,10 @@ import {
|
||||
} from "@/helpers/authentication.helper";
|
||||
// hooks
|
||||
import { useInstance } from "@/hooks/store";
|
||||
// services
|
||||
import { AuthService } from "@/services/auth.service";
|
||||
// types
|
||||
import { EAuthModes, EAuthSteps } from "@/types/auth";
|
||||
|
||||
const authService = new AuthService();
|
||||
const authService = new SitesAuthService();
|
||||
|
||||
export const AuthRoot: FC = observer(() => {
|
||||
// router params
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Eye, EyeOff, XCircle } from "lucide-react";
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { AuthService } from "@plane/services";
|
||||
import { Button, Input, Spinner } from "@plane/ui";
|
||||
// components
|
||||
import { PasswordStrengthMeter } from "@/components/account";
|
||||
// helpers
|
||||
import { E_PASSWORD_STRENGTH, getPasswordStrength } from "@/helpers/password.helper";
|
||||
// services
|
||||
import { AuthService } from "@/services/auth.service";
|
||||
// types
|
||||
import { EAuthModes, EAuthSteps } from "@/types/auth";
|
||||
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { CircleCheck, XCircle } from "lucide-react";
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { AuthService } from "@plane/services";
|
||||
import { Button, Input, Spinner } from "@plane/ui";
|
||||
// hooks
|
||||
import useTimer from "@/hooks/use-timer";
|
||||
// services
|
||||
import { AuthService } from "@/services/auth.service";
|
||||
// types
|
||||
import { EAuthModes } from "@/types/auth";
|
||||
|
||||
|
||||
@@ -7,15 +7,15 @@ import { usePathname, useSearchParams } from "next/navigation";
|
||||
import { usePopper } from "react-popper";
|
||||
import { LogOut } from "lucide-react";
|
||||
import { Popover, Transition } from "@headlessui/react";
|
||||
// plane imports
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { AuthService } from "@plane/services";
|
||||
import { Avatar, Button } from "@plane/ui";
|
||||
// helpers
|
||||
import { getFileURL } from "@/helpers/file.helper";
|
||||
import { queryParamGenerator } from "@/helpers/query-param-generator";
|
||||
// hooks
|
||||
import { useUser } from "@/hooks/store";
|
||||
// services
|
||||
import { AuthService } from "@/services/auth.service";
|
||||
|
||||
const authService = new AuthService();
|
||||
|
||||
|
||||
@@ -3,21 +3,19 @@
|
||||
import React, { useRef, useState } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
// editor
|
||||
// plane imports
|
||||
import { EditorRefApi } from "@plane/editor";
|
||||
// ui
|
||||
import { SitesFileService } from "@plane/services";
|
||||
import { TIssuePublicComment } from "@plane/types";
|
||||
import { TOAST_TYPE, setToast } from "@plane/ui";
|
||||
// editor components
|
||||
import { LiteTextEditor } from "@/components/editor/lite-text-editor";
|
||||
// hooks
|
||||
import { useIssueDetails, usePublish, useUser } from "@/hooks/store";
|
||||
// services
|
||||
import { FileService } from "@/services/file.service";
|
||||
const fileService = new FileService();
|
||||
// types
|
||||
import { Comment } from "@/types/issue";
|
||||
const fileService = new SitesFileService();
|
||||
|
||||
const defaultValues: Partial<Comment> = {
|
||||
const defaultValues: Partial<TIssuePublicComment> = {
|
||||
comment_html: "",
|
||||
};
|
||||
|
||||
@@ -43,9 +41,9 @@ export const AddComment: React.FC<Props> = observer((props) => {
|
||||
watch,
|
||||
formState: { isSubmitting },
|
||||
reset,
|
||||
} = useForm<Comment>({ defaultValues });
|
||||
} = useForm<TIssuePublicComment>({ defaultValues });
|
||||
|
||||
const onSubmit = async (formData: Comment) => {
|
||||
const onSubmit = async (formData: TIssuePublicComment) => {
|
||||
if (!anchor || !issueId || isSubmitting || !formData.comment_html) return;
|
||||
|
||||
await addIssueComment(anchor, issueId, formData)
|
||||
|
||||
@@ -3,8 +3,10 @@ import { observer } from "mobx-react";
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { Check, MessageSquare, MoreVertical, X } from "lucide-react";
|
||||
import { Menu, Transition } from "@headlessui/react";
|
||||
// components
|
||||
// plane imports
|
||||
import { EditorRefApi } from "@plane/editor";
|
||||
import { TIssuePublicComment } from "@plane/types";
|
||||
// components
|
||||
import { LiteTextEditor, LiteTextReadOnlyEditor } from "@/components/editor";
|
||||
import { CommentReactions } from "@/components/issues/peek-overview";
|
||||
// helpers
|
||||
@@ -13,12 +15,10 @@ import { getFileURL } from "@/helpers/file.helper";
|
||||
// hooks
|
||||
import { useIssueDetails, usePublish, useUser } from "@/hooks/store";
|
||||
import useIsInIframe from "@/hooks/use-is-in-iframe";
|
||||
// types
|
||||
import { Comment } from "@/types/issue";
|
||||
|
||||
type Props = {
|
||||
anchor: string;
|
||||
comment: Comment;
|
||||
comment: TIssuePublicComment;
|
||||
};
|
||||
|
||||
export const CommentCard: React.FC<Props> = observer((props) => {
|
||||
@@ -48,7 +48,7 @@ export const CommentCard: React.FC<Props> = observer((props) => {
|
||||
deleteIssueComment(anchor, peekId, comment.id);
|
||||
};
|
||||
|
||||
const handleCommentUpdate = async (formData: Comment) => {
|
||||
const handleCommentUpdate = async (formData: TIssuePublicComment) => {
|
||||
if (!anchor || !peekId) return;
|
||||
updateIssueComment(anchor, peekId, comment.id, formData);
|
||||
setIsEditing(false);
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { useRef, useEffect } from "react";
|
||||
import useSWR from "swr";
|
||||
// types
|
||||
// plane imports
|
||||
import { UserService } from "@plane/services";
|
||||
import { IUser } from "@plane/types";
|
||||
// services
|
||||
import { UserService } from "@/services/user.service";
|
||||
|
||||
export const useMention = () => {
|
||||
const userService = new UserService();
|
||||
const { data: user, isLoading: userDataLoading } = useSWR("currentUser", async () => userService.currentUser());
|
||||
const { data: user, isLoading: userDataLoading } = useSWR("currentUser", async () => userService.me());
|
||||
|
||||
const userRef = useRef<IUser | undefined>();
|
||||
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import axios, { AxiosInstance } from "axios";
|
||||
// store
|
||||
// import { rootStore } from "@/lib/store-context";
|
||||
|
||||
export abstract class APIService {
|
||||
protected baseURL: string | undefined;
|
||||
private axiosInstance: AxiosInstance;
|
||||
|
||||
constructor(baseURL: string | undefined) {
|
||||
this.baseURL = baseURL;
|
||||
this.axiosInstance = axios.create({
|
||||
baseURL: baseURL || "",
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
this.setupInterceptors();
|
||||
}
|
||||
|
||||
private setupInterceptors() {
|
||||
// this.axiosInstance.interceptors.response.use(
|
||||
// (response) => response,
|
||||
// (error) => {
|
||||
// const store = rootStore;
|
||||
// if (error.response && error.response.status === 401 && store.user.data) store.user.reset();
|
||||
// return Promise.reject(error);
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
get(url: string, params = {}) {
|
||||
return this.axiosInstance.get(url, params);
|
||||
}
|
||||
|
||||
post(url: string, data = {}, config = {}) {
|
||||
return this.axiosInstance.post(url, data, config);
|
||||
}
|
||||
|
||||
put(url: string, data = {}, config = {}) {
|
||||
return this.axiosInstance.put(url, data, config);
|
||||
}
|
||||
|
||||
patch(url: string, data = {}, config = {}) {
|
||||
return this.axiosInstance.patch(url, data, config);
|
||||
}
|
||||
|
||||
delete(url: string, data?: any, config = {}) {
|
||||
return this.axiosInstance.delete(url, { data, ...config });
|
||||
}
|
||||
|
||||
request(config = {}) {
|
||||
return this.axiosInstance(config);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
// types
|
||||
import { ICsrfTokenData, IEmailCheckData, IEmailCheckResponse } from "@/types/auth";
|
||||
|
||||
export class AuthService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async requestCSRFToken(): Promise<ICsrfTokenData> {
|
||||
return this.get("/auth/get-csrf-token/")
|
||||
.then((response) => response.data)
|
||||
.catch((error) => {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
|
||||
async emailCheck(data: IEmailCheckData): Promise<IEmailCheckResponse> {
|
||||
return this.post("/auth/spaces/email-check/", data, { headers: {} })
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async generateUniqueCode(data: { email: string }): Promise<void> {
|
||||
return this.post("/auth/spaces/magic-generate/", data, { headers: {} })
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
// types
|
||||
import { TPublicCycle } from "@/types/cycle";
|
||||
|
||||
export class CycleService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async getCycles(anchor: string): Promise<TPublicCycle[]> {
|
||||
return this.get(`/api/public/anchor/${anchor}/cycles/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import type { IInstanceInfo } from "@plane/types";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
|
||||
export class InstanceService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async getInstanceInfo(): Promise<IInstanceInfo> {
|
||||
return this.get("/api/instances/")
|
||||
.then((response) => response.data)
|
||||
.catch((error) => {
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
// types
|
||||
import { Comment, TIssuesResponse, IIssue } from "@/types/issue";
|
||||
|
||||
class IssueService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async fetchPublicIssues(anchor: string, params: any): Promise<TIssuesResponse> {
|
||||
return this.get(`/api/public/anchor/${anchor}/issues/`, {
|
||||
params,
|
||||
})
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async getIssueById(anchor: string, issueID: string): Promise<IIssue> {
|
||||
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async getIssueVotes(anchor: string, issueID: string): Promise<any> {
|
||||
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async createIssueVote(anchor: string, issueID: string, data: any): Promise<any> {
|
||||
return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async deleteIssueVote(anchor: string, issueID: string): Promise<any> {
|
||||
return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/votes/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async getIssueReactions(anchor: string, issueID: string): Promise<any> {
|
||||
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async createIssueReaction(anchor: string, issueID: string, data: any): Promise<any> {
|
||||
return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async deleteIssueReaction(anchor: string, issueID: string, reactionId: string): Promise<any> {
|
||||
return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/reactions/${reactionId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async getIssueComments(anchor: string, issueID: string): Promise<any> {
|
||||
return this.get(`/api/public/anchor/${anchor}/issues/${issueID}/comments/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async createIssueComment(anchor: string, issueID: string, data: any): Promise<Comment> {
|
||||
return this.post(`/api/public/anchor/${anchor}/issues/${issueID}/comments/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async updateIssueComment(anchor: string, issueID: string, commentId: string, data: any): Promise<any> {
|
||||
return this.patch(`/api/public/anchor/${anchor}/issues/${issueID}/comments/${commentId}/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async deleteIssueComment(anchor: string, issueID: string, commentId: string): Promise<any> {
|
||||
return this.delete(`/api/public/anchor/${anchor}/issues/${issueID}/comments/${commentId}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async createCommentReaction(
|
||||
anchor: string,
|
||||
commentId: string,
|
||||
data: {
|
||||
reaction: string;
|
||||
}
|
||||
): Promise<any> {
|
||||
return this.post(`/api/public/anchor/${anchor}/comments/${commentId}/reactions/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async deleteCommentReaction(anchor: string, commentId: string, reactionHex: string): Promise<any> {
|
||||
return this.delete(`/api/public/anchor/${anchor}/comments/${commentId}/reactions/${reactionHex}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default IssueService;
|
||||
@@ -1,18 +0,0 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { IIssueLabel } from "@plane/types";
|
||||
// services
|
||||
import { APIService } from "./api.service";
|
||||
|
||||
export class LabelService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async getLabels(anchor: string): Promise<IIssueLabel[]> {
|
||||
return this.get(`/api/public/anchor/${anchor}/labels/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
// types
|
||||
import { TPublicMember } from "@/types/member";
|
||||
|
||||
export class MemberService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async getAnchorMembers(anchor: string): Promise<TPublicMember[]> {
|
||||
return this.get(`/api/public/anchor/${anchor}/members/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
// types
|
||||
import { TPublicModule } from "@/types/modules";
|
||||
|
||||
export class ModuleService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async getModules(anchor: string): Promise<TPublicModule[]> {
|
||||
return this.get(`/api/public/anchor/${anchor}/modules/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import type { IProjectMember, IProjectMembership } from "@plane/types";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
|
||||
export class ProjectMemberService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async fetchProjectMembers(anchor: string): Promise<IProjectMembership[]> {
|
||||
return this.get(`/api/anchor/${anchor}/members/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async getProjectMember(anchor: string, memberID: string): Promise<IProjectMember> {
|
||||
return this.get(`/api/anchor/${anchor}/members/${memberID}/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { TProjectPublishSettings } from "@plane/types";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
|
||||
class PublishService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async fetchPublishSettings(anchor: string): Promise<TProjectPublishSettings> {
|
||||
return this.get(`/api/public/anchor/${anchor}/settings/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async fetchAnchorFromProjectDetails(workspaceSlug: string, projectID: string): Promise<TProjectPublishSettings> {
|
||||
return this.get(`/api/public/workspaces/${workspaceSlug}/projects/${projectID}/anchor/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default PublishService;
|
||||
@@ -1,18 +0,0 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { IState } from "@plane/types";
|
||||
// services
|
||||
import { APIService } from "./api.service";
|
||||
|
||||
export class StateService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async getStates(anchor: string): Promise<IState[]> {
|
||||
return this.get(`/api/public/anchor/${anchor}/states/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
import { API_BASE_URL } from "@plane/constants";
|
||||
import { IUser, TUserProfile } from "@plane/types";
|
||||
// services
|
||||
import { APIService } from "@/services/api.service";
|
||||
|
||||
export class UserService extends APIService {
|
||||
constructor() {
|
||||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async currentUser(): Promise<IUser> {
|
||||
return this.get("/api/users/me/")
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
|
||||
async updateUser(data: Partial<IUser>): Promise<IUser> {
|
||||
return this.patch("/api/users/me/", data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response?.data;
|
||||
});
|
||||
}
|
||||
|
||||
async getCurrentUserProfile(): Promise<TUserProfile> {
|
||||
return this.get("/api/users/me/profile/")
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
async updateCurrentUserProfile(data: Partial<TUserProfile>): Promise<TUserProfile> {
|
||||
return this.patch("/api/users/me/profile/", data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
throw error?.response;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import { action, makeObservable, observable, runInAction } from "mobx";
|
||||
// plane imports
|
||||
import { SitesCycleService } from "@plane/services";
|
||||
import { TPublicCycle } from "@/types/cycle";
|
||||
import { CycleService } from "../services/cycle.service";
|
||||
// store
|
||||
import { CoreRootStore } from "./root.store";
|
||||
|
||||
export interface ICycleStore {
|
||||
@@ -14,7 +16,7 @@ export interface ICycleStore {
|
||||
|
||||
export class CycleStore implements ICycleStore {
|
||||
cycles: TPublicCycle[] | undefined = undefined;
|
||||
cycleService: CycleService;
|
||||
cycleService: SitesCycleService;
|
||||
rootStore: CoreRootStore;
|
||||
|
||||
constructor(_rootStore: CoreRootStore) {
|
||||
@@ -24,14 +26,14 @@ export class CycleStore implements ICycleStore {
|
||||
// fetch action
|
||||
fetchCycles: action,
|
||||
});
|
||||
this.cycleService = new CycleService();
|
||||
this.cycleService = new SitesCycleService();
|
||||
this.rootStore = _rootStore;
|
||||
}
|
||||
|
||||
getCycleById = (cycleId: string | undefined) => this.cycles?.find((cycle) => cycle.id === cycleId);
|
||||
|
||||
fetchCycles = async (anchor: string) => {
|
||||
const cyclesResponse = await this.cycleService.getCycles(anchor);
|
||||
const cyclesResponse = await this.cycleService.list(anchor);
|
||||
runInAction(() => {
|
||||
this.cycles = cyclesResponse;
|
||||
});
|
||||
|
||||
@@ -5,9 +5,9 @@ import uniq from "lodash/uniq";
|
||||
import update from "lodash/update";
|
||||
import { action, makeObservable, observable, runInAction } from "mobx";
|
||||
import { computedFn } from "mobx-utils";
|
||||
// plane constants
|
||||
// plane imports
|
||||
import { ALL_ISSUES } from "@plane/constants";
|
||||
// types
|
||||
import { SitesIssueService } from "@plane/services";
|
||||
import {
|
||||
TIssueGroupByOptions,
|
||||
TGroupedIssues,
|
||||
@@ -19,8 +19,7 @@ import {
|
||||
TGroupedIssueCount,
|
||||
TPaginationData,
|
||||
} from "@plane/types";
|
||||
// services
|
||||
import IssueService from "@/services/issue.service";
|
||||
// types
|
||||
import { IIssue, TIssuesResponse } from "@/types/issue";
|
||||
import { CoreRootStore } from "../root.store";
|
||||
// constants
|
||||
@@ -98,7 +97,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore {
|
||||
setLoader: action.bound,
|
||||
});
|
||||
this.rootIssueStore = _rootStore;
|
||||
this.issueService = new IssueService();
|
||||
this.issueService = new SitesIssueService();
|
||||
}
|
||||
|
||||
getIssueIds = (groupId?: string, subGroupId?: string) => {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import set from "lodash/set";
|
||||
import { observable, action, makeObservable, runInAction } from "mobx";
|
||||
// types
|
||||
// plane imports
|
||||
import { InstanceService } from "@plane/services";
|
||||
import { IInstance, IInstanceConfig } from "@plane/types";
|
||||
// services
|
||||
import { InstanceService } from "@/services/instance.service";
|
||||
// store
|
||||
import { CoreRootStore } from "@/store/root.store";
|
||||
|
||||
@@ -59,7 +58,7 @@ export class InstanceStore implements IInstanceStore {
|
||||
try {
|
||||
this.isLoading = true;
|
||||
this.error = undefined;
|
||||
const instanceInfo = await this.instanceService.getInstanceInfo();
|
||||
const instanceInfo = await this.instanceService.info();
|
||||
runInAction(() => {
|
||||
this.isLoading = false;
|
||||
this.instance = instanceInfo.instance;
|
||||
|
||||
@@ -3,16 +3,14 @@ import set from "lodash/set";
|
||||
import { makeObservable, observable, action, runInAction } from "mobx";
|
||||
import { computedFn } from "mobx-utils";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
// plane types
|
||||
import { TFileSignedURLResponse } from "@plane/types";
|
||||
// plane imports
|
||||
import { SitesFileService, SitesIssueService } from "@plane/services";
|
||||
import { TFileSignedURLResponse, TIssuePublicComment } from "@plane/types";
|
||||
import { EFileAssetType } from "@plane/types/src/enums";
|
||||
// services
|
||||
import { FileService } from "@/services/file.service";
|
||||
import IssueService from "@/services/issue.service";
|
||||
// store
|
||||
import { CoreRootStore } from "@/store/root.store";
|
||||
// types
|
||||
import { Comment, IIssue, IPeekMode, IVote } from "@/types/issue";
|
||||
import { IIssue, IPeekMode, IVote } from "@/types/issue";
|
||||
|
||||
export interface IIssueDetailStore {
|
||||
loader: boolean;
|
||||
@@ -32,7 +30,7 @@ export interface IIssueDetailStore {
|
||||
// issue actions
|
||||
fetchIssueDetails: (anchor: string, issueID: string) => void;
|
||||
// comment actions
|
||||
addIssueComment: (anchor: string, issueID: string, data: any) => Promise<Comment>;
|
||||
addIssueComment: (anchor: string, issueID: string, data: any) => Promise<TIssuePublicComment>;
|
||||
updateIssueComment: (anchor: string, issueID: string, commentID: string, data: any) => Promise<any>;
|
||||
deleteIssueComment: (anchor: string, issueID: string, commentID: string) => void;
|
||||
uploadCommentAsset: (file: File, anchor: string, commentID?: string) => Promise<TFileSignedURLResponse>;
|
||||
@@ -59,8 +57,8 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
// root store
|
||||
rootStore: CoreRootStore;
|
||||
// services
|
||||
issueService: IssueService;
|
||||
fileService: FileService;
|
||||
issueService: SitesIssueService;
|
||||
fileService: SitesFileService;
|
||||
|
||||
constructor(_rootStore: CoreRootStore) {
|
||||
makeObservable(this, {
|
||||
@@ -91,8 +89,8 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
removeIssueVote: action,
|
||||
});
|
||||
this.rootStore = _rootStore;
|
||||
this.issueService = new IssueService();
|
||||
this.fileService = new FileService();
|
||||
this.issueService = new SitesIssueService();
|
||||
this.fileService = new SitesFileService();
|
||||
}
|
||||
|
||||
setPeekId = (issueID: string | null) => {
|
||||
@@ -123,7 +121,7 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
*/
|
||||
fetchIssueById = async (anchorId: string, issueId: string) => {
|
||||
try {
|
||||
const issueDetails = await this.issueService.getIssueById(anchorId, issueId);
|
||||
const issueDetails = await this.issueService.retrieve(anchorId, issueId);
|
||||
|
||||
runInAction(() => {
|
||||
set(this.details, [issueId], issueDetails);
|
||||
@@ -146,7 +144,7 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
this.error = null;
|
||||
|
||||
const issueDetails = await this.fetchIssueById(anchor, issueID);
|
||||
const commentsResponse = await this.issueService.getIssueComments(anchor, issueID);
|
||||
const commentsResponse = await this.issueService.listComments(anchor, issueID);
|
||||
|
||||
if (issueDetails) {
|
||||
runInAction(() => {
|
||||
@@ -168,7 +166,7 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
addIssueComment = async (anchor: string, issueID: string, data: any) => {
|
||||
try {
|
||||
const issueDetails = this.getIssueById(issueID);
|
||||
const issueCommentResponse = await this.issueService.createIssueComment(anchor, issueID, data);
|
||||
const issueCommentResponse = await this.issueService.addComment(anchor, issueID, data);
|
||||
if (issueDetails) {
|
||||
runInAction(() => {
|
||||
set(this.details, [issueID, "comments"], [...(issueDetails?.comments ?? []), issueCommentResponse]);
|
||||
@@ -196,9 +194,9 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
};
|
||||
});
|
||||
|
||||
await this.issueService.updateIssueComment(anchor, issueID, commentID, data);
|
||||
await this.issueService.updateComment(anchor, issueID, commentID, data);
|
||||
} catch (error) {
|
||||
const issueComments = await this.issueService.getIssueComments(anchor, issueID);
|
||||
const issueComments = await this.issueService.listComments(anchor, issueID);
|
||||
|
||||
runInAction(() => {
|
||||
this.details = {
|
||||
@@ -214,7 +212,7 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
|
||||
deleteIssueComment = async (anchor: string, issueID: string, commentID: string) => {
|
||||
try {
|
||||
await this.issueService.deleteIssueComment(anchor, issueID, commentID);
|
||||
await this.issueService.removeComment(anchor, issueID, commentID);
|
||||
const remainingComments = this.details[issueID].comments.filter((c) => c.id != commentID);
|
||||
runInAction(() => {
|
||||
this.details = {
|
||||
@@ -288,11 +286,11 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
};
|
||||
});
|
||||
|
||||
await this.issueService.createCommentReaction(anchor, commentID, {
|
||||
await this.issueService.addCommentReaction(anchor, commentID, {
|
||||
reaction: reactionHex,
|
||||
});
|
||||
} catch (error) {
|
||||
const issueComments = await this.issueService.getIssueComments(anchor, issueID);
|
||||
const issueComments = await this.issueService.listComments(anchor, issueID);
|
||||
|
||||
runInAction(() => {
|
||||
this.details = {
|
||||
@@ -324,9 +322,9 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
};
|
||||
});
|
||||
|
||||
await this.issueService.deleteCommentReaction(anchor, commentID, reactionHex);
|
||||
await this.issueService.removeCommentReaction(anchor, commentID, reactionHex);
|
||||
} catch (error) {
|
||||
const issueComments = await this.issueService.getIssueComments(anchor, issueID);
|
||||
const issueComments = await this.issueService.listComments(anchor, issueID);
|
||||
|
||||
runInAction(() => {
|
||||
this.details = {
|
||||
@@ -356,12 +354,12 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
);
|
||||
});
|
||||
|
||||
await this.issueService.createIssueReaction(anchor, issueID, {
|
||||
await this.issueService.addReaction(anchor, issueID, {
|
||||
reaction: reactionHex,
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("Failed to add issue vote");
|
||||
const issueReactions = await this.issueService.getIssueReactions(anchor, issueID);
|
||||
const issueReactions = await this.issueService.listReactions(anchor, issueID);
|
||||
runInAction(() => {
|
||||
set(this.details, [issueID, "reaction_items"], issueReactions);
|
||||
});
|
||||
@@ -378,10 +376,10 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
set(this.details, [issueID, "reaction_items"], newReactions);
|
||||
});
|
||||
|
||||
await this.issueService.deleteIssueReaction(anchor, issueID, reactionHex);
|
||||
await this.issueService.removeReaction(anchor, issueID, reactionHex);
|
||||
} catch (error) {
|
||||
console.log("Failed to remove issue reaction");
|
||||
const reactions = await this.issueService.getIssueReactions(anchor, issueID);
|
||||
const reactions = await this.issueService.listReactions(anchor, issueID);
|
||||
runInAction(() => {
|
||||
set(this.details, [issueID, "reaction_items"], reactions);
|
||||
});
|
||||
@@ -410,10 +408,10 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
});
|
||||
});
|
||||
|
||||
await this.issueService.createIssueVote(anchor, issueID, data);
|
||||
await this.issueService.addVote(anchor, issueID, data);
|
||||
} catch (error) {
|
||||
console.log("Failed to add issue vote");
|
||||
const issueVotes = await this.issueService.getIssueVotes(anchor, issueID);
|
||||
const issueVotes = await this.issueService.listVotes(anchor, issueID);
|
||||
|
||||
runInAction(() => {
|
||||
set(this.details, [issueID, "vote_items"], issueVotes);
|
||||
@@ -431,10 +429,10 @@ export class IssueDetailStore implements IIssueDetailStore {
|
||||
set(this.details, [issueID, "vote_items"], newVotes);
|
||||
});
|
||||
|
||||
await this.issueService.deleteIssueVote(anchor, issueID);
|
||||
await this.issueService.removeVote(anchor, issueID);
|
||||
} catch (error) {
|
||||
console.log("Failed to remove issue vote");
|
||||
const issueVotes = await this.issueService.getIssueVotes(anchor, issueID);
|
||||
const issueVotes = await this.issueService.listVotes(anchor, issueID);
|
||||
|
||||
runInAction(() => {
|
||||
set(this.details, [issueID, "vote_items"], issueVotes);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { action, makeObservable, runInAction } from "mobx";
|
||||
// types
|
||||
// plane imports
|
||||
import { SitesIssueService } from "@plane/services";
|
||||
import { IssuePaginationOptions, TLoader } from "@plane/types";
|
||||
// services
|
||||
import IssueService from "@/services/issue.service";
|
||||
// store
|
||||
import { CoreRootStore } from "@/store/root.store";
|
||||
// types
|
||||
@@ -24,7 +23,7 @@ export class IssueStore extends BaseIssuesStore implements IIssueStore {
|
||||
// root store
|
||||
rootStore: CoreRootStore;
|
||||
// services
|
||||
issueService: IssueService;
|
||||
issueService: SitesIssueService;
|
||||
|
||||
constructor(_rootStore: CoreRootStore) {
|
||||
super(_rootStore);
|
||||
@@ -36,7 +35,7 @@ export class IssueStore extends BaseIssuesStore implements IIssueStore {
|
||||
});
|
||||
|
||||
this.rootStore = _rootStore;
|
||||
this.issueService = new IssueService();
|
||||
this.issueService = new SitesIssueService();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,7 +58,7 @@ export class IssueStore extends BaseIssuesStore implements IIssueStore {
|
||||
|
||||
const params = this.rootStore.issueFilter.getFilterParams(options, anchor, undefined, undefined, undefined);
|
||||
|
||||
const response = await this.issueService.fetchPublicIssues(anchor, params);
|
||||
const response = await this.issueService.list(anchor, params);
|
||||
|
||||
// after fetching issues, call the base method to process the response further
|
||||
this.onfetchIssues(response, options);
|
||||
@@ -86,7 +85,7 @@ export class IssueStore extends BaseIssuesStore implements IIssueStore {
|
||||
subGroupId
|
||||
);
|
||||
// call the fetch issues API with the params for next page in issues
|
||||
const response = await this.issueService.fetchPublicIssues(anchor, params);
|
||||
const response = await this.issueService.list(anchor, params);
|
||||
|
||||
// after the next page of issues are fetched, call the base method to process the response
|
||||
this.onfetchNexIssues(response, groupId, subGroupId);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import set from "lodash/set";
|
||||
import { action, computed, makeObservable, observable, runInAction } from "mobx";
|
||||
// plane imports
|
||||
import { SitesLabelService } from "@plane/services";
|
||||
import { IIssueLabel } from "@plane/types";
|
||||
import { LabelService } from "@/services/label.service";
|
||||
// store
|
||||
import { CoreRootStore } from "./root.store";
|
||||
|
||||
export interface IIssueLabelStore {
|
||||
@@ -16,7 +18,7 @@ export interface IIssueLabelStore {
|
||||
|
||||
export class LabelStore implements IIssueLabelStore {
|
||||
labelMap: Record<string, IIssueLabel> = {};
|
||||
labelService: LabelService;
|
||||
labelService: SitesLabelService;
|
||||
rootStore: CoreRootStore;
|
||||
|
||||
constructor(_rootStore: CoreRootStore) {
|
||||
@@ -28,7 +30,7 @@ export class LabelStore implements IIssueLabelStore {
|
||||
// fetch action
|
||||
fetchLabels: action,
|
||||
});
|
||||
this.labelService = new LabelService();
|
||||
this.labelService = new SitesLabelService();
|
||||
this.rootStore = _rootStore;
|
||||
}
|
||||
|
||||
@@ -51,7 +53,7 @@ export class LabelStore implements IIssueLabelStore {
|
||||
};
|
||||
|
||||
fetchLabels = async (anchor: string) => {
|
||||
const labelsResponse = await this.labelService.getLabels(anchor);
|
||||
const labelsResponse = await this.labelService.list(anchor);
|
||||
runInAction(() => {
|
||||
this.labelMap = {};
|
||||
for (const label of labelsResponse) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import set from "lodash/set";
|
||||
import { action, computed, makeObservable, observable, runInAction } from "mobx";
|
||||
// plane imports
|
||||
import { SitesMemberService } from "@plane/services";
|
||||
|
||||
import { TPublicMember } from "@/types/member";
|
||||
import { MemberService } from "../services/member.service";
|
||||
import { CoreRootStore } from "./root.store";
|
||||
|
||||
export interface IIssueMemberStore {
|
||||
@@ -16,7 +18,7 @@ export interface IIssueMemberStore {
|
||||
|
||||
export class MemberStore implements IIssueMemberStore {
|
||||
memberMap: Record<string, TPublicMember> = {};
|
||||
memberService: MemberService;
|
||||
memberService: SitesMemberService;
|
||||
rootStore: CoreRootStore;
|
||||
|
||||
constructor(_rootStore: CoreRootStore) {
|
||||
@@ -28,7 +30,7 @@ export class MemberStore implements IIssueMemberStore {
|
||||
// fetch action
|
||||
fetchMembers: action,
|
||||
});
|
||||
this.memberService = new MemberService();
|
||||
this.memberService = new SitesMemberService();
|
||||
this.rootStore = _rootStore;
|
||||
}
|
||||
|
||||
@@ -52,7 +54,7 @@ export class MemberStore implements IIssueMemberStore {
|
||||
|
||||
fetchMembers = async (anchor: string) => {
|
||||
try {
|
||||
const membersResponse = await this.memberService.getAnchorMembers(anchor);
|
||||
const membersResponse = await this.memberService.list(anchor);
|
||||
runInAction(() => {
|
||||
this.memberMap = {};
|
||||
for (const member of membersResponse) {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import set from "lodash/set";
|
||||
import { action, computed, makeObservable, observable, runInAction } from "mobx";
|
||||
// plane imports
|
||||
import { SitesModuleService } from "@plane/services";
|
||||
// types
|
||||
import { TPublicModule } from "@/types/modules";
|
||||
import { ModuleService } from "../services/module.service";
|
||||
// root store
|
||||
import { CoreRootStore } from "./root.store";
|
||||
|
||||
export interface IIssueModuleStore {
|
||||
@@ -16,7 +19,7 @@ export interface IIssueModuleStore {
|
||||
|
||||
export class ModuleStore implements IIssueModuleStore {
|
||||
moduleMap: Record<string, TPublicModule> = {};
|
||||
moduleService: ModuleService;
|
||||
moduleService: SitesModuleService;
|
||||
rootStore: CoreRootStore;
|
||||
|
||||
constructor(_rootStore: CoreRootStore) {
|
||||
@@ -28,7 +31,7 @@ export class ModuleStore implements IIssueModuleStore {
|
||||
// fetch action
|
||||
fetchModules: action,
|
||||
});
|
||||
this.moduleService = new ModuleService();
|
||||
this.moduleService = new SitesModuleService();
|
||||
this.rootStore = _rootStore;
|
||||
}
|
||||
|
||||
@@ -52,7 +55,7 @@ export class ModuleStore implements IIssueModuleStore {
|
||||
|
||||
fetchModules = async (anchor: string) => {
|
||||
try {
|
||||
const modulesResponse = await this.moduleService.getModules(anchor);
|
||||
const modulesResponse = await this.moduleService.list(anchor);
|
||||
runInAction(() => {
|
||||
this.moduleMap = {};
|
||||
for (const issueModule of modulesResponse) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import set from "lodash/set";
|
||||
import { action, makeObservable, observable, runInAction } from "mobx";
|
||||
// types
|
||||
// plane imports
|
||||
import { UserService } from "@plane/services";
|
||||
import { TUserProfile } from "@plane/types";
|
||||
// services
|
||||
import { UserService } from "@/services/user.service";
|
||||
// store
|
||||
import { CoreRootStore } from "@/store/root.store";
|
||||
|
||||
@@ -85,7 +84,7 @@ export class ProfileStore implements IProfileStore {
|
||||
this.isLoading = true;
|
||||
this.error = undefined;
|
||||
});
|
||||
const userProfile = await this.userService.getCurrentUserProfile();
|
||||
const userProfile = await this.userService.profile();
|
||||
runInAction(() => {
|
||||
this.isLoading = false;
|
||||
this.data = userProfile;
|
||||
@@ -116,7 +115,7 @@ export class ProfileStore implements IProfileStore {
|
||||
if (this.data) set(this.data, userKey, data[userKey]);
|
||||
});
|
||||
}
|
||||
const userProfile = await this.userService.updateCurrentUserProfile(data);
|
||||
const userProfile = await this.userService.updateProfile(data);
|
||||
return userProfile;
|
||||
} catch (error) {
|
||||
if (currentUserProfileData) {
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import set from "lodash/set";
|
||||
import { makeObservable, observable, runInAction, action } from "mobx";
|
||||
// types
|
||||
// plane imports
|
||||
import { SitesProjectPublishService } from "@plane/services";
|
||||
import { TProjectPublishSettings } from "@plane/types";
|
||||
// services
|
||||
import PublishService from "@/services/publish.service";
|
||||
// store
|
||||
import { PublishStore } from "@/store/publish/publish.store";
|
||||
import { CoreRootStore } from "@/store/root.store";
|
||||
@@ -29,7 +28,7 @@ export class PublishListStore implements IPublishListStore {
|
||||
fetchPublishSettings: action,
|
||||
});
|
||||
// services
|
||||
this.publishService = new PublishService();
|
||||
this.publishService = new SitesProjectPublishService();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -37,7 +36,7 @@ export class PublishListStore implements IPublishListStore {
|
||||
* @param {string} anchor
|
||||
*/
|
||||
fetchPublishSettings = async (anchor: string) => {
|
||||
const response = await this.publishService.fetchPublishSettings(anchor);
|
||||
const response = await this.publishService.retrieveSettingsByAnchor(anchor);
|
||||
runInAction(() => {
|
||||
if (response.anchor) {
|
||||
set(this.publishMap, [response.anchor], new PublishStore(this.rootStore, response));
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import clone from "lodash/clone";
|
||||
import { action, computed, makeObservable, observable, runInAction } from "mobx";
|
||||
// plane imports
|
||||
import { SitesStateService } from "@plane/services";
|
||||
import { IState } from "@plane/types";
|
||||
// helpers
|
||||
import { sortStates } from "@/helpers/state.helper";
|
||||
import { StateService } from "@/services/state.service";
|
||||
// store
|
||||
import { CoreRootStore } from "./root.store";
|
||||
|
||||
export interface IStateStore {
|
||||
@@ -18,7 +21,7 @@ export interface IStateStore {
|
||||
|
||||
export class StateStore implements IStateStore {
|
||||
states: IState[] | undefined = undefined;
|
||||
stateService: StateService;
|
||||
stateService: SitesStateService;
|
||||
rootStore: CoreRootStore;
|
||||
|
||||
constructor(_rootStore: CoreRootStore) {
|
||||
@@ -30,7 +33,7 @@ export class StateStore implements IStateStore {
|
||||
// fetch action
|
||||
fetchStates: action,
|
||||
});
|
||||
this.stateService = new StateService();
|
||||
this.stateService = new SitesStateService();
|
||||
this.rootStore = _rootStore;
|
||||
}
|
||||
|
||||
@@ -42,7 +45,7 @@ export class StateStore implements IStateStore {
|
||||
getStateById = (stateId: string | undefined) => this.states?.find((state) => state.id === stateId);
|
||||
|
||||
fetchStates = async (anchor: string) => {
|
||||
const statesResponse = await this.stateService.getStates(anchor);
|
||||
const statesResponse = await this.stateService.list(anchor);
|
||||
runInAction(() => {
|
||||
this.states = statesResponse;
|
||||
});
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import set from "lodash/set";
|
||||
import { action, computed, makeObservable, observable, runInAction } from "mobx";
|
||||
// types
|
||||
// plane imports
|
||||
import { UserService } from "@plane/services";
|
||||
import { IUser } from "@plane/types";
|
||||
// services
|
||||
import { AuthService } from "@/services/auth.service";
|
||||
import { UserService } from "@/services/user.service";
|
||||
// store types
|
||||
import { ProfileStore, IProfileStore } from "@/store/profile.store";
|
||||
// store
|
||||
@@ -45,14 +43,12 @@ export class UserStore implements IUserStore {
|
||||
profile: IProfileStore;
|
||||
// service
|
||||
userService: UserService;
|
||||
authService: AuthService;
|
||||
|
||||
constructor(private store: CoreRootStore) {
|
||||
// stores
|
||||
this.profile = new ProfileStore(store);
|
||||
// service
|
||||
this.userService = new UserService();
|
||||
this.authService = new AuthService();
|
||||
// observables
|
||||
makeObservable(this, {
|
||||
// observables
|
||||
@@ -95,7 +91,7 @@ export class UserStore implements IUserStore {
|
||||
if (this.data === undefined) this.isLoading = true;
|
||||
this.error = undefined;
|
||||
});
|
||||
const user = await this.userService.currentUser();
|
||||
const user = await this.userService.me();
|
||||
if (user && user?.id) {
|
||||
await this.profile.fetchUserProfile();
|
||||
runInAction(() => {
|
||||
@@ -137,7 +133,7 @@ export class UserStore implements IUserStore {
|
||||
if (this.data) set(this.data, userKey, data[userKey]);
|
||||
});
|
||||
}
|
||||
const user = await this.userService.updateUser(data);
|
||||
const user = await this.userService.update(data);
|
||||
return user;
|
||||
} catch (error) {
|
||||
if (currentUserData) {
|
||||
|
||||
31
space/core/types/issue.d.ts
vendored
31
space/core/types/issue.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import { IWorkspaceLite, TIssue, TIssuePriorities, TStateGroups } from "@plane/types";
|
||||
import { IWorkspaceLite, TIssue, TIssuePriorities, TStateGroups, TIssuePublicComment } from "@plane/types";
|
||||
|
||||
export type TIssueLayout = "list" | "kanban" | "calendar" | "spreadsheet" | "gantt";
|
||||
export type TIssueLayoutOptions = {
|
||||
@@ -58,7 +58,7 @@ export interface IIssue
|
||||
| "link_count"
|
||||
| "estimate_point"
|
||||
> {
|
||||
comments: Comment[];
|
||||
comments: TIssuePublicComment[];
|
||||
reaction_items: IIssueReaction[];
|
||||
vote_items: IVote[];
|
||||
}
|
||||
@@ -106,33 +106,6 @@ export interface IVote {
|
||||
actor_details: ActorDetail;
|
||||
}
|
||||
|
||||
export interface Comment {
|
||||
actor_detail: ActorDetail;
|
||||
access: string;
|
||||
actor: string;
|
||||
attachments: any[];
|
||||
comment_html: string;
|
||||
comment_reactions: {
|
||||
actor_detail: ActorDetail;
|
||||
comment: string;
|
||||
id: string;
|
||||
reaction: string;
|
||||
}[];
|
||||
comment_stripped: string;
|
||||
created_at: Date;
|
||||
created_by: string;
|
||||
id: string;
|
||||
is_member: boolean;
|
||||
issue: string;
|
||||
issue_detail: IssueDetail;
|
||||
project: string;
|
||||
project_detail: ProjectDetail;
|
||||
updated_at: Date;
|
||||
updated_by: string;
|
||||
workspace: string;
|
||||
workspace_detail: IWorkspaceLite;
|
||||
}
|
||||
|
||||
export interface IIssueReaction {
|
||||
actor_details: ActorDetail;
|
||||
reaction: string;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
// plane internal
|
||||
import { MAX_FILE_SIZE } from "@plane/constants";
|
||||
import { TFileHandler } from "@plane/editor";
|
||||
|
||||
import { SitesFileService } from "@plane/services";
|
||||
// helpers
|
||||
import { getFileURL } from "@/helpers/file.helper";
|
||||
// services
|
||||
import { FileService } from "@/services/file.service";
|
||||
const fileService = new FileService();
|
||||
const sitesFileService = new SitesFileService();
|
||||
|
||||
/**
|
||||
* @description generate the file source using assetId
|
||||
@@ -42,19 +41,19 @@ export const getEditorFileHandlers = (args: TArgs): TFileHandler => {
|
||||
upload: uploadFile,
|
||||
delete: async (src: string) => {
|
||||
if (src?.startsWith("http")) {
|
||||
await fileService.deleteOldEditorAsset(workspaceId, src);
|
||||
await sitesFileService.deleteOldEditorAsset(workspaceId, src);
|
||||
} else {
|
||||
await fileService.deleteNewAsset(getEditorAssetSrc(anchor, src) ?? "");
|
||||
await sitesFileService.deleteNewAsset(getEditorAssetSrc(anchor, src) ?? "");
|
||||
}
|
||||
},
|
||||
restore: async (src: string) => {
|
||||
if (src?.startsWith("http")) {
|
||||
await fileService.restoreOldEditorAsset(workspaceId, src);
|
||||
await sitesFileService.restoreOldEditorAsset(workspaceId, src);
|
||||
} else {
|
||||
await fileService.restoreNewAsset(anchor, src);
|
||||
await sitesFileService.restoreNewAsset(anchor, src);
|
||||
}
|
||||
},
|
||||
cancel: fileService.cancelUpload,
|
||||
cancel: sitesFileService.cancelUpload,
|
||||
validation: {
|
||||
maxFileSize: MAX_FILE_SIZE,
|
||||
},
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
"@plane/editor": "*",
|
||||
"@plane/types": "*",
|
||||
"@plane/ui": "*",
|
||||
"@plane/services": "*",
|
||||
"@sentry/nextjs": "^8.32.0",
|
||||
"axios": "^1.7.9",
|
||||
"clsx": "^2.0.0",
|
||||
|
||||
Reference in New Issue
Block a user