wrolpi/app/src/components/admin/ExtensionInstallSuggestion.js
Roland 528a5702d0
ui: migrate the extension pages and Configs; five components they needed
Phase 2, part 1.  Three files leave Semantic UI (baseline 75 -> 72), and the
components they needed join the library and the gallery:

  Header       Semantic's shape (as/icon/subheader/dividing).  47 files use
               <Header>, and the level now picks the size, so the type scale
               stays a scale instead of each call site choosing a font size.
  Message      gains an icon and a dismiss button.
  ActionInput  input and button sharing one outline, for <Input action={...}/>.
  Loading      centered loader with a caption, replacing the
               <Loader active inline='centered'> + wrapper div in 19 places.
  Modal        becomes compound - Modal.Header/.Content/.Actions, plus
               Semantic's open, closeIcon, and size names - because 34 files
               are written against that shape.

test-utils mounts MantineProvider with ThemeProvider's exact configuration:
migrated components render Mantine internals and every one of their test files
would otherwise need its own provider.

One Semantic bleed found and fixed: semantic.min.css sets
`h1,h2,h3,h4,h5 { font-family: Lato }` and loads after Mantine's element rule,
so headings ignored the theme's body face.  Only visible in amber, where the
body is mono and the headings were not.  A class-level restatement outranks it;
the rule comes out when Semantic does.

Verified: 925 jest tests, clean production build, and a night-mode audit of
every painted pixel in the gallery (red-only, one known false positive).  The
Configs backup and restore flow was exercised against the real API.
2026-08-05 18:34:46 -06:00

43 lines
1.8 KiB
JavaScript

import React from "react";
import {Link} from "react-router";
import {Button, Message} from "../ui";
import {useLocalStorage} from "../Common";
import {useExtensionInstalled} from "../../hooks/customHooks";
import {isExtensionSupportedBrowser} from "./browserDetect";
// Top-of-dashboard nudge for users who don't yet have the WROLPi browser
// extension installed (or installed but haven't added this WROLPi as a
// destination). Hidden once the user installs+configures, or dismisses it.
// Only shown on Chromium / Firefox — Safari and other browsers cannot run
// the extension.
//
// Detection is via a meta tag injected by the extension's content script.
// The extension only injects on configured destination origins, so seeing
// the marker here means "extension is installed AND knows about this WROLPi".
export function ExtensionInstallSuggestion() {
const installed = useExtensionInstalled();
const [dismissed, setDismissed] = useLocalStorage(
'wrolpi-extension-banner-dismissed', false,
);
// installed === null means "still checking" — render nothing rather
// than flashing the banner before the content-script race resolves.
// Also skip on browsers that cannot install the extension (e.g. Safari).
if (installed !== false || dismissed || !isExtensionSupportedBrowser()) return null;
return <Message
kind='info'
icon='puzzle piece'
title='Install the WROLPi browser extension'
onDismiss={() => setDismissed(true)}
>
<p>
Send pages, videos, and feeds to this WROLPi straight from any
tab. Open-source and not distributed via the official browser
stores.
</p>
<Button component={Link} to='/admin/extension' role='primary' size='xs'>
Open install page
</Button>
</Message>;
}