diff --git a/client/src/api/datatypes.ts b/client/src/api/datatypes.ts new file mode 100644 index 000000000000..0b6d30a71c60 --- /dev/null +++ b/client/src/api/datatypes.ts @@ -0,0 +1,3 @@ +import { type components } from "@/api"; + +export type CompositeFileInfo = components["schemas"]["CompositeFileInfo"]; diff --git a/client/src/api/histories.ts b/client/src/api/histories.ts new file mode 100644 index 000000000000..ed10bb8efb1f --- /dev/null +++ b/client/src/api/histories.ts @@ -0,0 +1,3 @@ +import { type components } from "@/api"; + +export type HistoryContentsResult = components["schemas"]["HistoryContentsResult"]; diff --git a/client/src/components/Collections/CollectionCreatorModal.vue b/client/src/components/Collections/CollectionCreatorModal.vue new file mode 100644 index 000000000000..334f6586e0da --- /dev/null +++ b/client/src/components/Collections/CollectionCreatorModal.vue @@ -0,0 +1,326 @@ + + + + + diff --git a/client/src/components/Collections/ListCollectionCreator.vue b/client/src/components/Collections/ListCollectionCreator.vue index 5798187943f2..17324166aca9 100644 --- a/client/src/components/Collections/ListCollectionCreator.vue +++ b/client/src/components/Collections/ListCollectionCreator.vue @@ -1,41 +1,44 @@ diff --git a/client/src/components/Collections/PairCollectionCreator.vue b/client/src/components/Collections/PairCollectionCreator.vue index 2520a3a022f8..38ee98f530c9 100644 --- a/client/src/components/Collections/PairCollectionCreator.vue +++ b/client/src/components/Collections/PairCollectionCreator.vue @@ -1,32 +1,50 @@ @@ -382,10 +528,6 @@ onMounted(() => { margin-top: 8px; } - .main-help { - cursor: pointer; - } - .collection-elements-controls { margin-bottom: 8px; } @@ -433,6 +575,15 @@ onMounted(() => { text-decoration: none; } } + + &.selected { + border-color: black; + background: rgb(118, 119, 131); + color: white; + a { + color: white; + } + } } .empty-message { diff --git a/client/src/components/Collections/PairCollectionCreatorModal.js b/client/src/components/Collections/PairCollectionCreatorModal.js deleted file mode 100644 index 1cfa2a64dc71..000000000000 --- a/client/src/components/Collections/PairCollectionCreatorModal.js +++ /dev/null @@ -1,43 +0,0 @@ -import _l from "utils/localization"; -import Vue from "vue"; - -import { collectionCreatorModalSetup } from "./common/modal"; - -function pairCollectionCreatorModal(elements, options) { - options = options || {}; - options.title = _l("Create a collection from a pair of datasets"); - const { promise, showEl } = collectionCreatorModalSetup(options); - return import(/* webpackChunkName: "PairCollectionCreator" */ "./PairCollectionCreator.vue").then((module) => { - var pairCollectionCreatorInstance = Vue.extend(module.default); - var vm = document.createElement("div"); - showEl(vm); - new pairCollectionCreatorInstance({ - propsData: { - initialElements: elements, - creationFn: options.creationFn, - oncancel: options.oncancel, - oncreate: options.oncreate, - defaultHideSourceItems: options.defaultHideSourceItems, - }, - }).$mount(vm); - return promise; - }); -} -function createPairCollection(contents, defaultHideSourceItems = true) { - var elements = contents.toJSON(); - var promise = pairCollectionCreatorModal(elements, { - defaultHideSourceItems: defaultHideSourceItems, - creationFn: function (elements, name, hideSourceItems) { - elements = [ - { name: "forward", src: elements[0].src || "hda", id: elements[0].id }, - { name: "reverse", src: elements[1].src || "hda", id: elements[1].id }, - ]; - return contents.createHDCA(elements, "paired", name, hideSourceItems); - }, - }); - return promise; -} -export default { - pairCollectionCreatorModal: pairCollectionCreatorModal, - createPairCollection: createPairCollection, -}; diff --git a/client/src/components/Collections/PairedElementView.vue b/client/src/components/Collections/PairedElementView.vue index 364832a22db2..42cd1d9e8af0 100644 --- a/client/src/components/Collections/PairedElementView.vue +++ b/client/src/components/Collections/PairedElementView.vue @@ -1,69 +1,58 @@ diff --git a/client/src/components/Collections/PairedListCollectionCreator.test.js b/client/src/components/Collections/PairedListCollectionCreator.test.js index a798ba2f8f17..d62270b04335 100644 --- a/client/src/components/Collections/PairedListCollectionCreator.test.js +++ b/client/src/components/Collections/PairedListCollectionCreator.test.js @@ -1,48 +1,69 @@ +import { createTestingPinia } from "@pinia/testing"; import DATA from "@tests/test-data/paired-collection-creator.data.js"; import { mount, shallowMount } from "@vue/test-utils"; import PairedListCollectionCreator from "components/Collections/PairedListCollectionCreator"; +import flushPromises from "flush-promises"; +import Vue from "vue"; + +import { useServerMock } from "@/api/client/__mocks__"; + +// Mock the localize directive +// (otherwise we get: [Vue warn]: Failed to resolve directive: localize) +Vue.directive("localize", { + bind(el, binding) { + el.textContent = binding.value; + }, +}); + +const { server, http } = useServerMock(); describe("PairedListCollectionCreator", () => { let wrapper; + const pinia = createTestingPinia(); + + beforeEach(() => { + server.use( + http.get("/api/configuration", ({ response }) => { + return response(200).json({ + chunk_upload_size: 100, + file_sources_configured: true, + }); + }) + ); + }); + + it("performs an autopair on startup if we have a selection", async () => { + // Kind of deprecated because we are never using `props.fromSelection: true` anywhere - it("autopairs the dataset", async () => { wrapper = shallowMount(PairedListCollectionCreator, { propsData: { + historyId: "history_id", initialElements: DATA._1, - creationFn: () => { - return; - }, - oncreate: () => { - return; - }, - oncancel: () => { - return; - }, - hideSourceItems: false, + fromSelection: true, }, + pinia, }); - await wrapper.vm.$nextTick(); + + await flushPromises(); // Autopair is called on startup - expect(wrapper.findAll("li.dataset unpaired").length == 0).toBeTruthy(); + const pairsCountDisplay = wrapper.find('[data-description="number of pairs"]'); + expect(pairsCountDisplay.text()).toContain(`${DATA._1.length / 2} pairs`); }); - it("selects the correct name for an auotpair", async () => { + it("selects the correct name for an autopair", async () => { wrapper = mount(PairedListCollectionCreator, { propsData: { + historyId: "history_id", initialElements: DATA._2, - creationFn: () => { - return; - }, - oncreate: () => { - return; - }, - oncancel: () => { - return; - }, - hideSourceItems: false, + }, + pinia, + stubs: { + FontAwesomeIcon: true, + BPopover: true, }, }); - await wrapper.vm.$nextTick(); + + await flushPromises(); //change filter to .1.fastq/.2.fastq await wrapper.find("div.forward-unpaired-filter > div.input-group-append > button").trigger("click"); await wrapper @@ -56,7 +77,7 @@ describe("PairedListCollectionCreator", () => { const reverseFilter = wrapper.find("div.reverse-unpaired-filter > input").element.value; expect(reverseFilter).toBe(".2.fastq"); // click Autopair - await wrapper.find("a.autopair-link").trigger("click"); + await wrapper.find(".autopair-link").trigger("click"); //assert pair-name longer name const pairname = wrapper.find("span.pair-name"); expect(pairname.text()).toBe("DP134_1_FS_PSII_FSB_42C_A10"); @@ -65,20 +86,17 @@ describe("PairedListCollectionCreator", () => { it("removes the period from autopair name", async () => { wrapper = mount(PairedListCollectionCreator, { propsData: { + historyId: "history_id", initialElements: DATA._3, - creationFn: () => { - return; - }, - oncreate: () => { - return; - }, - oncancel: () => { - return; - }, - hideSourceItems: false, + }, + pinia, + stubs: { + FontAwesomeIcon: true, + BPopover: true, }, }); - await wrapper.vm.$nextTick(); + + await flushPromises(); //change filter to .1.fastq/.2.fastq await wrapper.find("div.forward-unpaired-filter > div.input-group-append > button").trigger("click"); await wrapper @@ -92,7 +110,7 @@ describe("PairedListCollectionCreator", () => { const reverseFilter = wrapper.find("div.reverse-unpaired-filter > input").element.value; expect(reverseFilter).toBe(".2.fastq"); // click Autopair - await wrapper.find("a.autopair-link").trigger("click"); + await wrapper.find(".autopair-link").trigger("click"); //assert pair-name longer name const pairname = wrapper.find("span.pair-name"); expect(pairname.text()).toBe("UII_moo_1"); @@ -101,20 +119,17 @@ describe("PairedListCollectionCreator", () => { it("autopairs correctly when filters are typed in", async () => { wrapper = mount(PairedListCollectionCreator, { propsData: { + historyId: "history_id", initialElements: DATA._4, - creationFn: () => { - return; - }, - oncreate: () => { - return; - }, - oncancel: () => { - return; - }, - hideSourceItems: false, + }, + pinia, + stubs: { + FontAwesomeIcon: true, + BPopover: true, }, }); - await wrapper.vm.$nextTick(); + + await flushPromises(); //change filter to _R1/_R2 await wrapper.find("div.forward-unpaired-filter > input").setValue("_R1"); await wrapper.find("div.reverse-unpaired-filter > input").setValue("_R2"); @@ -125,7 +140,7 @@ describe("PairedListCollectionCreator", () => { const reverseFilter = wrapper.find("div.reverse-unpaired-filter > input").element.value; expect(reverseFilter).toBe("_R2"); // click Autopair - await wrapper.find("a.autopair-link").trigger("click"); + await wrapper.find(".autopair-link").trigger("click"); //assert all pairs matched expect(wrapper.findAll("li.dataset unpaired").length == 0).toBeTruthy(); }); diff --git a/client/src/components/Collections/PairedListCollectionCreator.vue b/client/src/components/Collections/PairedListCollectionCreator.vue index c699c0de7077..86e4914cb193 100644 --- a/client/src/components/Collections/PairedListCollectionCreator.vue +++ b/client/src/components/Collections/PairedListCollectionCreator.vue @@ -1,1038 +1,1304 @@ + + - diff --git a/client/src/components/Collections/common/ClickToEdit.vue b/client/src/components/Collections/common/ClickToEdit.vue index da60f01880d9..b77925d65a1d 100644 --- a/client/src/components/Collections/common/ClickToEdit.vue +++ b/client/src/components/Collections/common/ClickToEdit.vue @@ -1,5 +1,8 @@ diff --git a/client/src/components/Collections/common/CollectionCreator.vue b/client/src/components/Collections/common/CollectionCreator.vue index 8ef14660d999..7e2401d0bd7b 100644 --- a/client/src/components/Collections/common/CollectionCreator.vue +++ b/client/src/components/Collections/common/CollectionCreator.vue @@ -1,38 +1,113 @@