mirror of
https://github.com/shuaiplus/nodewarden.git
synced 2026-06-20 13:00:39 +00:00
feat: update backup routes and navigation links for consistency
This commit is contained in:
+3
-3
@@ -52,7 +52,7 @@ import { t } from '@/lib/i18n';
|
|||||||
import { APP_NOTIFY_EVENT, type AppNotifyDetail } from '@/lib/app-notify';
|
import { APP_NOTIFY_EVENT, type AppNotifyDetail } from '@/lib/app-notify';
|
||||||
import type { AppPhase, Cipher, Folder as VaultFolder, Profile, Send, SessionState } from '@/lib/types';
|
import type { AppPhase, Cipher, Folder as VaultFolder, Profile, Send, SessionState } from '@/lib/types';
|
||||||
|
|
||||||
const IMPORT_ROUTE = '/help/import-export';
|
const IMPORT_ROUTE = '/backup/import-export';
|
||||||
const IMPORT_ROUTE_PATHS = [IMPORT_ROUTE, '/tools/import', '/tools/import-export', '/tools/import-data', '/import', '/import-export'] as const;
|
const IMPORT_ROUTE_PATHS = [IMPORT_ROUTE, '/tools/import', '/tools/import-export', '/tools/import-data', '/import', '/import-export'] as const;
|
||||||
const IMPORT_ROUTE_ALIASES: ReadonlySet<string> = new Set(IMPORT_ROUTE_PATHS.filter((path) => path !== IMPORT_ROUTE));
|
const IMPORT_ROUTE_ALIASES: ReadonlySet<string> = new Set(IMPORT_ROUTE_PATHS.filter((path) => path !== IMPORT_ROUTE));
|
||||||
const SETTINGS_HOME_ROUTE = '/settings';
|
const SETTINGS_HOME_ROUTE = '/settings';
|
||||||
@@ -918,7 +918,7 @@ export default function App() {
|
|||||||
if (location === '/sends') return t('nav_sends');
|
if (location === '/sends') return t('nav_sends');
|
||||||
if (location === '/admin') return t('nav_admin_panel');
|
if (location === '/admin') return t('nav_admin_panel');
|
||||||
if (location === '/security/devices') return t('nav_device_management');
|
if (location === '/security/devices') return t('nav_device_management');
|
||||||
if (location === '/help') return t('nav_backup_strategy');
|
if (location === '/backup') return t('nav_backup_strategy');
|
||||||
if (isImportRoute) return t('nav_import_export');
|
if (isImportRoute) return t('nav_import_export');
|
||||||
if (location === SETTINGS_ACCOUNT_ROUTE) return t('nav_account_settings');
|
if (location === SETTINGS_ACCOUNT_ROUTE) return t('nav_account_settings');
|
||||||
if (location === SETTINGS_HOME_ROUTE) return t('txt_settings');
|
if (location === SETTINGS_HOME_ROUTE) return t('txt_settings');
|
||||||
@@ -936,7 +936,7 @@ export default function App() {
|
|||||||
}, [phase, isImportHashRoute, location, navigate]);
|
}, [phase, isImportHashRoute, location, navigate]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (phase === 'app' && profile?.role !== 'admin' && location === '/help') {
|
if (phase === 'app' && profile?.role !== 'admin' && location === '/backup') {
|
||||||
navigate('/vault');
|
navigate('/vault');
|
||||||
}
|
}
|
||||||
}, [phase, profile?.role, location, navigate]);
|
}, [phase, profile?.role, location, navigate]);
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export default function AppAuthenticatedShell(props: AppAuthenticatedShellProps)
|
|||||||
<span>{t('nav_device_management')}</span>
|
<span>{t('nav_device_management')}</span>
|
||||||
</Link>
|
</Link>
|
||||||
{props.profile?.role === 'admin' && (
|
{props.profile?.role === 'admin' && (
|
||||||
<Link href="/help" className={`side-link ${props.location === '/help' ? 'active' : ''}`}>
|
<Link href="/backup" className={`side-link ${props.location === '/backup' ? 'active' : ''}`}>
|
||||||
<Cloud size={16} />
|
<Cloud size={16} />
|
||||||
<span>{t('nav_backup_strategy')}</span>
|
<span>{t('nav_backup_strategy')}</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { lazy, Suspense } from 'preact/compat';
|
import { lazy, Suspense } from 'preact/compat';
|
||||||
|
import { useEffect } from 'preact/hooks';
|
||||||
import { Link, Route, Switch } from 'wouter';
|
import { Link, Route, Switch } from 'wouter';
|
||||||
import { ArrowUpDown, Cloud, LogOut, Settings as SettingsIcon, Shield, ShieldUser } from 'lucide-preact';
|
import { ArrowUpDown, Cloud, LogOut, Settings as SettingsIcon, Shield, ShieldUser } from 'lucide-preact';
|
||||||
import type { ImportAttachmentFile, ImportResultSummary } from '@/components/ImportPage';
|
import type { ImportAttachmentFile, ImportResultSummary } from '@/components/ImportPage';
|
||||||
@@ -21,6 +22,13 @@ function RouteContentFallback() {
|
|||||||
return <div className="loading-screen">{t('txt_loading_nodewarden')}</div>;
|
return <div className="loading-screen">{t('txt_loading_nodewarden')}</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function LegacyBackupRedirect(props: { onNavigate: (path: string) => void }) {
|
||||||
|
useEffect(() => {
|
||||||
|
props.onNavigate('/backup');
|
||||||
|
}, [props]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
export interface AppMainRoutesProps {
|
export interface AppMainRoutesProps {
|
||||||
profile: Profile | null;
|
profile: Profile | null;
|
||||||
session: SessionState | null;
|
session: SessionState | null;
|
||||||
@@ -232,7 +240,7 @@ export default function AppMainRoutes(props: AppMainRoutesProps) {
|
|||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
{props.profile.role === 'admin' && (
|
{props.profile.role === 'admin' && (
|
||||||
<Link href="/help" className="mobile-settings-link">
|
<Link href="/backup" className="mobile-settings-link">
|
||||||
<Cloud size={18} />
|
<Cloud size={18} />
|
||||||
<span>{t('nav_backup_strategy')}</span>
|
<span>{t('nav_backup_strategy')}</span>
|
||||||
</Link>
|
</Link>
|
||||||
@@ -299,6 +307,9 @@ export default function AppMainRoutes(props: AppMainRoutesProps) {
|
|||||||
</Route>
|
</Route>
|
||||||
))}
|
))}
|
||||||
<Route path="/help">
|
<Route path="/help">
|
||||||
|
<LegacyBackupRedirect onNavigate={props.onNavigate} />
|
||||||
|
</Route>
|
||||||
|
<Route path="/backup">
|
||||||
{props.profile?.role === 'admin' ? (
|
{props.profile?.role === 'admin' ? (
|
||||||
<div className="stack">
|
<div className="stack">
|
||||||
{props.mobileLayout && (
|
{props.mobileLayout && (
|
||||||
|
|||||||
Reference in New Issue
Block a user