mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-01 00:08:27 +01:00
17e340ab40
At first, I was creating a new component, Project Banner, which was 90% of the old banner and 10% new code, but it did not feel right. The current banner is actually smart enough to be used in any container. So now, I have moved the outdated SDK banner to the project level. I like the simplicity of the change. ![image](https://github.com/Unleash/unleash/assets/964450/e57c1ace-e8f9-4866-a063-6f9ae561c6c0)
113 lines
5.0 KiB
TypeScript
113 lines
5.0 KiB
TypeScript
import { Suspense, useEffect } from 'react';
|
|
import { Route, Routes } from 'react-router-dom';
|
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
|
import { FeedbackNPS } from 'component/feedback/FeedbackNPS/FeedbackNPS';
|
|
import { LayoutPicker } from 'component/layout/LayoutPicker/LayoutPicker';
|
|
import Loader from 'component/common/Loader/Loader';
|
|
import NotFound from 'component/common/NotFound/NotFound';
|
|
import { ProtectedRoute } from 'component/common/ProtectedRoute/ProtectedRoute';
|
|
import { SWRProvider } from 'component/providers/SWRProvider/SWRProvider';
|
|
import ToastRenderer from 'component/common/ToastRenderer/ToastRenderer';
|
|
import { routes } from 'component/menu/routes';
|
|
import { useAuthDetails } from 'hooks/api/getters/useAuth/useAuthDetails';
|
|
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
|
|
import { SplashPageRedirect } from 'component/splash/SplashPageRedirect/SplashPageRedirect';
|
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
|
|
|
import MaintenanceBanner from './maintenance/MaintenanceBanner';
|
|
import { styled } from '@mui/material';
|
|
import { InitialRedirect } from './InitialRedirect';
|
|
import { InternalBanners } from './banners/internalBanners/InternalBanners';
|
|
import { ExternalBanners } from './banners/externalBanners/ExternalBanners';
|
|
import { EdgeUpgradeBanner } from './banners/EdgeUpgradeBanner/EdgeUpgradeBanner';
|
|
import { LicenseBanner } from './banners/internalBanners/LicenseBanner';
|
|
import { Demo } from './demo/Demo';
|
|
|
|
const StyledContainer = styled('div')(() => ({
|
|
'& ul': {
|
|
margin: 0,
|
|
},
|
|
}));
|
|
|
|
export const App = () => {
|
|
const { authDetails } = useAuthDetails();
|
|
const { refetch: refetchUiConfig } = useUiConfig();
|
|
|
|
const { user } = useAuthUser();
|
|
const hasFetchedAuth = Boolean(authDetails || user);
|
|
|
|
const { isOss, uiConfig } = useUiConfig();
|
|
|
|
const availableRoutes = isOss()
|
|
? routes.filter((route) => !route.enterprise)
|
|
: routes;
|
|
|
|
useEffect(() => {
|
|
if (hasFetchedAuth && Boolean(user?.id)) {
|
|
refetchUiConfig();
|
|
}
|
|
}, [authDetails, user]);
|
|
|
|
return (
|
|
<SWRProvider>
|
|
<Suspense fallback={<Loader />}>
|
|
<ConditionallyRender
|
|
condition={!hasFetchedAuth}
|
|
show={<Loader />}
|
|
elseShow={
|
|
<Demo>
|
|
<>
|
|
<ConditionallyRender
|
|
condition={Boolean(
|
|
uiConfig?.maintenanceMode,
|
|
)}
|
|
show={<MaintenanceBanner />}
|
|
/>
|
|
<LicenseBanner />
|
|
<ExternalBanners />
|
|
<InternalBanners />
|
|
<EdgeUpgradeBanner />
|
|
<StyledContainer>
|
|
<ToastRenderer />
|
|
<Routes>
|
|
{availableRoutes.map((route) => (
|
|
<Route
|
|
key={route.path}
|
|
path={route.path}
|
|
element={
|
|
<LayoutPicker
|
|
isStandalone={
|
|
route.isStandalone ===
|
|
true
|
|
}
|
|
>
|
|
<ProtectedRoute
|
|
route={route}
|
|
/>
|
|
</LayoutPicker>
|
|
}
|
|
/>
|
|
))}
|
|
<Route
|
|
path='/'
|
|
element={<InitialRedirect />}
|
|
/>
|
|
<Route
|
|
path='*'
|
|
element={<NotFound />}
|
|
/>
|
|
</Routes>
|
|
|
|
<FeedbackNPS openUrl='http://feedback.unleash.run' />
|
|
|
|
<SplashPageRedirect />
|
|
</StyledContainer>
|
|
</>
|
|
</Demo>
|
|
}
|
|
/>
|
|
</Suspense>
|
|
</SWRProvider>
|
|
);
|
|
};
|