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] Tool filtering fix for label handling #16168

Merged
merged 3 commits into from
Jun 1, 2023
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
16 changes: 14 additions & 2 deletions client/src/components/Panels/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,27 @@ export function removeDisabledTools(tools) {
});
}

function isToolObject(tool) {
// toolbox overhaul with typing will simplify this dramatically...
// Right now, our shorthand is that tools have no 'text', and don't match
// the model_class of the section/label.
if (!tool.text && tool.model_class !== "ToolSectionLabel" && tool.model_class !== "ToolSection") {
return true;
}
return false;
}

function flattenToolsSection(section) {
const flattenTools = [];
if (section.elems) {
section.elems.forEach((tool) => {
if (!tool.text) {
if (isToolObject(tool)) {
flattenTools.push(tool);
}
});
} else if (!section.text) {
} else if (isToolObject(section)) {
// This might be a top-level section-less tool and not actually a
// section.
flattenTools.push(section);
}
return flattenTools;
Expand Down
8 changes: 8 additions & 0 deletions client/src/components/ToolsView/testData/toolsList.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,13 @@
"version": "",
"id": "liftOver",
"name": "Lift-Over"
},
{
"model_class": "ToolSectionLabel",
"id": "testlabel3",
"text": null,
"version": "",
"description": null,
"links": null
}
]
1 change: 1 addition & 0 deletions client/tests/jest/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ module.exports = {
roots: ["<rootDir>/src/", "<rootDir>/tests/jest/standalone/"],
setupFilesAfterEnv: ["<rootDir>/tests/jest/jest.setup.js"],
testEnvironment: "jsdom",
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
transform: {
"^.+\\.js$": "babel-jest",
"^.*\\.(vue)$": "@vue/vue2-jest",
Expand Down