-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[docs] Add redirects for MUI X v6 #34296
Conversation
Signed-off-by: Matheus Wichman <matheushw@outlook.com>
@m4theushw This git diff is very large, it's hard to review. Adding an
Also, the title of this PR confuses me. I don't see why the JavaScript code of the
Hence I assume that the changes in the next branch we talked get here should only be about HTTP routes. |
@oliviertassinari I didn't know about
We need to change the
This is not the point of this PR but it can be done in the future. It's a more complex task to read the options from I'll also open a PR targeting When accessing https://mui.com/x/react-data-grid/ the options in the sidebar will be:
When accessing https://next.mui.com/x/react-data-grid/ the options in the sidebar will be:
|
docs/public/_redirects
Outdated
/x/react-data-grid/* https://docs-next--material-ui-x.netlify.app/x/:splat 200 | ||
/x/api/data-grid/* https://docs-next--material-ui-x.netlify.app/x/:splat 200 |
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.
I assume it should be?
/x/react-data-grid/* https://docs-next--material-ui-x.netlify.app/x/:splat 200 | |
/x/api/data-grid/* https://docs-next--material-ui-x.netlify.app/x/:splat 200 | |
/x/* https://docs-next--material-ui-x.netlify.app/x/:splat 200 |
…i into add-mui-x-v6-option
@@ -451,6 +451,7 @@ export default function AppNavDrawer(props) { | |||
versionSelector={renderVersionSelector([ | |||
// DATA_GRID_VERSION is set from the X repo | |||
{ text: `v${process.env.DATA_GRID_VERSION}`, current: true }, | |||
{ text: 'v5', href: `https://mui.com${languagePrefix}/components/data-grid/` }, |
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.
What is this line for? I assume this would be enough:
{ text: 'v5', href: `https://mui.com${languagePrefix}/components/data-grid/` }, |
I don't understand the previous argument used:
We need to change the docs/src/modules/components/AppNavDrawer.js component to add the new option. We don't duplicate this component in the X repo.
MUI X (v5, v6) is using and should be using the master branch of the mono repo for its code and docs infra, so I fail to understand how it has an impact.
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.
If I remove this line users won't have a link for the v5 version if they access a v6 page.
MUI X (v5, v6) is using and should be using the master branch of the mono repo for its code and docs infra, so I fail to understand how it has an impact.
It's related to why we can't remove the line above. When accessing https://next.mui.com/x/react-data-grid/ the menu will show v6-alpha.x
, v5
and v4
, and in https://mui.com/x/react-data-grid/ it will contain v6
, v5.17.4
and v4
. MUI X v5 will use the master branch of the monorepo, while v6 will use the next branch because I don't have the v6 version in the master branch of the MUI X repo to use here. It comes from package.json
.
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.
@m4theushw I think that as much as we can, there should be a single version of @mui/monorepo
(docs infra + code infra). The value is that fixes done to it like #34619 don't need to be cherry-picked on two different versions (next and master).
Now, if we assume that we have this as a constraint for the solution, then the option that seems to be the best is to continue in the direction that we started to serve the docs infra as a standalone product. This means, if we were using https://docusaurus.io/, we wouldn't go to docusaurus repo to open a PR to ask to update the versions. We would use the API it exposes to do such, I think we should do the same with all the docs that rely on the docs-infra.
I created mui/mui-x#6374 to demonstrate how this PR will work in production. See https://deploy-preview-6374--material-ui-x.netlify.app/x/react-data-grid/ We'll need to find a solution for cc @danilo-leal |
@m4theushw Thanks for the demo. From what I can see, mui/mui-x#6374 is based on https://github.com/mui/material-ui.git#master + #34296 but this PR is on the next branch, not the master branch. So I think that we should:
At the same time of 2, I think that we could look into the version displayed. It looks confusing, MUI X is on v5.17.2, the actual version of the date picker is not that much important as it's eventually the version of MUI X. |
Can the layout be something like this? so that we don't have to deal with the text-overflow in the future. cc @danilo-leal |
@siriwatknp On this one, I wonder if the root of the problem isn't that the side nav header was built for the cases of a product family that has sub-products. But it doesn't work with a standalone product, e.g. MUI Toolpad: https://mui.com/toolpad/getting-started/installation/. I think that it would work better with Toolpad only displayed once. In the case of MUI X, It's not clear to me if we should show "Date pickers" in the header. I think that we have eventually a lot more components to build in MUI X: Tree View, File Upload, Carousel, Scheduler, Sparkline, Window Splitter, Rich Text Editor, Cascader Select, Tour, Tree Select, Charts, Signature. It could look like this: and maybe:
|
I reverted the changes in
@oliviertassinari The specific version |
Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@m4theushw We started to cover the topic a bit in https://www.notion.so/mui-org/Scaling-docs-infra-to-more-teams-f8f2322f5a95436ab23044c3a939840b#36a08a48b8b949238f93f1566443545a when Andrew needed to update the same component. I think that it depends on the level of abstraction of the API that we want to expose in the docs-infra. We could use https://nextra.vercel.app/get-started as inspiration. For example, it could look like this: diff --git a/docs/pages/_app.js b/docs/pages/_app.js
index 9e157c4505..c12ad0ed76 100644
--- a/docs/pages/_app.js
+++ b/docs/pages/_app.js
@@ -171,6 +171,20 @@ Tip: you can access the documentation \`theme\` object directly in the console.
'font-family:monospace;color:#1976d2;font-size:12px;',
);
}
+
+function AppNavDrawerHeader() {
+ return (
+ <ProductIdentifier
+ name="MUI X"
+ metadata="MUI X"
+ versionSelector={renderVersionSelector([
+ { text: `v${process.env.DATA_GRID_VERSION}`, current: true },
+ { text: 'v4', href: `https://v4.mui.com${languagePrefix}/components/data-grid/` },
+ ])}
+ />
+ );
+}
+
function AppWrapper(props) {
const { children, emotionCache, pageProps } = props;
@@ -219,7 +233,7 @@ function AppWrapper(props) {
<LanguageNegotiation />
<CodeCopyProvider>
<CodeVariantProvider>
- <PageContext.Provider value={{ activePage, pages: productPages }}>
+ <PageContext.Provider value={{ activePage, pages: productPages, AppNavDrawerHeader }}>
<ThemeProvider>
<DocsStyledEngineProvider cacheLtr={emotionCache}>
{children} which MUI X can inject: https://github.com/mui/mui-x/blob/b8841eada5582cac03e3aa4b97711bf8f0719513/docs/pages/_app.js#L261. And on this repository: diff --git a/docs/src/modules/components/AppNavDrawer.js b/docs/src/modules/components/AppNavDrawer.js
index cd3452bd1c..058846ce94 100644
--- a/docs/src/modules/components/AppNavDrawer.js
+++ b/docs/src/modules/components/AppNavDrawer.js
@@ -281,7 +281,7 @@ const iOS = typeof navigator !== 'undefined' && /iPad|iPhone|iPod/.test(navigato
export default function AppNavDrawer(props) {
const { className, disablePermanent, mobileOpen, onClose, onOpen } = props;
- const { activePage, pages } = React.useContext(PageContext);
+ const { activePage, pages, AppNavDrawerHeader } = React.useContext(PageContext);
const router = useRouter();
const [anchorEl, setAnchorEl] = React.useState(null);
const userLanguage = useUserLanguage();
@@ -391,6 +391,7 @@ export default function AppNavDrawer(props) {
<SvgMuiLogo width={30} />
</Box>
</NextLink>
+ <AppNavDrawerHeader />
{canonicalAs.startsWith('/material-ui/') && (
<ProductIdentifier
name="Material UI"
@@ -440,32 +441,6 @@ export default function AppNavDrawer(props) {
])}
/>
)}
- {canonicalAs.startsWith('/x/introduction/') && (
- <ProductIdentifier name="Advanced components" metadata="MUI X" />
- )}
- {(canonicalAs.startsWith('/x/react-data-grid/') ||
- canonicalAs.startsWith('/x/api/data-grid/')) && (
- <ProductIdentifier
- name="Data Grid"
- metadata="MUI X"
- versionSelector={renderVersionSelector([
- // DATA_GRID_VERSION is set from the X repo
- { text: `v${process.env.DATA_GRID_VERSION}`, current: true },
- { text: 'v4', href: `https://v4.mui.com${languagePrefix}/components/data-grid/` },
- ])}
- />
- )}
- {(canonicalAs.startsWith('/x/react-date-pickers/') ||
- canonicalAs.startsWith('/x/api/date-pickers/')) && (
- <ProductIdentifier
- name="Date pickers"
- metadata="MUI X"
- versionSelector={renderVersionSelector([
- // DATE_PICKERS_VERSION is set from the X repo
- { text: `v${process.env.DATE_PICKERS_VERSION}`, current: true },
- ])}
- />
- )}
{canonicalAs.startsWith('/toolpad/') && (
<ProductIdentifier name="Toolpad" metadata="MUI Toolpad" />
)} |
@oliviertassinari We can go further and remove from |
|
||
## MUI Toolpad | ||
/static/toolpad/* https://mui-toolpad-docs.netlify.app/static/toolpad/:splat 200 | ||
/toolpad/_next/* https://mui-toolpad-docs.netlify.app/_next/:splat 200 | ||
/toolpad/* https://mui-toolpad-docs.netlify.app/toolpad/:splat 200 | ||
/r/toolpad-* https://mui-toolpad-docs.netlify.app/r/toolpad-:splat 200 | ||
|
||
/* https://mui.com/:splat 301! |
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.
Shouldn't it be 302 instead of 301? This redirect is temporary and will be removed as soon as we start working on the core v6
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.
Yeah, makes sense. In
$ curl -I https://next.mui.com/material-ui/react-alert/
HTTP/2 301
we could expect a 302.
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.
Addressed in #36296
Preview: https://deploy-preview-6374--material-ui-x.netlify.app/x/react-data-grid/
Preview: https://deploy-preview-34296--material-ui.netlify.app/I created this PR to change the default version shown when visiting a X page. Now it will show
v6...
by default in the dropdown below, and v5 will be the 2nd option.This can't be seen in the preview because I first need to merge this PR and upgrade the monorepo in the X repo.I also removed all other pages and added a redirect back to the stable docs. I don't want to have https://mui.com/material-ui/getting-started/overview/ and https://next.mui.com/material-ui/getting-started/overview/. After this PR is merged I'll open another one adding the v6 option in
master
.