Skip to content

Commit

Permalink
Merge pull request #345 from actiontech/fix/issue-2067-3
Browse files Browse the repository at this point in the history
[fix]: change file valid locale
  • Loading branch information
LZS911 authored Nov 29, 2023
2 parents 95b3296 + 382f723 commit ad12569
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/locale/en-US/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default {
placeholder: {
input: 'Please input {{name}}',
select: 'Please select {{name}}',
upload: 'Please upload {{name}}',
searchInput: 'Input the {{name}} to search',
searchSelect: 'Select the {{name}} to search',
},
Expand Down
1 change: 0 additions & 1 deletion src/locale/en-US/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ export default {
instanceSchema: '数据库',
sql: 'SQL语句',
sqlFile: 'SQL文件',
validateSqlFileMsg: '请上传SQL文件',
mybatisFile: 'Mybatis的XML文件',
zipFile: 'ZIP文件',

Expand Down
1 change: 1 addition & 0 deletions src/locale/zh-CN/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default {
placeholder: {
input: '请输入{{name}}',
select: '请选择{{name}}',
upload: '请上传{{name}}',
searchInput: '请输入要搜索的 {{name}}',
searchSelect: '请选择要搜索的 {{name}}',
},
Expand Down
1 change: 0 additions & 1 deletion src/locale/zh-CN/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ export default {
instanceSchema: '数据库',
sql: 'SQL语句',
sqlFile: 'SQL文件',
validateSqlFileMsg: '请上传SQL文件',
mybatisFile: 'Mybatis的XML文件',
zipFile: 'ZIP文件',

Expand Down
21 changes: 13 additions & 8 deletions src/page/Order/SqlStatementFormTabs/SqlStatementForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const SqlStatementForm: React.FC<SqlStatementFormProps> = ({

const resetUploadTypeContent = () => {
setCurrentSQLInputTYpe(SQLInputType.manualInput);
}
};

const { editorDidMount } = useMonacoEditor(form, {
formName: generateFieldName('sql'),
Expand Down Expand Up @@ -88,8 +88,7 @@ const SqlStatementForm: React.FC<SqlStatementFormProps> = ({
);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

}, []);

return (
<>
Expand Down Expand Up @@ -126,9 +125,9 @@ const SqlStatementForm: React.FC<SqlStatementFormProps> = ({
}}
rules={[
{
required: true
required: true,
},
...whiteSpaceSql()
...whiteSpaceSql(),
]}
>
<MonacoEditorFunComponent
Expand All @@ -151,7 +150,9 @@ const SqlStatementForm: React.FC<SqlStatementFormProps> = ({
rules={[
{
required: true,
message: t('order.sqlInfo.validateSqlFileMsg')
message: t('common.form.placeholder.upload', {
name: t('order.sqlInfo.sqlFile'),
}),
},
]}
getValueFromEvent={getFileFromUploadChangeEvent}
Expand All @@ -173,7 +174,9 @@ const SqlStatementForm: React.FC<SqlStatementFormProps> = ({
rules={[
{
required: true,
message: t('order.sqlInfo.validateSqlFileMsg')
message: t('common.form.placeholder.upload', {
name: t('order.sqlInfo.mybatisFile'),
}),
},
]}
getValueFromEvent={getFileFromUploadChangeEvent}
Expand All @@ -196,7 +199,9 @@ const SqlStatementForm: React.FC<SqlStatementFormProps> = ({
rules={[
{
required: true,
message: t('order.sqlInfo.validateSqlFileMsg')
message: t('common.form.placeholder.upload', {
name: t('order.sqlInfo.zipFile'),
}),
},
]}
getValueFromEvent={getFileFromUploadChangeEvent}
Expand Down
43 changes: 36 additions & 7 deletions src/page/SqlAuditRecord/Create/SQLInfoForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import {
Tooltip,
Upload,
} from 'antd';
import { PageFormLayout, ResponseCode, SqlFiledInitialValue } from '../../../data/common';
import {
PageFormLayout,
ResponseCode,
SqlFiledInitialValue,
} from '../../../data/common';
import {
AuditTypeEnum,
SQLInfoFormFields,
Expand Down Expand Up @@ -49,7 +53,7 @@ import { RuleUrlParamKey } from '../../Rule/useRuleFilterForm';
import { Link } from 'react-router-dom';
import { getInstanceTipListV1FunctionalModuleEnum } from '../../../api/instance/index.enum';
import EmptyBox from '../../../components/EmptyBox';
import { whiteSpaceSql } from '../../../utils/FormRule';
import { whiteSpaceSql, nameRule } from '../../../utils/FormRule';

const MonacoEditorFunComponent =
MonacoEditor as ComponentType<MonacoEditorProps>;
Expand Down Expand Up @@ -95,7 +99,6 @@ const SQLInfoForm: React.ForwardRefRenderFunction<
rules: [
{
required: true,
message: t('order.sqlInfo.validateSqlFileMsg')
},
],
};
Expand All @@ -108,7 +111,12 @@ const SQLInfoForm: React.ForwardRefRenderFunction<
...PageFormLayout.wrapperCol,
className: theme.editor,
},
rules: [{ required: uploadType === UploadTypeEnum.sql }, ...whiteSpaceSql()],
rules: [
{
required: uploadType === UploadTypeEnum.sql,
},
...whiteSpaceSql(),
],

children: (
<MonacoEditorFunComponent
Expand All @@ -127,7 +135,14 @@ const SQLInfoForm: React.ForwardRefRenderFunction<
return {
name: 'sqlFile',
label: t('sqlAudit.create.SQLInfo.uploadLabelEnum.sqlFile'),
rules: [{ required: uploadType === UploadTypeEnum.sqlFile }],
rules: [
{
required: uploadType === UploadTypeEnum.sqlFile,
message: t('common.form.placeholder.upload', {
name: t('sqlAudit.create.SQLInfo.uploadLabelEnum.sqlFile'),
}),
},
],
children: (
<Upload
accept=".sql"
Expand All @@ -143,7 +158,14 @@ const SQLInfoForm: React.ForwardRefRenderFunction<
return {
name: 'mybatisFile',
label: t('sqlAudit.create.SQLInfo.uploadLabelEnum.xmlFile'),
rules: [{ required: uploadType === UploadTypeEnum.xmlFile }],
rules: [
{
required: uploadType === UploadTypeEnum.xmlFile,
message: t('common.form.placeholder.upload', {
name: t('sqlAudit.create.SQLInfo.uploadLabelEnum.xmlFile'),
}),
},
],
children: (
<Upload
accept=".xml"
Expand All @@ -159,7 +181,14 @@ const SQLInfoForm: React.ForwardRefRenderFunction<
return {
name: 'zipFile',
label: t('sqlAudit.create.SQLInfo.uploadLabelEnum.zipFile'),
rules: [{ required: uploadType === UploadTypeEnum.zipFile }],
rules: [
{
required: uploadType === UploadTypeEnum.zipFile,
message: t('common.form.placeholder.upload', {
name: t('sqlAudit.create.SQLInfo.uploadLabelEnum.zipFile'),
}),
},
],
children: (
<Upload
accept=".zip"
Expand Down

0 comments on commit ad12569

Please sign in to comment.