mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-03 05:09:58 -05:00
app: only show extension install banner on Chromium/Firefox
The dashboard nudge is useless on Safari and other browsers that cannot run the WROLPi extension. Share detectBrowser and gate the banner with isExtensionSupportedBrowser.
This commit is contained in:
parent
46ba804a1b
commit
db7603012e
4 changed files with 54 additions and 12 deletions
|
|
@ -2,6 +2,7 @@ import React from "react";
|
|||
import {Button, Header, Icon, Segment} from "../Theme";
|
||||
import {Input, Message} from "semantic-ui-react";
|
||||
import {ThemeContext} from "../../contexts/contexts";
|
||||
import {detectBrowser} from "./browserDetect";
|
||||
|
||||
// The WROLPi browser extension is distributed off-store: Chrome users
|
||||
// sideload the unpacked .zip; Firefox users get a Mozilla-signed .xpi that
|
||||
|
|
@ -11,17 +12,6 @@ import {ThemeContext} from "../../contexts/contexts";
|
|||
const CHROME_ZIP_PATH = '/api/extensions/wrolpi-chrome.zip';
|
||||
const FIREFOX_XPI_PATH = '/api/extensions/wrolpi-firefox.xpi';
|
||||
|
||||
function detectBrowser() {
|
||||
if (typeof navigator === 'undefined') return 'unknown';
|
||||
const ua = navigator.userAgent || '';
|
||||
// Order matters: Edge / Brave / Opera all include 'Chrome' in their UA.
|
||||
if (ua.includes('Firefox')) return 'firefox';
|
||||
if (ua.includes('Edg/')) return 'chromium';
|
||||
if (ua.includes('OPR/') || ua.includes('Opera')) return 'chromium';
|
||||
if (ua.includes('Chrome')) return 'chromium';
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
function formatSize(bytes) {
|
||||
if (!bytes) return '';
|
||||
const kb = bytes / 1024;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue