From 39f0b026e69fc8f0579fa7774825fe7903e807d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bonnet?= Date: Mon, 12 Dec 2022 10:17:31 +0100 Subject: [PATCH] fix(access-alpha): remove beta access feature flag (#411) --- __tests__/utils/providers.tsx | 9 +++-- apps/console/src/app/app.tsx | 36 +++--------------- apps/console/src/main.tsx | 11 ++++-- libs/shared/router/src/index.ts | 2 - .../src/lib/beta-route/beta-route.spec.tsx | 13 ------- .../router/src/lib/beta-route/beta-route.tsx | 27 -------------- .../src/lib/pages/no-beta-access.spec.tsx | 10 ----- .../router/src/lib/pages/no-beta-access.tsx | 37 ------------------- libs/shared/router/src/lib/router.ts | 1 - .../lib/components/tooltip/tooltip.spec.tsx | 3 +- 10 files changed, 20 insertions(+), 129 deletions(-) delete mode 100644 libs/shared/router/src/lib/beta-route/beta-route.spec.tsx delete mode 100644 libs/shared/router/src/lib/beta-route/beta-route.tsx delete mode 100644 libs/shared/router/src/lib/pages/no-beta-access.spec.tsx delete mode 100644 libs/shared/router/src/lib/pages/no-beta-access.tsx diff --git a/__tests__/utils/providers.tsx b/__tests__/utils/providers.tsx index 1b39f6ed455..8af611a3436 100644 --- a/__tests__/utils/providers.tsx +++ b/__tests__/utils/providers.tsx @@ -1,4 +1,5 @@ import { Auth0Provider } from '@auth0/auth0-react' +import * as TooltipPrimitive from '@radix-ui/react-tooltip' import { configureStore } from '@reduxjs/toolkit' import posthog from 'posthog-js' import React, { ComponentType, ReactNode } from 'react' @@ -33,9 +34,11 @@ export const Wrapper: React.FC = ({ children, reduxState = initialRootSta return ( - - {children} - + + + {children} + + ) diff --git a/apps/console/src/app/app.tsx b/apps/console/src/app/app.tsx index c334000e6b7..33bdf47b17a 100644 --- a/apps/console/src/app/app.tsx +++ b/apps/console/src/app/app.tsx @@ -2,7 +2,7 @@ import { GTMProvider } from '@elgorditosalsero/react-gtm-hook' import axios from 'axios' import LogRocket from 'logrocket' import posthog from 'posthog-js' -import { useCallback, useEffect, useState } from 'react' +import { useCallback, useEffect } from 'react' import { useSelector } from 'react-redux' import { Navigate, Route, Routes } from 'react-router-dom' import { useIntercom } from 'react-use-intercom' @@ -12,15 +12,7 @@ import { PageLogin, PageLogoutFeature } from '@qovery/pages/login' import { PageOnboarding } from '@qovery/pages/onboarding' import { useAuth } from '@qovery/shared/auth' import { UserInterface } from '@qovery/shared/interfaces' -import { - BetaRoute, - LOGIN_URL, - LOGOUT_URL, - NO_BETA_ACCESS_URL, - NoBetaAccess, - ONBOARDING_URL, - ProtectedRoute, -} from '@qovery/shared/router' +import { LOGIN_URL, LOGOUT_URL, ONBOARDING_URL, ProtectedRoute } from '@qovery/shared/router' import { LoadingScreen } from '@qovery/shared/ui' import { useAuthInterceptor, useDocumentTitle } from '@qovery/shared/utils' import { environment } from '../environments/environment' @@ -30,8 +22,6 @@ export function App() { useDocumentTitle('Loading...') const { isLoading } = useAuth() - const [, setBetaAccess] = useState(false) - const gtmParams = { id: environment.gtm } const user = useSelector(selectUser) @@ -67,7 +57,6 @@ export function App() { // if (process.env['NODE_ENV'] === 'production') { // if onboarding feature flag activated we add onboarding routes to router - // const isOnboarding = posthog && posthog.isFeatureEnabled('v3-onboarding') const isOnboarding = environment.onboarding === 'true' if (isOnboarding) { ROUTER.push({ @@ -86,10 +75,7 @@ export function App() { useEffect(() => { if (user && user.sub) { - if (process.env['NODE_ENV'] !== 'production') { - posthog.feature_flags.override(['v3-beta']) - setBetaAccess(posthog.isFeatureEnabled('v3-beta')) - } else { + if (process.env['NODE_ENV'] === 'production') { initMonitorings(user) } } @@ -104,14 +90,6 @@ export function App() { } /> } /> - - - - } - /> {ROUTER.map( (route) => !route.layout && ( @@ -135,11 +113,9 @@ export function App() { ) : ( - - - {route.component} - - + + {route.component} + ) } diff --git a/apps/console/src/main.tsx b/apps/console/src/main.tsx index aedc14a9b30..fb9acea30aa 100644 --- a/apps/console/src/main.tsx +++ b/apps/console/src/main.tsx @@ -1,4 +1,5 @@ import { AppState, Auth0Provider } from '@auth0/auth0-react' +import * as TooltipPrimitive from '@radix-ui/react-tooltip' import { createBrowserHistory } from 'history' import posthog from 'posthog-js' import { createRoot } from 'react-dom/client' @@ -40,10 +41,12 @@ root.render( > - - - - + + + + + + diff --git a/libs/shared/router/src/index.ts b/libs/shared/router/src/index.ts index 8ad55e389c7..e972d52965f 100644 --- a/libs/shared/router/src/index.ts +++ b/libs/shared/router/src/index.ts @@ -1,4 +1,2 @@ export * from './lib/router' export * from './lib/protected-route/protected-route' -export * from './lib/beta-route/beta-route' -export * from './lib/pages/no-beta-access' diff --git a/libs/shared/router/src/lib/beta-route/beta-route.spec.tsx b/libs/shared/router/src/lib/beta-route/beta-route.spec.tsx deleted file mode 100644 index d7ad4679392..00000000000 --- a/libs/shared/router/src/lib/beta-route/beta-route.spec.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { render } from '__tests__/utils/setup-jest' -import BetaRoute from './beta-route' - -describe('BetaRoute', () => { - const ProtectedComponent = () => { - return
Protected component
- } - - it('should render successfully', () => { - const { baseElement } = render() - expect(baseElement).toBeTruthy() - }) -}) diff --git a/libs/shared/router/src/lib/beta-route/beta-route.tsx b/libs/shared/router/src/lib/beta-route/beta-route.tsx deleted file mode 100644 index d882e4bf246..00000000000 --- a/libs/shared/router/src/lib/beta-route/beta-route.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import posthog from 'posthog-js' -import { matchPath, useLocation, useParams } from 'react-router-dom' -import { NoBetaAccess } from '../pages/no-beta-access' -import { INFRA_LOGS_URL } from '../router' - -export interface IBetaRoute { - children: React.ReactElement -} - -export const BetaRoute = ({ children }: IBetaRoute) => { - const { organizationId = '', clusterId = '' } = useParams() - const location = useLocation() - - const matchLogInfraRoute = matchPath(location.pathname || '', INFRA_LOGS_URL(organizationId, clusterId)) - - if (posthog.isFeatureEnabled('v3-beta')) { - return children - } - - if (matchLogInfraRoute) { - return children - } - - return -} - -export default BetaRoute diff --git a/libs/shared/router/src/lib/pages/no-beta-access.spec.tsx b/libs/shared/router/src/lib/pages/no-beta-access.spec.tsx deleted file mode 100644 index b01eefdfb77..00000000000 --- a/libs/shared/router/src/lib/pages/no-beta-access.spec.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { render } from '__tests__/utils/setup-jest' -import { NoBetaAccess } from './no-beta-access' - -describe('NoBetaAccess', () => { - it('should render successfully', () => { - const { baseElement } = render() - - expect(baseElement).toBeTruthy() - }) -}) diff --git a/libs/shared/router/src/lib/pages/no-beta-access.tsx b/libs/shared/router/src/lib/pages/no-beta-access.tsx deleted file mode 100644 index 389de042006..00000000000 --- a/libs/shared/router/src/lib/pages/no-beta-access.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import posthog from 'posthog-js' -import { useSelector } from 'react-redux' -import { selectUser } from '@qovery/domains/user' -import { Link } from '@qovery/shared/ui' - -export function NoBetaAccess() { - const user = useSelector(selectUser) - - if (posthog.isFeatureEnabled('v3-beta')) { - window.location.reload() - } - - posthog.onFeatureFlags(() => { - if (posthog.isFeatureEnabled('v3-beta')) { - window.location.reload() - } - }) - - return ( -
-
-
- Qovery logo -
-

Access Denied!

-

- Hello {user.name},
You do not have access to Qovery v3 Alpha yet. Contact us on Intercom to be - invited -
- - (or go back to for now) - -

-
-
- ) -} diff --git a/libs/shared/router/src/lib/router.ts b/libs/shared/router/src/lib/router.ts index 5d6d639f56d..ebec39a1d95 100644 --- a/libs/shared/router/src/lib/router.ts +++ b/libs/shared/router/src/lib/router.ts @@ -11,7 +11,6 @@ export const INDEX_URL = '/' export const ORGANIZATION_URL = (organizationId = ':organizationId') => `/organization/${organizationId}` export const OVERVIEW_URL = (organizationId = ':organizationId', projectId = ':projectId') => `/organization/${organizationId}/project/${projectId}/overview` -export const NO_BETA_ACCESS_URL = '/no-beta-access' export interface Route { component: React.ReactElement path: string diff --git a/libs/shared/ui/src/lib/components/tooltip/tooltip.spec.tsx b/libs/shared/ui/src/lib/components/tooltip/tooltip.spec.tsx index 7917ce24ea9..2a95b99895a 100644 --- a/libs/shared/ui/src/lib/components/tooltip/tooltip.spec.tsx +++ b/libs/shared/ui/src/lib/components/tooltip/tooltip.spec.tsx @@ -1,5 +1,4 @@ -import { render } from '@testing-library/react' - +import { render } from '__tests__/utils/setup-jest' import Tooltip from './tooltip' describe('Tooltip', () => {