From 31e6f1dc3f012e7e1a7062f93241cf44aca4ae50 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Wed, 24 Jan 2024 15:59:32 +0500 Subject: [PATCH 1/2] fix upload modal loses its content when closed Remove key from `UploadContainer` that causes component data to be destroyed when modal is closed. Also, `eventReset()` the modal when there is an "immediate" drag-drop upload. --- client/src/components/Upload/DefaultBox.vue | 12 ++++++------ client/src/components/Upload/UploadContainer.vue | 2 +- client/src/components/Upload/UploadModal.vue | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/client/src/components/Upload/DefaultBox.vue b/client/src/components/Upload/DefaultBox.vue index 31722c9184a0..cba474744251 100644 --- a/client/src/components/Upload/DefaultBox.vue +++ b/client/src/components/Upload/DefaultBox.vue @@ -113,15 +113,15 @@ const queue = new UploadQueue({ }); /** Add files to queue */ -function addFiles(files) { +function addFiles(files, immediate = false) { if (!isRunning.value) { + if (immediate || !props.multiple) { + eventReset(); + } if (props.multiple) { queue.add(files); - } else { - eventReset(); - if (files.length > 0) { - queue.add([files[0]]); - } + } else if (files.length > 0) { + queue.add([files[0]]); } } } diff --git a/client/src/components/Upload/UploadContainer.vue b/client/src/components/Upload/UploadContainer.vue index ba4fa08dbcc6..9c7fe5a742dc 100644 --- a/client/src/components/Upload/UploadContainer.vue +++ b/client/src/components/Upload/UploadContainer.vue @@ -112,7 +112,7 @@ const showRegular = computed(() => !props.formats || hasRegularExtension); const showRules = computed(() => !props.formats || props.multiple); function immediateUpload(files) { - regular.value?.addFiles(files); + regular.value?.addFiles(files, true); } function toData(items, history_id, composite = false) { diff --git a/client/src/components/Upload/UploadModal.vue b/client/src/components/Upload/UploadModal.vue index 8aca0acde0dc..762abcc9afc0 100644 --- a/client/src/components/Upload/UploadModal.vue +++ b/client/src/components/Upload/UploadModal.vue @@ -86,7 +86,6 @@ defineExpose({ Date: Wed, 24 Jan 2024 17:23:39 +0500 Subject: [PATCH 2/2] add selenium test for upload modal not losing content on close This selenium makes sure that when users reopen upload modal, the content from prior or inprogress uploads is still there --- lib/galaxy_test/selenium/test_uploads.py | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lib/galaxy_test/selenium/test_uploads.py b/lib/galaxy_test/selenium/test_uploads.py index cad193f97f6e..6ce9607ea02e 100644 --- a/lib/galaxy_test/selenium/test_uploads.py +++ b/lib/galaxy_test/selenium/test_uploads.py @@ -174,6 +174,36 @@ def test_upload_paired_list(self): self.history_panel_wait_for_hid_hidden(3) self.history_panel_wait_for_hid_hidden(4) + @selenium_test + def test_upload_modal_retains_content(self): + self.home() + + # initialize 2 uploads and close modal + self.upload_start_click() + self.upload_queue_local_file(self.get_filename("1.sam")) + self.upload_paste_data("some pasted data") + self.wait_for_and_click_selector("button#btn-close") + + # reopen modal and check that the files are still there + self.upload_start_click() + self.wait_for_selector_visible("#upload-row-0.upload-init") + self.wait_for_selector_visible("#upload-row-1.upload-init") + + # perform upload and close modal + self.upload_start() + self.wait_for_and_click_selector("button#btn-close") + + # add another pasted file, but don't upload it + self.upload_start_click() + self.upload_paste_data("some more pasted data") + self.wait_for_and_click_selector("button#btn-close") + + # reopen modal and see 2 uploaded, 1 yet to upload + self.upload_start_click() + self.wait_for_selector_visible("#upload-row-0.upload-success") + self.wait_for_selector_visible("#upload-row-1.upload-success") + self.wait_for_selector_visible("#upload-row-2.upload-init") + @selenium_test @pytest.mark.gtn_screenshot @pytest.mark.local