Skip to content
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

Merged
merged 2 commits into from
Mar 7, 2023
Merged

Conversation

m4theushw
Copy link
Member

@m4theushw m4theushw commented Mar 3, 2023

The "v5" link in the drawer is still pointing to https://mui.com. This page now hosts the v6 docs.

image

@m4theushw m4theushw added the docs Improvements or additions to the documentation label Mar 3, 2023
@mui-bot
Copy link

mui-bot commented Mar 3, 2023

Netlify deploy preview

https://deploy-preview-36421--material-ui.netlify.app/

Bundle size report

No bundle size changes

Generated by 🚫 dangerJS against 7783058

@m4theushw m4theushw requested review from a team, michaldudak and mnajdova March 3, 2023 21:50
@@ -456,14 +456,14 @@ export default function AppNavDrawer(props) {
versionSelector={renderVersionSelector([
Copy link
Member

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/

Screenshot 2023-03-03 at 23 26 52

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" />
           )}

Copy link
Member Author

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/` },
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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 👍

@m4theushw m4theushw merged commit aff4ec6 into mui:master Mar 7, 2023
@m4theushw m4theushw deleted the update-link-to-v5-docs branch March 7, 2023 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work docs Improvements or additions to the documentation MUI X
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants