diff --git a/client/src/components/Panels/ToolBox.test.js b/client/src/components/Panels/ToolBox.test.js index e8e14f029cf8..6a7e9b3f9ee5 100644 --- a/client/src/components/Panels/ToolBox.test.js +++ b/client/src/components/Panels/ToolBox.test.js @@ -15,8 +15,11 @@ useConfig.mockReturnValue({ }); describe("ToolBox", () => { - const toolsMock = toolsList.tools; - const toolPanelMock = toolsListInPanel.default; + const toolsMock = toolsList.reduce((acc, item) => { + acc[item.id] = item; + return acc; + }, {}); + const toolPanelMock = toolsListInPanel; const resultsMock = ["liftOver1", "__FILTER_EMPTY_DATASETS__", "__UNZIP_COLLECTION__"]; let axiosMock; @@ -26,9 +29,9 @@ describe("ToolBox", () => { it("test filter functions correctly matching: (1) Tools store array-of-objects with (2) Results array", async () => { axiosMock - .onGet(`/api/tool_panel`) + .onGet(`/api/tool_panels/default`) .replyOnce(200, toolsListInPanel) - .onGet(`/api/tool_panel?in_panel=False`) + .onGet(`/api/tools?in_panel=False`) .replyOnce(200, toolsMock) .onGet(/api\/tools?.*/) .replyOnce(200, resultsMock); diff --git a/client/src/components/Panels/utilities.test.js b/client/src/components/Panels/utilities.test.js index dcf5e39c53a0..d743e64c4d98 100644 --- a/client/src/components/Panels/utilities.test.js +++ b/client/src/components/Panels/utilities.test.js @@ -80,8 +80,8 @@ describe("test helpers in tool searching utilities", () => { "__ZIP_COLLECTION__", ], keys: { description: 1, name: 0 }, - tools: Object.values(toolsList.tools), - panel: toolsListInPanel.default, + tools: toolsList, + panel: toolsListInPanel, }, { // name prioritized @@ -93,16 +93,16 @@ describe("test helpers in tool searching utilities", () => { "__FILTER_EMPTY_DATASETS__", ], keys: { description: 0, name: 1 }, - tools: Object.values(toolsList.tools), - panel: toolsListInPanel.default, + tools: toolsList, + panel: toolsListInPanel, }, { // whitespace precedes to ensure query.trim() works q: " filter empty datasets", expectedResults: ["__FILTER_EMPTY_DATASETS__"], keys: { description: 1, name: 2, combined: 0 }, - tools: Object.values(toolsList.tools), - panel: toolsListInPanel.default, + tools: toolsList, + panel: toolsListInPanel, }, { // hyphenated tool-name is searchable @@ -125,16 +125,16 @@ describe("test helpers in tool searching utilities", () => { q: "__ZIP_COLLECTION__", expectedResults: [], keys: { description: 1, name: 2 }, - tools: Object.values(toolsList.tools), - panel: toolsListInPanel.default, + tools: toolsList, + panel: toolsListInPanel, }, { // id is searchable if provided "id:" q: "id:__ZIP_COLLECTION__", expectedResults: ["__ZIP_COLLECTION__"], keys: { description: 1, name: 2 }, - tools: Object.values(toolsList.tools), - panel: toolsListInPanel.default, + tools: toolsList, + panel: toolsListInPanel, }, { // id is searchable if provided "tool_id:" @@ -152,8 +152,8 @@ describe("test helpers in tool searching utilities", () => { q: "filter datasets", expectedResults: ["__FILTER_FAILED_DATASETS__", "__FILTER_EMPTY_DATASETS__"], keys: { combined: 1, wordMatch: 0 }, - tools: Object.values(toolsList.tools), - panel: toolsListInPanel.default, + tools: toolsList, + panel: toolsListInPanel, }, ]; searches.forEach((search) => { @@ -168,38 +168,20 @@ describe("test helpers in tool searching utilities", () => { // Testing if just names work with DL search const filterQueries = ["Fillter", "FILYER", " Fitler", " filtr"]; filterQueries.forEach((q) => { - const { results, closestTerm } = searchToolsByKeys( - Object.values(toolsList.tools), - keys, - q, - "default", - toolsListInPanel.default - ); + const { results, closestTerm } = searchToolsByKeys(toolsList, keys, q, "default", toolsListInPanel); expect(results).toEqual(expectedResults); expect(closestTerm).toEqual("filter"); }); // Testing if names and description function with DL search let queries = ["datases from a collection", "from a colleection", "from a colleection"]; queries.forEach((q) => { - const { results } = searchToolsByKeys( - Object.values(toolsList.tools), - keys, - q, - "default", - toolsListInPanel.default - ); + const { results } = searchToolsByKeys(toolsList, keys, q, "default", toolsListInPanel); expect(results).toEqual(expectedResults); }); // Testing if different length queries correctly trigger changes in max DL distance queries = ["datae", "ppasetsfrom", "datass from a cppollection"]; queries.forEach((q) => { - const { results } = searchToolsByKeys( - Object.values(toolsList.tools), - keys, - q, - "default", - toolsListInPanel.default - ); + const { results } = searchToolsByKeys(toolsList, keys, q, "default", toolsListInPanel); expect(results).toEqual(expectedResults); }); }); @@ -207,16 +189,20 @@ describe("test helpers in tool searching utilities", () => { it("test tool filtering helpers on toolsList given list of ids", async () => { const ids = ["__FILTER_FAILED_DATASETS__", "liftOver1"]; // check length of first section from imported const toolsList - expect(toolsListInPanel.default["collection_operations"].tools).toHaveLength(4); + expect(toolsListInPanel["collection_operations"].tools).toHaveLength(4); // check length of same section from filtered toolsList const matchedTools = ids.map((id) => { return { id: id, sections: [], order: 0 }; }); - const toolResultsPanel = createSortedResultObject(matchedTools, toolsListInPanel.default); + const toolResultsPanel = createSortedResultObject(matchedTools, toolsListInPanel); const toolResultsSection = toolResultsPanel.resultPanel["collection_operations"]; expect(toolResultsSection.tools).toHaveLength(1); // check length of filtered tools (regardless of sections) - const filteredToolIds = Object.keys(filterTools(toolsList.tools, ids)); + const toolsById = toolsList.reduce((acc, item) => { + acc[item.id] = item; + return acc; + }, {}); + const filteredToolIds = Object.keys(filterTools(toolsById, ids)); expect(filteredToolIds).toHaveLength(2); }); }); diff --git a/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.test.js b/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.test.js index f798127e6711..f009126de465 100644 --- a/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.test.js +++ b/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.test.js @@ -18,15 +18,18 @@ describe("ToolSchemaJson/ToolsView.vue", () => { beforeEach(async () => { axiosMock = new MockAdapter(axios); - axiosMock.onGet("/api/tool_panel?in_panel=False&tool_help=True").reply(200, testToolsListResponse); - axiosMock.onGet("/api/tool_panel").reply(200, testToolsListInPanelResponse); + axiosMock.onGet("/api/tools?in_panel=False&tool_help=True").reply(200, testToolsListResponse); + axiosMock.onGet("/api/tool_panels/default").reply(200, testToolsListInPanelResponse); wrapper = shallowMount(ToolsJson, { localVue }); await flushPromises(); }); it("schema.org script element is created", async () => { - const toolsList = testToolsListResponse.tools; - const toolsListInPanel = testToolsListInPanelResponse.default; + const toolsList = testToolsListResponse.reduce((acc, item) => { + acc[item.id] = item; + return acc; + }, {}); + const toolsListInPanel = testToolsListInPanelResponse; const tools = wrapper.vm.createToolsJson(toolsList, toolsListInPanel); const schemaElement = document.getElementById("schema-json"); const schemaText = JSON.parse(schemaElement.text); diff --git a/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.vue b/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.vue index e5e2db7d1fbe..02faf529479f 100644 --- a/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.vue +++ b/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.vue @@ -11,20 +11,23 @@ export default { return { schemaTagObj: {} }; }, async created() { - let tools = {}; + let tools = []; await axios - .get(`${getAppRoot()}api/tool_panel?in_panel=False&tool_help=True`) + .get(`${getAppRoot()}api/tools?in_panel=False&tool_help=True`) .then(({ data }) => { - tools = data.tools; + tools = data.reduce((acc, item) => { + acc[item.id] = item; + return acc; + }, {}); }) .catch((error) => { - console.error("All tools by id not loaded", error); + console.error("List of all tools not loaded", error); }); if (Object.keys(tools).length > 0) { await axios - .get(`${getAppRoot()}api/tool_panel`) + .get(`${getAppRoot()}api/tool_panels/default`) .then(({ data }) => { - this.schemaTagObj = this.createToolsJson(tools, data.default); + this.schemaTagObj = this.createToolsJson(tools, data); const el = document.createElement("script"); el.id = "schema-json"; el.type = "application/ld+json"; @@ -32,7 +35,7 @@ export default { document.head.appendChild(el); }) .catch((error) => { - console.error("Tool sections not loaded", error); + console.error("Tool sections by id not loaded", error); }); } }, diff --git a/client/src/components/ToolsView/testData/toolsList.json b/client/src/components/ToolsView/testData/toolsList.json index 61cd0038ad64..cceb264bee95 100644 --- a/client/src/components/ToolsView/testData/toolsList.json +++ b/client/src/components/ToolsView/testData/toolsList.json @@ -1,104 +1,102 @@ -{ - "tools": { - "__UNZIP_COLLECTION__": { - "panel_section_name": "Collection Operations", - "xrefs": [], - "description": "", - "is_workflow_compatible": true, - "labels": [], - "help": "
This tool takes a paired dataset collection and builds two datasets from it. If mapped over a list of paired datasets, this tool will produce two lists of datasets.<\/p>\n
Example<\/strong><\/p>\n If a collection consists of two forward and two reverse datasets (e.g., forward and reverse reads from a sequencing experiment) this tool will output two collections: one consisting of forward reads and one of reverse reads.<\/p>\n This tool will create new history datasets from your collection but your quota usage will not increase.<\/p>\n",
- "edam_operations": [],
- "form_style": "regular",
- "edam_topics": [],
- "panel_section_id": "collection_operations",
- "version": "1.0.0",
- "link": "/tool_runner?tool_id=__UNZIP_COLLECTION__",
- "target": "galaxy_main",
- "min_width": -1,
- "model_class": "UnzipCollectionTool",
- "hidden": "",
- "id": "__UNZIP_COLLECTION__",
- "name": "Unzip Collection"
- },
- "__ZIP_COLLECTION__": {
- "panel_section_name": "Collection Operations",
- "xrefs": [],
- "description": "",
- "is_workflow_compatible": true,
- "labels": [],
- "help": " This tool takes two datasets and creates a dataset pair from them. Mapping over two lists, this tool can be used to build a list of dataset pairs from two individual lists of datasets.<\/p>\n Example<\/strong><\/p>\n If you have one collection containing only forward reads and one containing only reverse, this tools will "zip" them together into a simple paired collection.<\/p>\n This tool will create new history datasets for your collection but your quota usage will not increase.<\/p>\n",
- "edam_operations": [],
- "form_style": "regular",
- "edam_topics": [],
- "panel_section_id": "collection_operations",
- "version": "1.0.0",
- "link": "/tool_runner?tool_id=__ZIP_COLLECTION__",
- "target": "galaxy_main",
- "min_width": -1,
- "model_class": "ZipCollectionTool",
- "hidden": "",
- "id": "__ZIP_COLLECTION__",
- "name": "Zip Collection"
- },
- "__FILTER_FAILED_DATASETS__": {
- "panel_section_name": "Collection Operations",
- "xrefs": [],
- "description": "datasets from a collection",
- "is_workflow_compatible": true,
- "labels": [],
- "help": " This tool takes a dataset collection and filters out datasets in the failed state. This is useful for continuing a multi-sample analysis when one of more of the samples fails at some point.<\/p>\n This tool will create new history datasets from your collection but your quota usage will not increase.<\/p>\n",
- "edam_operations": [],
- "form_style": "regular",
- "edam_topics": [],
- "panel_section_id": "collection_operations",
- "version": "1.0.0",
- "link": "/tool_runner?tool_id=__FILTER_FAILED_DATASETS__",
- "target": "galaxy_main",
- "min_width": -1,
- "model_class": "FilterFailedDatasetsTool",
- "hidden": "",
- "id": "__FILTER_FAILED_DATASETS__",
- "name": "Filter failed"
- },
- "__FILTER_EMPTY_DATASETS__": {
- "panel_section_name": "Collection Operations",
- "xrefs": [],
- "description": "datasets from a collection",
- "is_workflow_compatible": true,
- "labels": [],
- "help": " This tool takes a dataset collection and filters out empty datasets. This is useful for continuing a multi-sample analysis when downstream tools require datasets to have content.<\/p>\n This tool will create new history datasets from your collection but your quota usage will not increase.<\/p>\n",
- "edam_operations": [],
- "form_style": "regular",
- "edam_topics": [],
- "panel_section_id": "collection_operations",
- "version": "1.0.0",
- "link": "/tool_runner?tool_id=__FILTER_EMPTY_DATASETS__",
- "target": "galaxy_main",
- "min_width": -1,
- "model_class": "FilterEmptyDatasetsTool",
- "hidden": "",
- "id": "__FILTER_EMPTY_DATASETS__",
- "name": "Filter empty"
- },
- "liftOver1": {
- "panel_section_name": "Lift-Over",
- "xrefs": [],
- "description": "between assemblies and genomes",
- "is_workflow_compatible": true,
- "labels": [],
- "help": " Make sure that the genome build of the input dataset is specified (click the pencil icon in the history item to set it if necessary).<\/p>\n This tool can work with interval, GFF, and GTF datasets. It requires the interval datasets to have chromosome in column 1,\nstart co-ordinate in column 2 and end co-ordinate in column 3. BED comments\nand track and browser lines will be ignored, but if other non-interval lines\nare present the tool will return empty output datasets.<\/p>\n
\n
\n