From 0a5563b2a7add8ed7d246d4c8cbdf9706a13b99b Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 21 Jun 2026 16:57:33 +0100 Subject: [PATCH] Add WebAppSwitcher component and related icons; update config for web app URLs --- assets/icons/openinappicon.svg | 26 ++++++++ assets/icons/openinbrowsericon.svg | 13 ++++ .../Dashboard/common/DashboardNavigation.jsx | 2 + .../Dashboard/common/WebAppSwitcher.jsx | 59 +++++++++++++++++++ src/components/Icons/OpenInAppIcon.jsx | 6 ++ src/components/Icons/OpenInBrowserIcon.jsx | 8 +++ src/config.js | 2 + 7 files changed, 116 insertions(+) create mode 100644 assets/icons/openinappicon.svg create mode 100644 assets/icons/openinbrowsericon.svg create mode 100644 src/components/Dashboard/common/WebAppSwitcher.jsx create mode 100644 src/components/Icons/OpenInAppIcon.jsx create mode 100644 src/components/Icons/OpenInBrowserIcon.jsx diff --git a/assets/icons/openinappicon.svg b/assets/icons/openinappicon.svg new file mode 100644 index 0000000..28251b8 --- /dev/null +++ b/assets/icons/openinappicon.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/icons/openinbrowsericon.svg b/assets/icons/openinbrowsericon.svg new file mode 100644 index 0000000..0ad76b0 --- /dev/null +++ b/assets/icons/openinbrowsericon.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/components/Dashboard/common/DashboardNavigation.jsx b/src/components/Dashboard/common/DashboardNavigation.jsx index 79a4e4a..35ab1e1 100644 --- a/src/components/Dashboard/common/DashboardNavigation.jsx +++ b/src/components/Dashboard/common/DashboardNavigation.jsx @@ -38,6 +38,7 @@ import SettingsIcon from '../../Icons/SettingsIcon' import DeveloperIcon from '../../Icons/DeveloperIcon' import { ElectronContext } from '../context/ElectronContext' import DashboardWindowButtons from './DashboardWindowButtons' +import WebAppSwitcher from './WebAppSwitcher' import { getSidebarDefaultPath, getSidebarMenuSections @@ -223,6 +224,7 @@ const DashboardNavigation = () => { style={{ marginTop: '-2px', marginRight: '6px' }} > + { + const { isElectron, openExternalUrl } = useContext(ElectronContext) + const location = useLocation() + const navigate = useNavigate() + + const getCurrentPath = () => + `${location.pathname}${location.search}${location.hash}` + + const handleClick = () => { + const path = getCurrentPath() + + if (isElectron) { + const url = window.location.protocol.startsWith('http') + ? `${window.location.origin}${path}` + : `${config.webAppUrl}${path}` + + openExternalUrl(url) + return + } + + const redirectType = + import.meta.env.MODE === 'development' ? 'app-localhost' : 'app-scheme' + const redirect = + redirectType === 'app-localhost' + ? `http://localhost:3500${path}` + : `farmcontrol://app${path}` + + const params = new URLSearchParams({ + redirect, + redirectType + }) + + navigate(`/applaunch?${params.toString()}`) + } + + return ( + +