mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: show tool name instead of bundle name in install prompt, add queued state
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import type { FeatureBundleState } from "@snapotter/shared";
|
import type { FeatureBundleState } from "@snapotter/shared";
|
||||||
import { AlertCircle, Download, Loader2, RotateCcw } from "lucide-react";
|
import { AlertCircle, Clock, Download, Loader2, RotateCcw } from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useFeaturesStore } from "@/stores/features-store";
|
import { useFeaturesStore } from "@/stores/features-store";
|
||||||
|
|
||||||
@@ -46,14 +46,17 @@ function formatTimeRemaining(ms: number): string {
|
|||||||
interface FeatureInstallPromptProps {
|
interface FeatureInstallPromptProps {
|
||||||
bundle: FeatureBundleState;
|
bundle: FeatureBundleState;
|
||||||
isAdmin: boolean;
|
isAdmin: boolean;
|
||||||
|
toolName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FeatureInstallPrompt({ bundle, isAdmin }: FeatureInstallPromptProps) {
|
export function FeatureInstallPrompt({ bundle, isAdmin, toolName }: FeatureInstallPromptProps) {
|
||||||
const { installBundle, clearError, installing, errors, startTimes } = useFeaturesStore();
|
const { installBundle, clearError, installing, errors, startTimes, queued } = useFeaturesStore();
|
||||||
const progress = installing[bundle.id] ?? null;
|
const progress = installing[bundle.id] ?? null;
|
||||||
const error = errors[bundle.id] ?? null;
|
const error = errors[bundle.id] ?? null;
|
||||||
const isInstalling = !!progress;
|
const isInstalling = !!progress;
|
||||||
|
const isQueued = queued.includes(bundle.id);
|
||||||
const startTime = startTimes[bundle.id] ?? null;
|
const startTime = startTimes[bundle.id] ?? null;
|
||||||
|
const displayName = toolName || bundle.name;
|
||||||
|
|
||||||
const [messageIndex, setMessageIndex] = useState(() =>
|
const [messageIndex, setMessageIndex] = useState(() =>
|
||||||
Math.floor(Math.random() * PROGRESS_MESSAGES.length),
|
Math.floor(Math.random() * PROGRESS_MESSAGES.length),
|
||||||
@@ -99,7 +102,7 @@ export function FeatureInstallPrompt({ bundle, isAdmin }: FeatureInstallPromptPr
|
|||||||
<div className="flex flex-col items-center justify-center h-full gap-6 text-center px-4">
|
<div className="flex flex-col items-center justify-center h-full gap-6 text-center px-4">
|
||||||
<Download className="h-16 w-16 text-muted-foreground" />
|
<Download className="h-16 w-16 text-muted-foreground" />
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<h2 className="text-xl font-semibold text-foreground">{bundle.name}</h2>
|
<h2 className="text-xl font-semibold text-foreground">{displayName}</h2>
|
||||||
<p className="text-muted-foreground max-w-md">{bundle.description}</p>
|
<p className="text-muted-foreground max-w-md">{bundle.description}</p>
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
This feature requires an additional download (~{bundle.estimatedSize})
|
This feature requires an additional download (~{bundle.estimatedSize})
|
||||||
@@ -139,13 +142,20 @@ export function FeatureInstallPrompt({ bundle, isAdmin }: FeatureInstallPromptPr
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!isInstalling && !error && (
|
{isQueued && (
|
||||||
|
<div className="flex items-center gap-2 text-muted-foreground">
|
||||||
|
<Clock className="h-5 w-5" />
|
||||||
|
<span className="text-sm font-medium">Queued for installation...</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!isInstalling && !error && !isQueued && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={handleInstall}
|
onClick={handleInstall}
|
||||||
className="px-6 py-2.5 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 font-medium"
|
className="px-6 py-2.5 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 font-medium"
|
||||||
>
|
>
|
||||||
Enable {bundle.name}
|
Enable {displayName}
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -292,7 +292,7 @@ export function ToolPage() {
|
|||||||
if (isAiTool && !toolInstalled && featureBundle) {
|
if (isAiTool && !toolInstalled && featureBundle) {
|
||||||
return (
|
return (
|
||||||
<AppLayout>
|
<AppLayout>
|
||||||
<FeatureInstallPrompt bundle={featureBundle} isAdmin={isAdmin} />
|
<FeatureInstallPrompt bundle={featureBundle} isAdmin={isAdmin} toolName={tool?.name} />
|
||||||
</AppLayout>
|
</AppLayout>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user