2024-07-23 11:51:03 +05:30
|
|
|
import { TPublishViewSettings } from "@plane/types";
|
2024-06-28 18:37:38 +05:30
|
|
|
import { EViewAccess } from "@/constants/views";
|
|
|
|
|
import { API_BASE_URL } from "@/helpers/common.helper";
|
|
|
|
|
import { ViewService as CoreViewService } from "@/services/view.service";
|
|
|
|
|
|
|
|
|
|
export class ViewService extends CoreViewService {
|
|
|
|
|
constructor() {
|
|
|
|
|
super(API_BASE_URL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async updateViewAccess(workspaceSlug: string, projectId: string, viewId: string, access: EViewAccess) {
|
2024-07-24 14:32:18 +05:30
|
|
|
return await this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/access/`, {
|
2024-06-28 18:37:38 +05:30
|
|
|
access,
|
|
|
|
|
}).catch((error) => {
|
|
|
|
|
throw error?.response?.data;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async lockView(workspaceSlug: string, projectId: string, viewId: string) {
|
2024-07-24 14:32:18 +05:30
|
|
|
return await this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/lock/`).catch(
|
|
|
|
|
(error) => {
|
|
|
|
|
throw error?.response?.data;
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-06-28 18:37:38 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async unLockView(workspaceSlug: string, projectId: string, viewId: string) {
|
2024-07-24 14:32:18 +05:30
|
|
|
return await this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/lock/`).catch(
|
2024-06-28 18:37:38 +05:30
|
|
|
(error) => {
|
|
|
|
|
throw error?.response?.data;
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-07-23 11:51:03 +05:30
|
|
|
|
2024-07-24 14:32:18 +05:30
|
|
|
async getPublishDetails(workspaceSlug: string, projectId: string, viewId: string) {
|
|
|
|
|
return await this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/publish/`)
|
|
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response?.data;
|
|
|
|
|
});
|
2024-07-23 11:51:03 +05:30
|
|
|
}
|
|
|
|
|
|
2024-07-24 14:32:18 +05:30
|
|
|
async publishView(workspaceSlug: string, projectId: string, viewId: string, data: TPublishViewSettings) {
|
|
|
|
|
return await this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/publish/`, {
|
|
|
|
|
...data,
|
|
|
|
|
view_props: {
|
|
|
|
|
list: true,
|
|
|
|
|
kanban: true,
|
|
|
|
|
calendar: true,
|
|
|
|
|
gantt: true,
|
|
|
|
|
spreadsheet: true,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response?.data;
|
|
|
|
|
});
|
2024-07-23 11:51:03 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async updatePublishedView(
|
|
|
|
|
workspaceSlug: string,
|
|
|
|
|
projectId: string,
|
|
|
|
|
viewId: string,
|
|
|
|
|
data: Partial<TPublishViewSettings>
|
2024-07-24 14:32:18 +05:30
|
|
|
) {
|
|
|
|
|
return await this.patch(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/publish/`, data)
|
|
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response?.data;
|
|
|
|
|
});
|
2024-07-23 11:51:03 +05:30
|
|
|
}
|
|
|
|
|
|
2024-07-24 14:32:18 +05:30
|
|
|
async unPublishView(workspaceSlug: string, projectId: string, viewId: string) {
|
|
|
|
|
return await this.delete(`/api/workspaces/${workspaceSlug}/projects/${projectId}/views/${viewId}/publish/`)
|
|
|
|
|
.then((response) => response?.data)
|
|
|
|
|
.catch((error) => {
|
|
|
|
|
throw error?.response?.data;
|
|
|
|
|
});
|
2024-07-23 11:51:03 +05:30
|
|
|
}
|
2024-06-28 18:37:38 +05:30
|
|
|
}
|