From 8e403fb0f2b21dae74208c282c891963bd38d6dd Mon Sep 17 00:00:00 2001 From: Sergei Garin Date: Mon, 20 May 2024 11:50:43 +0300 Subject: [PATCH] Remove access without account (#9987) Closes: https://github.com/enso-org/cloud-v2/issues/1229 This PR removes button "Continue without creating an account" on Login page. Aslo, This PR removes weird behaivor when dashboard goes into offline mode in canse if network error is happening --- app/ide-desktop/lib/dashboard/src/App.tsx | 7 +--- .../lib/dashboard/src/appUtils.tsx | 3 +- .../pages/authentication/EnterOfflineMode.tsx | 32 ------------------- .../src/pages/authentication/Login.tsx | 15 +-------- .../dashboard/src/providers/AuthProvider.tsx | 12 +------ .../lib/dashboard/src/text/english.json | 1 - 6 files changed, 4 insertions(+), 66 deletions(-) delete mode 100644 app/ide-desktop/lib/dashboard/src/pages/authentication/EnterOfflineMode.tsx diff --git a/app/ide-desktop/lib/dashboard/src/App.tsx b/app/ide-desktop/lib/dashboard/src/App.tsx index bd8ff964a47..579bebfa7dd 100644 --- a/app/ide-desktop/lib/dashboard/src/App.tsx +++ b/app/ide-desktop/lib/dashboard/src/App.tsx @@ -58,7 +58,6 @@ import SessionProvider from '#/providers/SessionProvider' import SupportsLocalBackendProvider from '#/providers/SupportsLocalBackendProvider' import ConfirmRegistration from '#/pages/authentication/ConfirmRegistration' -import EnterOfflineMode from '#/pages/authentication/EnterOfflineMode' import ErrorScreen from '#/pages/authentication/ErrorScreen' import ForgotPassword from '#/pages/authentication/ForgotPassword' import LoadingScreen from '#/pages/authentication/LoadingScreen' @@ -390,10 +389,7 @@ function AppRouter(props: AppRouterProps) { {/* Login & registration pages are visible to unauthenticated users. */} }> } /> - } - /> + } /> {/* Protected pages are visible to authenticated users. */} @@ -441,7 +437,6 @@ function AppRouter(props: AppRouterProps) { } /> } /> } /> - } /> {/* Soft-deleted user pages are visible to users who have been soft-deleted. */} }> diff --git a/app/ide-desktop/lib/dashboard/src/appUtils.tsx b/app/ide-desktop/lib/dashboard/src/appUtils.tsx index 361fb3a09b6..ac736a0f1f8 100644 --- a/app/ide-desktop/lib/dashboard/src/appUtils.tsx +++ b/app/ide-desktop/lib/dashboard/src/appUtils.tsx @@ -28,7 +28,6 @@ export const RESET_PASSWORD_PATH = '/password-reset' /** Path to the set username page. */ export const SET_USERNAME_PATH = '/set-username' /** Path to the offline mode entrypoint. */ -export const ENTER_OFFLINE_MODE_PATH = '/offline' /** Path to page in which the currently active payment plan can be managed. */ export const SUBSCRIBE_PATH = '/subscribe' export const SUBSCRIBE_SUCCESS_PATH = '/subscribe/success' @@ -36,7 +35,7 @@ export const SUBSCRIBE_SUCCESS_PATH = '/subscribe/success' export const ALL_PATHS_REGEX = new RegExp( `(?:${DASHBOARD_PATH}|${LOGIN_PATH}|${REGISTRATION_PATH}|${CONFIRM_REGISTRATION_PATH}|` + `${FORGOT_PASSWORD_PATH}|${RESET_PASSWORD_PATH}|${SET_USERNAME_PATH}|${RESTORE_USER_PATH}|` + - `${ENTER_OFFLINE_MODE_PATH}|${SUBSCRIBE_PATH}|${SUBSCRIBE_SUCCESS_PATH})$` + `${SUBSCRIBE_PATH}|${SUBSCRIBE_SUCCESS_PATH})$` ) // =========== diff --git a/app/ide-desktop/lib/dashboard/src/pages/authentication/EnterOfflineMode.tsx b/app/ide-desktop/lib/dashboard/src/pages/authentication/EnterOfflineMode.tsx deleted file mode 100644 index 4a4ccf8f9a8..00000000000 --- a/app/ide-desktop/lib/dashboard/src/pages/authentication/EnterOfflineMode.tsx +++ /dev/null @@ -1,32 +0,0 @@ -/** @file Page to enter offlin mode and redirect to dashboard. */ -import * as React from 'react' - -import * as appUtils from '#/appUtils' - -import * as navigateHooks from '#/hooks/navigateHooks' - -import * as authProvider from '#/providers/AuthProvider' - -// ======================== -// === EnterOfflineMode === -// ======================== - -/** An empty component redirecting users based on the backend response to user registration. */ -export default function EnterOfflineMode() { - const { goOffline } = authProvider.useAuth() - const navigate = navigateHooks.useNavigate() - - React.useEffect(() => { - void (async () => { - await goOffline(false) - window.setTimeout(() => { - navigate(appUtils.DASHBOARD_PATH) - }, 0) - })() - // This MUST only run once. This is fine because the above function *always* `navigate`s - // away. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []) - - return <> -} diff --git a/app/ide-desktop/lib/dashboard/src/pages/authentication/Login.tsx b/app/ide-desktop/lib/dashboard/src/pages/authentication/Login.tsx index 49352cadac4..330ba44dc06 100644 --- a/app/ide-desktop/lib/dashboard/src/pages/authentication/Login.tsx +++ b/app/ide-desktop/lib/dashboard/src/pages/authentication/Login.tsx @@ -29,14 +29,8 @@ import * as eventModule from '#/utilities/event' // === Login === // ============= -/** Props for a {@link Login}. */ -export interface LoginProps { - readonly supportsLocalBackend: boolean -} - /** A form for users to log in. */ -export default function Login(props: LoginProps) { - const { supportsLocalBackend } = props +export default function Login() { const location = router.useLocation() const { signInWithGoogle, signInWithGitHub, signInWithPassword } = authProvider.useAuth() const { getText } = textProvider.useText() @@ -61,13 +55,6 @@ export default function Login(props: LoginProps) { icon={CreateAccountIcon} text={getText('dontHaveAnAccount')} /> - {supportsLocalBackend && ( - - )} } > diff --git a/app/ide-desktop/lib/dashboard/src/providers/AuthProvider.tsx b/app/ide-desktop/lib/dashboard/src/providers/AuthProvider.tsx index 5c4a9cc0e50..37381982ac1 100644 --- a/app/ide-desktop/lib/dashboard/src/providers/AuthProvider.tsx +++ b/app/ide-desktop/lib/dashboard/src/providers/AuthProvider.tsx @@ -33,7 +33,7 @@ import type * as projectManager from '#/services/ProjectManager' import RemoteBackend from '#/services/RemoteBackend' import * as errorModule from '#/utilities/error' -import HttpClient, * as httpClient from '#/utilities/HttpClient' +import HttpClient from '#/utilities/HttpClient' import * as object from '#/utilities/object' import * as cognitoModule from '#/authentication/cognito' @@ -280,16 +280,6 @@ export default function AuthProvider(props: AuthProviderProps) { [onSessionError, /* should never change */ goOffline] ) - React.useEffect(() => { - const onFetchError = () => { - void goOffline() - } - document.addEventListener(httpClient.FETCH_ERROR_EVENT_NAME, onFetchError) - return () => { - document.removeEventListener(httpClient.FETCH_ERROR_EVENT_NAME, onFetchError) - } - }, [/* should never change */ goOffline]) - /** Fetch the JWT access token from the session via the AWS Amplify library. * * When invoked, retrieves the access token (if available) from the storage method chosen when diff --git a/app/ide-desktop/lib/dashboard/src/text/english.json b/app/ide-desktop/lib/dashboard/src/text/english.json index 4af8c840439..bc39efa25af 100644 --- a/app/ide-desktop/lib/dashboard/src/text/english.json +++ b/app/ide-desktop/lib/dashboard/src/text/english.json @@ -373,7 +373,6 @@ "signUpOrLoginWithGitHub": "Sign up or login with GitHub", "orLoginWithEmail": "or login with email", "dontHaveAnAccount": "Don't have an account?", - "continueWithoutCreatingAnAccount": "Continue without creating an account", "createANewAccount": "Create a new account", "confirmPasswordLabel": "Confirm password",