From ed2c955d82abf45f3d7ed2c156cad882d7e384cb Mon Sep 17 00:00:00 2001 From: sadnub Date: Thu, 10 Mar 2022 22:55:44 -0500 Subject: [PATCH] fix script lists and filtering for platform --- src/components/modals/agents/BulkAction.vue | 2 +- src/components/modals/agents/RunScript.vue | 5 ++++- src/components/scripts/ScriptManager.vue | 12 +++++++++--- src/utils/format.js | 7 +++++-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/components/modals/agents/BulkAction.vue b/src/components/modals/agents/BulkAction.vue index a6b4d99..0258931 100644 --- a/src/components/modals/agents/BulkAction.vue +++ b/src/components/modals/agents/BulkAction.vue @@ -324,7 +324,7 @@ export default { script => script.category || !script.supported_platforms || - !script.supported_platforms.length === 0 || + script.supported_platforms.length === 0 || script.supported_platforms.includes(state.value.osType) ) ); diff --git a/src/components/modals/agents/RunScript.vue b/src/components/modals/agents/RunScript.vue index 6f0a1e3..333da30 100644 --- a/src/components/modals/agents/RunScript.vue +++ b/src/components/modals/agents/RunScript.vue @@ -177,7 +177,10 @@ export default { return removeExtraOptionCategories( scriptOptions.value.filter( script => - script.category || !script.supported_platforms || script.supported_platforms.includes(props.agent.plat) + script.category || + !script.supported_platforms || + script.supported_platforms.length === 0 || + script.supported_platforms.includes(props.agent.plat) ) ); }); diff --git a/src/components/scripts/ScriptManager.vue b/src/components/scripts/ScriptManager.vue index c4049a5..1b3b1e7 100644 --- a/src/components/scripts/ScriptManager.vue +++ b/src/components/scripts/ScriptManager.vue @@ -330,9 +330,15 @@ - {{ - capitalize(plat) - }} + All + {{ capitalize(plat) }} diff --git a/src/utils/format.js b/src/utils/format.js index b888a9f..c3138de 100644 --- a/src/utils/format.js +++ b/src/utils/format.js @@ -5,12 +5,15 @@ import { validateTimePeriod } from "@/utils/validation" export function removeExtraOptionCategories(array) { let tmp = [] + + // loop through options and if two categories are next to each other remove the top one for (let i = 0; i < array.length; i++) { - if (!(array[i].category && array[i + 1].category)) { + if (i === array.length - 1 && !array[i].category) { // check if last item is not a category and add it + tmp.push(array[i]) + } else if (!(array[i].category && array[i + 1].category)) { tmp.push(array[i]) } } - return tmp }