Skip to content

Commit

Permalink
refactor(config): ent-2745 consolidate nav, routing configs (#656)
Browse files Browse the repository at this point in the history
* routerConfig, move const to routerHelpers, clean up comps and redux refs
* routerHelpers, generate nav, route, product groups, add routerConfig const
  • Loading branch information
cdcabrera committed Jul 13, 2021
1 parent ebba9ab commit d210017
Show file tree
Hide file tree
Showing 19 changed files with 1,443 additions and 543 deletions.
6 changes: 3 additions & 3 deletions src/components/authentication/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { NotAuthorized } from '@redhat-cloud-services/frontend-components/NotAut
import { connectRouter, reduxActions, reduxSelectors } from '../../redux';
import { rhsmApiTypes } from '../../types';
import { helpers } from '../../common';
import { Redirect, routerHelpers, routerConfig } from '../router/router';
import { Redirect, routerHelpers } from '../router/router';
import MessageView from '../messageView/messageView';
import { translate } from '../i18n/i18n';

Expand All @@ -16,7 +16,7 @@ import { translate } from '../i18n/i18n';
* @augments React.Component
*/
class Authentication extends Component {
appName = routerConfig.appName;
appName = routerHelpers.appName;

removeListeners = helpers.noop;

Expand Down Expand Up @@ -119,7 +119,7 @@ Authentication.propTypes = {
setAppName: PropTypes.func,
session: PropTypes.shape({
authorized: PropTypes.shape({
[routerConfig.appName]: PropTypes.bool
[routerHelpers.appName]: PropTypes.bool
}),
errorCodes: PropTypes.arrayOf(PropTypes.string),
pending: PropTypes.bool,
Expand Down
8 changes: 3 additions & 5 deletions src/components/productView/productViewMissing.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button, Card, CardBody, CardFooter, CardTitle, Gallery, Title, PageSect
import { ArrowRightIcon } from '@patternfly/react-icons';
import { useHistory } from 'react-router-dom';
import { PageLayout, PageHeader } from '../pageLayout/pageLayout';
import { routerConfig, routerHelpers } from '../router/router';
import { routerHelpers } from '../router/router';
import { helpers } from '../../common';
import { translate } from '../i18n/i18n';

Expand Down Expand Up @@ -48,9 +48,7 @@ const ProductViewMissing = ({ basePath, products, t }) => {
const filteredProducts = Object.values(updatedProducts);
return (
(filteredProducts.length && filteredProducts) ||
routerConfig.navigation.filter(
({ isSearchable, productParameter }) => (isSearchable && productParameter) || false
)
products.filter(({ isSearchable, productParameter }) => (isSearchable && productParameter) || false)
);
};

Expand Down Expand Up @@ -128,7 +126,7 @@ ProductViewMissing.propTypes = {
*/
ProductViewMissing.defaultProps = {
basePath: routerHelpers.basePath,
products: routerConfig.navigation,
products: routerHelpers.navigation,
t: translate
};

Expand Down
154 changes: 148 additions & 6 deletions src/components/router/__tests__/__snapshots__/router.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ exports[`Router Component should render a basic component: basic 1`] = `
routes={
Array [
Object {
"activateOnError": false,
"component": Object {
"$$typeof": Symbol(react.lazy),
"_init": [Function],
Expand All @@ -115,10 +116,12 @@ exports[`Router Component should render a basic component: basic 1`] = `
},
"disabled": false,
"exact": true,
"redirect": null,
"render": true,
"to": "/:variant(rhel|rhel-arm|rhel-ibmpower|rhel-ibmz|rhel-x86)",
"to": "/rhel",
},
Object {
"activateOnError": false,
"component": Object {
"$$typeof": Symbol(react.lazy),
"_init": [Function],
Expand All @@ -129,10 +132,76 @@ exports[`Router Component should render a basic component: basic 1`] = `
},
"disabled": false,
"exact": true,
"redirect": null,
"render": true,
"to": "/rhel-arm",
},
Object {
"activateOnError": false,
"component": Object {
"$$typeof": Symbol(react.lazy),
"_init": [Function],
"_payload": Object {
"_result": [Function],
"_status": -1,
},
},
"disabled": false,
"exact": true,
"redirect": null,
"render": true,
"to": "/rhel-ibmpower",
},
Object {
"activateOnError": false,
"component": Object {
"$$typeof": Symbol(react.lazy),
"_init": [Function],
"_payload": Object {
"_result": [Function],
"_status": -1,
},
},
"disabled": false,
"exact": true,
"redirect": null,
"render": true,
"to": "/rhel-ibmz",
},
Object {
"activateOnError": false,
"component": Object {
"$$typeof": Symbol(react.lazy),
"_init": [Function],
"_payload": Object {
"_result": [Function],
"_status": -1,
},
},
"disabled": false,
"exact": true,
"redirect": null,
"render": true,
"to": "/rhel-x86",
},
Object {
"activateOnError": false,
"component": Object {
"$$typeof": Symbol(react.lazy),
"_init": [Function],
"_payload": Object {
"_result": [Function],
"_status": -1,
},
},
"disabled": false,
"exact": true,
"redirect": null,
"render": true,
"to": "/openshift-container",
},
Object {
"activateOnError": false,
"component": Object {
"$$typeof": Symbol(react.lazy),
"_init": [Function],
Expand All @@ -143,10 +212,28 @@ exports[`Router Component should render a basic component: basic 1`] = `
},
"disabled": false,
"exact": true,
"redirect": null,
"render": true,
"to": "/openshift-dedicated",
},
Object {
"activateOnError": false,
"component": Object {
"$$typeof": Symbol(react.lazy),
"_init": [Function],
"_payload": Object {
"_result": [Function],
"_status": -1,
},
},
"disabled": false,
"exact": true,
"redirect": null,
"render": true,
"to": "/satellite",
},
Object {
"activateOnError": false,
"component": Object {
"$$typeof": Symbol(react.lazy),
"_init": [Function],
Expand All @@ -157,8 +244,25 @@ exports[`Router Component should render a basic component: basic 1`] = `
},
"disabled": false,
"exact": true,
"redirect": null,
"render": true,
"to": "/:variant(satellite|satellite-capsule|satellite-server)",
"to": "/satellite-capsule",
},
Object {
"activateOnError": false,
"component": Object {
"$$typeof": Symbol(react.lazy),
"_init": [Function],
"_payload": Object {
"_result": [Function],
"_status": -1,
},
},
"disabled": false,
"exact": true,
"redirect": null,
"render": true,
"to": "/satellite-server",
},
Object {
"activateOnError": true,
Expand All @@ -172,10 +276,12 @@ exports[`Router Component should render a basic component: basic 1`] = `
},
"disabled": false,
"exact": true,
"redirect": null,
"render": true,
"to": "/optin",
},
Object {
"activateOnError": false,
"component": Object {
"$$typeof": Symbol(react.lazy),
"_init": [Function],
Expand All @@ -196,8 +302,32 @@ exports[`Router Component should render a basic component: basic 1`] = `
<Switch>
<Route
exact={true}
key="/:variant(rhel|rhel-arm|rhel-ibmpower|rhel-ibmz|rhel-x86)"
path="/:variant(rhel|rhel-arm|rhel-ibmpower|rhel-ibmz|rhel-x86)"
key="/rhel"
path="/rhel"
render={[Function]}
/>
<Route
exact={true}
key="/rhel-arm"
path="/rhel-arm"
render={[Function]}
/>
<Route
exact={true}
key="/rhel-ibmpower"
path="/rhel-ibmpower"
render={[Function]}
/>
<Route
exact={true}
key="/rhel-ibmz"
path="/rhel-ibmz"
render={[Function]}
/>
<Route
exact={true}
key="/rhel-x86"
path="/rhel-x86"
render={[Function]}
/>
<Route
Expand All @@ -214,8 +344,20 @@ exports[`Router Component should render a basic component: basic 1`] = `
/>
<Route
exact={true}
key="/:variant(satellite|satellite-capsule|satellite-server)"
path="/:variant(satellite|satellite-capsule|satellite-server)"
key="/satellite"
path="/satellite"
render={[Function]}
/>
<Route
exact={true}
key="/satellite-capsule"
path="/satellite-capsule"
render={[Function]}
/>
<Route
exact={true}
key="/satellite-server"
path="/satellite-server"
render={[Function]}
/>
<Route
Expand Down
Loading

0 comments on commit d210017

Please sign in to comment.