All files / frontend/src/containers/Prefs PrefsRouted.tsx

100% Statements 4/4
100% Branches 14/14
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                      1x 6x     6x       6x                            
import { Routes, Route, Navigate } from 'react-router';
import PrefsGeneral from './PrefsGeneral';
import PrefsAdvanced from './PrefsAdvanced';
import PrefsAppSettingsGeneral from './PrefsAppSettingsGeneral';
import PrefsApplicationStorage from './PrefsApplicationStorage';
import PrefsGit from './PrefsGit';
import PrefsLogging from './PrefsLogging';
import PrefsHugo from './PrefsHugo';
import PrefsVariables from './PrefsVariables';
import { useEnvironment } from '../../hooks/useEnvironment';
 
export const PrefsRouted = () => {
  const { isStandalone } = useEnvironment();
 
  // In standalone mode, instance settings are managed externally — redirect to general
  const instanceSettingsElement = isStandalone
    ? <Navigate to="/prefs/general" replace />
    : undefined;
 
  return (
    <Routes>
      <Route path="general" element={<PrefsGeneral />} />
      <Route path="advanced" element={<PrefsAdvanced />} />
      <Route path="appsettings-general" element={instanceSettingsElement || <PrefsAppSettingsGeneral />} />
      <Route path="storage" element={instanceSettingsElement || <PrefsApplicationStorage />} />
      <Route path="git" element={instanceSettingsElement || <PrefsGit />} />
      <Route path="logging" element={instanceSettingsElement || <PrefsLogging />} />
      <Route path="hugo" element={instanceSettingsElement || <PrefsHugo />} />
      <Route path="variables" element={instanceSettingsElement || <PrefsVariables />} />
      <Route path="*" element={<PrefsGeneral />} />
    </Routes>
  );
};