2729e45f862a7cade4d2c107ba9c1adc395c3e79 chmalee Tue Apr 1 13:39:46 2025 -0700 Dont parse a missing fileList variable. Warn the user that their hub name or file name they are creating has invalid characters before submission so they can edit them sooner, refs Jairo email diff --git src/hg/js/hgMyData.js src/hg/js/hgMyData.js index 46f2e79e207..6a813a3547e 100644 --- src/hg/js/hgMyData.js +++ src/hg/js/hgMyData.js @@ -895,32 +895,34 @@ } } }); return table; } function init() { cart.setCgi('hgMyData'); cart.debug(debugCartJson); // TODO: write functions for // creating default trackDbs // editing trackDbs // get the state from the history stack if it exists if (typeof uiData !== 'undefined' && typeof uiState.userFiles !== 'undefined') { _.assign(uiState, uiData.userFiles); + if (uiState.fileList) { parseFileListIntoHash(uiState.fileList); } + } // first add the top level directories/files let table = showExistingFiles(uiState.fileList); // TODO: add event handlers for editing defaults, grouping into hub $("#newTrackHubDialog").dialog({ modal: true, autoOpen: false, title: "Create new track hub", closeOnEscape: true, minWidth: 400, minHeight: 120 }); // create a custom uppy plugin to batch change the type and db fields class BatchChangePlugin extends Uppy.BasePlugin { constructor(uppy, opts) { @@ -1068,30 +1070,45 @@ } if (this.uppy.getFiles().length < 2) { this.removeBatchSelectsFromDashboard(); } }); this.uppy.on("dashboard:modal-closed", () => { if (this.uppy.getFiles().length < 2) { this.removeBatchSelectsFromDashboard(); } let allFiles = this.uppy.getFiles(); let completeFiles = this.uppy.getFiles().filter((f) => f.progress.uploadComplete === true); if (allFiles.length === completeFiles.length) { this.uppy.clear(); } }); + this.uppy.on("dashboard:file-edit-complete", (file) => { + // check the filename and hubname metadata and warn the user + // to edit them if they are wrong. unfortunately I cannot + // figure out how to force the file card to re-toggle + // and jump back into the editor from here + let fileNameMatch = file.meta.name.match(fileNameRegex); + let parentDirMatch = file.meta.parentDir.match(parentDirRegex); + const dash = uppy.getPlugin("Dashboard"); + if (!fileNameMatch || fileNameMatch[0] !== file.meta.name) { + uppy.info(`Error: File name has special characters, please rename file: '${file.meta.name}' to only include alpha-numeric characters, period, dash, underscore or plus.`, 'error', 5000); + } + if (!parentDirMatch || parentDirMatch[0] !== file.meta.parentDir) { + uppy.info(`Error: Hub name has special characters, please rename hub: '${file.meta.parentDir}' to only include alpha-numeric characters, period, dash, underscore, or plus.`, 'error', 5000); + } + }); } uninstall() { // not really used because we aren't ever uninstalling the uppy instance this.uppy.off("file-added"); } } let uppyOptions = { trigger: ".uploadButton", showProgressDetails: true, note: "The UCSC Genome Browser is not a HIPAA compliant data store. Do not upload patient information or other sensitive data files here, as anyone with the URL can view them.", meta: {"genome": null, "fileType": null}, restricted: {requiredMetaFields: ["genome"]}, closeModalOnClickOutside: true, closeAfterFinish: true, theme: 'auto',