From 389dfd08f774acd93402489ed44ce2d8463d6bec Mon Sep 17 00:00:00 2001 From: jeffvli Date: Tue, 9 Dec 2025 19:58:24 -0800 Subject: [PATCH] render login page on SERVER_LOCK (#1172) --- .../components/action-required-container.tsx | 2 -- .../action-required/components/server-required.tsx | 12 +++--------- .../routes/action-required-route.tsx | 13 +++++++++---- src/renderer/features/login/routes/login-route.tsx | 12 +++++------- .../features/search/components/server-commands.tsx | 7 ++----- .../servers/components/add-server-form.tsx | 14 ++++---------- .../sidebar/components/server-selector-items.tsx | 7 ++----- .../features/titlebar/components/app-menu.tsx | 4 +--- src/renderer/router/app-outlet.tsx | 12 +----------- 9 files changed, 27 insertions(+), 56 deletions(-) diff --git a/src/renderer/features/action-required/components/action-required-container.tsx b/src/renderer/features/action-required/components/action-required-container.tsx index ac5d78f82..f9448e5c2 100644 --- a/src/renderer/features/action-required/components/action-required-container.tsx +++ b/src/renderer/features/action-required/components/action-required-container.tsx @@ -1,7 +1,6 @@ import { ReactNode } from 'react'; import { Group } from '/@/shared/components/group/group'; -import { Icon } from '/@/shared/components/icon/icon'; import { Stack } from '/@/shared/components/stack/stack'; import { Text } from '/@/shared/components/text/text'; @@ -13,7 +12,6 @@ interface ActionRequiredContainerProps { export const ActionRequiredContainer = ({ children, title }: ActionRequiredContainerProps) => ( - {title} diff --git a/src/renderer/features/action-required/components/server-required.tsx b/src/renderer/features/action-required/components/server-required.tsx index dc4489fef..58c3fda98 100644 --- a/src/renderer/features/action-required/components/server-required.tsx +++ b/src/renderer/features/action-required/components/server-required.tsx @@ -28,20 +28,14 @@ const localSettings = isElectron() ? window.api.localSettings : null; export const ServerRequired = () => { const serverList = useServerList(); - const serverLock = - (localSettings - ? !!localSettings.env.SERVER_LOCK - : !!window.SERVER_LOCK && - window.SERVER_TYPE && - window.SERVER_NAME && - window.SERVER_URL) || false; + const isServerLock = Boolean(window.SERVER_LOCK) || false; - if (Object.keys(serverList).length > 0) { + if (Object.keys(serverList).length > 1) { return ( - {!serverLock && ( + {!isServerLock && ( <> 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 0e511d7fa..721c0e49c 100644 --- a/src/renderer/features/action-required/routes/action-required-route.tsx +++ b/src/renderer/features/action-required/routes/action-required-route.tsx @@ -1,5 +1,4 @@ import { openModal } from '@mantine/modals'; -import isElectron from 'is-electron'; import { useTranslation } from 'react-i18next'; import { Navigate } from 'react-router'; @@ -7,6 +6,7 @@ import { PageHeader } from '/@/renderer/components/page-header/page-header'; import { ActionRequiredContainer } from '/@/renderer/features/action-required/components/action-required-container'; import { ServerCredentialRequired } from '/@/renderer/features/action-required/components/server-credential-required'; import { ServerRequired } from '/@/renderer/features/action-required/components/server-required'; +import LoginRoute from '/@/renderer/features/login/routes/login-route'; import { ServerList } from '/@/renderer/features/servers/components/server-list'; import { AnimatedPage } from '/@/renderer/features/shared/components/animated-page'; import { PageErrorBoundary } from '/@/renderer/features/shared/components/page-error-boundary'; @@ -18,14 +18,15 @@ 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(); const isServerRequired = !currentServer; const isCredentialRequired = currentServer && !currentServer.credential; + const isServerLock = Boolean(window.SERVER_LOCK) || false; + const isLoginRequired = isServerLock && !currentServer; + const checks = [ { component: , @@ -49,6 +50,10 @@ const ActionRequiredRoute = () => { }); }; + if (isLoginRequired) { + return ; + } + return ( @@ -64,7 +69,7 @@ const ActionRequiredRoute = () => { {canReturnHome && } {/* This should be displayed if a credential is required */} - {isCredentialRequired && !localSettings?.env.SERVER_LOCK && ( + {isCredentialRequired && !isServerLock && (