Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ declare global {
targetSelector: string,
): Chainable<void>;
loadLandingPage(): Chainable<void>;
removeWidget(widgetId: string): void;
removeWidget(widgetId: string): Chainable<void>;
}
}
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"cypress:run:cp": "cypress run --component",
"fixjs": "eslint src cypress --fix",
"lint": "eslint src cypress .storybook",
"nightly": "npm-run-all build lint && npm run test -- -u",
"postinstall": "ts-patch install && rm -rf .cache",
"start": "fec dev",
"static": "fec static",
Expand Down
87 changes: 19 additions & 68 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,82 +1,33 @@
import React, {
Suspense,
createContext,
lazy,
useEffect,
useState,
} from 'react';
import '@patternfly/patternfly/utilities/Text/text.css';
import { Route, Routes } from 'react-router-dom';
import React, { Suspense } from 'react';
import useChrome from '@redhat-cloud-services/frontend-components/useChrome';
import { Bullseye } from '@patternfly/react-core/dist/dynamic/layouts/Bullseye';
import { Spinner } from '@patternfly/react-core/dist/dynamic/components/Spinner';
import { useNavigate } from 'react-router-dom';
import NotificationsProvider from '@redhat-cloud-services/frontend-components-notifications/NotificationsProvider';

const Landing = lazy(
() => import(/* webpackCunkName: "Landing" */ './routes/Landing'),
);
const Maintenance = lazy(
() => import(/* webpackCunkName: "Maintenance" */ './routes/Maintenance'),
);
const NotFound = lazy(
() => import(/* webpackCunkName: "NotFound" */ './routes/404'),
);

const routes = {
landing: '/',
maintenance: '/maintenance',
};
import '@patternfly/patternfly/utilities/Text/text.css';

export const PermissionContext = createContext<{
isOrgAdmin?: boolean;
}>({});
import Landing from './routes/Landing';

/**
* The module chrome mounts at exactly `/` (CRD: app `landing`, module
* `./RootApp`, route `/` exact). Chrome owns routing: any location change
* away from `/` stops matching chrome's route for this app and unmounts
* it — there is nothing to route to in here. The app's entire job is the
* Landing composition that mounts widgetLayout's layout engine.
*/
const App: React.FC<{ layoutType?: string }> = ({ layoutType }) => {
const [isOrgAdmin, setIsOrgAdmin] = useState<boolean>(false);
const chrome = useChrome();
const navigate = useNavigate();
const { on } = useChrome();

chrome?.updateDocumentTitle?.('Hybrid Cloud Console Home', false);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one isn't dead code: updateDocumentTitle('Hybrid Cloud Console Home') sets the browser tab title on the landing page, and its removal isn't mentioned in the description. Please restore it (in AppEntry or Landing), and the title should go through react-intl in #927 too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch on updateDocumentTitle — restored in the amended commit; the title goes through react-intl in #927 as suggested.


useEffect(() => {
chrome.auth
.getUser()
.then(
(user) => user && setIsOrgAdmin(!!user?.identity?.user?.is_org_admin),
);
}, []);

useEffect(() => {
const unregister = on('APP_NAVIGATION', (event) =>
navigate(`/${event.navId}`),
);
return () => {
unregister?.();
};
}, []);

return (
<PermissionContext.Provider value={{ isOrgAdmin }}>
<NotificationsProvider />
<Suspense
fallback={
<Bullseye>
<Spinner size="xl" />
</Bullseye>
}
>
<Routes>
<Route
path={routes.landing}
element={<Landing layoutType={layoutType} />}
/>
<Route path={routes.maintenance} element={<Maintenance />} />
<Route path="*" element={<NotFound />} />
</Routes>
</Suspense>
</PermissionContext.Provider>
<Suspense
fallback={
<Bullseye>
<Spinner size="xl" />
</Bullseye>
}
>
<Landing layoutType={layoutType} />
</Suspense>
);
};

Expand Down
244 changes: 0 additions & 244 deletions src/components/__tests__/__snapshots__/icon-404.test.tsx.snap

This file was deleted.

10 changes: 0 additions & 10 deletions src/components/__tests__/icon-404.test.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions src/components/icon-404.scss

This file was deleted.

Loading
Loading