-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
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] Update link to v5 docs #36421
Conversation
Netlify deploy previewhttps://deploy-preview-36421--material-ui.netlify.app/ Bundle size report |
@@ -456,14 +456,14 @@ export default function AppNavDrawer(props) { | |||
versionSelector={renderVersionSelector([ |
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 is also a good opportunity to fix missing product identifier on some of the MUI X pages like https://mui.com/x/whats-new/
It would make way more sense to handle these if
statements as mutually exclusive:
diff --git a/docs/src/modules/components/AppNavDrawer.js b/docs/src/modules/components/AppNavDrawer.js
index 5f997aa9f3..4fb05fbf17 100644
--- a/docs/src/modules/components/AppNavDrawer.js
+++ b/docs/src/modules/components/AppNavDrawer.js
@@ -277,6 +277,89 @@ function reduceChildRoutes(context) {
return items;
}
+function XProductIdentifier({ pathname, languagePrefix, renderVersionSelector }) {
+ if (!pathname.startsWith('/x/')) {
+ return null;
+ }
+ if (pathname.startsWith('/x/react-data-grid/') || pathname.startsWith('/x/api/data-grid/')) {
+ return (
+ <ProductIdentifier
+ name="Data Grid"
+ metadata="MUI X"
+ versionSelector={renderVersionSelector([
+ // DATA_GRID_VERSION is set from the X repo
+ {
+ text: 'v6',
+ ...(process.env.DATA_GRID_VERSION.startsWith('6')
+ ? {
+ text: `v${process.env.DATA_GRID_VERSION}`,
+ current: true,
+ }
+ : {
+ href: `https://mui.com${languagePrefix}/components/data-grid/`,
+ }),
+ },
+ {
+ text: 'v5',
+ ...(process.env.DATA_GRID_VERSION.startsWith('5')
+ ? {
+ text: `v${process.env.DATA_GRID_VERSION}`,
+ current: true,
+ }
+ : {
+ href: `https://v5.mui.com${languagePrefix}/components/data-grid/`,
+ }),
+ },
+ { text: 'v4', href: `https://v4.mui.com${languagePrefix}/components/data-grid/` },
+ ])}
+ />
+ );
+ }
+ if (
+ pathname.startsWith('/x/react-date-pickers/') ||
+ pathname.startsWith('/x/api/date-pickers/')
+ ) {
+ return (
+ <ProductIdentifier
+ name="Date pickers"
+ metadata="MUI X"
+ versionSelector={renderVersionSelector([
+ // DATE_PICKERS_VERSION is set from the X repo
+ {
+ ...(process.env.DATE_PICKERS_VERSION.startsWith('6')
+ ? {
+ text: `v${process.env.DATE_PICKERS_VERSION}`,
+ current: true,
+ }
+ : {
+ text: `v6-next`,
+ href: `https://next.mui.com${languagePrefix}/components/data-grid/`,
+ }),
+ },
+ {
+ ...(process.env.DATE_PICKERS_VERSION.startsWith('5')
+ ? {
+ text: `v${process.env.DATE_PICKERS_VERSION}`,
+ current: true,
+ }
+ : {
+ text: `v5`,
+ href: `https://mui.com${languagePrefix}/components/data-grid/`,
+ }),
+ },
+ ])}
+ />
+ );
+ }
+ return <ProductIdentifier name="Advanced components" metadata="MUI X" />;
+}
+
+XProductIdentifier.propTypes = {
+ languagePrefix: PropTypes.string.isRequired,
+ pathname: PropTypes.string.isRequired,
+ renderVersionSelector: PropTypes.func.isRequired,
+};
+
// iOS is hosted on high-end devices. We can enable the backdrop transition without
// dropping frames. The performance will be good enough.
// So: <SwipeableDrawer disableBackdropTransition={false} />
@@ -445,74 +528,11 @@ 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: 'v6',
- ...(process.env.DATA_GRID_VERSION.startsWith('6')
- ? {
- text: `v${process.env.DATA_GRID_VERSION}`,
- current: true,
- }
- : {
- href: `https://mui.com${languagePrefix}/components/data-grid/`,
- }),
- },
- {
- text: 'v5',
- ...(process.env.DATA_GRID_VERSION.startsWith('5')
- ? {
- text: `v${process.env.DATA_GRID_VERSION}`,
- current: true,
- }
- : {
- href: `https://v5.mui.com${languagePrefix}/components/data-grid/`,
- }),
- },
- { 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
- {
- ...(process.env.DATE_PICKERS_VERSION.startsWith('6')
- ? {
- text: `v${process.env.DATE_PICKERS_VERSION}`,
- current: true,
- }
- : {
- text: `v6-next`,
- href: `https://next.mui.com${languagePrefix}/components/data-grid/`,
- }),
- },
- {
- ...(process.env.DATE_PICKERS_VERSION.startsWith('5')
- ? {
- text: `v${process.env.DATE_PICKERS_VERSION}`,
- current: true,
- }
- : {
- text: `v5`,
- href: `https://mui.com${languagePrefix}/components/data-grid/`,
- }),
- },
- ])}
- />
- )}
+ <XProductIdentifier
+ pathname={canonicalAs}
+ languagePrefix={languagePrefix}
+ renderVersionSelector={renderVersionSelector}
+ />
{canonicalAs.startsWith('/toolpad/') && (
<ProductIdentifier name="Toolpad" metadata="MUI Toolpad" />
)}
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'll invest in #35078 instead.
@@ -474,7 +474,7 @@ export default function AppNavDrawer(props) { | |||
current: true, | |||
} | |||
: { | |||
href: `https://mui.com${languagePrefix}/components/data-grid/`, | |||
href: `https://v5.mui.com${languagePrefix}/components/data-grid/`, | |||
}), | |||
}, | |||
{ text: 'v4', href: `https://v4.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.
Eventually, we should be able to control product identifier in the MUI X repo to reduce the complexity of such a change.
We can add a slot prop to the AppLayoutDocs
component.
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.
Actually I already did this. The idea was to use it for the first alpha, however, we needed it ASAP forcing to go on the easiest path, then other priorities came and I didn't invest more time into 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.
Cool, I did not know this PR exists 👍
The "v5" link in the drawer is still pointing to https://mui.com. This page now hosts the v6 docs.