[WEB-1397] chore: update project publish types (#4841)
* chore: update project publish types * chore: added additional entity name * chore: updated types
This commit is contained in:
parent
c4f5093492
commit
ae3dcc3dbd
9 changed files with 59 additions and 68 deletions
|
|
@ -6,7 +6,7 @@ import { useParams } from "next/navigation";
|
|||
import { Controller, useForm } from "react-hook-form";
|
||||
import { Check, ExternalLink, Globe2 } from "lucide-react";
|
||||
// types
|
||||
import { IProject, TProjectPublishLayouts, TPublishSettings } from "@plane/types";
|
||||
import { IProject, TProjectPublishLayouts, TProjectPublishSettings } from "@plane/types";
|
||||
// ui
|
||||
import { Button, Loader, ToggleSwitch, TOAST_TYPE, setToast, CustomSelect, ModalCore, EModalWidth } from "@plane/ui";
|
||||
// helpers
|
||||
|
|
@ -21,7 +21,7 @@ type Props = {
|
|||
onClose: () => void;
|
||||
};
|
||||
|
||||
const defaultValues: Partial<TPublishSettings> = {
|
||||
const defaultValues: Partial<TProjectPublishSettings> = {
|
||||
is_comments_enabled: false,
|
||||
is_reactions_enabled: false,
|
||||
is_votes_enabled: false,
|
||||
|
|
@ -81,12 +81,12 @@ export const PublishProjectModal: React.FC<Props> = observer((props) => {
|
|||
}
|
||||
}, [fetchPublishSettings, isOpen, project, projectPublishSettings, workspaceSlug]);
|
||||
|
||||
const handlePublishProject = async (payload: Partial<TPublishSettings>) => {
|
||||
const handlePublishProject = async (payload: Partial<TProjectPublishSettings>) => {
|
||||
if (!workspaceSlug) return;
|
||||
await publishProject(workspaceSlug.toString(), project.id, payload);
|
||||
};
|
||||
|
||||
const handleUpdatePublishSettings = async (payload: Partial<TPublishSettings>) => {
|
||||
const handleUpdatePublishSettings = async (payload: Partial<TProjectPublishSettings>) => {
|
||||
if (!workspaceSlug || !payload.id) return;
|
||||
|
||||
await updatePublishSettings(workspaceSlug.toString(), project.id, payload.id, payload).then((res) => {
|
||||
|
|
@ -124,7 +124,7 @@ export const PublishProjectModal: React.FC<Props> = observer((props) => {
|
|||
.map(([key, value]) => key)
|
||||
.filter((l) => VIEW_OPTIONS.find((o) => o.key === l));
|
||||
|
||||
const handleFormSubmit = async (formData: Partial<TPublishSettings>) => {
|
||||
const handleFormSubmit = async (formData: Partial<TProjectPublishSettings>) => {
|
||||
if (!selectedLayouts || selectedLayouts.length === 0) {
|
||||
setToast({
|
||||
type: TOAST_TYPE.ERROR,
|
||||
|
|
@ -134,7 +134,7 @@ export const PublishProjectModal: React.FC<Props> = observer((props) => {
|
|||
return;
|
||||
}
|
||||
|
||||
const payload: Partial<TPublishSettings> = {
|
||||
const payload: Partial<TProjectPublishSettings> = {
|
||||
id: formData.id,
|
||||
is_comments_enabled: formData.is_comments_enabled,
|
||||
is_reactions_enabled: formData.is_reactions_enabled,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// types
|
||||
import { TPublishSettings } from "@plane/types";
|
||||
import { TProjectPublishSettings } from "@plane/types";
|
||||
// helpers
|
||||
import { API_BASE_URL } from "@/helpers/common.helper";
|
||||
// services
|
||||
|
|
@ -10,7 +10,7 @@ export class ProjectPublishService extends APIService {
|
|||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async fetchPublishSettings(workspaceSlug: string, projectID: string): Promise<TPublishSettings> {
|
||||
async fetchPublishSettings(workspaceSlug: string, projectID: string): Promise<TProjectPublishSettings> {
|
||||
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectID}/project-deploy-boards/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
|
|
@ -21,8 +21,8 @@ export class ProjectPublishService extends APIService {
|
|||
async publishProject(
|
||||
workspaceSlug: string,
|
||||
projectID: string,
|
||||
data: Partial<TPublishSettings>
|
||||
): Promise<TPublishSettings> {
|
||||
data: Partial<TProjectPublishSettings>
|
||||
): Promise<TProjectPublishSettings> {
|
||||
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectID}/project-deploy-boards/`, data)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
|
|
@ -34,8 +34,8 @@ export class ProjectPublishService extends APIService {
|
|||
workspaceSlug: string,
|
||||
projectID: string,
|
||||
project_publish_id: string,
|
||||
data: Partial<TPublishSettings>
|
||||
): Promise<TPublishSettings> {
|
||||
data: Partial<TProjectPublishSettings>
|
||||
): Promise<TProjectPublishSettings> {
|
||||
return this.patch(
|
||||
`/api/workspaces/${workspaceSlug}/projects/${projectID}/project-deploy-boards/${project_publish_id}/`,
|
||||
data
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import set from "lodash/set";
|
|||
import unset from "lodash/unset";
|
||||
import { observable, action, makeObservable, runInAction } from "mobx";
|
||||
// types
|
||||
import { TPublishSettings } from "@plane/types";
|
||||
import { TProjectPublishSettings } from "@plane/types";
|
||||
// services
|
||||
import { ProjectPublishService } from "@/services/project";
|
||||
// store
|
||||
|
|
@ -13,22 +13,22 @@ export interface IProjectPublishStore {
|
|||
generalLoader: boolean;
|
||||
fetchSettingsLoader: boolean;
|
||||
// observables
|
||||
publishSettingsMap: Record<string, TPublishSettings>; // projectID => TPublishSettings
|
||||
publishSettingsMap: Record<string, TProjectPublishSettings>; // projectID => TProjectPublishSettings
|
||||
// helpers
|
||||
getPublishSettingsByProjectID: (projectID: string) => TPublishSettings | undefined;
|
||||
getPublishSettingsByProjectID: (projectID: string) => TProjectPublishSettings | undefined;
|
||||
// actions
|
||||
fetchPublishSettings: (workspaceSlug: string, projectID: string) => Promise<TPublishSettings>;
|
||||
fetchPublishSettings: (workspaceSlug: string, projectID: string) => Promise<TProjectPublishSettings>;
|
||||
updatePublishSettings: (
|
||||
workspaceSlug: string,
|
||||
projectID: string,
|
||||
projectPublishId: string,
|
||||
data: Partial<TPublishSettings>
|
||||
) => Promise<TPublishSettings>;
|
||||
data: Partial<TProjectPublishSettings>
|
||||
) => Promise<TProjectPublishSettings>;
|
||||
publishProject: (
|
||||
workspaceSlug: string,
|
||||
projectID: string,
|
||||
data: Partial<TPublishSettings>
|
||||
) => Promise<TPublishSettings>;
|
||||
data: Partial<TProjectPublishSettings>
|
||||
) => Promise<TProjectPublishSettings>;
|
||||
unPublishProject: (workspaceSlug: string, projectID: string, projectPublishId: string) => Promise<void>;
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +37,7 @@ export class ProjectPublishStore implements IProjectPublishStore {
|
|||
generalLoader: boolean = false;
|
||||
fetchSettingsLoader: boolean = false;
|
||||
// observables
|
||||
publishSettingsMap: Record<string, TPublishSettings> = {};
|
||||
publishSettingsMap: Record<string, TProjectPublishSettings> = {};
|
||||
// root store
|
||||
projectRootStore: ProjectRootStore;
|
||||
// services
|
||||
|
|
@ -65,9 +65,9 @@ export class ProjectPublishStore implements IProjectPublishStore {
|
|||
/**
|
||||
* @description returns the publish settings of a particular project
|
||||
* @param {string} projectID
|
||||
* @returns {TPublishSettings | undefined}
|
||||
* @returns {TProjectPublishSettings | undefined}
|
||||
*/
|
||||
getPublishSettingsByProjectID = (projectID: string): TPublishSettings | undefined =>
|
||||
getPublishSettingsByProjectID = (projectID: string): TProjectPublishSettings | undefined =>
|
||||
this.publishSettingsMap?.[projectID] ?? undefined;
|
||||
|
||||
/**
|
||||
|
|
@ -103,7 +103,7 @@ export class ProjectPublishStore implements IProjectPublishStore {
|
|||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
publishProject = async (workspaceSlug: string, projectID: string, data: Partial<TPublishSettings>) => {
|
||||
publishProject = async (workspaceSlug: string, projectID: string, data: Partial<TProjectPublishSettings>) => {
|
||||
try {
|
||||
runInAction(() => {
|
||||
this.generalLoader = true;
|
||||
|
|
@ -135,7 +135,7 @@ export class ProjectPublishStore implements IProjectPublishStore {
|
|||
workspaceSlug: string,
|
||||
projectID: string,
|
||||
projectPublishId: string,
|
||||
data: Partial<TPublishSettings>
|
||||
data: Partial<TProjectPublishSettings>
|
||||
) => {
|
||||
try {
|
||||
runInAction(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue