feat: gate auto-updates behind license entitlement (#48) #58
7 changed files with 49 additions and 3 deletions
|
|
@ -5,6 +5,9 @@
|
|||
### Ajouté
|
||||
- CI : nouveau workflow `check.yml` qui exécute `cargo check`/`cargo test` et le build frontend sur chaque push de branche et PR, détectant les erreurs avant le merge plutôt qu'au moment de la release (#60)
|
||||
|
||||
### Modifié
|
||||
- Les mises à jour automatiques sont maintenant réservées à l'édition Base ; l'édition Gratuite affiche un message invitant à activer une licence (#48)
|
||||
|
||||
## [0.6.7] - 2026-03-29
|
||||
|
||||
### Modifié
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@
|
|||
### Added
|
||||
- CI: new `check.yml` workflow runs `cargo check`/`cargo test` and the frontend build on every branch push and PR, catching errors before merge instead of waiting for the release tag (#60)
|
||||
|
||||
### Changed
|
||||
- Automatic updates are now gated behind the Base edition entitlement; the Free edition shows an upgrade hint instead of fetching updates (#48)
|
||||
|
||||
## [0.6.7] - 2026-03-29
|
||||
|
||||
### Changed
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { useState } from "react";
|
|||
import { useTranslation } from "react-i18next";
|
||||
import { AlertTriangle, ChevronDown, ChevronUp, RefreshCw, Download, Mail, Bug } from "lucide-react";
|
||||
import { check } from "@tauri-apps/plugin-updater";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
interface ErrorPageProps {
|
||||
error?: string;
|
||||
|
|
@ -10,7 +11,7 @@ interface ErrorPageProps {
|
|||
export default function ErrorPage({ error }: ErrorPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [showDetails, setShowDetails] = useState(false);
|
||||
const [updateStatus, setUpdateStatus] = useState<"idle" | "checking" | "available" | "upToDate" | "error">("idle");
|
||||
const [updateStatus, setUpdateStatus] = useState<"idle" | "checking" | "available" | "upToDate" | "notEntitled" | "error">("idle");
|
||||
const [updateVersion, setUpdateVersion] = useState<string | null>(null);
|
||||
const [updateError, setUpdateError] = useState<string | null>(null);
|
||||
|
||||
|
|
@ -18,6 +19,13 @@ export default function ErrorPage({ error }: ErrorPageProps) {
|
|||
setUpdateStatus("checking");
|
||||
setUpdateError(null);
|
||||
try {
|
||||
const allowed = await invoke<boolean>("check_entitlement", {
|
||||
feature: "auto-update",
|
||||
});
|
||||
if (!allowed) {
|
||||
setUpdateStatus("notEntitled");
|
||||
return;
|
||||
}
|
||||
const update = await check();
|
||||
if (update) {
|
||||
setUpdateStatus("available");
|
||||
|
|
@ -89,6 +97,11 @@ export default function ErrorPage({ error }: ErrorPageProps) {
|
|||
{t("error.upToDate")}
|
||||
</p>
|
||||
)}
|
||||
{updateStatus === "notEntitled" && (
|
||||
<p className="text-sm text-[var(--muted-foreground)]">
|
||||
{t("error.updateNotEntitled")}
|
||||
</p>
|
||||
)}
|
||||
{updateStatus === "error" && updateError && (
|
||||
<p className="text-sm text-[var(--destructive)]">{updateError}</p>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { useReducer, useCallback, useRef } from "react";
|
||||
import { check, type Update } from "@tauri-apps/plugin-updater";
|
||||
import { relaunch } from "@tauri-apps/plugin-process";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
type UpdateStatus =
|
||||
| "idle"
|
||||
|
|
@ -10,6 +11,7 @@ type UpdateStatus =
|
|||
| "downloading"
|
||||
| "readyToInstall"
|
||||
| "installing"
|
||||
| "notEntitled"
|
||||
| "error";
|
||||
|
||||
interface UpdaterState {
|
||||
|
|
@ -29,6 +31,7 @@ type UpdaterAction =
|
|||
| { type: "DOWNLOAD_PROGRESS"; downloaded: number; contentLength: number | null }
|
||||
| { type: "READY_TO_INSTALL" }
|
||||
| { type: "INSTALLING" }
|
||||
| { type: "NOT_ENTITLED" }
|
||||
| { type: "ERROR"; error: string };
|
||||
|
||||
const initialState: UpdaterState = {
|
||||
|
|
@ -56,6 +59,8 @@ function reducer(state: UpdaterState, action: UpdaterAction): UpdaterState {
|
|||
return { ...state, status: "readyToInstall", error: null };
|
||||
case "INSTALLING":
|
||||
return { ...state, status: "installing", error: null };
|
||||
case "NOT_ENTITLED":
|
||||
return { ...state, status: "notEntitled", error: null };
|
||||
case "ERROR":
|
||||
return { ...state, status: "error", error: action.error };
|
||||
}
|
||||
|
|
@ -68,6 +73,16 @@ export function useUpdater() {
|
|||
const checkForUpdate = useCallback(async () => {
|
||||
dispatch({ type: "CHECK_START" });
|
||||
try {
|
||||
// Auto-updates are gated behind the entitlements module (Issue #46/#48).
|
||||
// The check is centralized server-side via `check_entitlement` so the
|
||||
// tier→feature mapping lives in one place.
|
||||
const allowed = await invoke<boolean>("check_entitlement", {
|
||||
feature: "auto-update",
|
||||
});
|
||||
if (!allowed) {
|
||||
dispatch({ type: "NOT_ENTITLED" });
|
||||
return;
|
||||
}
|
||||
const update = await check();
|
||||
if (update) {
|
||||
updateRef.current = update;
|
||||
|
|
|
|||
|
|
@ -436,7 +436,8 @@
|
|||
"installing": "Installing...",
|
||||
"error": "Update failed",
|
||||
"retryButton": "Retry",
|
||||
"releaseNotes": "What's New"
|
||||
"releaseNotes": "What's New",
|
||||
"notEntitled": "Automatic updates are available with the Base edition. Activate a license to enable them."
|
||||
},
|
||||
"dataManagement": {
|
||||
"title": "Data Management",
|
||||
|
|
@ -827,6 +828,7 @@
|
|||
"checkUpdate": "Check for updates",
|
||||
"updateAvailable": "Update available: v{{version}}",
|
||||
"upToDate": "The application is up to date",
|
||||
"updateNotEntitled": "Automatic updates are available with the Base edition.",
|
||||
"contactUs": "Contact us",
|
||||
"contactEmail": "Send an email to",
|
||||
"reportIssue": "Report an issue"
|
||||
|
|
|
|||
|
|
@ -436,7 +436,8 @@
|
|||
"installing": "Installation en cours...",
|
||||
"error": "Erreur lors de la mise à jour",
|
||||
"retryButton": "Réessayer",
|
||||
"releaseNotes": "Nouveautés"
|
||||
"releaseNotes": "Nouveautés",
|
||||
"notEntitled": "Les mises à jour automatiques sont disponibles avec l'édition Base. Activez une licence pour les utiliser."
|
||||
},
|
||||
"dataManagement": {
|
||||
"title": "Gestion des données",
|
||||
|
|
@ -827,6 +828,7 @@
|
|||
"checkUpdate": "Vérifier les mises à jour",
|
||||
"updateAvailable": "Mise à jour disponible : v{{version}}",
|
||||
"upToDate": "L'application est à jour",
|
||||
"updateNotEntitled": "Les mises à jour automatiques sont disponibles avec l'édition Base.",
|
||||
"contactUs": "Nous contacter",
|
||||
"contactEmail": "Envoyez un email à",
|
||||
"reportIssue": "Signaler un problème"
|
||||
|
|
|
|||
|
|
@ -155,6 +155,14 @@ export default function SettingsPage() {
|
|||
</div>
|
||||
)}
|
||||
|
||||
{/* not entitled (free edition) */}
|
||||
{state.status === "notEntitled" && (
|
||||
<div className="flex items-start gap-2 text-sm text-[var(--muted-foreground)]">
|
||||
<AlertCircle size={16} className="mt-0.5 shrink-0" />
|
||||
<p>{t("settings.updates.notEntitled")}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* up to date */}
|
||||
{state.status === "upToDate" && (
|
||||
<div className="flex items-center justify-between">
|
||||
|
|
|
|||
Loading…
Reference in a new issue