Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[23.0] Make Expression Tools searchable in ToolBoxWorkflow #16022

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/src/components/Panels/Common/ToolSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<script>
import { getGalaxyInstance } from "app";
import DelayedInput from "components/Common/DelayedInput";
import { normalizeTools, searchToolsByKeys } from "../utilities.js";
import { flattenTools, searchToolsByKeys } from "../utilities.js";

export default {
name: "ToolSearch",
Expand Down Expand Up @@ -98,7 +98,7 @@ export default {
return this.currentPanelView === "default" ? "section" : "ontology";
},
toolsList() {
return normalizeTools(this.toolbox);
return flattenTools(this.toolbox);
},
},
methods: {
Expand Down
11 changes: 6 additions & 5 deletions client/src/components/Panels/ToolBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
:current-panel-view="currentPanelView"
:placeholder="titleSearchTools"
:show-advanced.sync="showAdvanced"
:toolbox="toolbox"
:toolbox="tools"
:query="query"
@onQuery="onQuery"
@onResults="onResults" />
Expand Down Expand Up @@ -125,6 +125,9 @@ export default {
};
},
computed: {
tools() {
return hideToolsSection(this.toolbox);
},
queryTooShort() {
return this.query && this.query.length < 3;
},
Expand All @@ -133,11 +136,9 @@ export default {
},
sections() {
if (this.showSections) {
return filterToolSections(this.toolbox, this.results);
return filterToolSections(this.tools, this.results);
} else {
return hasResults(this.results)
? filterTools(this.toolbox, this.results)
: hideToolsSection(this.toolbox);
return hasResults(this.results) ? filterTools(this.tools, this.results) : this.tools;
}
},
isUser() {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Panels/ToolBoxWorkflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default {
return this.query && this.query.length < 3;
},
noResults() {
return this.query && this.results.length === 0;
return this.query && (!this.results || this.results.length === 0);
},
hasWorkflowSection() {
return this.workflows.length > 0;
Expand Down
20 changes: 7 additions & 13 deletions client/src/components/Panels/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function createWhooshQuery(filterSettings, panelView, toolbox) {
// Given toolbox and search results, returns filtered tool results
export function filterTools(tools, results) {
let toolsResults = [];
tools = normalizeTools(tools);
tools = flattenTools(tools);
toolsResults = mapToolsResults(tools, results);
toolsResults = sortToolsResults(toolsResults);
toolsResults = removeDuplicateResults(toolsResults);
Expand Down Expand Up @@ -110,10 +110,12 @@ export function searchToolsByKeys(tools, keys, query) {
return orderBy(returnedTools, ["order"], ["desc"]).map((tool) => tool.id);
}

export function normalizeTools(tools) {
tools = hideToolsSection(tools);
tools = flattenTools(tools);
return tools;
export function flattenTools(tools) {
let normalizedTools = [];
tools.forEach((section) => {
normalizedTools = normalizedTools.concat(flattenToolsSection(section));
});
return normalizedTools;
}

export function hideToolsSection(tools) {
Expand Down Expand Up @@ -198,11 +200,3 @@ function deleteEmptyToolsSections(tools, results) {

return tools;
}

function flattenTools(tools) {
let normalizedTools = [];
tools.forEach((section) => {
normalizedTools = normalizedTools.concat(flattenToolsSection(section));
});
return normalizedTools;
}
10 changes: 5 additions & 5 deletions client/src/components/Panels/utilities.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import toolsList from "components/ToolsView/testData/toolsList";
import { createWhooshQuery, filterTools, filterToolSections, normalizeTools, searchToolsByKeys } from "./utilities";
import { createWhooshQuery, filterTools, filterToolSections, flattenTools, searchToolsByKeys } from "./utilities";

describe("test helpers in tool searching utilities", () => {
it("test parsing helper that converts settings to whoosh query", async () => {
Expand All @@ -25,7 +25,7 @@ describe("test helpers in tool searching utilities", () => {
"__ZIP_COLLECTION__",
];
let keys = { description: 1, name: 0 };
let results = searchToolsByKeys(normalizeTools(toolsList), keys, q);
let results = searchToolsByKeys(flattenTools(toolsList), keys, q);
expect(results).toEqual(expectedResults);

expectedResults = [
Expand All @@ -35,14 +35,14 @@ describe("test helpers in tool searching utilities", () => {
"__FILTER_EMPTY_DATASETS__",
];
keys = { description: 0, name: 1 };
results = searchToolsByKeys(normalizeTools(toolsList), keys, q);
results = searchToolsByKeys(flattenTools(toolsList), keys, q);
expect(results).toEqual(expectedResults);

// whitespace precedes to ensure query.trim() works
q = " filter empty datasets";
expectedResults = ["__FILTER_EMPTY_DATASETS__"];
keys = { description: 1, name: 2, combined: 0 };
results = searchToolsByKeys(normalizeTools(toolsList), keys, q);
results = searchToolsByKeys(flattenTools(toolsList), keys, q);
expect(results).toEqual(expectedResults);

const tempToolsList = [
Expand All @@ -64,7 +64,7 @@ describe("test helpers in tool searching utilities", () => {
q = "uMi tools extract ";
expectedResults = ["toolshed.g2.bx.psu.edu/repos/iuc/umi_tools_extract/umi_tools_extract/1.1.2+galaxy2"];
keys = { description: 1, name: 2, hyphenated: 0 };
results = searchToolsByKeys(normalizeTools(tempToolsList), keys, q);
results = searchToolsByKeys(flattenTools(tempToolsList), keys, q);
expect(results).toEqual(expectedResults);
});

Expand Down