2ce19ed02e1d1657b6750b506d01d6fe3cb56e8c chmalee Tue May 26 09:12:23 2026 -0700 Make myVariants Add Annotation button present below the image whether you are logged in or not. If not logged in, direct user to login, refs #33808 diff --git src/hg/hgTracks/hgTracks.c src/hg/hgTracks/hgTracks.c index a7fe58baf32..dda58090698 100644 --- src/hg/hgTracks/hgTracks.c +++ src/hg/hgTracks/hgTracks.c @@ -8877,33 +8877,33 @@ hPrintf(" "); if (!multiRegionButtonTop) { printMultiRegionButton(); hPrintf(" "); } hButtonMaybePressed("hgt.toggleRevCmplDisp", "Reverse", revCmplDisp ? "Show forward strand at this location - keyboard shortcut: r, then v" : "Show reverse strand at this location - keyboard shortcut: r, then v", NULL, revCmplDisp); hPrintf(" "); hButtonWithOnClick("hgt.setWidth", "Resize", "Resize image width to browser window size - keyboard shortcut: r, then s", "hgTracksSetWidth()"); -// put up the My Variants dialog if the hg.conf statement is present -// and the visitor is logged in (anonymous users can't write to the table). -if (cfgOptionBooleanDefault("doMyVariants", FALSE) && getUserName() != NULL) +// put up the My Variants dialog if the hg.conf statement is present. +// Anonymous visitors see the button too; the JS dialog tells them to log in. +if (cfgOptionBooleanDefault("doMyVariants", FALSE)) { hPrintf("<button id=\"myVariantsButton\" title=\"Add an item to the My Annotations track\">Add Annotation</button>"); jsInline("var doMyVariants = true;\n"); jsInlineF("var userIsLoggedIn = %s;\n", getUserName() != NULL ? "true" : "false"); // Get existing project values for dropdown char *userName = getUserName(); if (userName) { struct slName *projects = myVariantsGetProjects(userName); if (projects) { struct jsonElement *projectList = newJsonList(NULL); struct slName *proj; for (proj = projects; proj != NULL; proj = proj->next) jsonListAdd(projectList, newJsonString(proj->name)); @@ -8924,30 +8924,39 @@ slFreeList(&customFields); } /* Get hidden field names for the restore UI */ struct slName *hiddenFields = myVariantsGetHiddenFields(userName); if (hiddenFields) { struct jsonElement *hfList = newJsonList(NULL); struct slName *hf; for (hf = hiddenFields; hf != NULL; hf = hf->next) jsonListAdd(hfList, newJsonString(hf->name)); slReverse(&hfList->val.jeList); jsonObjectAdd(jsonForClient, "myVariantsHiddenFields", hfList); slFreeList(&hiddenFields); } } + else if (loginSystemEnabled() || wikiLinkEnabled()) + { + // Hand the JS dialog a login URL that returns to this hgTracks page. + char *retUrl = wikiLinkEncodeReturnUrl(cartSessionId(cart), "hgTracks", ""); + char *loginUrl = wikiLinkUserLoginUrlReturning(cartSessionId(cart), retUrl); + jsInlineF("var myVariantsLoginUrl = \"%s\";\n", loginUrl); + freez(&retUrl); + freez(&loginUrl); + } } // put the track download interface behind hg.conf control if (cfgOptionBooleanDefault("showDownloadUi", TRUE)) jsInline("var showDownloadButton = true;\n"); // remove the hg.conf option once this feature is released if (cfgOptionBooleanDefault("showIgv", FALSE)) { puts(" <button id='hgtIgv' type='button' " "title='Add an IGV.js window below the UCSC Browser, to open files from " "your local harddisk or server' >Add IGV Tracks</button>"); //jsInline("document.getElementById('hgtIgv').addEventListener('click', onIgvClick);"); }