-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cmf): react-router v4 integration #324
Conversation
packages/cmf/src/App.js
Outdated
@@ -3,8 +3,8 @@ | |||
*/ | |||
import React from 'react'; | |||
import { Provider } from 'react-redux'; | |||
import { createHashHistory } from 'history'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this repleacement, our history.js
is deprecated but still here but not working, it imports import { hashHistory } from 'react-router';
which is not available anymore.
I suggest to remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
packages/cmf/src/UIRouter.js
Outdated
const routes = api.route.getRoutesFromSettings(context, props.routes); | ||
function CMFRouter(props) { | ||
const routes = props.routes; | ||
const history = props.history || createHashHistory(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be used explicitly. It is used by App.js which inject the history. We can drop that createHashHistory()
packages/cmf/src/UIRouter.js
Outdated
if (props.view && !Component.CMFContainer) { | ||
Component = api.route.connectView(context, Component, props.view); | ||
} | ||
if (props.path === '/') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is only for the root configuration, it would be better to move this directly in CMFRouter
Another thing that we mentionned together was to use the <Redirect>
component from react-router instead of our custom one for the /
route. This would introduce a breaking change, since settings.json would change for this root route
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UIRouter.js needs to be tested
* chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * deps management * Update .storybook/main.js * chore(Storybook): Algolia support * chore(Storybook): Algolia support * yarn dedup [skip ci] * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * chore(Storybook): Algolia support * Update .storybook/preview.js * chore(Storybook): Algolia support * yarn.lock update * use process.env * use process.env prefixed by Storybook * searchbar placeholder * do not open on focus * wrong hit props * og * og * og * og * search bar style * search bar style * Update .storybook/preview-head.html * review * review * Update src/docs/SearchBar.component.js Co-authored-by: Benrajalu <rajalubenoit@gmail.com> Co-authored-by: Benrajalu <rajalubenoit@gmail.com>
Please check if the PR fulfills these requirements
guidelines
What is the current behavior? (You can also link to an open issue here)
we are using react-router v3.X
#90
What is the new behavior?
We have an app under examples/cmf-app, you can install and start (this is the output from yo talend:react-cmf)
react-router v4.0.0 integration.
The concept has completly changed, so we need to re-think our integration.
Now routing is done using , , ... components.
Please check the docs: https://github.com/ReactTraining/react-router
and the migration guide: https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/guides/migrating.md
The idea behind this new integration is to keep routes in configuration.
Does this PR introduce a breaking change?
React-router v4
UIRouter to CMFRouter
The component UIRouter has been renamed to CMFRouter.
But you should not use this component explicitly and let CMF handle this.
Before
After
Optional path parameters
From
(/:paramName)
to/:paramName?
.Before
After
onEnter/onLeave router parameters
Now the router parameter has the react-router v4
match
object instead of react-router v3nextState
object.Before
After
HomeListView stacked drawers
The stacked drawers route settings are not hierarchical anymore, they are siblings.
Before
After
WithDrawer
This component is used in HomeListView stacked drawers implementation. It used to manage drawers transitions in this entry point, but that not the case anymore.
To ensure that your drawer has an enter/leave animation, wrap it with
<Drawer.Animation>
. Please read the next section to see how to use it.Before
After
Drawer.Animation
<Drawer.Animation>
api has changed to manage the open and close animation. The children can now trigger a close animation and callback.({ close, transitioned, active }) => <React element>
.close()
: a function to close the drawer with its animation.transitioned
: boolean that indicates if the animation is finished.active
: boolean that indicates if the drawer is open.Drawer
It had a z-index set to 100. This is unlikely, but you may experiment issues that some element under the drawer appears on top.
In that case you should rework your HTML markup to not rely on z-indexes. Otherwise, contribute to fix if possible without z-index.
Other information:
Because CMF support custom routing you already use react-router v4 but you can't use customization through the registry, so this is why this PR is still important.
Status
