diff --git a/src/renderer/features/action-required/routes/action-required-route.tsx b/src/renderer/features/action-required/routes/action-required-route.tsx index 51040f751..087f986a5 100644 --- a/src/renderer/features/action-required/routes/action-required-route.tsx +++ b/src/renderer/features/action-required/routes/action-required-route.tsx @@ -1,4 +1,5 @@ import { openModal } from '@mantine/modals'; +import isElectron from 'is-electron'; import { useTranslation } from 'react-i18next'; import { Navigate } from 'react-router'; @@ -16,6 +17,8 @@ import { Group } from '/@/shared/components/group/group'; import { Icon } from '/@/shared/components/icon/icon'; import { Stack } from '/@/shared/components/stack/stack'; +const localSettings = isElectron() ? window.api.localSettings : null; + const ActionRequiredRoute = () => { const { t } = useTranslation(); const currentServer = useCurrentServerWithCredential(); @@ -60,7 +63,7 @@ const ActionRequiredRoute = () => { {canReturnHome && } {/* This should be displayed if a credential is required */} - {isCredentialRequired && ( + {isCredentialRequired && !localSettings?.env.SERVER_LOCK && ( + + + + + + ); +}; + +export default LoginRoute; diff --git a/src/renderer/features/search/components/server-commands.tsx b/src/renderer/features/search/components/server-commands.tsx index 31abfc0fb..90b4b03ff 100644 --- a/src/renderer/features/search/components/server-commands.tsx +++ b/src/renderer/features/search/components/server-commands.tsx @@ -1,4 +1,5 @@ import { openModal } from '@mantine/modals'; +import isElectron from 'is-electron'; import { Dispatch, useCallback } from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router'; @@ -9,6 +10,8 @@ import { AppRoute } from '/@/renderer/router/routes'; import { useAuthStoreActions, useServerList } from '/@/renderer/store'; import { ServerListItemWithCredential } from '/@/shared/types/domain-types'; +const localSettings = isElectron() ? window.api.localSettings : null; + interface ServerCommandsProps { handleClose: () => void; setPages: (pages: CommandPalettePages[]) => void; @@ -42,6 +45,8 @@ export const ServerCommands = ({ handleClose, setPages, setQuery }: ServerComman [handleClose, navigate, setCurrentServer, setPages, setQuery], ); + const serverLock = localSettings?.env.SERVER_LOCK || false; + return ( <> {`${serverList[key].name}...`} ))} - - - {t('page.appMenu.manageServers', { postProcess: 'sentenceCase' })}... - - + {!serverLock && ( + + + {t('page.appMenu.manageServers', { postProcess: 'sentenceCase' })}... + + + )} ); diff --git a/src/renderer/features/servers/components/add-server-form.tsx b/src/renderer/features/servers/components/add-server-form.tsx index 64ea4187f..6f14a0d72 100644 --- a/src/renderer/features/servers/components/add-server-form.tsx +++ b/src/renderer/features/servers/components/add-server-form.tsx @@ -301,7 +301,7 @@ export const AddServerForm = ({ onCancel }: AddServerFormProps) => { })} /> )} - + {onCancel && ( {t('common.cancel')} )} diff --git a/src/renderer/features/sidebar/components/server-selector-items.tsx b/src/renderer/features/sidebar/components/server-selector-items.tsx index 5fb85f046..d5db0f1bd 100644 --- a/src/renderer/features/sidebar/components/server-selector-items.tsx +++ b/src/renderer/features/sidebar/components/server-selector-items.tsx @@ -1,5 +1,6 @@ import { openModal } from '@mantine/modals'; import { useQuery, useQueryClient } from '@tanstack/react-query'; +import isElectron from 'is-electron'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router'; @@ -16,6 +17,8 @@ import { Icon } from '/@/shared/components/icon/icon'; import { ServerListItemWithCredential, ServerType } from '/@/shared/types/domain-types'; import { ServerFeature } from '/@/shared/types/features-types'; +const localSettings = isElectron() ? window.api.localSettings : null; + export const ServerSelectorItems = () => { const { t } = useTranslation(); const navigate = useNavigate(); @@ -87,6 +90,8 @@ export const ServerSelectorItems = () => { }); }; + const serverLock = localSettings?.env.SERVER_LOCK || false; + return ( <> @@ -120,12 +125,14 @@ export const ServerSelectorItems = () => { ); })} - } - onClick={handleManageServersModal} - > - {t('page.appMenu.manageServers', { postProcess: 'sentenceCase' })} - + {!serverLock && ( + } + onClick={handleManageServersModal} + > + {t('page.appMenu.manageServers', { postProcess: 'sentenceCase' })} + + )} {musicFolders && musicFolders.items.length > 0 && ( <> diff --git a/src/renderer/router/app-outlet.tsx b/src/renderer/router/app-outlet.tsx index bd12b4463..b97309677 100644 --- a/src/renderer/router/app-outlet.tsx +++ b/src/renderer/router/app-outlet.tsx @@ -1,4 +1,5 @@ import { NuqsAdapter } from '@offlegacy/nuqs-hash-router'; +import isElectron from 'is-electron'; import { useMemo } from 'react'; import { Navigate, Outlet } from 'react-router'; @@ -9,10 +10,14 @@ import { Center } from '/@/shared/components/center/center'; import { Spinner } from '/@/shared/components/spinner/spinner'; import { AuthState } from '/@/shared/types/types'; +const localSettings = isElectron() ? window.api.localSettings : null; + export const AppOutlet = () => { const currentServer = useCurrentServer(); const authState = useServerAuthenticated(); + const serverLock = localSettings?.env.SERVER_LOCK || false; + const isActionsRequired = useMemo(() => { const isServerRequired = !currentServer; @@ -30,6 +35,10 @@ export const AppOutlet = () => { ); } + if (serverLock && !currentServer) { + return ; + } + if (isActionsRequired || authState === AuthState.INVALID) { return ; } diff --git a/src/renderer/router/app-router.tsx b/src/renderer/router/app-router.tsx index e25edbd7c..9c59848f3 100644 --- a/src/renderer/router/app-router.tsx +++ b/src/renderer/router/app-router.tsx @@ -35,6 +35,8 @@ const InvalidRoute = lazy( () => import('/@/renderer/features/action-required/routes/invalid-route'), ); +const LoginRoute = lazy(() => import('/@/renderer/features/login/routes/login-route')); + const HomeRoute = lazy(() => import('/@/renderer/features/home/routes/home-route')); const ArtistListRoute = lazy(() => import('/@/renderer/features/artists/routes/artist-list-route')); @@ -209,6 +211,7 @@ export const AppRouter = () => { element={} path={AppRoute.ACTION_REQUIRED} /> + } path={AppRoute.LOGIN} /> diff --git a/src/renderer/router/routes.ts b/src/renderer/router/routes.ts index 7a49f6243..8647dbc65 100644 --- a/src/renderer/router/routes.ts +++ b/src/renderer/router/routes.ts @@ -1,6 +1,7 @@ export enum AppRoute { ACTION_REQUIRED = '/action-required', EXPLORE = '/explore', + LOGIN = '/login', FAKE_LIBRARY_ALBUM_DETAILS = '/library/albums/dummy/:albumId', HOME = '/', LIBRARY_ALBUM_ARTISTS = '/library/album-artists',