Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into release_1.9.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	frontend/src/App.vue
#	frontend/src/config/i18n/cn.js
#	frontend/src/config/i18n/en.js
  • Loading branch information
normal-wls committed Oct 28, 2024
2 parents b081385 + 148617a commit a45985a
Show file tree
Hide file tree
Showing 26 changed files with 164 additions and 94 deletions.
2 changes: 1 addition & 1 deletion app_desc.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
spec_version: 2
app_version: "1.8.0"
app_version: "1.8.1"
app:
region: default
bk_app_code: &APP_CODE bk_flow_engine
Expand Down
4 changes: 3 additions & 1 deletion bkflow/interface/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def bkflow_settings(request):
frontend_entry_url = "{}bkflow".format(settings.STATIC_URL) if settings.RUN_VER == "open" else "/static/bkflow"
enable_notice_center = int(EnvironmentVariables.objects.get_var("ENABLE_NOTICE_CENTER", 0))
language = request.COOKIES.get("blueking_language", "zh-cn")
doc_lang_mappings = {"zh-cn": "ZH", "en": "EN"}
run_ver_key = "BKAPP_RUN_VER_NAME" if language == "zh-cn" else "BKAPP_RUN_VER_NAME_{}".format(language.upper())

ctx = {
Expand All @@ -36,7 +37,8 @@ def bkflow_settings(request):
"MEMBER_SELECTOR_DATA_HOST": settings.MEMBER_SELECTOR_DATA_HOST,
"APP_CODE": settings.APP_CODE,
"USERNAME": request.user.username,
"BK_DOC_URL": f"{env.BK_DOC_CENTER_HOST}/markdown/ZH/BKFlow/1.8/UserGuide/Introduce/introduce.md",
"BK_DOC_URL": f"{env.BK_DOC_CENTER_HOST}/markdown/{doc_lang_mappings.get(language, 'ZH')}/BKFlow/1.8"
f"/UserGuide/Introduce/introduce.md",
# 是否开启通知中心
"ENABLE_NOTICE_CENTER": enable_notice_center,
"BK_PAAS_SHARED_RES_URL": env.BKPAAS_SHARED_RES_URL,
Expand Down
81 changes: 40 additions & 41 deletions bkflow/pipeline_plugins/query/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,55 +21,54 @@

import logging

import requests
from django.conf import settings
from django.http import JsonResponse
from django.utils.translation import ugettext_lazy as _

logger = logging.getLogger("root")


def variable_select_source_data_proxy(request):
"""
@summary: 获取下拉框源数据的通用接口
@summary: 获取下拉框源数据的通用接口,暂时关闭该接口
@param request:
@return:
"""
url = request.GET.get("url")
try:
response = requests.get(url=url, verify=False, timeout=10)
except Exception as e:
logger.exception("variable select get data from url[url={url}] raise error: {error}".format(url=url, error=e))
text = _("请求数据异常: {error}").format(error=e)
data = [{"text": text, "value": ""}]
return JsonResponse(data, safe=False)
return JsonResponse([{"text": "text1", "value": "value1"}])

try:
data = response.json()
except Exception:
try:
content = response.content.decode(response.encoding)
logger.exception(
"variable select get data from url[url={url}] is not a valid JSON: {data}".format(
url=url, data=content[:500]
)
)
except Exception:
logger.exception("variable select get data from url[url={url}] data is not a valid JSON".format(url=url))
text = _("返回数据格式错误,不是合法 JSON 格式")
data = [{"text": text, "value": ""}]
return JsonResponse(data, safe=False)

# 支持开发者对远程数据源数据配置处理函数,进行再处理
post_process_function = getattr(settings, "REMOTE_SOURCE_DATA_TRANSFORM_FUNCTION", None)
if post_process_function and callable(post_process_function):
try:
data = post_process_function(data)
except Exception as e:
logger.exception(
"variable select transforming data from remote resource url[url={url}] "
"raise error: {error}".format(url=url, error=e)
)
text = _("远程数据源数据转换失败: {error}").format(error=e)
data = [{"text": text, "value": ""}]
return JsonResponse(data, safe=False)
# url = request.GET.get("url")
# try:
# response = requests.get(url=url, verify=False, timeout=10)
# except Exception as e:
# logger.exception("variable select get data from url[url={url}] raise error: {error}".format(url=url, error=e))
# text = _("请求数据异常: {error}").format(error=e)
# data = [{"text": text, "value": ""}]
# return JsonResponse(data, safe=False)
#
# try:
# data = response.json()
# except Exception:
# try:
# content = response.content.decode(response.encoding)
# logger.exception(
# "variable select get data from url[url={url}] is not a valid JSON: {data}".format(
# url=url, data=content[:500]
# )
# )
# except Exception:
# logger.exception("variable select get data from url[url={url}] data is not a valid JSON".format(url=url))
# text = _("返回数据格式错误,不是合法 JSON 格式")
# data = [{"text": text, "value": ""}]
# return JsonResponse(data, safe=False)
#
# # 支持开发者对远程数据源数据配置处理函数,进行再处理
# post_process_function = getattr(settings, "REMOTE_SOURCE_DATA_TRANSFORM_FUNCTION", None)
# if post_process_function and callable(post_process_function):
# try:
# data = post_process_function(data)
# except Exception as e:
# logger.exception(
# "variable select transforming data from remote resource url[url={url}] "
# "raise error: {error}".format(url=url, error=e)
# )
# text = _("远程数据源数据转换失败: {error}").format(error=e)
# data = [{"text": text, "value": ""}]
# return JsonResponse(data, safe=False)
34 changes: 18 additions & 16 deletions bkflow/pipeline_plugins/static/variables/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
hookable: true,
items: [{name: gettext("自定义"), value: "0"}, {name: gettext("远程数据源"), value: "1"}],
value: "0",
hidden: true,
validation: [
{
type: "required"
Expand All @@ -29,7 +30,7 @@
attrs: {
name: gettext("选项"),
hookable: true,
placeholder: gettext('请输入数据源信息,自定义数据源格式为 [{"text": "", "value": ""}...],若是远程数据源则填写返回该格式数据的 URL'),
placeholder: gettext('请输入数据源信息,自定义数据源格式为 [{"text": "", "value": ""}...]'),
validation: [
{
type: "required"
Expand Down Expand Up @@ -73,10 +74,11 @@
let remote_url = "";
let items = [];
let placeholder = '';
if (metaConfig.datasource === "1") {
remote_url = $.context.get('site_url') + 'api/plugin_query/variable_select_source_data_proxy/?url=' + metaConfig.items_text;
remote = true;
} else {
// if (metaConfig.datasource === "1") {
// remote_url = $.context.get('site_url') + 'api/plugin_query/variable_select_source_data_proxy/?url=' + metaConfig.items_text;
// remote = true;
// }
if (metaConfig.datasource === "0") {
try {
items = JSON.parse(metaConfig.items_text);
} catch (err) {
Expand All @@ -92,16 +94,16 @@
let multiple = false;
let default_val = metaConfig.default || '';

if (metaConfig.type === "1") {
multiple = true;
default_val = [];
if (metaConfig.default) {
let vals = metaConfig.default.split(',');
for (let i in vals) {
default_val.push(vals[i].trim());
}
}
}
// if (metaConfig.type === "1") {
// multiple = true;
// default_val = [];
// if (metaConfig.default) {
// let vals = metaConfig.default.split(',');
// for (let i in vals) {
// default_val.push(vals[i].trim());
// }
// }
// }
return {
tag_code: this.tag_code,
type: "select",
Expand All @@ -115,7 +117,7 @@
remote_url: remote_url,
placeholder: placeholder,
remote_data_init: function (data) {
return data
return data;
},
validation: [
{
Expand Down
18 changes: 18 additions & 0 deletions bkflow/space/migrations/0007_alter_space_app_code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.15 on 2024-10-09 03:06

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('space', '0006_auto_20240823_1544'),
]

operations = [
migrations.AlterField(
model_name='space',
name='app_code',
field=models.CharField(max_length=32, verbose_name='应用ID'),
),
]
2 changes: 1 addition & 1 deletion bkflow/space/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Space(CommonModel):
id = models.AutoField(_("空间ID"), primary_key=True)
# 空间名不允许重复
name = models.CharField(_("空间名称"), max_length=32, null=False, blank=False, unique=True)
app_code = models.CharField(_("APP Code"), max_length=32, null=False, blank=False)
app_code = models.CharField(_("应用ID"), max_length=32, null=False, blank=False)
desc = models.CharField(_("空间描述"), max_length=128, null=True, blank=True)
platform_url = models.CharField(_("平台提供服务的地址"), max_length=256, null=False, blank=False)
create_type = models.CharField(
Expand Down
1 change: 1 addition & 0 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ body {
}
.with-system-notice {
height: calc(100vh - 40px) !important;
.navigation-nav,
.container-content {
max-height: calc(100vh - 92px)!important;
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/layout/NavigationHeadLeft.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
},
methods: {
onHandleNavClick(nav) {
if (this.navActive === nav.id) return;
const { meta } = this.$route;
if (this.navActive === nav.id && meta.admin) return;
if (nav.id === 'space-manager') {
this.$router.push({ name: 'spaceAdmin' });
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/config/i18n/cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,11 @@ const cn = {
'描述:': '描述:',
'关联流程:': '关联流程:',
请选择: '请选择',
'ID/名称/创建人/更新人/所属模板 Id/所属作用域类型/所属作用域值': 'ID/名称/创建人/更新人/所属模板 Id/所属作用域类型/所属作用域值',
'ID/名称/创建人/更新人/所属模板 ID/所属作用域类型/所属作用域值': 'ID/名称/创建人/更新人/所属模板 ID/所属作用域类型/所属作用域值',
操作: '操作',
所属作用域类型: '所属作用域类型',
所属作用域值: '所属作用域值',
'所属模板 Id': '所属模板 Id',
'所属模板 ID': '所属模板 ID',
创建人: '创建人',
更新人: '更新人',
恢复默认值: '恢复默认值',
Expand All @@ -399,7 +399,7 @@ const cn = {
'数据格式不正确,应为JSON格式': '数据格式不正确,应为JSON格式',
'确认" {0} "恢复默认值?': '确认" {0} "恢复默认值?',
'删除成功!': '删除成功!',
'ID/任务名称/创建人/执行人/所属模板 Id/所属作用域类型/所属作用域值': 'ID/任务名称/创建人/执行人/所属模板 Id/所属作用域类型/所属作用域值',
'ID/任务名称/创建人/执行人/所属模板 ID/所属作用域类型/所属作用域值': 'ID/任务名称/创建人/执行人/所属模板 ID/所属作用域类型/所属作用域值',
引擎操作: '引擎操作',
任务名称: '任务名称',
执行人: '执行人',
Expand All @@ -409,14 +409,14 @@ const cn = {
未知: '未知',
'任务删除成功!': '任务删除成功!',
新建任务: '新建任务',
模板Id: '模板Id',
模板ID: '模板ID',
请求参数: '请求参数',
'请求参数格式不正确,应为JSON格式': '请求参数格式不正确,应为JSON格式',
任务创建成功: '任务创建成功',
新建流程: '新建流程',
流程名称: '流程名称',
流程创建成功: '流程创建成功',
'ID/模板名称/创建人/更新人/启用/所属作用域类型/所属作用域值': 'ID/模板名称/创建人/更新人/启用/所属作用域类型/所属作用域值',
'ID/流程名称/创建人/更新人/启用/所属作用域类型/所属作用域值': 'ID/流程名称/创建人/更新人/启用/所属作用域类型/所属作用域值',
创建流程: '创建流程',
'当前已选择 x 条数据': '当前已选择 {num} 条数据',
',': ',',
Expand Down
14 changes: 7 additions & 7 deletions frontend/src/config/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const en = {
系统管理: 'System Management',
中文: 'Chinese',
产品文档: 'Documentation',
版本日志: 'Release note',
版本日志: 'Release Notes',
流程: 'Process',
任务: 'Task',
调试任务: 'Debug Task',
Expand Down Expand Up @@ -386,11 +386,11 @@ const en = {
'描述:': 'Description:',
'关联流程:': 'Related Process:',
请选择: 'Please Select',
'ID/名称/创建人/更新人/所属模板 Id/所属作用域类型/所属作用域值': 'ID/Name/Created by/Updater/Template ID/Scope Type/Scope Value',
'ID/名称/创建人/更新人/所属模板 ID/所属作用域类型/所属作用域值': 'ID/Name/Created by/Updater/Template ID/Scope Type/Scope Value',
操作: 'Operation',
所属作用域类型: 'Scope Type',
所属作用域值: 'Scope Value',
'所属模板 Id': 'Template ID',
'所属模板 ID': 'Template ID',
创建人: 'Created by',
更新人: 'Updater',
恢复默认值: 'Reset',
Expand All @@ -399,7 +399,7 @@ const en = {
'数据格式不正确,应为JSON格式': 'Incorrect data format, should be in JSON format',
'确认" {0} "恢复默认值?': 'Confirm to reset value for "{0}"?',
'删除成功!': 'Deleted Successfully!',
'ID/任务名称/创建人/执行人/所属模板 Id/所属作用域类型/所属作用域值': 'ID/Task Name/Created by/Executor/Template ID/Scope Type/Scope Value',
'ID/任务名称/创建人/执行人/所属模板 ID/所属作用域类型/所属作用域值': 'ID/Task Name/Created by/Executor/Template ID/Scope Type/Scope Value',
引擎操作: 'Engine Operation',
任务名称: 'Task Name',
执行人: 'Executor',
Expand All @@ -409,14 +409,14 @@ const en = {
未知: 'Unknown',
'任务删除成功!': 'Task Deleted Successfully!',
新建任务: 'Create Task',
模板Id: 'Template ID',
模板ID: 'Template ID',
请求参数: 'Request Parameters',
'请求参数格式不正确,应为JSON格式': 'Request parameters are not in the correct format, should be in JSON format',
任务创建成功: 'Task Created Successfully',
新建流程: 'Add',
流程名称: 'Process Name',
流程创建成功: 'Process Created Successfully',
'ID/模板名称/创建人/更新人/启用/所属作用域类型/所属作用域值': 'ID/Template Name/Created by/Updater/Enabled/Scope Type/Scope Value',
'ID/流程名称/创建人/更新人/启用/所属作用域类型/所属作用域值': 'ID/Flow Name/Created by/Updater/Enabled/Scope Type/Scope Value',
创建流程: 'Add',
'当前已选择 x 条数据': 'Currently Selected {num} Items',
',': ', ',
Expand Down Expand Up @@ -894,7 +894,7 @@ const en = {
'流程任务事件并进行自动化扩展。': 'process and task events and automate scaling.',
支持计算和存储资源隔离: 'Computing & Storage Resource Isolation',
'任务执行和数据可与其他接入空间隔离。': 'Task execution data can be isolated from other access spaces.',
退出登录: 'Sign out',
退出登录: 'Sign Out',
首页: 'Home',
字段标识已经存在: 'Field identifier already exists',
key值只能由数字和字母组成且不能以数字开头: 'Key value can only consist of letters and numbers and cannot start with a number',
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/mixins/tableHeader.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

import TableRenderHeader from '@/components/common/TableRenderHeader.vue';
import i18n from '@/config/i18n/index.js';

const tableHeader = {
methods: {
Expand All @@ -17,8 +18,8 @@ const tableHeader = {
</TableRenderHeader>;
} if (['scope_type', 'scope_value'].includes(column.property)) {
const tips = column.property === 'scope_type'
? '指对应资源在接入平台所属的作用域范围的类型,方便接入平台对资源进行自定义过滤。如该资源属于业务 1,则该字段的值可设为"project"。'
: '指对应资源在接入平台所属的作用域范围的值,方便接入平台对资源进行自定义过滤。如该资源属于业务1,则该字段的值可设为"1"。';
? i18n.t('scopeType')
: i18n.t('scopeValue');
return h('span', {
class: 'scope-column-label',
}, [
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/scss/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,10 @@
white-space: nowrap;
word-wrap: normal;
text-overflow: ellipsis;
}
}
.bk-table-fixed-right {
border-bottom: none;
}
}
// 异常提示固定高度
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/views/admin/Space/DecisionTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<table-operate
ref="taskOperate"
:space-id="spaceId"
:placeholder="$t('ID/名称/创建人/更新人/所属模板 Id/所属作用域类型/所属作用域值')"
:placeholder="$t('ID/名称/创建人/更新人/所属模板 ID/所属作用域类型/所属作用域值')"
:search-list="searchList"
@updateSearchValue="searchValue = $event"
@changeRequest="handleSearchSelectChange">
Expand Down Expand Up @@ -126,7 +126,7 @@
},
{
id: 'template_id',
label: i18n.t('所属模板 Id'),
label: i18n.t('所属模板 ID'),
width: 100,
},
{
Expand Down Expand Up @@ -170,7 +170,7 @@
},
{
id: 'template_id',
name: i18n.t('所属模板 Id'),
name: i18n.t('所属模板 ID'),
},
{
id: 'scope_type',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/admin/Space/SpaceConfig/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
const TABLE_FIELDS = [
{
id: 'name',
label: 'Name',
label: i18n.t('名字'),
},
{
id: 'desc',
Expand Down
Loading

0 comments on commit a45985a

Please sign in to comment.