diff --git a/jupyter-openbis-extension/static/uploadDialog.js b/jupyter-openbis-extension/static/uploadDialog.js index 6b0ac727300cb7419d491caf06afc0b325313055..11cc7f651666265f1820a8f6b01bb53e82c09373 100644 --- a/jupyter-openbis-extension/static/uploadDialog.js +++ b/jupyter-openbis-extension/static/uploadDialog.js @@ -59,13 +59,16 @@ define([ } function getOpenBISHistoryId() { + // Default empty history id var resultDatasetHistoryId = ""; + // Search for the history id on the metadata, new format, hidden from the user if(Jupyter && Jupyter.notebook && Jupyter.notebook.metadata && Jupyter.notebook.metadata.openbisHistoryId) { resultDatasetHistoryId = Jupyter.notebook.metadata.openbisHistoryId; } + // Search for the history id on the cells, older format if (!resultDatasetHistoryId) { var resultDatasetHistoryIdIdx = 0; while(Jupyter.notebook.get_cell(resultDatasetHistoryIdIdx) != null) { @@ -79,7 +82,7 @@ define([ resultDatasetHistoryIdIdx++; } } - return resultDatasetHistoryId; + return resultDatasetHistoryId; // We always return at least the empty one } function getDatasetTypes(env, connection_name, dataset_types, input_fields) { @@ -129,7 +132,7 @@ define([ var mem = state.uploadDataSetTypes[dts[dataset_types.selectedIndex].code] if (mem == null) { mem = { - "$HISTORY_ID" : getOpenBISHistoryId() + "$HISTORY_ID" : getOpenBISHistoryId() // History Id should get automatically populated if available } } input_field.value = pa.code in mem ? mem[pa.code] : ""