Skip to content

Commit 02c64bf

Browse files
authored
dev: dashboards layout, store, services and types (#2367)
* chore: dashboards layout and store * chore: rename services
1 parent aaf7369 commit 02c64bf

File tree

15 files changed

+394
-2
lines changed

15 files changed

+394
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./workspace-dashboards.service";
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// plane constants
2+
import { API_BASE_URL } from "@plane/constants";
3+
// plane types
4+
import { TWorkspaceDashboard } from "@plane/types";
5+
import { APIService } from "../api.service";
6+
7+
export class WorkspaceDashboardsService extends APIService {
8+
constructor(BASE_URL?: string) {
9+
super(BASE_URL || API_BASE_URL);
10+
}
11+
12+
/**
13+
* Retrieves the list of dashboards for a specific workspace
14+
* @param {string} workspaceSlug - The unique identifier for the workspace
15+
* @returns {Promise<TWorkspaceDashboard>} Promise resolving to dashboard data
16+
* @throws {Error} If the API request fails
17+
*/
18+
async list(workspaceSlug: string): Promise<TWorkspaceDashboard[]> {
19+
return this.get(`/api/workspaces/${workspaceSlug}/dashboards/`)
20+
.then((response) => response?.data)
21+
.catch((error) => {
22+
throw error?.response?.data;
23+
});
24+
}
25+
26+
/**
27+
* Retrieves detailed information about a specific dashboard
28+
* @param {string} workspaceSlug - The unique identifier for the workspace
29+
* @param {string} dashboardId - The unique identifier for the dashboard
30+
* @returns {Promise<TWorkspaceDashboard>} Promise resolving to dashboard details
31+
* @throws {Error} If the API request fails
32+
*/
33+
async retrieve(workspaceSlug: string, dashboardId: string): Promise<TWorkspaceDashboard> {
34+
return this.get(`/api/workspaces/${workspaceSlug}/dashboards/${dashboardId}/`)
35+
.then((response) => response?.data)
36+
.catch((error) => {
37+
throw error?.response?.data;
38+
});
39+
}
40+
41+
/**
42+
* Creates a new dashboard within a workspace
43+
* @param {string} workspaceSlug - The unique identifier for the workspace
44+
* @param {Partial<TWorkspaceDashboard>} data - Partial dashboard data to create
45+
* @returns {Promise<TWorkspaceDashboard>} Promise resolving to the created dashboard data
46+
* @throws {Error} If the API request fails
47+
*/
48+
async create(workspaceSlug: string, data: Partial<TWorkspaceDashboard>): Promise<TWorkspaceDashboard> {
49+
return this.post(`/api/workspaces/${workspaceSlug}/dashboards/`, data)
50+
.then((response) => response?.data)
51+
.catch((error) => {
52+
throw error?.response?.data;
53+
});
54+
}
55+
56+
/**
57+
* Updates a specific dashboard within a workspace
58+
* @param {string} workspaceSlug - The unique identifier for the workspace
59+
* @param {string} dashboardId - The unique identifier for the dashboard
60+
* @param {Partial<TWorkspaceDashboard>} data - Partial dashboard data to update
61+
* @returns {Promise<TWorkspaceDashboard>} Promise resolving to the updated dashboard data
62+
* @throws {Error} If the API request fails
63+
*/
64+
async update(
65+
workspaceSlug: string,
66+
dashboardId: string,
67+
data: Partial<TWorkspaceDashboard>
68+
): Promise<TWorkspaceDashboard> {
69+
return this.patch(`/api/workspaces/${workspaceSlug}/dashboard/${dashboardId}/`, data)
70+
.then((response) => response?.data)
71+
.catch((error) => {
72+
throw error?.response?.data;
73+
});
74+
}
75+
76+
/**
77+
* Removes a specific dashboard within a workspace
78+
* @param {string} workspaceSlug - The unique identifier for the workspace
79+
* @param {string} dashboardId - The unique identifier for the dashboard
80+
* @throws {Error} If the API request fails
81+
*/
82+
async destroy(workspaceSlug: string, dashboardId: string): Promise<void> {
83+
return this.delete(`/api/workspaces/${workspaceSlug}/dashboards/${dashboardId}/`)
84+
.then((response) => response?.data)
85+
.catch((error) => {
86+
throw error?.response?.data;
87+
});
88+
}
89+
}

packages/services/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ export * from "./developer";
44
export * from "./auth";
55
export * from "./cycle";
66
export * from "./dashboard";
7+
export * from "./dashboards";
78
export * from "./instance";
89
export * from "./intake";
910
export * from "./module";
1011
export * from "./user";
1112
export * from "./project";
1213
export * from "./workspace";
13-
export * from "./job"
14+
export * from "./job";
1415
export * from "./file";
1516
export * from "./label";
1617
export * from "./state";

packages/types/src/dashboards.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type TWorkspaceDashboard = {
2+
id: string | undefined;
3+
};

packages/types/src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export * from "./stickies";
4343
export * from "./intake";
4444
// enterprise
4545
export * from "./active-cycle";
46+
export * from "./dashboards";
4647
export * from "./payment";
4748
export * from "./teamspace";
4849
export * from "./initiatives";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// "use client";
2+
3+
// // components
4+
// import { ContentWrapper } from "@/components/core";
5+
6+
export default function DashboardDetailsLayout({ children }: { children: React.ReactNode }) {
7+
return <>{children}</>;
8+
9+
// return (
10+
// <>
11+
// <ContentWrapper>{children}</ContentWrapper>
12+
// </>
13+
// );
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { notFound } from "next/navigation";
2+
3+
// "use client";
4+
5+
// // components
6+
// import { PageHead } from "@/components/core";
7+
8+
export default function DashboardDetailsPage() {
9+
notFound();
10+
// return (
11+
// <>
12+
// <PageHead title="Dashboards" />
13+
// </>
14+
// );
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// "use client"
2+
//
3+
// // components
4+
// import { ContentWrapper } from "@/components/core";
5+
6+
export default function DashboardsListLayout({ children }: { children: React.ReactNode }) {
7+
return <>{children}</>;
8+
// return (
9+
// <>
10+
// <ContentWrapper>{children}</ContentWrapper>
11+
// </>
12+
// );
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { notFound } from "next/navigation";
2+
3+
// "use client"
4+
//
5+
// // components
6+
// import { PageHead } from "@/components/core";
7+
8+
export default function DashboardsListPage() {
9+
notFound();
10+
// return (
11+
// <>
12+
// <PageHead title="Dashboards" />
13+
// </>
14+
// );
15+
}

web/ee/hooks/store/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export * from "./use-workspace-subscription";
77
export * from "./issue-types";
88
export * from "./worklogs";
99
export * from "./use-self-hosted-subscription";
10+
export * from "./use-workspace-dashboards";
1011
export * from "./use-workspace-features";
1112
export * from "./workspace-project-states";
1213
export * from "./importers";

0 commit comments

Comments
 (0)