Skip to content

Commit d3b9291

Browse files
committed
feat: open url in browser
1 parent 64415fc commit d3b9291

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

desktop-app/src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { app, BrowserWindow } from "electron";
1+
import { app, BrowserWindow, ipcMain, shell } from "electron";
22
import { wrapMainService } from "./messaging/wrapMainService";
33
import { DappMarketplaceService } from "./services/marketplace/service";
44
import { DumpDeployerService } from "./services/dump-deployer/service";
@@ -33,6 +33,16 @@ const createWindow = () => {
3333
"dump-deployer"
3434
);
3535
wrapMainService(docker, "docker");
36+
ipcMain.handle(
37+
"open-url-in-browser",
38+
(_, url: string | Record<string, string>) => {
39+
if (typeof url === "string") {
40+
shell.openExternal(url);
41+
} else if (typeof url === "object") {
42+
shell.openExternal(url[process.platform] || url.default);
43+
}
44+
}
45+
);
3646

3747
if (isDev) {
3848
mainWindow.loadURL("http://localhost:3001/index.html");

desktop-app/src/preload.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// See the Electron documentation for details on how to use preload scripts:
22
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
33

4-
import { contextBridge } from "electron";
4+
import { contextBridge, ipcRenderer } from "electron";
55
import { registerRendererService } from "./messaging/registerRendererService";
66

77
const localhostService = {
@@ -25,6 +25,9 @@ const localhostService = {
2525
channelName: "docker",
2626
methodNames: ["isDockerAvailable"],
2727
}),
28+
openUrlInBrowser(url: string) {
29+
ipcRenderer.invoke("open-url-in-browser", url);
30+
},
2831
};
2932

3033
contextBridge.exposeInMainWorld("localhostService", localhostService);

ui/src/_dev/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const service = {
66
marketplace,
77
docker: new DevDockerService(),
88
deployer: new DeploymentsService(),
9+
openUrlInBrowser(url: string | Record<string, string>) {},
910
};
1011

1112
export default service;

ui/src/features/docker/ui/DockerCheck.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Spin, Button, Typography } from "antd";
33
import { useAppDispatch, useAppSelector } from "shared/model/hooks";
44
import { selectDockerAvailability } from "../model/slice";
55
import { checkDockerAvailability } from "../api/check";
6+
import service from "localhostService";
67

78
export const DockerCheck: React.FC<PropsWithChildren> = ({ children }) => {
89
const dispatch = useAppDispatch();
@@ -37,8 +38,24 @@ export const DockerCheck: React.FC<PropsWithChildren> = ({ children }) => {
3738
<Typography.Title level={3} className="text-3xl font-bold mb-6">
3839
Ooops! We can't connect the docker
3940
</Typography.Title>
40-
<div className="flex justify-center items-center w-full h-full">
41+
<div className="flex justify-center items-center w-full h-full flex-col">
4142
<Button onClick={checkAgainClickHandler}>Try again</Button>
43+
<Button
44+
type="link"
45+
onClick={() =>
46+
service.openUrlInBrowser({
47+
win32:
48+
"https://docs.docker.com/desktop/install/windows-install/",
49+
darwin:
50+
"https://docs.docker.com/desktop/install/mac-install/",
51+
default:
52+
"https://docs.docker.com/desktop/install/windows-install/",
53+
})
54+
}
55+
className="mt-3"
56+
>
57+
Or install it
58+
</Button>
4259
</div>
4360
</div>
4461
</div>

0 commit comments

Comments
 (0)