[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
|
|
@ -1,6 +1,6 @@
|
|||
import { notFound, redirect } from "next/navigation";
|
||||
// types
|
||||
import { TPublishSettings } from "@plane/types";
|
||||
import { TProjectPublishSettings } from "@plane/types";
|
||||
// services
|
||||
import PublishService from "@/services/publish.service";
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ export default async function IssuesPage(props: Props) {
|
|||
const { workspaceSlug, projectId } = params;
|
||||
const { board, peekId } = searchParams;
|
||||
|
||||
let response: TPublishSettings | undefined = undefined;
|
||||
let response: TProjectPublishSettings | undefined = undefined;
|
||||
try {
|
||||
response = await publishService.fetchAnchorFromProjectDetails(workspaceSlug, projectId);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -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 @@ class PublishService extends APIService {
|
|||
super(API_BASE_URL);
|
||||
}
|
||||
|
||||
async fetchPublishSettings(anchor: string): Promise<TPublishSettings> {
|
||||
async fetchPublishSettings(anchor: string): Promise<TProjectPublishSettings> {
|
||||
return this.get(`/api/public/anchor/${anchor}/settings/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
|
|
@ -18,7 +18,7 @@ class PublishService extends APIService {
|
|||
});
|
||||
}
|
||||
|
||||
async fetchAnchorFromProjectDetails(workspaceSlug: string, projectID: string): Promise<TPublishSettings> {
|
||||
async fetchAnchorFromProjectDetails(workspaceSlug: string, projectID: string): Promise<TProjectPublishSettings> {
|
||||
return this.get(`/api/public/workspaces/${workspaceSlug}/projects/${projectID}/anchor/`)
|
||||
.then((response) => response?.data)
|
||||
.catch((error) => {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
import { observable, makeObservable, computed } from "mobx";
|
||||
// types
|
||||
import { IWorkspaceLite, TProjectDetails, TPublishEntityType, TPublishSettings, TPublishViewProps } from "@plane/types";
|
||||
import {
|
||||
IWorkspaceLite,
|
||||
TProjectDetails,
|
||||
TPublishEntityType,
|
||||
TProjectPublishSettings,
|
||||
TProjectPublishViewProps,
|
||||
} from "@plane/types";
|
||||
// store types
|
||||
import { RootStore } from "@/store/root.store";
|
||||
|
||||
export interface IPublishStore extends TPublishSettings {
|
||||
export interface IPublishStore extends TProjectPublishSettings {
|
||||
// computed
|
||||
workspaceSlug: string | undefined;
|
||||
canComment: boolean;
|
||||
|
|
@ -27,14 +33,14 @@ export class PublishStore implements IPublishStore {
|
|||
is_reactions_enabled: boolean;
|
||||
updated_at: string | undefined;
|
||||
updated_by: string | undefined;
|
||||
view_props: TPublishViewProps | undefined;
|
||||
view_props: TProjectPublishViewProps | undefined;
|
||||
is_votes_enabled: boolean;
|
||||
workspace: string | undefined;
|
||||
workspace_detail: IWorkspaceLite | undefined;
|
||||
|
||||
constructor(
|
||||
private store: RootStore,
|
||||
publishSettings: TPublishSettings
|
||||
publishSettings: TProjectPublishSettings
|
||||
) {
|
||||
this.anchor = publishSettings.anchor;
|
||||
this.is_comments_enabled = publishSettings.is_comments_enabled;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import set from "lodash/set";
|
||||
import { makeObservable, observable, runInAction, action } from "mobx";
|
||||
// types
|
||||
import { TPublishSettings } from "@plane/types";
|
||||
import { TProjectPublishSettings } from "@plane/types";
|
||||
// services
|
||||
import PublishService from "@/services/publish.service";
|
||||
// store
|
||||
|
|
@ -13,7 +13,7 @@ export interface IPublishListStore {
|
|||
// observables
|
||||
publishMap: Record<string, PublishStore>; // anchor => PublishStore
|
||||
// actions
|
||||
fetchPublishSettings: (pageId: string) => Promise<TPublishSettings>;
|
||||
fetchPublishSettings: (pageId: string) => Promise<TProjectPublishSettings>;
|
||||
}
|
||||
|
||||
export class PublishListStore implements IPublishListStore {
|
||||
|
|
@ -42,7 +42,13 @@ export class PublishListStore implements IPublishListStore {
|
|||
const response = await this.publishService.fetchPublishSettings(anchor);
|
||||
runInAction(() => {
|
||||
if (response.anchor && response.view_props) {
|
||||
this.store.issueFilter.updateLayoutOptions(response?.view_props);
|
||||
this.store.issueFilter.updateLayoutOptions({
|
||||
list: !!response.view_props.list,
|
||||
kanban: !!response.view_props.kanban,
|
||||
calendar: !!response.view_props.calendar,
|
||||
gantt: !!response.view_props.gantt,
|
||||
spreadsheet: !!response.view_props.spreadsheet,
|
||||
});
|
||||
set(this.publishMap, [response.anchor], new PublishStore(this.store, response));
|
||||
}
|
||||
});
|
||||
|
|
|
|||
24
space/types/publish.d.ts
vendored
24
space/types/publish.d.ts
vendored
|
|
@ -1,24 +0,0 @@
|
|||
import { IWorkspaceLite } from "@plane/types";
|
||||
import { TProjectDetails, TViewDetails } from "@/types/project";
|
||||
|
||||
export type TPublishEntityType = "project";
|
||||
|
||||
export type TPublishSettings = {
|
||||
anchor: string | undefined;
|
||||
is_comments_enabled: boolean;
|
||||
created_at: string | undefined;
|
||||
created_by: string | undefined;
|
||||
entity_identifier: string | undefined;
|
||||
entity_name: TPublishEntityType | undefined;
|
||||
id: string | undefined;
|
||||
inbox: unknown;
|
||||
project: string | undefined;
|
||||
project_details: TProjectDetails | undefined;
|
||||
is_reactions_enabled: boolean;
|
||||
updated_at: string | undefined;
|
||||
updated_by: string | undefined;
|
||||
view_props: TViewDetails | undefined;
|
||||
is_votes_enabled: boolean;
|
||||
workspace: string | undefined;
|
||||
workspace_detail: IWorkspaceLite | undefined;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue