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


\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


\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

What it does<\/strong><\/p>\n

This tool is based on the LiftOver utility and Chain track from the UC Santa Cruz Genome Browser<\/a>.<\/p>\n

It converts coordinates and annotations between assemblies and genomes. It produces 2 files, one containing all the mapped coordinates and the other containing the unmapped coordinates, if any.<\/p>\n

\n<\/blockquote>\n
\n

Example<\/strong><\/p>\n

Converting the following hg16 intervals to hg18 intervals:<\/p>\n

\nchrX  85170   112199  AK002185  0  +\nchrX  110458  112199  AK097346  0  +\nchrX  112203  121212  AK074528  0  -\n<\/pre>\n

will produce the following hg18 intervals:<\/p>\n

\nchrX  132991  160020  AK002185  0  +\nchrX  158279  160020  AK097346  0  +\nchrX  160024  169033  AK074528  0  -\n<\/pre>\n",
-        "edam_operations": [],
-        "form_style": "regular",
-        "edam_topics": [],
-        "panel_section_id": "liftOver",
-        "version": "1.0.6",
-        "link": "/tool_runner?tool_id=liftOver1",
-        "target": "galaxy_main",
-        "min_width": -1,
-        "model_class": "Tool",
-        "hidden": "",
-        "id": "liftOver1",
-        "name": "Convert genome coordinates"
-      }
-    ],
-    "model_class": "ToolSection",
-    "version": "",
-    "id": "liftOver",
-    "name": "Lift-Over"
-  },
-  {
-    "model_class": "ToolSectionLabel",
-    "id": "testlabel3",
-    "text": null,
-    "version": "",
-    "description": null,
-    "links": null
+{
+  "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


\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


\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

What it does<\/strong><\/p>\n

This tool is based on the LiftOver utility and Chain track from the UC Santa Cruz Genome Browser<\/a>.<\/p>\n

It converts coordinates and annotations between assemblies and genomes. It produces 2 files, one containing all the mapped coordinates and the other containing the unmapped coordinates, if any.<\/p>\n

\n<\/blockquote>\n
\n

Example<\/strong><\/p>\n

Converting the following hg16 intervals to hg18 intervals:<\/p>\n

\nchrX  85170   112199  AK002185  0  +\nchrX  110458  112199  AK097346  0  +\nchrX  112203  121212  AK074528  0  -\n<\/pre>\n

will produce the following hg18 intervals:<\/p>\n

\nchrX  132991  160020  AK002185  0  +\nchrX  158279  160020  AK097346  0  +\nchrX  160024  169033  AK074528  0  -\n<\/pre>\n",
+      "edam_operations": [],
+      "form_style": "regular",
+      "edam_topics": [],
+      "panel_section_id": "liftOver",
+      "version": "1.0.6",
+      "link": "/tool_runner?tool_id=liftOver1",
+      "target": "galaxy_main",
+      "min_width": -1,
+      "model_class": "Tool",
+      "hidden": "",
+      "id": "liftOver1",
+      "name": "Convert genome coordinates"
+    }
   }
-]
+}
diff --git a/client/src/components/ToolsView/testData/toolsListInPanel.json b/client/src/components/ToolsView/testData/toolsListInPanel.json
new file mode 100644
index 000000000000..ab5d9aa7090e
--- /dev/null
+++ b/client/src/components/ToolsView/testData/toolsListInPanel.json
@@ -0,0 +1,28 @@
+{
+  "default": {
+    "collection_operations": {
+      "tools": [
+        "__UNZIP_COLLECTION__", "__ZIP_COLLECTION__", "__FILTER_FAILED_DATASETS__", "__FILTER_EMPTY_DATASETS__"
+      ],
+      "model_class": "ToolSection",
+      "version": "",
+      "id": "collection_operations",
+      "name": "Collection Operations"
+    },
+    "liftOver": {
+      "tools": ["liftOver1"],
+      "model_class": "ToolSection",
+      "version": "",
+      "id": "liftOver",
+      "name": "Lift-Over"
+    },
+    "testlabel1": {
+      "model_class": "ToolSectionLabel",
+      "id": "testlabel1",
+      "text": null,
+      "version": "",
+      "description": null,
+      "links": null
+    }
+  }
+}
diff --git a/client/src/components/providers/storeProviders.js b/client/src/components/providers/storeProviders.js
index f3f109a4bc39..2c2531d5149b 100644
--- a/client/src/components/providers/storeProviders.js
+++ b/client/src/components/providers/storeProviders.js
@@ -194,5 +194,3 @@ export const StoreProvider = (storeAction, storeGetter) => {
         },
     };
 };
-
-export const ToolsProvider = StoreProvider("fetchAllTools", "getTools");