diff --git a/packages/types/src/view.d.ts b/packages/types/src/view.d.ts index 6d557a074..0cbc2d48d 100644 --- a/packages/types/src/view.d.ts +++ b/packages/types/src/view.d.ts @@ -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; diff --git a/web/components/inbox/inbox-issue-actions.tsx b/web/components/inbox/inbox-issue-actions.tsx index 0ca28b950..3f8b9ef14 100644 --- a/web/components/inbox/inbox-issue-actions.tsx +++ b/web/components/inbox/inbox-issue-actions.tsx @@ -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; + updateInboxIssueStatus: (data: TInboxDetailedStatus) => Promise; removeInboxIssue: () => Promise; }; diff --git a/web/services/inbox.service.ts b/web/services/inbox.service.ts deleted file mode 100644 index a36d356ce..000000000 --- a/web/services/inbox.service.ts +++ /dev/null @@ -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 { - 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 { - 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): Promise { - 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 { - 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 { - 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 { - 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 { - 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 } - ): Promise { - 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 { - return this.post(`/api/workspaces/${workspaceSlug}/projects/${projectId}/inboxes/${inboxId}/inbox-issues/`, data) - .then((response) => response?.data) - .catch((error) => { - throw error?.response?.data; - }); - } -} diff --git a/web/store/inbox/inbox_filter.store.ts b/web/store/inbox/inbox_filter.store.ts index c4566acbe..72e19c04b 100644 --- a/web/store/inbox/inbox_filter.store.ts +++ b/web/store/inbox/inbox_filter.store.ts @@ -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"; diff --git a/web/store/view/view-root.store.ts b/web/store/view/view-root.store.ts index fb775b877..02438c7cd 100644 --- a/web/store/view/view-root.store.ts +++ b/web/store/view/view-root.store.ts @@ -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) => { 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; diff --git a/web/store/view/view.store.ts b/web/store/view/view.store.ts index e7cf8b8c2..cd5b7ed06 100644 --- a/web/store/view/view.store.ts +++ b/web/store/view/view.store.ts @@ -12,9 +12,9 @@ export type TViews = TView & { // actions updateName: (name: string) => Promise; updateDescription: (description: string) => Promise; - updateFilters: (filters: TViewFilters) => Promise; - updateDisplayFilters: (display_filters: TViewDisplayFilters) => Promise; - updateDisplayProperties: (display_properties: TViewDisplayProperties) => Promise; + updateFilters: (filters: Partial) => Promise; + updateDisplayFilters: (display_filters: Partial) => Promise; + updateDisplayProperties: (display_properties: Partial) => Promise; lockView: () => Promise; unlockView: () => Promise; }; @@ -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) => { 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) => { 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) => { 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;