diff --git a/cypress.config.ts b/cypress.config.ts index dce3ed31d..f90523287 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -34,7 +34,7 @@ export default defineConfig({ }, e2e: { blockHosts: ['consent.trustarc.com'], - baseUrl: 'https://stage.foo.redhat.com:1337/beta', + baseUrl: 'https://stage.foo.redhat.com:1337/', env: { E2E_USER: process.env.E2E_USER, E2E_PASSWORD: process.env.E2E_PASSWORD, diff --git a/cypress/e2e/auth/OIDC/OIDCState.cy.ts b/cypress/e2e/auth/OIDC/OIDCState.cy.ts index 680a4df00..e37192d2b 100644 --- a/cypress/e2e/auth/OIDC/OIDCState.cy.ts +++ b/cypress/e2e/auth/OIDC/OIDCState.cy.ts @@ -26,10 +26,11 @@ describe('OIDC State', () => { // Enable cypress exceptions again return true; }); + cy.wait(1000); // The reloader should preserve pathname and query params const url = new URL(win.location.href); expect(url.hash).to.be.empty; - expect(url.pathname).to.eq('/beta/foo/bar'); + expect(url.pathname).to.eq('/foo/bar'); expect(url.search).to.eq('?baz=quaz'); cy.contains('Insights QA').should('exist'); }); diff --git a/src/components/AppFilter/useAppFilter.ts b/src/components/AppFilter/useAppFilter.ts index ae894ed76..8bf9846ad 100644 --- a/src/components/AppFilter/useAppFilter.ts +++ b/src/components/AppFilter/useAppFilter.ts @@ -17,17 +17,7 @@ export type AppFilterBucket = { links: NavItem[]; }; -export const requiredBundles = [ - 'application-services', - 'openshift', - 'insights', - 'edge', - 'ansible', - 'settings', - 'iam', - 'quay', - 'subscriptions', -]; +export const requiredBundles = ['application-services', 'openshift', 'insights', 'edge', 'ansible', 'settings', 'iam', 'quay', 'subscriptions']; export const itLessBundles = ['openshift', 'insights', 'settings', 'iam']; diff --git a/src/components/Feedback/FeedbackModal.tsx b/src/components/Feedback/FeedbackModal.tsx index 4a683d77b..943c9276a 100644 --- a/src/components/Feedback/FeedbackModal.tsx +++ b/src/components/Feedback/FeedbackModal.tsx @@ -1,5 +1,5 @@ import React, { memo, useContext, useState } from 'react'; -import { useAtomValue } from 'jotai'; +import { useAtom, useAtomValue } from 'jotai'; import { Button } from '@patternfly/react-core/dist/dynamic/components/Button'; import { Card, CardBody, CardTitle } from '@patternfly/react-core/dist/dynamic/components/Card'; import { FlexItem } from '@patternfly/react-core/dist/dynamic/layouts/Flex'; @@ -13,7 +13,6 @@ import OutlinedCommentsIcon from '@patternfly/react-icons/dist/dynamic/icons/out import { DeepRequired } from 'utility-types'; import { ChromeUser } from '@redhat-cloud-services/types'; import { useIntl } from 'react-intl'; -import { useAtom, useAtomValue } from 'jotai'; import { isFeedbackModalOpenAtom, usePendoFeedbackAtom } from '../../state/atoms/feedbackModalAtom'; import feedbackIllo from '../../../static/images/feedback_illo.svg'; diff --git a/src/components/Header/Tools.tsx b/src/components/Header/Tools.tsx index a567b33e8..029f45bc8 100644 --- a/src/components/Header/Tools.tsx +++ b/src/components/Header/Tools.tsx @@ -33,7 +33,7 @@ const LOCAL_PREVIEW = localStorage.getItem('chrome:local-preview') === 'true'; const isITLessEnv = ITLess(); /** - * @deprecated Switch release will be replaces by the internal chrome state variable + * @deprecated Switch release will be replaced by the internal chrome state variable */ export const switchRelease = (isBeta: boolean, pathname: string, previewEnabled: boolean) => { cookie.set('cs_toggledRelease', 'true'); @@ -185,6 +185,13 @@ const Tools = () => { : []), ]; + const handleToggle = () => { + if (!LOCAL_PREVIEW) { + switchRelease(isPreview, location.pathname, previewEnabled); + } + setIsPreview(); + }; + useEffect(() => { if (user) { setState({ @@ -244,12 +251,7 @@ const Tools = () => { }, { title: betaSwitcherTitle, - onClick: () => { - if (!LOCAL_PREVIEW) { - switchRelease(isPreview, location.pathname, previewEnabled); - } - setIsPreview(); - }, + onClick: handleToggle, }, { title: 'separator' }, ...aboutMenuDropdownItems, @@ -279,12 +281,7 @@ const Tools = () => { labelOff="Preview off" aria-label="Preview switcher" isChecked={isPreview} - onChange={() => { - if (!LOCAL_PREVIEW) { - switchRelease(isPreview, location.pathname, previewEnabled); - } - setIsPreview(); - }} + onChange={handleToggle} isReversed className="chr-c-beta-switcher" /> diff --git a/src/state/atoms/releaseAtom.ts b/src/state/atoms/releaseAtom.ts index 31faf80dc..dc8fae6ac 100644 --- a/src/state/atoms/releaseAtom.ts +++ b/src/state/atoms/releaseAtom.ts @@ -3,16 +3,20 @@ import { updateVisibilityFunctionsBeta, visibilityFunctionsExist } from '../../u import { atomWithToggle } from './utils'; import { getUnleashClient, unleashClientExists } from '../../components/FeatureFlags/unleashClient'; -export const isPreviewAtom = atomWithToggle(undefined, (isPreview) => { - // Required to change the `isBeta` function return value in the visibility functions - if (visibilityFunctionsExist()) { - updateVisibilityFunctionsBeta(isPreview); - axios.post('/api/chrome-service/v1/user/update-ui-preview', { uiPreview: isPreview }); - } - if (unleashClientExists()) { - // Required to change the `platform.chrome.ui.preview` context in the feature flags, TS is bugged - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - getUnleashClient().updateContext({ 'platform.chrome.ui.preview': isPreview }); +export const isPreviewAtom = atomWithToggle(undefined, async (isPreview) => { + try { + // Required to change the `isBeta` function return value in the visibility functions + if (visibilityFunctionsExist()) { + updateVisibilityFunctionsBeta(isPreview); + await axios.post('/api/chrome-service/v1/user/update-ui-preview', { uiPreview: isPreview }); + } + if (unleashClientExists()) { + // Required to change the `platform.chrome.ui.preview` context in the feature flags, TS is bugged + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + getUnleashClient().updateContext({ 'platform.chrome.ui.preview': isPreview }); + } + } catch (error) { + console.error('Failed to update the visibility functions or feature flags context', error); } }); diff --git a/src/utils/initUserConfig.ts b/src/utils/initUserConfig.ts index e9db70611..3a2c81ae7 100644 --- a/src/utils/initUserConfig.ts +++ b/src/utils/initUserConfig.ts @@ -13,6 +13,7 @@ export type ChromeUserConfig = { export const initChromeUserConfig = async ({ getUser, token }: { getUser: () => Promise; token: string }) => { const LOCAL_PREVIEW = localStorage.getItem('chrome:local-preview') === 'true'; let config: ChromeUserConfig; + // FIXME: remove this once fully switched to internal preview if (!LOCAL_PREVIEW) { config = { data: {