Skip to content

Commit

Permalink
Merge pull request #3423 from hLinx/feature_3.11
Browse files Browse the repository at this point in the history
Feature 3.11
  • Loading branch information
hLinx authored Feb 13, 2025
2 parents e31d925 + cd09960 commit 89b51c3
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@
type: Object,
required: true,
},
windowsInterpreter: {
type: String,
},
variable: {
type: Array,
default: () => [],
Expand Down Expand Up @@ -348,6 +351,55 @@
message: I18n.t('目标服务器必填'),
trigger: 'blur',
},
{
validator: () => {
if (!this.windowsInterpreter) {
return true;
}
return new Promise((resolve) => {
this.$refs.ipSelector.getHostList()
.then((hostList) => {
const nonWindowsHostList = _.filter(hostList, item => !/windows/i.test(item.os_type));
if (nonWindowsHostList.length < 1) {
return resolve(true);
}
const infoboxHandle = this.$bkInfo({
title: I18n.t('自定义windows解释器路径'),
maskClose: false,
escClose: false,
draggable: false,
showFooter: false,
closeIcon: false,
width: 450,
subHeader: (
<div>
<div style="font-size: 14px; line-height: 22px; color: #63656E; text-align: center">
{I18n.t('执行目标包含 Linux 服务器,但自定义解释器仅对 Windows 有效,请知悉。')}
</div>
<div style="padding: 24px 0 21px; text-align: center">
<bk-button
onClick={() => {
resolve(true);
infoboxHandle.close();
}}
style="width: 96px"
theme="primary">
{ I18n.t('好的') }
</bk-button>
</div>
</div>
),
closeFn: () => {
resolve(true);
infoboxHandle.close();
},
});
});
});
},
message: I18n.t('目标服务器必填'),
trigger: 'blur',
},
];
},
methods: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from="execute"
mode="onlyHost"
property="targetServers"
:windows-interpreter="formData[windowsInterpreterField]"
@on-change="handleTargetChange" />
</template>
<script>
Expand All @@ -46,6 +47,10 @@
type: String,
required: true,
},
windowsInterpreterField: {
type: String,
required: true,
},
formData: {
type: Object,
default: () => ({}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
:execute-target="formData[field]"
from="template"
property="executeTarget"
:windows-interpreter="formData[windowsInterpreterField]"
@on-change="handleTargetChange" />
</template>
<script>
Expand All @@ -45,6 +46,10 @@
type: String,
required: true,
},
windowsInterpreterField: {
type: String,
required: true,
},
formData: {
type: Object,
default: () => ({}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<template>
<bk-form-item
v-show="isShow"
class="form-item-content"
error-display-type="normal"
:label="t('解释器')"
:property="field"
:required="isCustom"
:rules="rules">
<bk-checkbox
v-model="isCustom"
:value="isCustom"
@change="handleCustomChange">
<span
v-bk-tooltips="t('使用目标机器指定路径下的解释器运行本脚本(仅对Windows有效)')"
Expand All @@ -27,16 +28,23 @@
</bk-form-item>
</template>
<script setup>
import { ref, watch } from 'vue';
import { computed, ref, watch } from 'vue';
import { useI18n } from '@/i18n';
import {
formatScriptTypeValue,
} from '@/utils/assist';
const props = defineProps({
field: {
type: String,
required: true,
},
languageField: {
type: String,
required: true,
},
formData: {
type: Object,
required: true,
Expand All @@ -49,6 +57,8 @@
const isCustom = ref(false);
const isShow = computed(() => !['Shell', 'SQL'].includes(formatScriptTypeValue(props.formData[props.languageField])));
const rules = [
{
validator: (value) => {
Expand All @@ -63,14 +73,22 @@
];
watch(() => props.formData, () => {
if (props.formData[props.field] !== undefined) {
isCustom.value = true;
isCustom.value = props.formData[props.field] !== undefined;
}, {
immediate: true,
deep: true,
});
watch(isShow, () => {
if (!isShow.value) {
emits('on-change', props.field, undefined);
}
}, {
immediate: true,
});
const handleCustomChange = (custom) => {
isCustom.value = custom;
emits('on-change', props.field, custom ? '' : undefined);
};
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/i18n/language/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -567,5 +567,6 @@
"使用目标机器指定路径下的解释器运行本脚本(仅对Windows有效)": "Run this script using the interpreter in the specified path on the target hosts (Only for Windows)",
"自定义windows解释器路径": "Customize the Interpreter Path in Windows",
"输入目标机器上的自定义解释器软件路径,如:D:\\Software\\python3\\python.exe。请勿指定命令行选项。": "Enter the path of the custom interpreter software on the target machine, such as: D:\\Software\\python3\\python.exe",
"解释器路径有误,需为合法的文件路径、且以 .exe 结尾。": "Interpreter path is invalid; it must be a valid file path ending with .exe."
"解释器路径有误,需为合法的文件路径、且以 .exe 结尾。": "Interpreter path is invalid; it must be a valid file path ending with .exe.",
"执行目标包含 Linux 服务器,但自定义解释器仅对 Windows 有效,请知悉。": "Please note: The execution targets include Linux hosts, but the interpreter is only supported on Windows."
}
3 changes: 2 additions & 1 deletion src/frontend/src/i18n/language/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -567,5 +567,6 @@
"使用目标机器指定路径下的解释器运行本脚本(仅对Windows有效)": "使用目标机器指定路径下的解释器运行本脚本(仅对Windows有效)",
"自定义windows解释器路径": "自定义windows解释器路径",
"输入目标机器上的自定义解释器软件路径,如:D:\\Software\\python3\\python.exe。请勿指定命令行选项。": "输入目标机器上的自定义解释器软件路径,如:D:\\Software\\python3\\python.exe。请勿指定命令行选项。",
"解释器路径有误,需为合法的文件路径、且以 .exe 结尾。": "解释器路径有误,需为合法的文件路径、且以 .exe 结尾。"
"解释器路径有误,需为合法的文件路径、且以 .exe 结尾。": "解释器路径有误,需为合法的文件路径、且以 .exe 结尾。",
"执行目标包含 Linux 服务器,但自定义解释器仅对 Windows 有效,请知悉。": "执行目标包含 Linux 服务器,但自定义解释器仅对 Windows 有效,请知悉。"
}
1 change: 1 addition & 0 deletions src/frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,5 @@ entryTask.add('', (context) => {
render: h => h(EntryApp),
});
});

entryTask.start();
2 changes: 2 additions & 0 deletions src/frontend/src/views/fast-execution/exec-script/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<item-factory
field="windowsInterpreter"
:form-data="formData"
language-field="scriptLanguage"
name="windowsInterpreter"
@on-change="handleChange" />
<item-factory
Expand All @@ -89,6 +90,7 @@
field="taskTarget"
:form-data="formData"
name="executeTargetOfExecution"
windows-interpreter-field="windowsInterpreter"
@on-change="handleChange" />
<item-factory
enabled-field="rollingEnabled"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<item-factory
field="windowsInterpreter"
:form-data="formData"
language-field="scriptLanguage"
name="windowsInterpreter"
@on-change="handleChange" />
<item-factory
Expand All @@ -88,6 +89,7 @@
:form-data="formData"
name="executeTargetOfTemplate"
:variable="variable"
windows-interpreter-field="windowsInterpreter"
@on-change="handleChange" />
</jb-form>
</template>
Expand Down

0 comments on commit 89b51c3

Please sign in to comment.