feat(gui): open links in default browser (#50)

This commit is contained in:
Einliterflasche 2024-09-04 17:11:06 +02:00 committed by GitHub
parent e4141c763b
commit ff2e3ae8dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 218 additions and 191 deletions

View file

@ -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",
},
],
},
},
];

View file

@ -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",

View file

@ -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";

View file

@ -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({
@ -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>
);

View file

@ -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) => ({
@ -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>

View file

@ -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/cli-darwin-arm64@2.0.0-beta.21":
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"
@ -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"