Skip to content

Commit 709f2f4

Browse files
committed
new devtools ui
1 parent c45ec93 commit 709f2f4

File tree

73 files changed

+1247
-375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1247
-375
lines changed

packages/devtools/electron.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { ElectronAPI } from "@electron-toolkit/preload";
2+
3+
declare global {
4+
interface Window {
5+
electron: ElectronAPI & {
6+
store: {
7+
get: (key: string) => T;
8+
set: (key: string, val: T) => void;
9+
delete: (key: string) => void;
10+
};
11+
};
12+
api: unknown;
13+
}
14+
}

packages/devtools/package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
},
5252
"dependencies": {
5353
"@electron-toolkit/preload": "^3.0.1",
54-
"@hyper-fetch/core": "file:./../core/",
55-
"@hyper-fetch/devtools-plugin": "file:./../devtools-plugin/",
56-
"@hyper-fetch/react": "file:./../react/",
57-
"@hyper-fetch/sockets": "file:./../sockets/",
54+
"@hyper-fetch/core": "*",
55+
"@hyper-fetch/devtools-plugin": "*",
56+
"@hyper-fetch/react": "*",
57+
"@hyper-fetch/sockets": "*",
5858
"@radix-ui/react-avatar": "^1.1.3",
5959
"@radix-ui/react-checkbox": "^1.0.4",
6060
"@radix-ui/react-collapsible": "^1.1.3",
@@ -90,11 +90,13 @@
9090
"react-dom": "^19.0.0",
9191
"react-json-tree": "^0.19.0",
9292
"react-textarea-autosize": "^8.5.7",
93+
"recharts": "^2.15.1",
9394
"sonner": "^1.4.41",
9495
"tailwind-merge": "^3.0.2",
9596
"tailwindcss-animate": "^1.0.7",
9697
"use-immer": "^0.11.0",
97-
"zod": "^3.23.8"
98+
"zod": "^3.23.8",
99+
"zustand": "^5.0.3"
98100
},
99101
"lint-staged": {
100102
"*.{js,jsx,ts,tsx}": [

packages/devtools/src/app/main.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { app, BrowserWindow } from "electron";
1+
import { app, BrowserWindow, clipboard, Data, ipcMain, nativeImage } from "electron";
22
import path from "node:path";
33
import started from "electron-squirrel-startup";
4+
import Store from "electron-store";
45

56
import { startServer } from "../server";
67

@@ -9,6 +10,7 @@ if (started) {
910
app.quit();
1011
}
1112

13+
const store = new Store();
1214
const createWindow = () => {
1315
// Create the browser window.
1416
const mainWindow = new BrowserWindow({
@@ -17,6 +19,7 @@ const createWindow = () => {
1719
width: 1200,
1820
height: 800,
1921
webPreferences: {
22+
sandbox: false,
2023
preload: path.join(__dirname, "preload.js"),
2124
},
2225
});
@@ -29,14 +32,42 @@ const createWindow = () => {
2932
}
3033

3134
// Open the DevTools.
32-
mainWindow.webContents.openDevTools();
35+
if (process.env.NODE_ENV !== "production") {
36+
mainWindow.webContents.openDevTools();
37+
}
3338
};
3439

3540
// This method will be called when Electron has finished
3641
// initialization and is ready to create browser windows.
3742
// Some APIs can only be used after this event occurs.
3843
app.on("ready", createWindow);
3944

45+
app.whenReady().then(() => {
46+
ipcMain.on("electron-store-get", async (event, val) => {
47+
// eslint-disable-next-line no-param-reassign
48+
event.returnValue = store.get(val);
49+
});
50+
ipcMain.on("electron-store-set", async (_, key, val) => {
51+
store.set(key, val);
52+
});
53+
54+
ipcMain.on("electron-store-delete", async (_, key) => {
55+
try {
56+
store.delete(key);
57+
} catch (error) {
58+
console.error("🚀 ~ ipcMain.on ~ error:", error);
59+
}
60+
});
61+
62+
ipcMain.on("clipboard", async (_, val: Data & { img?: string }) => {
63+
if (val.img) {
64+
clipboard.writeImage(nativeImage.createFromBuffer(Buffer.from(val.img, "base64")));
65+
} else {
66+
clipboard.write(val);
67+
}
68+
});
69+
});
70+
4071
// Quit when all windows are closed, except on macOS. There, it's common
4172
// for applications and their menu bar to stay active until the user quits
4273
// explicitly with Cmd + Q.
Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,41 @@
1-
import { DevtoolsWorkspaces } from "frontend/context/devtools.context";
1+
import { DevtoolsOnlineProjects } from "frontend/context/devtools.context";
22
import { Layout } from "./components/layout/layout";
3-
import { useConnectWorkspaces } from "./hooks/use-connect-workspaces";
3+
import { useOnlineProjects } from "./hooks/use-connect-workspaces";
44
import { Route } from "./routing/router";
55

66
export function App() {
7-
const { workspaces, setWorkspaces, activeWorkspace, setActiveWorkspace } = useConnectWorkspaces();
7+
const { projects, setProjects } = useOnlineProjects();
88

9-
const setRequestList = (workspaceName: string, requestList: any) => {
10-
setWorkspaces((draft) => {
11-
const selectedWorkspace = draft[workspaceName];
12-
if (selectedWorkspace) {
13-
selectedWorkspace.requests = requestList;
9+
const setRequestList = (projectId: string, requestList: any) => {
10+
setProjects((draft) => {
11+
const selectedProject = draft[projectId];
12+
if (selectedProject) {
13+
selectedProject.requests = requestList;
1414
}
1515
});
1616
};
1717

1818
return (
1919
<Layout>
20-
<DevtoolsWorkspaces
21-
workspaces={workspaces}
22-
activeWorkspace={activeWorkspace}
23-
setActiveWorkspace={setActiveWorkspace}
24-
setRequestList={setRequestList}
25-
>
20+
<DevtoolsOnlineProjects projects={projects} setRequestList={setRequestList}>
2621
<Route to="dashboard" />
27-
<Route to="project" />
2822
<Route to="dashboard.projects" />
29-
<Route to="dashboard.resources" />
23+
<Route to="dashboard.onlineProjects" />
3024
<Route to="dashboard.members" />
3125
<Route to="dashboard.settings" />
3226
<Route to="dashboard.activities" />
3327
<Route to="dashboard.favorites" />
3428
<Route to="dashboard.recentlyVisited" />
35-
<Route to="project.workspace" />
36-
<Route to="project.network" />
37-
<Route to="project.cache" />
38-
<Route to="project.queues" />
39-
<Route to="project.settings" />
29+
<Route to="workspace" />
30+
<Route to="workspace.network" />
31+
<Route to="workspace.cache" />
32+
<Route to="workspace.queues" />
33+
<Route to="workspace.settings" />
4034
{/* {activeWorkspace && workspaces[activeWorkspace] && (
4135
<Devtools workspace={activeWorkspace} client={workspaces[activeWorkspace].client} />
4236
)} */}
4337
{/* TODO NO CONTENT */}
44-
</DevtoolsWorkspaces>
38+
</DevtoolsOnlineProjects>
4539
</Layout>
4640
);
4741
}

packages/devtools/src/frontend/components/app/header/header.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable jsx-a11y/control-has-associated-label */
22
import { XIcon } from "lucide-react";
33

4-
import { useDevtoolsContext, useWorkspaces } from "frontend/pages/project/_context/devtools.context";
5-
import { DevtoolsModule } from "frontend/pages/project/_context/devtools.types";
4+
import { useDevtoolsContext, useOnlineProjects } from "frontend/pages/workspace/_context/devtools.context";
5+
import { DevtoolsModule } from "frontend/pages/workspace/_context/devtools.types";
66
import { tokens } from "frontend/theme/tokens";
77
import { createStyles } from "frontend/theme/use-styles.hook";
88
import { LogoIcon } from "frontend/icons/logo";
@@ -90,7 +90,7 @@ export const Header = (props: React.HTMLProps<HTMLDivElement>) => {
9090
const css = styles.useStyles();
9191

9292
const { setOpen, setModule } = useDevtoolsContext("DevtoolsHeader");
93-
const { activeWorkspace, workspaces } = useWorkspaces("DevtoolsWorkspace");
93+
const { activeWorkspace, workspaces } = useOnlineProjects("DevtoolsWorkspace");
9494

9595
const workspace = activeWorkspace ? workspaces[activeWorkspace] : null;
9696
const name = workspace?.name || "Devtools";

packages/devtools/src/frontend/components/app/menu/menu.constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
// SquareChartGanttIcon,
88
} from "lucide-react";
99

10-
import { DevtoolsModule } from "frontend/pages/project/_context/devtools.types";
10+
import { DevtoolsModule } from "frontend/pages/workspace/_context/devtools.types";
1111

1212
export const menuIcons: Partial<
1313
Record<DevtoolsModule, React.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>>

packages/devtools/src/frontend/components/app/menu/menu.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createStyles } from "frontend/theme/use-styles.hook";
2-
import { useDevtoolsContext } from "frontend/pages/project/_context/devtools.context";
3-
import { DevtoolsModule } from "frontend/pages/project/_context/devtools.types";
2+
import { useDevtoolsContext } from "frontend/pages/workspace/_context/devtools.context";
3+
import { DevtoolsModule } from "frontend/pages/workspace/_context/devtools.types";
44
import { menuIcons } from "./menu.constants";
55
import { tokens } from "frontend/theme/tokens";
66
import { useAppContext } from "../app.context";

packages/devtools/src/frontend/components/app/resizable/resizable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect } from "react";
22
import { Resizable as ResizableComponent } from "re-resizable";
33

4-
import { useDevtoolsContext } from "frontend/pages/project/_context/devtools.context";
4+
import { useDevtoolsContext } from "frontend/pages/workspace/_context/devtools.context";
55
import { createStyles } from "frontend/theme/use-styles.hook";
66
import { minSizes, sizes } from "./resizable.constants";
77

packages/devtools/src/frontend/components/json-viewer/json-viewer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { CommonExternalProps, JSONTree } from "react-json-tree";
33
import { produce } from "immer";
44

5-
import { useDevtoolsContext } from "frontend/pages/project/_context/devtools.context";
65
import { Value } from "./value/value";
76
import { Label } from "./label/label";
87
import { getRaw, getTheme, updateValue } from "./json-viewer.utils";
@@ -21,7 +20,8 @@ export const JSONViewer = ({
2120
onChange?: (value: any) => void;
2221
} & Partial<Omit<CommonExternalProps, "data" | "theme" | "valueRenderer">>) => {
2322
const css = styles.useStyles();
24-
const { theme } = useDevtoolsContext("JSONViewer");
23+
// const { theme } = useDevtoolsContext("JSONViewer");
24+
const theme = "light";
2525

2626
const handleOnChange = (path: (number | string)[]) => (value: any) => {
2727
if (onChange) {

packages/devtools/src/frontend/components/toolbar/toolbar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as Select from "frontend/components/select/select";
44
import * as DropdownMenu from "frontend/components/dropdown/dropdown";
55
import { IconButton } from "frontend/components/icon-button/icon-button";
66
import { Bar } from "frontend/components/bar/bar";
7-
import { useDevtoolsContext, useWorkspaces } from "frontend/pages/project/_context/devtools.context";
7+
import { useDevtoolsContext, useOnlineProjects } from "frontend/pages/workspace/_context/devtools.context";
88
import { tokens } from "frontend/theme/tokens";
99

1010
export enum Positions {
@@ -23,7 +23,7 @@ const positionsIcons = {
2323
export const Toolbar = ({ children }: { children: React.ReactNode }) => {
2424
const { isOnline, setIsOnline, position, setPosition, theme, setTheme, isStandalone } =
2525
useDevtoolsContext("DevtoolsOptions");
26-
const { workspaces, activeWorkspace, setActiveWorkspace } = useWorkspaces("DevtoolsOptions");
26+
const { workspaces, activeWorkspace, setActiveWorkspace } = useOnlineProjects("DevtoolsOptions");
2727

2828
return (
2929
<Bar>

0 commit comments

Comments
 (0)