Simpl-Resultat/src/components/shared/DownloadLatestButton.tsx
le king fu 170b22d356
All checks were successful
PR Check — Frontend / frontend (pull_request) Successful in 1m39s
fix(upsell): apply the review of #362
- Render tests for the upsell CTAs (UpsellCtas.render.test.tsx): the
  reviewer's probe, which needs no jsdom (react-dom/server in the node
  environment, plus the FilterPanel.test.tsx pattern of calling a
  component as a function). It pins the Base/Premium CTA on UpsellGate,
  the router guard of HaveKeyButton, the localized product URL, the
  Premium note and the onNavigate forwarding, none of which the suite
  guarded before.
- A failure to open the browser (openUrl) is now logged through
  logError in PurchaseButton, DownloadLatestButton and LicenseCard,
  instead of vanishing as an unhandled rejection that never reaches the
  in-app logs. Tested for both shared buttons.
- upsellCtaFor: comment the trap in making Premium purchasable, since
  PurchaseButton sells Base only.
- ADR 0017 amendment: the Account card text holds in practice only;
  current_entitlements still grants Premium to an active subscription,
  a dormant path until a subscription is sold.
- User guide and in-app docs: the purchase step now comes before the
  key entry, and the Balance button is named "Get Premium".
- CHANGELOG: "Maximus Account" in English, "every screen that requires
  it" in both files (the Balance screen sells nothing), and the French
  elision before a guillemet.

Refs #346

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 20:47:04 -04:00

40 lines
1.4 KiB
TypeScript

import { useTranslation } from "react-i18next";
import { openUrl } from "@tauri-apps/plugin-opener";
import { Download } from "lucide-react";
import { purchaseUrl } from "../../shared/purchaseUrl";
import { logError } from "../../services/logService";
const DEFAULT_LAYOUT = "inline-flex items-center justify-center gap-2 text-sm";
const COLOURS = "text-[var(--primary)] hover:underline";
interface DownloadLatestButtonProps {
/** Replaces the default layout classes; colours stay fixed. */
className?: string;
}
/**
* "Download the latest version", shown in the free edition where automatic updates
* are locked (issue #346). It opens the product page, which serves the latest
* installers directly (la-compagnie-maximus#153). No update check runs here: the
* free edition makes no network call for updates. A failure to open the browser
* is logged, like PurchaseButton's.
*/
export default function DownloadLatestButton({
className = DEFAULT_LAYOUT,
}: DownloadLatestButtonProps) {
const { t, i18n } = useTranslation();
return (
<button
type="button"
onClick={() =>
void openUrl(purchaseUrl(i18n.language)).catch((e) =>
logError("Product page: openUrl failed", e),
)
}
className={`${className} ${COLOURS}`}
>
<Download className="h-4 w-4" />
{t("settings.updates.downloadLatest")}
</button>
);
}