Skip to content

Commit

Permalink
feat(gui): open links in default browser (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
Einliterflasche authored Sep 4, 2024
1 parent e4141c7 commit ff2e3ae
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 190 deletions.
347 changes: 172 additions & 175 deletions Cargo.lock

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions src-gui/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ export default [
languageOptions: { globals: globals.browser },
rules: {
"react/react-in-jsx-scope": "off",
// Disallow the use of the `open` on the gloal object
"no-restricted-globals": [
"warn",
{
name: "open",
message:
"Use the open(...) function from @tauri-apps/plugin-shell instead",
},
],
// Disallow the use of the `open` on the `window` object
"no-restricted-properties": [
"warn",
{
object: "window",
property: "open",
message:
"Use the open(...) function from @tauri-apps/plugin-shell instead",
},
],
},
},
];
1 change: 1 addition & 0 deletions src-gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@reduxjs/toolkit": "^2.2.6",
"@tauri-apps/api": "2.0.0-rc.1",
"@tauri-apps/plugin-clipboard-manager": "^2.0.0-rc.0",
"@tauri-apps/plugin-shell": "^2.0.0-rc.0",
"humanize-duration": "^3.32.1",
"lodash": "^4.17.21",
"multiaddr": "^10.0.1",
Expand Down
1 change: 1 addition & 0 deletions src-gui/src/renderer/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box, CssBaseline, makeStyles } from "@material-ui/core";
import { indigo } from "@material-ui/core/colors";
import { createTheme, ThemeProvider } from "@material-ui/core/styles";
import "@tauri-apps/plugin-shell";
import { Route, MemoryRouter as Router, Routes } from "react-router-dom";
import Navigation, { drawerWidth } from "./navigation/Navigation";
import HelpPage from "./pages/help/HelpPage";
Expand Down
3 changes: 2 additions & 1 deletion src-gui/src/renderer/components/icons/LinkIconButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IconButton } from "@material-ui/core";
import { open } from "@tauri-apps/plugin-shell";
import { ReactNode } from "react";

export default function LinkIconButton({
Expand All @@ -9,7 +10,7 @@ export default function LinkIconButton({
children: ReactNode;
}) {
return (
<IconButton component="span" onClick={() => window.open(url, "_blank")}>
<IconButton component="span" onClick={() => open(url)}>
{children}
</IconButton>
);
Expand Down
13 changes: 4 additions & 9 deletions src-gui/src/renderer/components/pages/help/ContactInfoBox.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, Button, makeStyles, Typography } from "@material-ui/core";
import { open } from "@tauri-apps/plugin-shell";
import InfoBox from "../../modal/swap/InfoBox";

const useStyles = makeStyles((theme) => ({
Expand Down Expand Up @@ -27,19 +28,13 @@ export default function ContactInfoBox() {
}
additionalContent={
<Box className={classes.spacedBox}>
<Button
variant="outlined"
onClick={() => window.open(GITHUB_ISSUE_URL)}
>
<Button variant="outlined" onClick={() => open(GITHUB_ISSUE_URL)}>
Open GitHub issue
</Button>
<Button
variant="outlined"
onClick={() => window.open(MATRIX_ROOM_URL)}
>
<Button variant="outlined" onClick={() => open(MATRIX_ROOM_URL)}>
Join Matrix room
</Button>
<Button variant="outlined" onClick={() => window.open(DISCORD_URL)}>
<Button variant="outlined" onClick={() => open(DISCORD_URL)}>
Join Discord
</Button>
</Box>
Expand Down
12 changes: 12 additions & 0 deletions src-gui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,11 @@
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-2.0.0-rc.3.tgz#1dd17530de9cafd854f77d3feeca1732a985a81e"
integrity sha512-k1erUfnoOFJwL5VNFZz0BQZ2agNstG7CNOjwpdWMl1vOaVuSn4DhJtXB0Deh9lZaaDlfrykKOyZs9c3XXpMi5Q==

"@tauri-apps/api@^2.0.0-rc.4":
version "2.0.0-rc.4"
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-2.0.0-rc.4.tgz#2b4c3493d86382981787c52006c6c9e5bf16bc08"
integrity sha512-UNiIhhKG08j4ooss2oEEVexffmWkgkYlC2M3GcX3VPtNsqFgVNL8Mcw/4Y7rO9M9S+ffAMnLOF5ypzyuyb8tyg==

"@tauri-apps/[email protected]":
version "2.0.0-beta.21"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.0.0-beta.21.tgz#9dc6f306b14d58b0b4fbf218ffbb31831e28cf4d"
Expand Down Expand Up @@ -708,6 +713,13 @@
dependencies:
"@tauri-apps/api" "^2.0.0-rc.0"

"@tauri-apps/plugin-shell@^2.0.0-rc.0":
version "2.0.0-rc.1"
resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-shell/-/plugin-shell-2.0.0-rc.1.tgz#9facf3bbcedfa2de676cb4cfc703687377aa12a3"
integrity sha512-JtNROc0rqEwN/g93ig5pK4cl1vUo2yn+osCpY9de64cy/d9hRzof7AuYOgvt/Xcd5VPQmlgo2AGvUh5sQRSR1A==
dependencies:
"@tauri-apps/api" "^2.0.0-rc.4"

"@types/babel__core@^7.20.5":
version "7.20.5"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.20.5.tgz#3df15f27ba85319caa07ba08d0721889bb39c017"
Expand Down
1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ serde_json = "1"
swap = { path = "../swap", features = [ "tauri" ] }
tauri = { version = "2.0.0-rc.1", features = [ "config-json5" ] }
tauri-plugin-clipboard-manager = "2.1.0-beta.7"
tauri-plugin-shell = "2.0.0-rc.2"
9 changes: 4 additions & 5 deletions src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": [
"main"
],
"windows": ["main"],
"permissions": [
"core:event:allow-emit",
"core:event:default",
"clipboard-manager:allow-write-text"
"clipboard-manager:allow-write-text",
"shell:allow-open"
]
}
}
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ fn setup(app: &mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_clipboard_manager::init())
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![
get_balance,
get_swap_infos_all,
Expand Down

0 comments on commit ff2e3ae

Please sign in to comment.