mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
SettingsPageLayout
This commit is contained in:
9 files changed
+308
-496
No files matched your search
@@ -0,0 +1,78 @@
|
||||
import { ArrowLeft, type LucideIcon } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import type { ReactNode } from 'react';
|
||||
|
||||
interface SettingsPageLayoutProps {
|
||||
/** The icon component to display next to the title */
|
||||
icon: LucideIcon;
|
||||
/** Translation key for the page title */
|
||||
titleKey: string;
|
||||
/** Translation key for the page description */
|
||||
descriptionKey: string;
|
||||
/** The main content of the settings page */
|
||||
children: ReactNode;
|
||||
/** Optional className for the content container */
|
||||
className?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared layout component for all settings pages.
|
||||
* Provides consistent header structure with mobile back button, icon, title, and description.
|
||||
*/
|
||||
export function SettingsPageLayout({
|
||||
icon: Icon,
|
||||
titleKey,
|
||||
descriptionKey,
|
||||
children,
|
||||
className = 'space-y-6',
|
||||
}: SettingsPageLayoutProps) {
|
||||
const { t } = useTranslation();
|
||||
const isMobile = useIsMobile();
|
||||
const navigate = useNavigate();
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6 pb-16">
|
||||
{isMobile && (
|
||||
<div className="space-y-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/settings')}
|
||||
className="h-8 w-auto px-2 -ml-2"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
{t('backToSettings')}
|
||||
</Button>
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Icon className="h-6 w-6 text-primary" />
|
||||
{t(titleKey)}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t(descriptionKey)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isMobile && (
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Icon className="h-6 w-6 text-primary" />
|
||||
{t(titleKey)}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t(descriptionKey)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className={className}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+13
-46
@@ -1,6 +1,6 @@
|
||||
import { useState, useMemo, useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Check, Bot, ArrowLeft, Trash2, GripVertical, ChevronDown, RotateCcw, FileText, Plus, Edit, X } from 'lucide-react';
|
||||
import { Check, Bot, Trash2, GripVertical, ChevronDown, RotateCcw, FileText, Plus, Edit, X } from 'lucide-react';
|
||||
import {
|
||||
DndContext,
|
||||
closestCenter,
|
||||
@@ -35,10 +35,10 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { useAISettings } from '@/hooks/useAISettings';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useAppContext } from '@/hooks/useAppContext';
|
||||
import { useNavigate, Link } from 'react-router-dom';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { SettingsPageLayout } from '@/components/SettingsPageLayout';
|
||||
import type { AIProvider } from '@/contexts/AISettingsContext';
|
||||
import { AI_PROVIDER_PRESETS, type PresetProvider } from '@/lib/aiProviderPresets';
|
||||
import { ExternalFavicon } from '@/components/ExternalFavicon';
|
||||
@@ -204,8 +204,6 @@ function generateIdFromName(name: string): string {
|
||||
export function AISettings() {
|
||||
const { t } = useTranslation();
|
||||
const { settings, updateSettings, setProvider, removeProvider, setProviders, isLoading } = useAISettings();
|
||||
const isMobile = useIsMobile();
|
||||
const navigate = useNavigate();
|
||||
const { user } = useCurrentUser();
|
||||
const { config, defaultConfig, updateConfig } = useAppContext();
|
||||
const [customProviderName, setCustomProviderName] = useState('');
|
||||
@@ -352,44 +350,13 @@ export function AISettings() {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6 pb-16">
|
||||
{isMobile && (
|
||||
<div className="space-y-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/settings')}
|
||||
className="h-8 w-auto px-2 -ml-2"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
{t('backToSettings')}
|
||||
</Button>
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Bot className="h-6 w-6 text-primary" />
|
||||
{t('aiSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('aiSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isMobile && (
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Bot className="h-6 w-6 text-primary" />
|
||||
{t('aiSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('aiSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<SettingsPageLayout
|
||||
icon={Bot}
|
||||
titleKey="aiSettings"
|
||||
descriptionKey="aiSettingsDescription"
|
||||
>
|
||||
{isLoading ? (
|
||||
<div className="space-y-6">
|
||||
<>
|
||||
{/* Loading skeleton for configured providers */}
|
||||
<div className="space-y-3">
|
||||
<Skeleton className="h-4 w-40" />
|
||||
@@ -412,9 +379,9 @@ export function AISettings() {
|
||||
<div className="space-y-3">
|
||||
<Skeleton className="h-16 w-full rounded-lg" />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="space-y-6">
|
||||
<>
|
||||
{/* Configured Providers */}
|
||||
{settings.providers.length > 0 && (
|
||||
<div className="space-y-3">
|
||||
@@ -802,7 +769,7 @@ export function AISettings() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Render credits dialog outside of accordion structure */}
|
||||
@@ -820,7 +787,7 @@ export function AISettings() {
|
||||
/>
|
||||
);
|
||||
})()}
|
||||
</div>
|
||||
</SettingsPageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,15 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Info, ExternalLink, Loader2, AlertTriangle, ArrowLeft, Code, Globe } from 'lucide-react';
|
||||
import { Info, ExternalLink, Loader2, AlertTriangle, Code, Globe } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { SettingsPageLayout } from '@/components/SettingsPageLayout';
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { EmailSubscription } from '@/components/EmailSubscription';
|
||||
|
||||
export function AboutSettings() {
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useIsMobile();
|
||||
const [license, setLicense] = useState<string | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -43,41 +40,11 @@ export function AboutSettings() {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
{isMobile && (
|
||||
<div className="space-y-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/settings')}
|
||||
className="h-8 w-auto px-2 -ml-2"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
{t('backToSettings')}
|
||||
</Button>
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Info className="h-6 w-6 text-primary" />
|
||||
{t('aboutShakespeare')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('aboutShakespeareDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isMobile && (
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Info className="h-6 w-6 text-primary" />
|
||||
{t('aboutShakespeare')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('aboutShakespeareDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<SettingsPageLayout
|
||||
icon={Info}
|
||||
titleKey="aboutShakespeare"
|
||||
descriptionKey="aboutShakespeareDescription"
|
||||
>
|
||||
|
||||
<div className="space-y-6 max-w-xl">
|
||||
{/* Email Updates */}
|
||||
@@ -187,7 +154,7 @@ export function AboutSettings() {
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</SettingsPageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Rocket, ArrowLeft, Trash2, Check, GripVertical, ChevronDown, Plus } from 'lucide-react';
|
||||
import { Rocket, Trash2, Check, GripVertical, ChevronDown, Plus } from 'lucide-react';
|
||||
import { SettingsPageLayout } from '@/components/SettingsPageLayout';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import {
|
||||
DropdownMenu,
|
||||
@@ -40,8 +41,7 @@ import { useDeploySettings } from '@/hooks/useDeploySettings';
|
||||
import { useNetlifyOAuth } from '@/hooks/useNetlifyOAuth';
|
||||
import { useVercelOAuth } from '@/hooks/useVercelOAuth';
|
||||
import { useCurrentUser } from '@/hooks/useCurrentUser';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { useNavigate, Link } from 'react-router-dom';
|
||||
import { Link } from 'react-router-dom';
|
||||
import type { DeployProvider } from '@/contexts/DeploySettingsContext';
|
||||
import { ExternalFavicon } from '@/components/ExternalFavicon';
|
||||
import { normalizeUrl } from '@/lib/url';
|
||||
@@ -427,8 +427,6 @@ export function DeploySettings() {
|
||||
const { t } = useTranslation();
|
||||
const { settings, removeProvider, setProviders, isInitialized } = useDeploySettings();
|
||||
const { user } = useCurrentUser();
|
||||
const isMobile = useIsMobile();
|
||||
const navigate = useNavigate();
|
||||
|
||||
// OAuth hooks
|
||||
const netlifyOAuth = useNetlifyOAuth();
|
||||
@@ -669,44 +667,13 @@ export function DeploySettings() {
|
||||
const availablePresets = PRESET_PROVIDERS.filter(preset => !configuredProviderIds.includes(preset.id));
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
{isMobile && (
|
||||
<div className="space-y-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/settings')}
|
||||
className="h-8 w-auto px-2 -ml-2"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
{t('backToSettings')}
|
||||
</Button>
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Rocket className="h-6 w-6 text-primary" />
|
||||
{t('deploySettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('deploySettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isMobile && (
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Rocket className="h-6 w-6 text-primary" />
|
||||
{t('deploySettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('deploySettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<SettingsPageLayout
|
||||
icon={Rocket}
|
||||
titleKey="deploySettings"
|
||||
descriptionKey="deploySettingsDescription"
|
||||
>
|
||||
{!isInitialized ? (
|
||||
<div className="space-y-6">
|
||||
<>
|
||||
{/* Loading skeleton for configured providers */}
|
||||
<div className="space-y-3">
|
||||
<Skeleton className="h-4 w-40" />
|
||||
@@ -730,9 +697,9 @@ export function DeploySettings() {
|
||||
<div className="space-y-3">
|
||||
<Skeleton className="h-16 w-full rounded-lg" />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="space-y-6">
|
||||
<>
|
||||
{/* Configured Providers */}
|
||||
{settings.providers.length > 0 && (
|
||||
<div className="space-y-3">
|
||||
@@ -1180,9 +1147,9 @@ export function DeploySettings() {
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</SettingsPageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+12
-46
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Check, GitBranch, ArrowLeft, Trash2, ChevronDown, Plus, User, GripVertical } from 'lucide-react';
|
||||
import { Check, GitBranch, Trash2, ChevronDown, Plus, User, GripVertical } from 'lucide-react';
|
||||
import {
|
||||
DndContext,
|
||||
closestCenter,
|
||||
@@ -36,8 +36,7 @@ import {
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { useGitSettings } from '@/hooks/useGitSettings';
|
||||
import { useGitHubOAuth } from '@/hooks/useGitHubOAuth';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { SettingsPageLayout } from '@/components/SettingsPageLayout';
|
||||
import type { GitCredential } from '@/contexts/GitSettingsContext';
|
||||
import { PasswordInput } from '@/components/ui/password-input';
|
||||
import { ExternalInput } from '@/components/ui/external-input';
|
||||
@@ -192,8 +191,6 @@ export function GitSettings() {
|
||||
const { t } = useTranslation();
|
||||
const { settings, addCredential, removeCredential, setCredentials, updateSettings, isInitialized } = useGitSettings();
|
||||
const { initiateOAuth, isLoading: isOAuthLoading, error: oauthError, isOAuthConfigured } = useGitHubOAuth();
|
||||
const isMobile = useIsMobile();
|
||||
const navigate = useNavigate();
|
||||
const [customName, setCustomName] = useState('');
|
||||
const [customOrigin, setCustomOrigin] = useState('');
|
||||
const [customUsername, setCustomUsername] = useState('');
|
||||
@@ -283,44 +280,13 @@ export function GitSettings() {
|
||||
const availablePresets = PRESET_PROVIDERS.filter(preset => !configuredOrigins.includes(preset.origin));
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
{isMobile && (
|
||||
<div className="space-y-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/settings')}
|
||||
className="h-8 w-auto px-2 -ml-2"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
{t('backToSettings')}
|
||||
</Button>
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<GitBranch className="h-6 w-6 text-primary" />
|
||||
{t('gitSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('gitSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isMobile && (
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<GitBranch className="h-6 w-6 text-primary" />
|
||||
{t('gitSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('gitSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<SettingsPageLayout
|
||||
icon={GitBranch}
|
||||
titleKey="gitSettings"
|
||||
descriptionKey="gitSettingsDescription"
|
||||
>
|
||||
{!isInitialized ? (
|
||||
<div className="space-y-6">
|
||||
<>
|
||||
{/* Loading skeleton for configured credentials */}
|
||||
<div className="space-y-3">
|
||||
<Skeleton className="h-4 w-40" />
|
||||
@@ -348,9 +314,9 @@ export function GitSettings() {
|
||||
<div className="space-y-3">
|
||||
<Skeleton className="h-16 w-full rounded-lg" />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="space-y-6">
|
||||
<>
|
||||
{/* Configured Credentials */}
|
||||
{settings.credentials.length > 0 && (
|
||||
<div className="space-y-3">
|
||||
@@ -645,9 +611,9 @@ export function GitSettings() {
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</SettingsPageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+11
-44
@@ -1,6 +1,7 @@
|
||||
import { ArrowLeft, Wifi, Users, UserPlus, LogOut, Trash2, User, Plus, Server, Key } from 'lucide-react';
|
||||
import { Wifi, Users, UserPlus, LogOut, Trash2, User, Plus, Server, Key } from 'lucide-react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { SettingsPageLayout } from '@/components/SettingsPageLayout';
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
@@ -8,8 +9,6 @@ import { RelayListManager } from '@/components/RelayListManager';
|
||||
import { GraspListManager } from '@/components/GraspListManager';
|
||||
import SimpleLoginDialog from '@/components/auth/SimpleLoginDialog';
|
||||
import SimpleSignupDialog from '@/components/auth/SimpleSignupDialog';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useLoggedInAccounts, type Account } from '@/hooks/useLoggedInAccounts';
|
||||
import { genUserName } from '@/lib/genUserName';
|
||||
import { useState } from 'react';
|
||||
@@ -22,8 +21,6 @@ const sanitizeFilename = (filename: string) => {
|
||||
|
||||
export function NostrSettings() {
|
||||
const { t } = useTranslation();
|
||||
const isMobile = useIsMobile();
|
||||
const navigate = useNavigate();
|
||||
const { authors, currentUser, setLogin, removeLogin, isLoading } = useLoggedInAccounts();
|
||||
const [showLoginDialog, setShowLoginDialog] = useState(false);
|
||||
const [showSignupDialog, setShowSignupDialog] = useState(false);
|
||||
@@ -104,43 +101,13 @@ export function NostrSettings() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
{isMobile && (
|
||||
<div className="space-y-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/settings')}
|
||||
className="h-8 w-auto px-2 -ml-2"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
{t('backToSettings')}
|
||||
</Button>
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Wifi className="h-6 w-6 text-primary" />
|
||||
{t('nostrSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('nostrSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isMobile && (
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Wifi className="h-6 w-6 text-primary" />
|
||||
{t('nostrSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('nostrSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-6 max-w-xl">
|
||||
<>
|
||||
<SettingsPageLayout
|
||||
icon={Wifi}
|
||||
titleKey="nostrSettings"
|
||||
descriptionKey="nostrSettingsDescription"
|
||||
className="space-y-6 max-w-xl"
|
||||
>
|
||||
{/* Account Management */}
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center gap-2">
|
||||
@@ -281,7 +248,7 @@ export function NostrSettings() {
|
||||
</div>
|
||||
<GraspListManager />
|
||||
</div>
|
||||
</div>
|
||||
</SettingsPageLayout>
|
||||
|
||||
{/* Login Dialog */}
|
||||
<SimpleLoginDialog
|
||||
@@ -304,7 +271,7 @@ export function NostrSettings() {
|
||||
setShowLoginDialog(true);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,57 +1,23 @@
|
||||
import { Settings2, ArrowLeft } from "lucide-react";
|
||||
import { Settings2 } from "lucide-react";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { SettingsPageLayout } from '@/components/SettingsPageLayout';
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { ThemePicker } from "@/components/ThemePicker";
|
||||
import { LanguagePicker } from "@/components/LanguagePicker";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { useIsMobile } from "@/hooks/useIsMobile";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useAppContext } from "@/hooks/useAppContext";
|
||||
|
||||
export function Preferences() {
|
||||
const { t } = useTranslation();
|
||||
const isMobile = useIsMobile();
|
||||
const navigate = useNavigate();
|
||||
const { config, updateConfig } = useAppContext();
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
{isMobile && (
|
||||
<div className="space-y-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/settings')}
|
||||
className="h-8 w-auto px-2 -ml-2"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
{t('backToSettings')}
|
||||
</Button>
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Settings2 className="h-6 w-6 text-primary" />
|
||||
{t('preferences')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('preferencesDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isMobile && (
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Settings2 className="h-6 w-6 text-primary" />
|
||||
{t('preferences')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('preferencesDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<SettingsPageLayout
|
||||
icon={Settings2}
|
||||
titleKey="preferences"
|
||||
descriptionKey="preferencesDescription"
|
||||
>
|
||||
|
||||
<Card className="max-w-md">
|
||||
<CardContent className="pt-6">
|
||||
@@ -101,7 +67,7 @@ export function Preferences() {
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</SettingsPageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+157
-190
@@ -1,15 +1,15 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Download, Trash2, AlertTriangle, Loader2, Database, Info, ArrowLeft, Shield } from 'lucide-react';
|
||||
import { Download, Trash2, AlertTriangle, Loader2, Database, Info, Shield } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { SettingsPageLayout } from '@/components/SettingsPageLayout';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from '@/components/ui/alert-dialog';
|
||||
import { Progress } from '@/components/ui/progress';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
import { useFS } from '@/hooks/useFS';
|
||||
import { useIsMobile } from '@/hooks/useIsMobile';
|
||||
import { useOffline } from '@/hooks/useOffline';
|
||||
import {
|
||||
isPersistentStorageSupported,
|
||||
@@ -42,9 +42,8 @@ export function StorageSettings() {
|
||||
const [isPersistent, setIsPersistent] = useState<boolean | null>(null);
|
||||
const { toast } = useToast();
|
||||
const { fs } = useFS();
|
||||
const navigate = useNavigate();
|
||||
const isMobile = useIsMobile();
|
||||
const { clearCache } = useOffline();
|
||||
const navigate = useNavigate();
|
||||
|
||||
// Format bytes to human readable format
|
||||
const formatBytes = (bytes: number): string => {
|
||||
@@ -270,201 +269,169 @@ export function StorageSettings() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
{isMobile && (
|
||||
<div className="space-y-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/settings')}
|
||||
className="h-8 w-auto px-2 -ml-2"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
{t('backToSettings')}
|
||||
</Button>
|
||||
<SettingsPageLayout
|
||||
icon={Database}
|
||||
titleKey="storageSettings"
|
||||
descriptionKey="storageSettingsDescription"
|
||||
className="space-y-4"
|
||||
>
|
||||
{/* Storage Information */}
|
||||
{storageError ? (
|
||||
<div className="flex items-center gap-2 text-muted-foreground">
|
||||
<Info className="h-4 w-4" />
|
||||
<span className="text-sm">{storageError}</span>
|
||||
</div>
|
||||
) : storageInfo ? (
|
||||
<div className="space-y-4">
|
||||
{/* Usage Progress */}
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Database className="h-6 w-6 text-primary" />
|
||||
{t('storageSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('storageSettingsDescription')}
|
||||
</p>
|
||||
<div className="flex justify-between items-center text-sm">
|
||||
<span>{t('used')}: {formatBytes(storageInfo.usage)}</span>
|
||||
<span>{t('available')}: {formatBytes(storageInfo.quota)}</span>
|
||||
</div>
|
||||
<Progress
|
||||
value={storageInfo.quota > 0 ? (storageInfo.usage / storageInfo.quota) * 100 : 0}
|
||||
className="h-2"
|
||||
/>
|
||||
<div className="text-xs text-muted-foreground text-center">
|
||||
{storageInfo.quota > 0
|
||||
? t('usagePercentage', { percentage: ((storageInfo.usage / storageInfo.quota) * 100).toFixed(1) })
|
||||
: t('usageUnavailable')
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center gap-2 text-muted-foreground">
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
<span className="text-sm">{t('loadingStorageInfo')}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isMobile && (
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Database className="h-6 w-6 text-primary" />
|
||||
{t('storageSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('storageSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-4">
|
||||
{/* Storage Information */}
|
||||
{storageError ? (
|
||||
<div className="flex items-center gap-2 text-muted-foreground">
|
||||
<Info className="h-4 w-4" />
|
||||
<span className="text-sm">{storageError}</span>
|
||||
{/* Persist Data */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Shield className="h-5 w-5" />
|
||||
{t('persistData')}
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{t('persistDataDescription')}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="flex items-center justify-start">
|
||||
<Switch
|
||||
id="persistent-storage"
|
||||
checked={isPersistent === true}
|
||||
onCheckedChange={handlePersistentStorageToggle}
|
||||
disabled={isRequestingPersistent || isPersistent === null}
|
||||
/>
|
||||
</div>
|
||||
) : storageInfo ? (
|
||||
<div className="space-y-4">
|
||||
{/* Usage Progress */}
|
||||
<div className="space-y-2">
|
||||
<div className="flex justify-between items-center text-sm">
|
||||
<span>{t('used')}: {formatBytes(storageInfo.usage)}</span>
|
||||
<span>{t('available')}: {formatBytes(storageInfo.quota)}</span>
|
||||
</div>
|
||||
<Progress
|
||||
value={storageInfo.quota > 0 ? (storageInfo.usage / storageInfo.quota) * 100 : 0}
|
||||
className="h-2"
|
||||
/>
|
||||
<div className="text-xs text-muted-foreground text-center">
|
||||
{storageInfo.quota > 0
|
||||
? t('usagePercentage', { percentage: ((storageInfo.usage / storageInfo.quota) * 100).toFixed(1) })
|
||||
: t('usageUnavailable')
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center gap-2 text-muted-foreground">
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
<span className="text-sm">{t('loadingStorageInfo')}</span>
|
||||
</div>
|
||||
)}
|
||||
{/* Export Files */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Download className="h-5 w-5" />
|
||||
{t('exportFiles')}
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{t('exportFilesDescription')}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Button
|
||||
onClick={handleExportFiles}
|
||||
disabled={isExporting}
|
||||
className="w-full sm:w-auto"
|
||||
>
|
||||
{isExporting ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
|
||||
{t('exporting')}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Download className="h-4 w-4 mr-2" />
|
||||
{t('exportAllFiles')}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Persist Data */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Shield className="h-5 w-5" />
|
||||
{t('persistData')}
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{t('persistDataDescription')}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="flex items-center justify-start">
|
||||
<Switch
|
||||
id="persistent-storage"
|
||||
checked={isPersistent === true}
|
||||
onCheckedChange={handlePersistentStorageToggle}
|
||||
disabled={isRequestingPersistent || isPersistent === null}
|
||||
/>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Export Files */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<Download className="h-5 w-5" />
|
||||
{t('exportFiles')}
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{t('exportFilesDescription')}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Button
|
||||
onClick={handleExportFiles}
|
||||
disabled={isExporting}
|
||||
className="w-full sm:w-auto"
|
||||
>
|
||||
{isExporting ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
|
||||
{t('exporting')}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Download className="h-4 w-4 mr-2" />
|
||||
{t('exportAllFiles')}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Clear All Data */}
|
||||
<Card className="border-destructive/20">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2 text-destructive">
|
||||
<Trash2 className="h-5 w-5" />
|
||||
{t('clearAllData')}
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{t('clearAllDataDescription')}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button
|
||||
variant="destructive"
|
||||
disabled={isClearing}
|
||||
className="w-full sm:w-auto"
|
||||
{/* Clear All Data */}
|
||||
<Card className="border-destructive/20">
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center gap-2 text-destructive">
|
||||
<Trash2 className="h-5 w-5" />
|
||||
{t('clearAllData')}
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
{t('clearAllDataDescription')}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<AlertDialog>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button
|
||||
variant="destructive"
|
||||
disabled={isClearing}
|
||||
className="w-full sm:w-auto"
|
||||
>
|
||||
{isClearing ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
|
||||
{t('clearing')}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Trash2 className="h-4 w-4 mr-2" />
|
||||
{t('clearAllData')}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle className="flex items-center gap-2">
|
||||
<AlertTriangle className="h-5 w-5 text-destructive" />
|
||||
{t('areYouSure')}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription className="space-y-2">
|
||||
<p>
|
||||
{t('clearDataWarning')}
|
||||
</p>
|
||||
<ul className="list-disc list-inside space-y-1 text-sm">
|
||||
<li>{t('allProjects')}</li>
|
||||
<li>{t('aiSettingsAndKeys')}</li>
|
||||
<li>{t('gitCredentialsSettings')}</li>
|
||||
<li>{t('userPreferences')}</li>
|
||||
<li>{t('cachedData')}</li>
|
||||
</ul>
|
||||
<p className="font-medium text-destructive">
|
||||
{t('actionCannotBeUndone')}
|
||||
</p>
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('cancel')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleClearAllData}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{isClearing ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 mr-2 animate-spin" />
|
||||
{t('clearing')}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Trash2 className="h-4 w-4 mr-2" />
|
||||
{t('clearAllData')}
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</AlertDialogTrigger>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle className="flex items-center gap-2">
|
||||
<AlertTriangle className="h-5 w-5 text-destructive" />
|
||||
{t('areYouSure')}
|
||||
</AlertDialogTitle>
|
||||
<AlertDialogDescription className="space-y-2">
|
||||
<p>
|
||||
{t('clearDataWarning')}
|
||||
</p>
|
||||
<ul className="list-disc list-inside space-y-1 text-sm">
|
||||
<li>{t('allProjects')}</li>
|
||||
<li>{t('aiSettingsAndKeys')}</li>
|
||||
<li>{t('gitCredentialsSettings')}</li>
|
||||
<li>{t('userPreferences')}</li>
|
||||
<li>{t('cachedData')}</li>
|
||||
</ul>
|
||||
<p className="font-medium text-destructive">
|
||||
{t('actionCannotBeUndone')}
|
||||
</p>
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>{t('cancel')}</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleClearAllData}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
>
|
||||
{t('yesClearAllData')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
{t('yesClearAllData')}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</SettingsPageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { Settings, ArrowLeft, RefreshCw, Trash2, XCircle, Loader2, RotateCcw, Cog, Globe, Image, Code, Monitor, Award, Bug, FolderTree, Terminal as TerminalIcon, GitBranch } from "lucide-react";
|
||||
import { Settings, RefreshCw, Trash2, XCircle, Loader2, RotateCcw, Cog, Globe, Image, Code, Monitor, Award, Bug, FolderTree, Terminal as TerminalIcon, GitBranch } from "lucide-react";
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useState, useEffect, useMemo } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { SettingsPageLayout } from '@/components/SettingsPageLayout';
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
|
||||
import { useIsMobile } from "@/hooks/useIsMobile";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useAppContext } from "@/hooks/useAppContext";
|
||||
import { useOffline } from "@/hooks/useOffline";
|
||||
import { useToast } from "@/hooks/useToast";
|
||||
@@ -15,8 +14,6 @@ import { Terminal } from "@/components/Terminal";
|
||||
|
||||
export function SystemSettings() {
|
||||
const { t } = useTranslation();
|
||||
const isMobile = useIsMobile();
|
||||
const navigate = useNavigate();
|
||||
const { config, defaultConfig, updateConfig } = useAppContext();
|
||||
const { toast } = useToast();
|
||||
const { serviceWorkerRegistration, updateServiceWorker, clearCache } = useOffline();
|
||||
@@ -256,41 +253,11 @@ export function SystemSettings() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="p-6 space-y-6">
|
||||
{isMobile && (
|
||||
<div className="space-y-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() => navigate('/settings')}
|
||||
className="h-8 w-auto px-2 -ml-2"
|
||||
>
|
||||
<ArrowLeft className="h-4 w-4 mr-2" />
|
||||
{t('backToSettings')}
|
||||
</Button>
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Settings className="h-6 w-6 text-primary" />
|
||||
{t('systemSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('systemSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{!isMobile && (
|
||||
<div className="space-y-2">
|
||||
<h1 className="text-2xl font-bold flex items-center gap-3">
|
||||
<Settings className="h-6 w-6 text-primary" />
|
||||
{t('systemSettings')}
|
||||
</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{t('systemSettingsDescription')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
<SettingsPageLayout
|
||||
icon={Settings}
|
||||
titleKey="systemSettings"
|
||||
descriptionKey="systemSettingsDescription"
|
||||
>
|
||||
|
||||
<div className="space-y-3 max-w-xl">
|
||||
{/* Service Worker Configuration */}
|
||||
@@ -1029,7 +996,7 @@ export function SystemSettings() {
|
||||
</AccordionItem>
|
||||
</Accordion>
|
||||
</div>
|
||||
</div>
|
||||
</SettingsPageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user