diff --git a/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.test.js b/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.test.js index 4ca041d96ac2..26e9423a497a 100644 --- a/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.test.js +++ b/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.test.js @@ -6,6 +6,7 @@ import flushPromises from "flush-promises"; import { getLocalVue } from "tests/jest/helpers"; import testToolsListResponse from "../testData/toolsList"; +import testToolsListInPanelResponse from "../testData/toolsListInPanel"; import ToolsJson from "./ToolsJson"; const localVue = getLocalVue(); @@ -17,13 +18,16 @@ describe("ToolSchemaJson/ToolsView.vue", () => { beforeEach(async () => { axiosMock = new MockAdapter(axios); - axiosMock.onGet("/api/tools?tool_help=True").reply(200, testToolsListResponse); + axiosMock.onGet("/api/tools?in_panel=False&tool_help=True").reply(200, testToolsListResponse); + axiosMock.onGet("/api/tools").reply(200, testToolsListInPanelResponse); wrapper = shallowMount(ToolsJson, { localVue }); await flushPromises(); }); it("schema.org script element is created", async () => { - const tools = wrapper.vm.createToolsJson(testToolsListResponse); + const toolsList = testToolsListResponse.tools; + const toolsListInPanel = testToolsListInPanelResponse.default; + const tools = wrapper.vm.createToolsJson(toolsList, toolsListInPanel); const schemaElement = document.getElementById("schema-json"); const schemaText = JSON.parse(schemaElement.text); expect(tools["@graph"].length === 5).toBeTruthy(); diff --git a/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.vue b/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.vue index d991ab53a9fa..300257bd2857 100644 --- a/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.vue +++ b/client/src/components/ToolsView/ToolsSchemaJson/ToolsJson.vue @@ -10,26 +10,39 @@ export default { data() { return { schemaTagObj: {} }; }, - created() { - axios - .get(`${getAppRoot()}api/tools?tool_help=True`) - .then((response) => { - this.schemaTagObj = this.createToolsJson(response.data); - const el = document.createElement("script"); - el.id = "schema-json"; - el.type = "application/ld+json"; - el.text = JSON.stringify(this.schemaTagObj); - document.head.appendChild(el); + async created() { + let tools = {}; + await axios + .get(`${getAppRoot()}api/tools?in_panel=False&tool_help=True`) + .then(({ data }) => { + tools = data.tools; }) .catch((error) => { - console.error(error); + console.error("All tools by id not loaded", error); }); + if (Object.keys(tools).length > 0) { + await axios + .get(`${getAppRoot()}api/tools`) + .then(({ data }) => { + this.schemaTagObj = this.createToolsJson(tools, data.default); + const el = document.createElement("script"); + el.id = "schema-json"; + el.type = "application/ld+json"; + el.text = JSON.stringify(this.schemaTagObj); + document.head.appendChild(el); + }) + .catch((error) => { + console.error("Tool sections not loaded", error); + }); + } }, methods: { - createToolsJson(tools) { + createToolsJson(tools, panel) { + const sections = Object.values(panel); function extractSections(acc, section) { - function extractTools(_acc, tool) { - return tool.name + function extractTools(_acc, toolId) { + const tool = tools[toolId]; + return tool && tool.name ? [ ..._acc, { @@ -44,15 +57,15 @@ export default { ] : _acc; } - if ("elems" in section) { - return acc.concat(section.elems.reduce(extractTools, [])); + if ("tools" in section) { + return acc.concat(section.tools.reduce(extractTools, [])); } else { return acc; } } return { "@context": "http://schema.org", - "@graph": tools.reduce(extractSections, []), + "@graph": sections.reduce(extractSections, []), }; }, }, diff --git a/client/src/components/ToolsView/testData/toolsList.json b/client/src/components/ToolsView/testData/toolsList.json index 953ee3e2c288..61cd0038ad64 100644 --- a/client/src/components/ToolsView/testData/toolsList.json +++ b/client/src/components/ToolsView/testData/toolsList.json @@ -1,126 +1,104 @@ -[ - { - "elems": [ - { - "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"
- },
- {
- "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"
- },
- {
- "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"
- },
- {
- "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"
- }
- ],
- "model_class": "ToolSection",
- "version": "",
- "id": "collection_operations",
- "name": "Collection Operations"
- },
- {
- "elems": [
- {
- "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