diff --git a/src/components/modals/agents/BulkAction.vue b/src/components/modals/agents/BulkAction.vue index ab5e58e..a6b4d99 100644 --- a/src/components/modals/agents/BulkAction.vue +++ b/src/components/modals/agents/BulkAction.vue @@ -319,14 +319,15 @@ export default { const filteredScriptOptions = computed(() => { if (props.mode !== "script") return []; - if (state.value.osType === "linux") - return removeExtraOptionCategories( - scriptOptions.value.filter(script => script.category || script.shell === "shell" || script.shell === "python") - ); - else - return removeExtraOptionCategories( - scriptOptions.value.filter(script => script.category || script.shell !== "shell") - ); + return removeExtraOptionCategories( + scriptOptions.value.filter( + script => + script.category || + !script.supported_platforms || + !script.supported_platforms.length === 0 || + script.supported_platforms.includes(state.value.osType) + ) + ); }); // component lifecycle hooks diff --git a/src/components/modals/agents/RunScript.vue b/src/components/modals/agents/RunScript.vue index d4dcf5a..6f0a1e3 100644 --- a/src/components/modals/agents/RunScript.vue +++ b/src/components/modals/agents/RunScript.vue @@ -174,14 +174,12 @@ export default { } const filteredScriptOptions = computed(() => { - if (props.agent.plat === "linux") - return removeExtraOptionCategories( - scriptOptions.value.filter(script => script.category || script.shell === "shell" || script.shell === "python") - ); - else - return removeExtraOptionCategories( - scriptOptions.value.filter(script => script.category || script.shell !== "shell") - ); + return removeExtraOptionCategories( + scriptOptions.value.filter( + script => + script.category || !script.supported_platforms || script.supported_platforms.includes(props.agent.plat) + ) + ); }); // watchers diff --git a/src/components/scripts/ScriptFormModal.vue b/src/components/scripts/ScriptFormModal.vue index cf99806..03db026 100644 --- a/src/components/scripts/ScriptFormModal.vue +++ b/src/components/scripts/ScriptFormModal.vue @@ -38,6 +38,16 @@ map-options label="Shell Type" /> + // composable imports -import { ref, computed, watch, onMounted } from "vue"; +import { ref, computed, onMounted } from "vue"; import { useQuasar, useDialogPluginComponent } from "quasar"; import { saveScript, editScript, downloadScript } from "@/api/scripts"; -import { useAgentDropdown } from "@/composables/agents"; +import { useAgentDropdown, agentPlatformOptions } from "@/composables/agents"; import { notifySuccess } from "@/utils/notify"; // ui imports @@ -186,16 +196,6 @@ export default { const loading = ref(false); const agentLoading = ref(false); - // watch(script.value, (newValue, oldValue) => { - // if (!props.script && script.value.script_body === "") { - // if (newValue.shell === "shell") { - // script.value.script_body = "#!/bin/bash\n\n# don't forget to include the shebang above!\n\n"; - // } else if (newValue.shell === "python") { - // script.value.script_body = "#!/usr/bin/python3\n\n# don't forget to include the shebang above!\n\n"; - // } - // } - // }); - const title = computed(() => { if (props.script) { return props.readonly @@ -274,6 +274,7 @@ export default { // non-reactive data shellOptions, + agentPlatformOptions, //computed title, diff --git a/src/components/scripts/ScriptManager.vue b/src/components/scripts/ScriptManager.vue index 9f05b84..c4049a5 100644 --- a/src/components/scripts/ScriptManager.vue +++ b/src/components/scripts/ScriptManager.vue @@ -66,6 +66,16 @@ @click="setShowCommunityScripts(!showCommunityScripts)" /> + +