fix: build errors in the inbox store and updated the types for filters, display_filters and display_properties in the global views

This commit is contained in:
gurusainath 2024-01-30 14:58:35 +05:30
parent 5674acd985
commit 05e4311e06
6 changed files with 40 additions and 164 deletions

View File

@ -53,22 +53,16 @@ export type TViewDisplayProperties = {
updated_on: boolean;
};
export type TViewProps = {
filters: TViewFilters;
display_filters: TViewDisplayFilters;
display_properties: TViewDisplayProperties;
};
export type TView = {
id: string;
workspace: string;
project: string | undefined;
name: string;
description: string | undefined;
description: string;
query: string;
filters: undefined;
display_filters: undefined;
display_properties: undefined;
filters: TViewFilters;
display_filters: TViewDisplayFilters;
display_properties: TViewDisplayProperties;
access: TViewAccess;
owned_by: string;
sort_order: number;

View File

@ -18,7 +18,7 @@ import { Button } from "@plane/ui";
// icons
import { CheckCircle2, ChevronDown, ChevronUp, Clock, FileStack, Trash2, XCircle } from "lucide-react";
// types
import type { TInboxStatus, TInboxDetailedStatus } from "@plane/types";
import type { TInboxDetailedStatus } from "@plane/types";
import { EUserProjectRoles } from "constants/project";
type TInboxIssueActionsHeader = {
@ -29,7 +29,7 @@ type TInboxIssueActionsHeader = {
};
type TInboxIssueOperations = {
updateInboxIssueStatus: (data: TInboxStatus) => Promise<void>;
updateInboxIssueStatus: (data: TInboxDetailedStatus) => Promise<void>;
removeInboxIssue: () => Promise<void>;
};

View File

@ -1,122 +0,0 @@
import { APIService } from "services/api.service";
// helpers
import { API_BASE_URL } from "helpers/common.helper";
// types
import type { IInboxIssue, IInbox, TInboxStatus, IInboxQueryParams } from "@plane/types";
export class InboxService extends APIService {
constructor() {
super(API_BASE_URL);
}
async getInboxes(workspaceSlug: string, projectId: string): Promise<IInbox[]> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/inboxes/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async getInboxById(workspaceSlug: string, projectId: string, inboxId: string): Promise<IInbox> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/inboxes/${inboxId}/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async patchInbox(workspaceSlug: string, projectId: string, inboxId: string, data: Partial<IInbox>): Promise<any> {
return this.patch(`/api/workspaces/${workspaceSlug}/projects/${projectId}/inboxes/${inboxId}/`, data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async getInboxIssues(
workspaceSlug: string,
projectId: string,
inboxId: string,
params?: IInboxQueryParams
): Promise<IInboxIssue[]> {
return this.get(`/api/workspaces/${workspaceSlug}/projects/${projectId}/inboxes/${inboxId}/inbox-issues/`, {
params,
})
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async getInboxIssueById(
workspaceSlug: string,
projectId: string,
inboxId: string,
inboxIssueId: string
): Promise<IInboxIssue> {
return this.get(
`/api/workspaces/${workspaceSlug}/projects/${projectId}/inboxes/${inboxId}/inbox-issues/${inboxIssueId}/`
)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async deleteInboxIssue(
workspaceSlug: string,
projectId: string,
inboxId: string,
inboxIssueId: string
): Promise<any> {
return this.delete(
`/api/workspaces/${workspaceSlug}/projects/${projectId}/inboxes/${inboxId}/inbox-issues/${inboxIssueId}/`
)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async markInboxStatus(
workspaceSlug: string,
projectId: string,
inboxId: string,
inboxIssueId: string,
data: TInboxStatus
): Promise<IInboxIssue> {
return this.patch(
`/api/workspaces/${workspaceSlug}/projects/${projectId}/inboxes/${inboxId}/inbox-issues/${inboxIssueId}/`,
data
)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async patchInboxIssue(
workspaceSlug: string,
projectId: string,
inboxId: string,
inboxIssueId: string,
data: { issue: Partial<IInboxIssue> }
): Promise<any> {
return this.patch(
`/api/workspaces/${workspaceSlug}/projects/${projectId}/inboxes/${inboxId}/inbox-issues/${inboxIssueId}/`,
data
)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async createInboxIssue(workspaceSlug: string, projectId: string, inboxId: string, data: any): Promise<IInboxIssue> {
return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/inboxes/${inboxId}/inbox-issues/`, data)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}

View File

@ -2,7 +2,7 @@ import { observable, action, makeObservable, runInAction, computed } from "mobx"
import set from "lodash/set";
import isEmpty from "lodash/isEmpty";
// services
import { InboxService } from "services/inbox.service";
import { InboxService } from "services/inbox/inbox.service";
// types
import { RootStore } from "store/root.store";
import { TInboxIssueFilterOptions, TInboxIssueFilters, TInboxIssueQueryParams, TInbox } from "@plane/types";

View File

@ -53,7 +53,7 @@ export class ViewRoot implements TViewRoot {
fetch = async () => {
try {
const { workspaceSlug, projectId } = this.store.app.router;
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug) return;
const views = await this.service.fetch(workspaceSlug, projectId);
if (!views) return;
@ -69,7 +69,7 @@ export class ViewRoot implements TViewRoot {
create = async (_view: Partial<TView>) => {
try {
const { workspaceSlug, projectId } = this.store.app.router;
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug) return;
const view = await this.service.create(workspaceSlug, _view, projectId);
if (!view) return;
@ -83,7 +83,7 @@ export class ViewRoot implements TViewRoot {
delete = async (viewId: string) => {
try {
const { workspaceSlug, projectId } = this.store.app.router;
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug) return;
await this.service.remove(workspaceSlug, viewId, projectId);
@ -96,7 +96,7 @@ export class ViewRoot implements TViewRoot {
duplicate = async (viewId: string) => {
try {
const { workspaceSlug, projectId } = this.store.app.router;
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug) return;
const view = await this.service.duplicate(workspaceSlug, viewId, projectId);
if (!view) return;

View File

@ -12,9 +12,9 @@ export type TViews = TView & {
// actions
updateName: (name: string) => Promise<void>;
updateDescription: (description: string) => Promise<void>;
updateFilters: (filters: TViewFilters) => Promise<void>;
updateDisplayFilters: (display_filters: TViewDisplayFilters) => Promise<void>;
updateDisplayProperties: (display_properties: TViewDisplayProperties) => Promise<void>;
updateFilters: (filters: Partial<TViewFilters>) => Promise<void>;
updateDisplayFilters: (display_filters: Partial<TViewDisplayFilters>) => Promise<void>;
updateDisplayProperties: (display_properties: Partial<TViewDisplayProperties>) => Promise<void>;
lockView: () => Promise<void>;
unlockView: () => Promise<void>;
};
@ -24,11 +24,11 @@ export class Views implements TViews {
workspace: string;
project: string | undefined;
name: string;
description: string | undefined;
description: string;
query: string;
filters: undefined;
display_filters: undefined;
display_properties: undefined;
filters: TViewFilters;
display_filters: TViewDisplayFilters;
display_properties: TViewDisplayProperties;
access: TViewAccess;
owned_by: string;
sort_order: number;
@ -82,7 +82,7 @@ export class Views implements TViews {
updateName = async (name: string) => {
try {
const { workspaceSlug, projectId } = this.store.app.router;
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug) return;
const view = await this.service.update(workspaceSlug, this.id, { name: name }, projectId);
if (!view) return;
@ -96,7 +96,7 @@ export class Views implements TViews {
updateDescription = async (description: string) => {
try {
const { workspaceSlug, projectId } = this.store.app.router;
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug) return;
const view = await this.service.update(workspaceSlug, this.id, { description: description }, projectId);
if (!view) return;
@ -107,12 +107,15 @@ export class Views implements TViews {
}
};
updateFilters = async (filters: any) => {
updateFilters = async (filters: Partial<TViewFilters>) => {
try {
const { workspaceSlug, projectId } = this.store.app.router;
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug) return;
const view = await this.service.update(workspaceSlug, this.id, { filters: filters }, projectId);
const viewFilters = this.filters;
const _filters = { ...viewFilters, ...filters };
const view = await this.service.update(workspaceSlug, this.id, { filters: _filters }, projectId);
if (!view) return;
this.filters = view.filters;
@ -121,12 +124,15 @@ export class Views implements TViews {
}
};
updateDisplayFilters = async (display_filters: any) => {
updateDisplayFilters = async (display_filters: Partial<TViewDisplayFilters>) => {
try {
const { workspaceSlug, projectId } = this.store.app.router;
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug) return;
const view = await this.service.update(workspaceSlug, this.id, { display_filters: display_filters }, projectId);
const viewDisplayFilters = this.display_filters;
const _filters = { ...viewDisplayFilters, ...display_filters };
const view = await this.service.update(workspaceSlug, this.id, { display_filters: _filters }, projectId);
if (!view) return;
this.display_filters = view.display_filters;
@ -135,17 +141,15 @@ export class Views implements TViews {
}
};
updateDisplayProperties = async (display_properties: any) => {
updateDisplayProperties = async (display_properties: Partial<TViewDisplayProperties>) => {
try {
const { workspaceSlug, projectId } = this.store.app.router;
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug) return;
const view = await this.service.update(
workspaceSlug,
this.id,
{ display_properties: display_properties },
projectId
);
const viewDisplayProperties = this.display_properties;
const _filters = { ...viewDisplayProperties, ...display_properties };
const view = await this.service.update(workspaceSlug, this.id, { display_properties: _filters }, projectId);
if (!view) return;
this.display_properties = view.display_properties;
@ -157,7 +161,7 @@ export class Views implements TViews {
lockView = async () => {
try {
const { workspaceSlug, projectId } = this.store.app.router;
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug) return;
const view = await this.service.lock(workspaceSlug, this.id, projectId);
if (!view) return;
@ -171,7 +175,7 @@ export class Views implements TViews {
unlockView = async () => {
try {
const { workspaceSlug, projectId } = this.store.app.router;
if (!workspaceSlug || !projectId) return;
if (!workspaceSlug) return;
const view = await this.service.unlock(workspaceSlug, this.id, projectId);
if (!view) return;