-
Notifications
You must be signed in to change notification settings - Fork 28
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
Update to react-router@6
#979
Conversation
Pushed an update to get SceneAppPage and most demos to work Scene apps needs a big update
|
e85e581
to
65f02c1
Compare
I have spent sometime trying to green out all the test case, and although I think got somewhere, there are some weird things that might need someone with deeper knowledge of the scenes projects. The main issue is with the tests under the scenes package: for some reason the inline @grafana/dashboards-squad |
77516f0
to
8ee5f00
Compare
@leventebalogh I see the tests are passing, did you find the issue? |
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.
Thanks for working on this @leventebalogh
How does this work for apps built with scenes that run in Grafana? Will they continue to work as long as they are built with an older version of scenes, or will they break when Grafana and scenes runs on router@v6?
Yes, thanks @oscarkilhed, we managed to green them out with @jackw 👍
I am currently testing out these changes with an example plugin, and as soon as I am done with that I'll update the PR description with correct instructions on what steps plugins need to take for updating. (We will probably also have a migration page for this) At the time being Grafana still supports plugins both using react-router@v5 or react-router@v6. This means, that plugins built with an earlier scenes version will still be supported (at least until core is updated to use react-router@v6 fully - then they will break). As far as I know scenes is bundled (and not externalised), so it shouldn't be a problem that core is depending on a different version (for now). I'll double check this though as well, and update the PR description! This must be major version bump though, as any plugins updating to this scenes version will also need to update some things in their source code. |
@leventebalogh do we need any additional steps for this to work in grafana/grafana? Did a draft scenes bump PR to launch a drone pipeline and quite a lot of tests are erroring out 🤔 |
c982524
to
abedd6d
Compare
Thanks @Sergej-Vlasov, nice catch! 🙏 It looks like the issue was that core Grafana had a different version of |
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.
@leventebalogh great job! This seems to be working now!
Since this is a major release lets postpone the merge a bit to allow any bugfixes/docs to land before hand. You can still start working on updating plugins in the mean time by using canary release of this PR.
We have the release notes with how to handle this breaking change but I think it would also be beneficial to include this in https://grafana.com/developers/scenes/
@Sergej-Vlasov Thanks, sure 👍
Yeah, I think adding some migration docs would make sense as well, as this is a bit more "complicated" change, similar to what we have in https://grafana.com/developers/plugin-tools/migration-guides/update-from-grafana-versions/. |
abedd6d
to
6f20014
Compare
3f3a8e4
to
4ee67d2
Compare
🚀 PR was released in |
Fixes #608
Updates the scenes packages to use react-router v6.
This probably requires a major version bump, as it's going to be a breaking change for plugins that depend on scenes.
Why?
We are in the process of migrating Grafana core and also internal plugins to use react-router v6, however any plugin that is depending on scenes cannot easily do it (or at least it's a complicated task). Scenes still using react-router v5 is a blocker for plugins that would like to update.
Huge thanks to @jackw for the help of discovering and removing some of the circular dependences in the scenes package that were causing Jest to go mental.
Release notes
This release marks a big change where scene app based routing is using react-router v6 under the hood. This sadly requires several changes to plugins as react-router now requires all route paths to be relative.
Updating a plugin
Example plugin update PR →
react-router-dom
-package.json
@types/react-router-dom
-package.json
-"@types/react-router-dom": "^5.2.0",
react-router-dom
-.config/webpack/webpack.config.ts
externals: [ // Required for dynamic publicPath resolution { 'amd-module': 'module' }, 'lodash', 'jquery', 'moment', 'slate', 'emotion', '@emotion/react', '@emotion/css', 'prismjs', 'slate-plain-serializer', '@grafana/slate-react', 'react', 'react-dom', 'react-redux', 'redux', 'rxjs', 'react-router', - 'react-router-dom', 'd3', 'angular', '@grafana/ui', '@grafana/runtime', '@grafana/data',
react-router@v6
-.cprc.json
Add the following line in the
.cprc.json
:{ "features": { + "useReactRouterV6": true } }
<Route>
: use relative wildcard routes<Route>
: use theelement
prop<Switch>
: replace withRoutes
routePath
prop to each<SceneAppPage>
. It needs to include a wildcard if there are any drill-down or tab pages under it.routePath
prop defined on drill-downs relative and include a wildcard.Testing
📦 Published PR as canary version:
6.0.0--canary.979.13200094417.0
✨ Test out this PR locally via: