-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MGMT-17147: Update openshift-assisted/ui-lib to react-router-dom v6 (#…
…2637) * Setup the router compatibility package * Use useNavigate instead of useHistory * Migrate /ocm and /common to compat Routes * Migrate /cim to compat routes * Remove old react-router-dom package * Make UIRouter children optional
- Loading branch information
Showing
30 changed files
with
153 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import type React from 'react'; | ||
import { BrowserRouter, Route } from 'react-router-dom'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import { CompatRouter, Route } from 'react-router-dom-v5-compat'; | ||
import { Page } from '@patternfly/react-core'; | ||
import * as OCM from '@openshift-assisted/ui-lib/ocm'; | ||
import { Header } from './Header'; | ||
import '../i18n'; | ||
|
||
const { HostsClusterDetailTabMock, Routes, Features, Config } = OCM; | ||
const { HostsClusterDetailTabMock, UILibRoutes, Features, Config } = OCM; | ||
window.__app__ = { OCM }; | ||
|
||
export const App: React.FC = () => ( | ||
<BrowserRouter basename={Config.routeBasePath}> | ||
<Page header={<Header />} isManagedSidebar defaultManagedSidebarIsOpen={false}> | ||
<Routes allEnabledFeatures={Features.STANDALONE_DEPLOYMENT_ENABLED_FEATURES}> | ||
<Route path={'/day2-flow-mock'} component={HostsClusterDetailTabMock} /> | ||
</Routes> | ||
</Page> | ||
<CompatRouter> | ||
<Page header={<Header />} isManagedSidebar defaultManagedSidebarIsOpen={false}> | ||
<UILibRoutes allEnabledFeatures={Features.STANDALONE_DEPLOYMENT_ENABLED_FEATURES}> | ||
<Route path={'/day2-flow-mock'} element={<HostsClusterDetailTabMock />} /> | ||
</UILibRoutes> | ||
</Page> | ||
</CompatRouter> | ||
</BrowserRouter> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
libs/ui-lib/lib/cim/components/Hypershift/DetailsPage/NodePoolsTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import { Switch, Route, Redirect } from 'react-router-dom'; | ||
import { Routes, Route, Navigate, Outlet } from 'react-router-dom-v5-compat'; | ||
import { Clusters, ClusterPage, NewClusterPage } from './clusters'; | ||
import type { FeatureListType } from '../../common/features/featureGate'; | ||
import { routeBasePath } from '../config'; | ||
import { AssistedUILibVersion } from './ui'; | ||
import { storeDay1 } from '../store'; | ||
import { useFeatureDetection } from '../hooks/use-feature-detection'; | ||
|
||
export const Routes: React.FC<{ allEnabledFeatures: FeatureListType }> = ({ | ||
export const UILibRoutes = ({ | ||
allEnabledFeatures, | ||
children, | ||
}: { | ||
allEnabledFeatures: FeatureListType; | ||
children?: React.ReactNode; | ||
}) => { | ||
useFeatureDetection(allEnabledFeatures); | ||
|
||
return ( | ||
<Provider store={storeDay1}> | ||
<AssistedUILibVersion /> | ||
<Switch> | ||
<Route path={`${routeBasePath}/clusters/~new`} component={NewClusterPage} /> | ||
<Route path={`${routeBasePath}/clusters/:clusterId`} component={ClusterPage} /> | ||
<Route path={`${routeBasePath}/clusters`} component={Clusters} /> | ||
<Routes> | ||
<Route path="clusters" element={<Outlet />}> | ||
<Route path="~new" element={<NewClusterPage />} /> | ||
<Route path=":clusterId" element={<ClusterPage />} /> | ||
<Route index element={<Clusters />} /> | ||
</Route> | ||
{children} | ||
<Redirect to={`${routeBasePath}/clusters`} /> | ||
</Switch> | ||
<Route path="*" element={<Navigate to="clusters" />} /> | ||
</Routes> | ||
</Provider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
libs/ui-lib/lib/ocm/components/clusterWizard/ClusterDetailsForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.