This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch developer_portal
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 1c0a960e6231a15b5fb6d7503c6e41436e4a6054
Author: Evan Rusackas <e...@rusackas.com>
AuthorDate: Tue Apr 1 20:32:37 2025 -0600

    better versioning dropdowns
---
 docs/components/versions.json                      |  1 +
 .../version-1.1.0/test.mdx                         |  2 +-
 .../version-1.1.0/ui-components/button.mdx         |  4 +-
 .../version-1.0.0/ui-components/button.md          |  4 +-
 docs/docusaurus.config.ts                          | 25 ++-----
 docs/src/pages/tutorials.tsx                       | 21 ------
 docs/src/pages/tutorials/getting-started.tsx       | 21 ------
 docs/src/theme/DocVersionBanner/index.js           | 77 ++++++++++++++++++++++
 docs/src/theme/DocVersionBanner/styles.module.css  | 49 ++++++++++++++
 docs/src/webpack.extend.ts                         |  6 ++
 10 files changed, 145 insertions(+), 65 deletions(-)

diff --git a/docs/components/versions.json b/docs/components/versions.json
index 5e1abcd8a6..81fc2b722b 100644
--- a/docs/components/versions.json
+++ b/docs/components/versions.json
@@ -1,3 +1,4 @@
 [
+  "1.1.0",
   "1.0.0"
 ]
diff --git a/docs/components_versioned_docs/version-1.1.0/test.mdx 
b/docs/components_versioned_docs/version-1.1.0/test.mdx
index 5d45c22561..dad5ef8dbf 100644
--- a/docs/components_versioned_docs/version-1.1.0/test.mdx
+++ b/docs/components_versioned_docs/version-1.1.0/test.mdx
@@ -2,7 +2,7 @@
 title: Test
 ---
 
-import { StoryExample } from '../src/components/StorybookWrapper';
+import { StoryExample } from '@docs/components/StorybookWrapper';
 
 # Test
 
diff --git 
a/docs/components_versioned_docs/version-1.1.0/ui-components/button.mdx 
b/docs/components_versioned_docs/version-1.1.0/ui-components/button.mdx
index 9c73618dec..aaf446a4fd 100644
--- a/docs/components_versioned_docs/version-1.1.0/ui-components/button.mdx
+++ b/docs/components_versioned_docs/version-1.1.0/ui-components/button.mdx
@@ -3,8 +3,8 @@ title: Button Component
 sidebar_position: 1
 ---
 
-import { StoryExample, StoryWithControls } from 
'../../src/components/StorybookWrapper';
-import Button from '../../../superset-frontend/src/components/Button';
+import { StoryExample, StoryWithControls } from 
'@docs/components/StorybookWrapper';
+import Button from '@superset/components/Button';
 
 # Button Component
 
diff --git 
a/docs/components_versioned_docs/version-1.1.0/versioned_docs/version-1.0.0/ui-components/button.md
 
b/docs/components_versioned_docs/version-1.1.0/versioned_docs/version-1.0.0/ui-components/button.md
index 6e8675f649..ec769f6db7 100644
--- 
a/docs/components_versioned_docs/version-1.1.0/versioned_docs/version-1.0.0/ui-components/button.md
+++ 
b/docs/components_versioned_docs/version-1.1.0/versioned_docs/version-1.0.0/ui-components/button.md
@@ -3,8 +3,8 @@ title: Button Component (v1.0.0)
 sidebar_position: 1
 ---
 
-import { StoryExample, StoryWithControls } from 
'../../../../src/components/StorybookWrapper';
-import Button from '../../../../../superset-frontend/src/components/Button';
+import { StoryExample, StoryWithControls } from 
'@docs/components/StorybookWrapper';
+import Button from '@superset/components/Button';
 
 # Button Component (v1.0.0)
 
diff --git a/docs/docusaurus.config.ts b/docs/docusaurus.config.ts
index b7969a5359..7d989898aa 100644
--- a/docs/docusaurus.config.ts
+++ b/docs/docusaurus.config.ts
@@ -211,8 +211,8 @@ const config: Config = {
         docItemComponent: '@theme/DocItem',
         includeCurrentVersion: true,
         // Show version dropdown
-        lastVersion: '1.0.0',
-        onlyIncludeVersions: ['current', '1.0.0'],
+        lastVersion: '1.1.0',
+        onlyIncludeVersions: ['current', '1.1.0', '1.0.0'],
         // Set the default version to redirect to
         versions: {
           current: {
@@ -220,6 +220,11 @@ const config: Config = {
             path: 'next',
             banner: 'unreleased',
           },
+          '1.1.0': {
+            label: '1.1.0',
+            path: '1.1.0',
+            banner: 'none',
+          },
           '1.0.0': {
             label: '1.0.0',
             path: '1.0.0',
@@ -303,22 +308,6 @@ const config: Config = {
         srcDark: '/img/superset-logo-horiz-dark.svg',
       },
       items: [
-        // Add version dropdown for components
-        {
-          type: 'docsVersionDropdown',
-          position: 'right',
-          docsPluginId: 'components',
-          dropdownItemsAfter: [],
-          dropdownActiveClassDisabled: true,
-        },
-        // Add version dropdown for tutorials
-        {
-          type: 'docsVersionDropdown',
-          position: 'right',
-          docsPluginId: 'tutorials',
-          dropdownItemsAfter: [],
-          dropdownActiveClassDisabled: true,
-        },
         {
           label: 'Tutorials',
           to: '/tutorials',
diff --git a/docs/src/pages/tutorials.tsx b/docs/src/pages/tutorials.tsx
deleted file mode 100644
index 08edb403fb..0000000000
--- a/docs/src/pages/tutorials.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import React, { useEffect } from 'react';
-import { useHistory } from '@docusaurus/router';
-import versions from '../../tutorials/versions.json';
-
-export default function TutorialsRedirect(): JSX.Element {
-  const history = useHistory();
-
-  useEffect(() => {
-    // Get the latest released version (first one in the versions array)
-    const latestVersion = versions.length > 0 ? versions[0] : '1.0.0';
-
-    // Redirect to the latest version
-    history.replace(`/tutorials/${latestVersion}`);
-  }, [history]);
-
-  return (
-    <div>
-      <p>Redirecting to Tutorials...</p>
-    </div>
-  );
-}
diff --git a/docs/src/pages/tutorials/getting-started.tsx 
b/docs/src/pages/tutorials/getting-started.tsx
deleted file mode 100644
index 81c7e65bd3..0000000000
--- a/docs/src/pages/tutorials/getting-started.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import React, { useEffect } from 'react';
-import { useHistory } from '@docusaurus/router';
-import versions from '../../../tutorials/versions.json';
-
-export default function GettingStartedRedirect(): JSX.Element {
-  const history = useHistory();
-
-  useEffect(() => {
-    // Get the latest released version (first one in the versions array)
-    const latestVersion = versions.length > 0 ? versions[0] : '1.0.0';
-
-    // Redirect to the latest version
-    history.replace(`/tutorials/${latestVersion}/getting-started`);
-  }, [history]);
-
-  return (
-    <div>
-      <p>Redirecting to Getting Started Tutorials...</p>
-    </div>
-  );
-}
diff --git a/docs/src/theme/DocVersionBanner/index.js 
b/docs/src/theme/DocVersionBanner/index.js
new file mode 100644
index 0000000000..28d00883ee
--- /dev/null
+++ b/docs/src/theme/DocVersionBanner/index.js
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import DocVersionBanner from '@theme-original/DocVersionBanner';
+import {
+  useActivePlugin,
+  useDocsVersion,
+  useVersions,
+} from '@docusaurus/plugin-content-docs/client';
+import { useLocation } from '@docusaurus/router';
+import { useDocsPreferredVersion } from '@docusaurus/theme-common';
+import { Dropdown } from 'antd';
+import { DownOutlined } from '@ant-design/icons';
+
+import styles from './styles.module.css';
+
+export default function DocVersionBannerWrapper(props) {
+  const activePlugin = useActivePlugin();
+  const { pathname } = useLocation();
+  const pluginId = activePlugin?.pluginId;
+
+  // Only show version selector for docs, components, and tutorials
+  const isVersioned = ['default', 'components', 
'tutorials'].includes(pluginId);
+
+  const { preferredVersion } = useDocsPreferredVersion(pluginId);
+  const versions = useVersions(pluginId);
+  const version = useDocsVersion();
+
+  // Create dropdown items for version selection
+  const items = versions.map(v => ({
+    key: v.name,
+    label: (
+      <a href={v.path}>
+        {v.label}
+        {v.name === version.name && ' (current)'}
+      </a>
+    ),
+  }));
+
+  return (
+    <>
+      <DocVersionBanner {...props} />
+      {isVersioned && (
+        <div className={styles.versionBanner}>
+          <div className={styles.versionContainer}>
+            <span className={styles.versionLabel}>Version:</span>
+            <Dropdown menu={{ items }} trigger={['click']}>
+              <a
+                onClick={e => e.preventDefault()}
+                className={styles.versionSelector}
+              >
+                {version.label} <DownOutlined />
+              </a>
+            </Dropdown>
+          </div>
+        </div>
+      )}
+    </>
+  );
+}
diff --git a/docs/src/theme/DocVersionBanner/styles.module.css 
b/docs/src/theme/DocVersionBanner/styles.module.css
new file mode 100644
index 0000000000..3f16c16286
--- /dev/null
+++ b/docs/src/theme/DocVersionBanner/styles.module.css
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+.versionBanner {
+  background-color: var(--ifm-color-emphasis-100);
+  padding: 0.5rem 1rem;
+  margin-bottom: 1rem;
+  border-bottom: 1px solid var(--ifm-color-emphasis-200);
+}
+
+.versionContainer {
+  display: flex;
+  align-items: center;
+  max-width: var(--ifm-container-width);
+  margin: 0 auto;
+  padding: 0 var(--ifm-spacing-horizontal);
+}
+
+.versionLabel {
+  font-weight: bold;
+  margin-right: 0.5rem;
+}
+
+.versionSelector {
+  cursor: pointer;
+  color: var(--ifm-color-primary);
+  font-weight: 500;
+}
+
+.versionSelector:hover {
+  text-decoration: none;
+  color: var(--ifm-color-primary-darker);
+}
diff --git a/docs/src/webpack.extend.ts b/docs/src/webpack.extend.ts
index 20061d38ea..489fbdb7f6 100644
--- a/docs/src/webpack.extend.ts
+++ b/docs/src/webpack.extend.ts
@@ -36,6 +36,12 @@ export default function webpackExtendPlugin(): Plugin<void> {
               __dirname,
               '../../superset-frontend/node_modules/@superset-ui/core',
             ),
+            // Add aliases for our components to make imports easier
+            '@docs/components': path.resolve(__dirname, '../src/components'),
+            '@superset/components': path.resolve(
+              __dirname,
+              '../../superset-frontend/src/components',
+            ),
             // Add proper Storybook aliases
             '@storybook/blocks': path.resolve(
               __dirname,

Reply via email to