mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-07 09:24:09 +00:00
4f26f22cce
* feat: add license gating system with Lemon Squeezy integration Add Community/Pro tier infrastructure: - LicenseService singleton with Lemon Squeezy license API integration - /api/license endpoints (GET info, POST activate/deactivate/validate) - 14-day Pro trial activated automatically on first boot - 72-hour periodic validation with 30-day offline grace period - LicenseContext provider for frontend tier awareness - License settings tab with activation UI and status display - ProBadge and ProGate reusable components for feature gating - requirePro per-route guard for backend Pro-only endpoints - Proxy bypass for /api/license routes (local-only, never proxied) * feat: add user profile dropdown and reorganize top navigation - Create UserProfileDropdown component with settings, billing, theme toggle (System/Light/Dark), documentation links, and logout button - Remove logout button from sidebar header - Remove standalone settings button from top bar - Move theme toggle from Settings modal to profile dropdown - Inject app version via Vite define from root package.json - Add globals.d.ts for __APP_VERSION__ type declaration * refactor(settings): remove appearance tab from settings modal Theme toggle was moved to the User Profile Dropdown in the previous commit. Remove the now-redundant Appearance section, its nav button, and the unused theme/setTheme props from SettingsModal. * feat: add fleet view dashboard and about settings section Fleet Overview: aggregates all nodes into a card grid showing status, container counts, CPU/RAM/disk usage bars. Pro tier unlocks stack drill-down with auto-refresh (30s). Backend endpoints /api/fleet/overview and /api/fleet/node/:nodeId/stacks query nodes in parallel. About section in Settings: displays version, license tier, status, instance ID, and links to docs/changelog/issues. Sidebar perf fix: stack status fetches now run in parallel via Promise.allSettled instead of sequential for-loop, significantly reducing load time for nodes with many stacks. Also removes version number from User Profile Dropdown (now in About). * fix(ci): resolve Docker build and E2E test failures - Copy root package.json into frontend build stage so vite.config.ts can read the app version during Docker multi-stage build. - Update auth E2E test: logout button moved into User Profile Dropdown. - Update nodes E2E test: Settings button moved into User Profile Dropdown.
74 lines
2.8 KiB
TypeScript
74 lines
2.8 KiB
TypeScript
import { type ReactNode, useState } from 'react';
|
|
import { Crown } from 'lucide-react';
|
|
import { Button } from '@/components/ui/button';
|
|
import { useLicense } from '@/context/LicenseContext';
|
|
|
|
interface ProGateProps {
|
|
children: ReactNode;
|
|
featureName?: string;
|
|
}
|
|
|
|
const DISMISS_KEY = 'sencho-upgrade-prompt-dismissed';
|
|
const DISMISS_DURATION_MS = 24 * 60 * 60 * 1000; // 24 hours (session-like)
|
|
|
|
function isDismissedFromStorage(): boolean {
|
|
const dismissedAt = localStorage.getItem(DISMISS_KEY);
|
|
return !!dismissedAt && Date.now() - parseInt(dismissedAt, 10) < DISMISS_DURATION_MS;
|
|
}
|
|
|
|
export function ProGate({ children, featureName = 'This feature' }: ProGateProps) {
|
|
const { isPro } = useLicense();
|
|
const [dismissed, setDismissed] = useState(isDismissedFromStorage);
|
|
|
|
if (isPro) return <>{children}</>;
|
|
|
|
if (dismissed) {
|
|
return (
|
|
<div className="relative">
|
|
<div className="opacity-40 pointer-events-none select-none blur-[2px]">
|
|
{children}
|
|
</div>
|
|
<div className="absolute inset-0 flex items-start justify-center pt-8">
|
|
<div className="flex items-center gap-2 px-3 py-1.5 rounded-full bg-muted/80 border border-border text-muted-foreground text-xs">
|
|
<Crown className="w-3 h-3" />
|
|
Upgrade to Pro to unlock
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="flex flex-col items-center justify-center h-full gap-6 p-8">
|
|
<div className="flex items-center justify-center w-16 h-16 rounded-2xl bg-muted/50 border border-border">
|
|
<Crown className="w-8 h-8 text-muted-foreground" />
|
|
</div>
|
|
<div className="text-center max-w-md">
|
|
<h3 className="text-lg font-semibold mb-2">{featureName} requires Sencho Pro</h3>
|
|
<p className="text-sm text-muted-foreground">
|
|
Unlock advanced features like fleet management, viewer accounts, and more with a Sencho Pro license.
|
|
</p>
|
|
</div>
|
|
<div className="flex gap-3">
|
|
<Button
|
|
variant="outline"
|
|
size="sm"
|
|
onClick={() => {
|
|
localStorage.setItem(DISMISS_KEY, Date.now().toString());
|
|
setDismissed(true);
|
|
}}
|
|
>
|
|
Dismiss
|
|
</Button>
|
|
<Button
|
|
size="sm"
|
|
onClick={() => window.open('https://sencho.io/pricing', '_blank')}
|
|
>
|
|
<Crown className="w-4 h-4 mr-2" />
|
|
Get Sencho Pro
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|