Skip to content

Commit

Permalink
Merge branch 'master' into feat_template_download
Browse files Browse the repository at this point in the history
  • Loading branch information
luofann committed Mar 1, 2024
2 parents 44f07ac + ecf364d commit 2cbaae6
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 14 deletions.
5 changes: 3 additions & 2 deletions bcs-services/bcs-bscp/ui/src/i18n/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default {
用户: 'User',
用户组: 'User group',
配置内容: 'Configuration content',
文件大小100M以内: 'File size within 100MB',
'文件大小{size}M以内': 'File size within {size}M',
'属主(own)': 'Owner',
'属组(group)': 'Group',
'其他人(other)': 'Other',
Expand All @@ -134,7 +134,7 @@ export default {
'无效的路径,路径不符合Unix文件路径格式规范': 'Invalid path, the path does not comply with the Unix file path format specification',
最大长度200个字符: 'Maximum length of 200 characters',
请上传文件: 'Please upload the file',
配置内容不能超过50M: 'Configuration content cannot exceed 50MB',
'配置内容不能超过{size}M': 'Configuration content cannot exceed {size}M',
配置项名称: 'Configuration item name',
配置项值: 'Configuration item value',
'请输入(仅支持大小不超过2M)': 'Please enter (only supports size no more than 2M)',
Expand Down Expand Up @@ -251,6 +251,7 @@ export default {
移除套餐: 'Remove plan',
替换版本: 'Replace version',
下载: 'Download',
下载模板文件: 'Download template',
'确认删除该配置文件?': 'Confirm to delete this profile?',
'确认移除该配置模板套餐?': 'Are you sure to remove this configuration template package?',
配置模板套餐: 'Configure template package',
Expand Down
5 changes: 3 additions & 2 deletions bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default {
用户: '用户',
用户组: '用户组',
配置内容: '配置内容',
文件大小100M以内: '文件大小100M以内',
'文件大小{size}M以内': '文件大小{size}M以内',
'属主(own)': '属主(own)',
'属组(group)': '属组(group)',
'其他人(other)': '其他人(other)',
Expand All @@ -134,7 +134,7 @@ export default {
'无效的路径,路径不符合Unix文件路径格式规范': '无效的路径,路径不符合Unix文件路径格式规范',
最大长度200个字符: '最大长度200个字符',
请上传文件: '请上传文件',
配置内容不能超过50M: '配置内容不能超过50M',
'配置内容不能超过{size}M': '配置内容不能超过{size}M',
配置项名称: '配置项名称',
配置项值: '配置项值',
'请输入(仅支持大小不超过2M)': '请输入(仅支持大小不超过2M)',
Expand Down Expand Up @@ -251,6 +251,7 @@ export default {
移除套餐: '移除套餐',
替换版本: '替换版本',
下载: '下载',
下载模板文件: '下载模板文件',
'确认删除该配置文件?': '确认删除该配置文件?',
'确认移除该配置模板套餐?': '确认移除该配置模板套餐?',
配置模板套餐: '配置模板套餐',
Expand Down
2 changes: 1 addition & 1 deletion bcs-services/bcs-bscp/ui/src/store/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ISpaceDetail, IPermissionResource, IPermissionQueryResourceItem } from
export default defineStore('global', () => {
const bscpVersion = ref(''); // 产品版本号
const spaceId = ref(''); // 空间id
const spaceFeatureFlags = ref<{ [key: string]: boolean }>({}); // 空间的配置开关
const spaceFeatureFlags = ref<{ [key: string]: any }>({}); // 空间的配置开关
const spaceList = ref<ISpaceDetail[]>([]);
// @ts-ignore
const showNotice = ref(window.ENABLE_BK_NOTICE === 'true'); // 是否展示消息通知
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="editor-title">
<div class="tips">
<InfoLine class="info-icon" />
{{ t('仅支持大小不超过') }}50M
{{ t('仅支持大小不超过') }}{{ props.sizeLimit }}M
</div>
<div class="btns">
<ReadFileContent
Expand Down Expand Up @@ -58,11 +58,13 @@
defineProps<{
content: string;
variables?: IVariableEditParams[];
sizeLimit?: number;
editable: boolean;
}>(),
{
variables: () => [],
editable: true,
sizeLimit: 100,
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
class="config-uploader"
url=""
theme="button"
:tip="t('文件大小100M以内')"
:size="100"
:tip="t('文件大小{size}M以内', { size: props.fileSizeLimit })"
:size="props.fileSizeLimit"
:disabled="!editable"
:multiple="false"
:files="fileList"
Expand Down Expand Up @@ -122,6 +122,7 @@
:content="stringContent"
:editable="editable"
:variables="props.variables"
:size-limit="props.fileSizeLimit"
@change="handleStringContentChange" />
</bk-form-item>
</bk-form>
Expand Down Expand Up @@ -165,10 +166,12 @@
bkBizId: string;
id: number; // 服务ID或者模板空间ID
fileUploading?: boolean;
fileSizeLimit?: number;
isTpl?: boolean; // 是否未模板配置文件,非模板配置文件和模板配置文件的上传、下载接口参数有差异
}>(),
{
editable: true,
fileSizeLimit: 100,
},
);
Expand Down Expand Up @@ -362,8 +365,8 @@
return false;
}
} else if (localVal.value.file_type === 'text') {
if (stringLengthInBytes(stringContent.value) > 1024 * 1024 * 50) {
BkMessage({ theme: 'error', message: t('配置内容不能超过50M') });
if (stringLengthInBytes(stringContent.value) > 1024 * 1024 * props.fileSizeLimit) {
BkMessage({ theme: 'error', message: t('配置内容不能超过{size}M', { size: props.fileSizeLimit }) });
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:editable="true"
:bk-biz-id="props.bkBizId"
:id="props.appId"
:file-size-limit="spaceFeatureFlags.RESOURCE_LIMIT.maxConfigItemSize"
@change="handleFormChange" />
<section class="action-btns">
<bk-button theme="primary" :loading="pending" :disabled="fileUploading" @click="handleSubmit">
Expand All @@ -26,14 +27,17 @@
<script lang="ts" setup>
import { ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { storeToRefs } from 'pinia';
import Message from 'bkui-vue/lib/message';
import { IConfigEditParams, IFileConfigContentSummary } from '../../../../../../../../../types/config';
import { createServiceConfigItem, updateConfigContent } from '../../../../../../../../api/config';
import { getConfigEditParams } from '../../../../../../../../utils/config';
import useModalCloseConfirmation from '../../../../../../../../utils/hooks/use-modal-close-confirmation';
import ConfigForm from '../config-form.vue';
import useServiceStore from '../../../../../../../../store/service';
import { storeToRefs } from 'pinia';
import useGlobalStore from '../../../../../../../../store/global';
const { spaceFeatureFlags } = storeToRefs(useGlobalStore());
const props = defineProps<{
show: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
:editable="true"
:bk-biz-id="props.bkBizId"
:id="props.appId"
:file-size-limit="spaceFeatureFlags.RESOURCE_LIMIT.maxConfigItemSize"
@change="handleChange" />
</bk-loading>
<section class="action-btns">
Expand Down Expand Up @@ -45,10 +46,12 @@
} from '../../../../../../../api/config';
import { getConfigEditParams } from '../../../../../../../utils/config';
import { IConfigEditParams, IFileConfigContentSummary } from '../../../../../../../../types/config';
import useGlobalStore from '../../../../../../../store/global';
import useConfigStore from '../../../../../../../store/config';
import useModalCloseConfirmation from '../../../../../../../utils/hooks/use-modal-close-confirmation';
const { t } = useI18n();
const { spaceFeatureFlags } = storeToRefs(useGlobalStore());
const { versionData } = storeToRefs(useConfigStore());
const props = defineProps<{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
<template>
<div class="download-config" @click="handleDownload">
<slot>
<bk-button text :theme="props.theme" :loading="pending">{{ $t('下载') }}</bk-button>
<bk-button text :theme="props.theme" :loading="pending">{{ props.text || t('下载') }}</bk-button>
</slot>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { getTemplateVersionsNameByIds, downloadTemplateContent } from '../../../../../../../api/template';
import { fileDownload } from '../../../../../../../utils/file';
const { t } = useI18n();
const props = withDefaults(
defineProps<{
spaceId: string;
templateSpaceId: number;
templateId: number;
theme: string;
text?: string;
}>(),
{
theme: 'primary',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<DownloadConfig
class="action-item"
theme="default"
:text="$t('下载模板文件')"
:space-id="spaceId"
:template-space-id="currentTemplateSpace"
:template-id="row.id" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@
return false;
}
} else if (formData.value.file_type === 'text') {
if (stringLengthInBytes(stringContent.value) > 1024 * 1024 * 50) {
Message({ theme: 'error', message: t('配置内容不能超过50M') });
if (stringLengthInBytes(stringContent.value) > 1024 * 1024 * 100) {
Message({ theme: 'error', message: `${t('配置内容不能超过')} 100M` });
return false;
}
}
Expand Down

0 comments on commit 2cbaae6

Please sign in to comment.