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

V1.9.0 merge to master #76

Merged
merged 9 commits into from
Dec 4, 2024
Merged
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: black
language_version: python3
- repo: https://github.com/pycqa/isort
rev: 5.6.4
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@antv/x6-vue-shape": "^2.0.11",
"@babel/core": "^7.14.3",
"@blueking/bkcharts": "^2.0.6",
"@blueking/bkui-form": "0.0.41",
"@blueking/bkui-form": "0.0.42-beta.11",
"@blueking/login-modal": "^1.0.1",
"@blueking/notice-component-vue2": "^2.0.1",
"@blueking/platform-config": "^1.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ export const parseValue = (data = '', config) => {
}
}

// 检查value是否包含(")
if (typeof data === 'string' && /\"/g.test(data)) {
message = '暂不支持带有英文双引号(") 的输入值';
return { value, type, message };
}

// 定义一个函数来验证整数
const validateInt = (val) => {
if (!intRegex.test(val)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<value-selector
:key="`${item.left.obj.key}-${item.compare}-value`"
v-model="item.right.obj.value"
v-validate="{ required: judgeRequired(item, 'right') }"
v-validate="{ required: judgeRequired(item, 'right'), decisionValueRegex: { pattern: valueRegex } }"
:class="[
'value-input',
{
Expand Down Expand Up @@ -157,11 +157,13 @@
acc[cur.id] = cur.type;
return acc;
}, {});
const valueRegex = /^((?!\").)*$/;
return {
ruleInfo: {},
fieldList: this.inputs,
fieldTypeMap,
optionList: [],
valueRegex,
};
},
watch: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
:label="$t('选项名称')"
:required="true"
:property="'name'"
:rules="rules.required">
:rules="rules.name">
<bk-input
v-model="optionFormData.name"
:maxlength="16"
Expand All @@ -66,7 +66,7 @@
:label="$t('选项值')"
:required="true"
:property="'id'"
:rules="rules.required">
:rules="rules.value">
<bk-input
ref="idInput"
v-model="optionFormData.id" />
Expand Down Expand Up @@ -108,6 +108,7 @@
<script>
import VueDraggable from 'vuedraggable';
import tools from '@/utils/tools.js';
import i18n from '@/config/i18n/index.js';
export default {
name: 'SelectField',
components: {
Expand Down Expand Up @@ -137,13 +138,25 @@
dropRowIndex: -1,
optionFormData: {},
rules: {
required: [
name: [
{
required: true,
message: this.$t('必填项'),
trigger: 'blur',
},
],
value: [
{
required: true,
message: this.$t('必填项'),
trigger: 'blur',
},
{
validator: val => (!/\"/g.test(val)),
message: i18n.t('暂不支持带有英文双引号(") 的输入值'),
trigger: 'change',
},
],
},
};
},
Expand Down Expand Up @@ -275,12 +288,15 @@
if (optionInfo) {
optionInfo.name = name;
optionInfo.id = id;
optionInfo.incomplete = !name || !id;
optionInfo.incomplete = !name || !id || /\"/g.test(id);
}
this.optionFormData = {};
},
handlePopoverShow(index) {
this.$refs.optionPopover[index].showHandler();
this.$nextTick(() => {
this.optionFormData.id && this.$refs.optionForm[index].validate();
});
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@
},
validate() {
return this.$refs.fieldForm.validate().then((valid) => {
if (valid) {
return this.formData.options.items.every(item => item.id && item.name);
if (valid && this.formData.type === 'select') {
return this.formData.options.items.every(item => item.id && item.name && !/\"/g.test(item.id));
}
return valid;
});
Expand Down
13 changes: 13 additions & 0 deletions frontend/src/components/DecisionTable/components/TableBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,19 @@
}
});
}
// 校验文本内容值是否包含英文双引号(")
if (result) {
row.forEach((cell) => {
const { from, type } = cell.column;
if (type === 'string') {
const value = from === 'outputs' ? cell.condition.value : cell.condition.right.obj.value;
if (/\"/g.test(value)) {
cell.isError = true;
result = false;
}
}
});
}
});
return result;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
class="is-error"
@click="toggleEditing">
<i
v-bk-tooltips="$t('内容填写不完整')"
v-bk-tooltips="{ content: errorTipContent }"
class="bk-icon icon-exclamation-circle-shape" />
</div>
</div>
Expand All @@ -44,6 +44,7 @@
import OutputCell from './components/OutputCell.vue';
import { generateCellText } from '../../common/field.js';
import tools from '@/utils/tools.js';
import i18n from '@/config/i18n/index.js';
export default {
name: 'DecisionTableCell',
components: {
Expand Down Expand Up @@ -93,6 +94,9 @@
const { rowIndex, colIndex } = this.cell;
return rowIndex === this.editCell.rowIndex && colIndex === this.editCell.colIndex;
},
errorTipContent() {
return this.cellText ? i18n.t('暂不支持带有英文双引号(") 的输入值') : i18n.t('内容填写不完整');
},
},
watch: {
cell: {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/config/i18n/cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ const cn = {
待复用调试任务: '待复用调试任务',
复用成功: '复用成功',
id或name不唯一: 'id或name不唯一',
'暂不支持带有英文双引号(") 的输入值': '暂不支持带有英文双引号(") 的输入值',
};

export default cn;
1 change: 1 addition & 0 deletions frontend/src/config/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ const en = {
待复用调试任务: 'Pending Reuse Debug Task',
复用成功: 'Reuse success',
id或name不唯一: 'ID or name is not unique',
'暂不支持带有英文双引号(") 的输入值': 'Input values containing English double quotes (\") are not supported at the moment',
};

export default en;
9 changes: 9 additions & 0 deletions frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ Validator.extend('integer', {
getMessage: (field, args) => args + i18n.t('间隔时间必须是正整数'),
validate: value => Number(value) >= 1 && Number(value) % 1 === 0,
});
// 扩展自定义值正则表达式规则
Validator.extend('decisionValueRegex', {
validate(value, { pattern }) {
const regex = new RegExp(pattern);
return regex.test(value);
},
params: ['pattern'], // 定义参数
getMessage: () => i18n.t('暂不支持带有英文双引号(") 的输入值'),
});
Validator.localize({
en: {
messages: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
if (editorInstance) {
editorInstance.layoutCodeEditorInstance();
}
if (!val) {
this.formData = {};
}
});
},
},
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/views/task/TaskExecute/ExecuteInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@
},
// 补充记录缺少的字段
async setFillRecordField(record) {
const { version, component_code: componentCode } = this.nodeDetailConfig;
const { version, component_code: componentCode, componentData = {} } = this.nodeDetailConfig;
const { inputs, state } = record;
let { outputs } = record;
// 执行记录的outputs可能为Object格式,需要转为Array格式
Expand Down Expand Up @@ -563,7 +563,8 @@
const { constants } = islegacySubProcess ? this.pipelineData : this.componentValue.pipeline;
this.renderConfig = await this.getSubflowInputsConfig(constants);
} else if (componentCode) { // 任务节点需要加载标准插件
await this.getNodeConfig(componentCode, version, inputs.plugin_version);
const pluginVersion = componentData.plugin_version?.value;
await this.getNodeConfig(componentCode, version, pluginVersion);
}
inputsInfo = Object.keys(inputs).reduce((acc, cur) => {
const scheme = Array.isArray(this.renderConfig)
Expand Down
17 changes: 7 additions & 10 deletions frontend/src/views/template/TemplateEdit/NodeConfig/NodeConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@
const { uniform_api_plugin_method: method, uniform_api_plugin_url: realMetaUrl } = component.data;
Object.assign(data, {
plugin: 'uniform_api',
name: `${category.name}_${name}`,
name: `${category.name}-${name}`,
pluginId: id,
method: method.value,
groupId: category.id,
Expand Down Expand Up @@ -1415,10 +1415,10 @@
// 节点配置面板表单校验,基础信息和输入参数
validate() {
return this.$refs.basicInfo.validate().then(() => {
if (this.isApiPlugin) {
const { jsonSchemaInput } = this.$refs;
let result = jsonSchemaInput ? jsonSchemaInput.validate() : true;
if (result) {
if (this.$refs.inputParams) {
let result = this.$refs.inputParams.validate();
// api插件额外校验json类型
if (this.isApiPlugin && result) {
// 校验api插件中json数据是否符合JSON格式
result = this.handleJsonValueParse(true);
if (!result) {
Expand All @@ -1430,9 +1430,6 @@
}
return result;
}
if (this.$refs.inputParams) {
return this.$refs.inputParams.validate();
}
if (this.$refs.dmnInputParams) {
return this.$refs.dmnInputParams.validate();
}
Expand Down Expand Up @@ -1542,10 +1539,10 @@
version: this.isThirdParty ? '1.0.0' : version,
};
if (this.isApiPlugin && this.basicInfo.pluginId) { // 新版api插件中component包含pluginId字段
const { pluginId, nodeName, metaUrl, groupId, groupName } = this.basicInfo;
const { pluginId, name, metaUrl, groupId, groupName } = this.basicInfo;
component.api_meta = {
id: pluginId,
name: nodeName,
name: name.split('-')[1],
meta_url: metaUrl,
category: {
id: groupId,
Expand Down
11 changes: 6 additions & 5 deletions frontend/src/views/template/TemplateMock/MockExecute/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
</template>

<script>
import { mapActions } from 'vuex';
import { mapActions, mapState } from 'vuex';
import tools from '@/utils/tools';
import TaskParamEdit from './components/TaskParamEdit.vue';
import MockRecode from './components/MockRecode.vue';
Expand All @@ -108,10 +108,6 @@
type: String,
default: '',
},
creator: {
type: String,
default: '',
},
templateId: {
type: [String, Number],
default: '',
Expand Down Expand Up @@ -139,6 +135,11 @@
unMockExpend: false,
};
},
computed: {
...mapState({
creator: state => state.username,
}),
},
created() {
this.loadData();
},
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/views/template/TemplateMock/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
v-else-if="!templateDataLoading"
ref="mockExecute"
:mock-task-name="mockTaskName"
:creator="creator"
:template-id="templateId"
:selected-nodes="selectedNodes"
:tpl-actions="tplActions"
Expand Down Expand Up @@ -106,7 +105,6 @@
curSelectedNodeId: '',
saveLoading: false,
executeLoading: false,
creator: '',
mockSchemeId: '',
lastSchemeMsg: null,
isShowConditionEdit: false,
Expand Down Expand Up @@ -227,7 +225,6 @@
};
const templateData = await this.loadTemplateData(data);
this.tplActions = templateData.auth;
this.creator = templateData.creator;
this.tplSpaceId = templateData.space_id;
this.setTemplateData(templateData);
this.setSpaceId(templateData.space_id);
Expand Down
2 changes: 1 addition & 1 deletion plugin_service/api_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def wrapper(request: Request):
plugin_client = PluginServiceApiClient(plugin_code)
except PluginServiceException as e:
logger.error(f"[inject_plugin_client] error: {e}")
return JsonResponse({"message": e, "result": False, "data": None})
return JsonResponse({"message": str(e), "result": False, "data": None})
setattr(request, "plugin_client", plugin_client)
return func(request)

Expand Down
Loading