From 8f7bab31b0cee01519ceee71c78eb8d00d8108f8 Mon Sep 17 00:00:00 2001 From: Bryan Florkiewicz Date: Mon, 9 Sep 2024 13:35:01 -0400 Subject: [PATCH] Code review comments - convert satellite token to module --- config/webpack.plugins.js | 1 + frontend.yml | 5 +++++ src/components/Header/Header.tsx | 10 +++++----- src/components/RootApp/ScalprumRoot.tsx | 2 -- src/layouts/SatelliteToken.tsx | 7 +++++++ 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/config/webpack.plugins.js b/config/webpack.plugins.js index b28d07268e..b10ed2da83 100644 --- a/config/webpack.plugins.js +++ b/config/webpack.plugins.js @@ -37,6 +37,7 @@ const plugins = (dev = false, beta = false, restricted = false) => { './DownloadButton': resolve(__dirname, '../src/pdf/DownloadButton.tsx'), './LandingNavFavorites': resolve(__dirname, '../src/components/FavoriteServices/LandingNavFavorites.tsx'), './DashboardFavorites': resolve(__dirname, '../src/components/FavoriteServices/DashboardFavorites.tsx'), + './SatelliteToken': resolve(__dirname, '../src/layouts/SatelliteToken.tsx'), }, shared: [ { react: { singleton: true, eager: true, requiredVersion: deps.react } }, diff --git a/frontend.yml b/frontend.yml index 0f383bb9a9..35ed2f7bd1 100644 --- a/frontend.yml +++ b/frontend.yml @@ -19,6 +19,11 @@ objects: manifestLocation: "/apps/chrome/js/fed-mods.json" config: ssoUrl: ${SSO_URL} + modules: + - id: 'satellite-token' + module: './SatelliteToken' + routes: + - pathname: /insights/satellite frontend: paths: - / diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index a8e4dc5e80..3c7a2a296a 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -1,5 +1,6 @@ import React, { Fragment, Suspense, useContext, useState } from 'react'; import ReactDOM from 'react-dom'; +import { useFlag } from '@unleash/proxy-client-react'; import Tools from './Tools'; import UnAuthtedHeader from './UnAuthtedHeader'; import { MastheadBrand, MastheadContent, MastheadMain } from '@patternfly/react-core/dist/dynamic/components/Masthead'; @@ -15,7 +16,6 @@ import { DeepRequired } from 'utility-types'; import './Header.scss'; import { activationRequestURLs } from '../../utils/consts'; -import { ITLess } from '../../utils/common'; import SearchInput from '../Search/SearchInput'; import AllServicesDropdown from '../AllServicesDropdown/AllServicesDropdown'; import Breadcrumbs, { Breadcrumbsprops } from '../Breadcrumbs/Breadcrumbs'; @@ -40,7 +40,6 @@ export const Header = ({ breadcrumbsProps }: { breadcrumbsProps?: Breadcrumbspro const { user } = useContext(ChromeAuthContext) as DeepRequired; const search = new URLSearchParams(window.location.search).keys().next().value; const isActivationPath = activationRequestURLs.includes(search); - const isITLessEnv = ITLess(); const { pathname } = useLocation(); const noBreadcrumb = !['/', '/allservices', '/favoritedservices'].includes(pathname); const { md, lg } = useWindowWidth(); @@ -48,6 +47,7 @@ export const Header = ({ breadcrumbsProps }: { breadcrumbsProps?: Breadcrumbspro const hideAllServices = (isOpen: boolean) => { setSearchOpen(isOpen); }; + const isITLess = useFlag('platform.chrome.itless'); return ( @@ -64,7 +64,7 @@ export const Header = ({ breadcrumbsProps }: { breadcrumbsProps?: Breadcrumbspro - {user?.identity?.org_id && !isITLessEnv && ReactDOM.createPortal(, document.body)} + {user?.identity?.org_id && !isITLess && ReactDOM.createPortal(, document.body)} {user && isActivationPath && } @@ -72,10 +72,10 @@ export const Header = ({ breadcrumbsProps }: { breadcrumbsProps?: Breadcrumbspro {user && ( {!(!md && searchOpen) && } - {isITLessEnv && user?.identity?.user?.is_org_admin && } + {isITLess && user?.identity?.user?.is_org_admin && } )} - {user && !isITLessEnv && ( + {user && !isITLess && ( diff --git a/src/components/RootApp/ScalprumRoot.tsx b/src/components/RootApp/ScalprumRoot.tsx index 75fd234600..fbfe14eb16 100644 --- a/src/components/RootApp/ScalprumRoot.tsx +++ b/src/components/RootApp/ScalprumRoot.tsx @@ -14,7 +14,6 @@ import chromeHistory from '../../utils/chromeHistory'; import DefaultLayout from '../../layouts/DefaultLayout'; import AllServices from '../../layouts/AllServices'; import FavoritedServices from '../../layouts/FavoritedServices'; -import SatelliteToken from '../../layouts/SatelliteToken'; import historyListener from '../../utils/historyListener'; import SegmentContext from '../../analytics/SegmentContext'; import LoadingFallback from '../../utils/loading-fallback'; @@ -259,7 +258,6 @@ const ScalprumRoot = memo( } /> )} - {ITLess() && } />} } /> } /> diff --git a/src/layouts/SatelliteToken.tsx b/src/layouts/SatelliteToken.tsx index e128848eae..eb38404e60 100644 --- a/src/layouts/SatelliteToken.tsx +++ b/src/layouts/SatelliteToken.tsx @@ -1,5 +1,6 @@ import React, { useContext, useEffect, useState } from 'react'; import axios from 'axios'; +import { useFlag } from '@unleash/proxy-client-react'; import { Header } from '../components/Header/Header'; import { Button } from '@patternfly/react-core/dist/dynamic/components/Button'; import { Card, CardBody, CardTitle } from '@patternfly/react-core/dist/dynamic/components/Card'; @@ -11,11 +12,17 @@ import SatelliteTable from '../components/Satellite/SatelliteTable'; import IPWhitelistTable from '../components/Satellite/IPWhitelistTable'; import { getEnv } from '../utils/common'; import ChromeAuthContext from '../auth/ChromeAuthContext'; +import NotFoundRoute from '../components/NotFoundRoute'; const SatelliteToken: React.FC = () => { const [token, setToken] = useState(''); const [error, setError] = useState(null); const { user } = useContext(ChromeAuthContext); + const isITLess = useFlag('platform.chrome.itless'); + + if (!isITLess) { + return ; + } const generateToken = () => { axios