ianmcook commented on code in PR #2860:
URL: https://github.com/apache/arrow-adbc/pull/2860#discussion_r2107245812


##########
docs/source/_static/version.js:
##########
@@ -30,48 +30,117 @@ function adbcInjectVersionSwitcher() {
     // path;version\npath2;version2;\n...
     // Versions are sorted at generation time
 
-    versions
-        .trim()
-        .split(/\n/g)
-        .map((version) => version.split(/;/))
-        // Most recent on top
-        .reverse()
-        .forEach((version) => {
-            const el = document.createElement("a");
-            // Variable injected by template
-            el.setAttribute("href", versionsRoot + "/" + version[0]);
-            el.innerText = version[1];
-            if (version[1] === currentVersion) {
-                el.classList.toggle("active");
-            }
-            const li = document.createElement("li");
-            li.appendChild(el);
-            root.appendChild(li);
+    const parsedVersions = versions
+          .trim()
+          .split(/\n/g)
+          .map((version) => version.split(/;/))
+    // Most recent on top
+          .reverse();
+    parsedVersions.forEach((version) => {
+        const el = document.createElement("a");
+        // Variable injected by template
+        el.setAttribute("href", versionsRoot + "/" + version[0]);
+        el.innerText = version[1];
+        if (version[1] === currentVersion) {
+            el.classList.toggle("active");
+        }
+        const li = document.createElement("li");
+        li.appendChild(el);
+        root.appendChild(li);
 
-            el.addEventListener("click", (e) => {
-                e.preventDefault();
-                try {
-                    let relativePart = window.location.pathname.replace(/^\//, 
"");
-                    // Remove the adbc/ prefix
-                    relativePart = relativePart.replace(/^adbc[^\/]+\//, "");
-                    // Remove the version number
-                    relativePart = relativePart.replace(/^[^\/]+\//, "");
-                    const newUrl = 
`${el.getAttribute("href")}/${relativePart}`;
-                    window.fetch(newUrl).then((resp) => {
-                        if (resp.status === 200) {
-                            window.location.href = newUrl;
-                        } else {
-                            window.location.href = el.getAttribute("href");
-                        }
-                    }, () => {
+        el.addEventListener("click", (e) => {
+            e.preventDefault();
+            try {
+                let relativePart = window.location.pathname.replace(/^\//, "");
+                // Remove the adbc/ prefix
+                relativePart = relativePart.replace(/^adbc[^\/]+\//, "");
+                // Remove the version number
+                relativePart = relativePart.replace(/^[^\/]+\//, "");
+                const newUrl = `${el.getAttribute("href")}/${relativePart}`;
+                window.fetch(newUrl).then((resp) => {
+                    if (resp.status === 200) {
+                        window.location.href = newUrl;
+                    } else {
                         window.location.href = el.getAttribute("href");
-                    });
-                } catch (e) {
+                    }
+                }, () => {
                     window.location.href = el.getAttribute("href");
-                }
-                return false;
-            });
+                });
+            } catch (e) {
+                window.location.href = el.getAttribute("href");
+            }
+            return false;
+        });
+    });
+
+    // Inject a banner warning if the user is looking at older/development
+    // version documentation
+
+    // If the user has dismissed the popup, don't show it again
+    const storageKey = "adbc-ignored-version-warnings";
+    const ignoreVersionWarnings = new Set();
+    try {
+        const savedVersions = JSON.parse(window.localStorage[storageKey]);
+        for (const version of savedVersions) {
+            ignoreVersionWarnings.add(version);
+        }
+    } catch (e) {
+        // ignore
+    }
+
+    if (ignoreVersionWarnings.has(currentVersion)) {
+        return;
+    }
+
+    let warningBanner = null;
+    const redirectUrl = `${versionsRoot}/current`;
+    let redirectText = null;
+    if (currentVersion.endsWith(" (dev)")) {
+        warningBanner = "This is documentation for an unstable development 
version.";
+        redirectText = "Switch to stable version";
+    } else {
+        const stableVersions = parsedVersions
+              .filter(v => v[0] === "current");
+        if (stableVersions.length > 0) {
+            const stableVersion = stableVersions[0][1].match(/^(.+) 
\(current\)/)[1];
+            if (currentVersion !== stableVersion) {
+                warningBanner = `This is documentation for version 
${currentVersion}.`;
+                redirectText = `Switch to stable version`;

Review Comment:
   I think this is slightly clearer language when you're switching from an old 
version.
   ```suggestion
                   redirectText = `Switch to current stable version`;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to