d5180601357304b9a9edef820745a66896ec09ad
max
  Tue Sep 15 05:48:46 2026 -0700
hgMyData: find the Hub Upload tab by its panel, not by counting to three, refs #38353

hgHubConnect only prints the Hub Development tab when hgHubConnect.validateHub is set, so on
a mirror with storeUserFiles on and validateHub off, Hub Upload is the third tab.  It then
got neither the upload instructions nor the HTTPS warning.

diff --git src/hg/js/hgMyData.js src/hg/js/hgMyData.js
index b92a55d5086..5a578a838a2 100644
--- src/hg/js/hgMyData.js
+++ src/hg/js/hgMyData.js
@@ -3057,31 +3057,36 @@
             `<li>Paste this URL into the ` +
             `<a href="hgHubConnect#unlistedHubs" style="color:#121E9A">Connected Hubs</a> tab ` +
             `on this site. You can also build a link that connects the hub automatically, see ` +
             `<a href="../goldenPath/help/hgTrackHubHelp.html#Sharing" ` +
             `style="color:#121E9A" target="_blank">Sharing Track Hubs</a>.</li>` +
             `</ol>` +
             `</div>`);
     }
 
     let inited = false; // keep track of first init for tab switching purposes
     function init() {
         cart.setCgiAndUrl(fileListEndpoint);
         cart.debug(debugCartJson);
         // get the file list immediately upon page load
         let activeTab = $("#tabs").tabs( "option", "active" );
-        if (activeTab === 3) {
+        // Which tab this is depends on what the mirror turns on: hgHubConnect only prints
+        // the Hub Development tab when hgHubConnect.validateHub is set, so on a mirror with
+        // storeUserFiles on and validateHub off, Hub Upload is the third tab and not the
+        // fourth.  Find it by its panel instead of counting.
+        let hubUploadTab = $('#tabs > ul > li > a[href="#hubUpload"]').parent().index();
+        if (hubUploadTab >= 0 && activeTab === hubUploadTab) {
             let url = new URL(window.location.href);
             if (url.protocol === "http:") {
                 warn(`The hub upload feature is only available over HTTPS. Please load the HTTPS version of ` +
                         `our site: <a href="https:${url.host}${url.pathname}${url.search}">https:${url.host}${url.pathname}${url.search}</a>`);
             } else if ((url.protocol + "//" + url.host) !== loginHost) {
                 showMirrorOnlyMessage();
             } else if (!inited && isLoggedIn) {
                 cart.send({ getHubSpaceUIState: {}}, handleRefreshState, handleErrorState);
                 cart.flush();
             } else {
                 showExistingFiles([]);
             }
         }
     }