Skip to content

Commit

Permalink
Adress PR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyperkid123 committed Jun 19, 2024
1 parent 34dfe7a commit d4ed4b7
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 39 deletions.
2 changes: 1 addition & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/auth/OIDC/OIDCState.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
12 changes: 1 addition & 11 deletions src/components/AppFilter/useAppFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down
3 changes: 1 addition & 2 deletions src/components/Feedback/FeedbackModal.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down
23 changes: 10 additions & 13 deletions src/components/Header/Tools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -185,6 +185,13 @@ const Tools = () => {
: []),
];

const handleToggle = () => {
if (!LOCAL_PREVIEW) {
switchRelease(isPreview, location.pathname, previewEnabled);
}
setIsPreview();
};

useEffect(() => {
if (user) {
setState({
Expand Down Expand Up @@ -244,12 +251,7 @@ const Tools = () => {
},
{
title: betaSwitcherTitle,
onClick: () => {
if (!LOCAL_PREVIEW) {
switchRelease(isPreview, location.pathname, previewEnabled);
}
setIsPreview();
},
onClick: handleToggle,
},
{ title: 'separator' },
...aboutMenuDropdownItems,
Expand Down Expand Up @@ -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"
/>
Expand Down
26 changes: 15 additions & 11 deletions src/state/atoms/releaseAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
1 change: 1 addition & 0 deletions src/utils/initUserConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type ChromeUserConfig = {
export const initChromeUserConfig = async ({ getUser, token }: { getUser: () => Promise<ChromeUser>; 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: {
Expand Down

0 comments on commit d4ed4b7

Please sign in to comment.