fix: resource label value validation
This commit is contained in:
@@ -46,7 +46,7 @@ export default {
|
||||
'common.button.disabled': 'Disabled',
|
||||
'common.button.upgrade': 'Upgrade',
|
||||
'common.input.holder': 'Please enter',
|
||||
'common.validate.value': 'value is required',
|
||||
'common.validate.value': '{name} value is required',
|
||||
'common.button.edit': 'Edit',
|
||||
'common.button.authorize': 'Role Authorization',
|
||||
'common.button.confirm': 'Confirm',
|
||||
|
||||
@@ -8,6 +8,7 @@ export default {
|
||||
'resources.table.labels': 'Labels',
|
||||
'resources.table.hostname': 'Hostname',
|
||||
'resources.table.key.tips': 'The same key exists.',
|
||||
'resources.form.label': 'Label',
|
||||
'resources.form.advanced': 'Advanced',
|
||||
'resources.form.enablePartialOffload': 'Allow CPU Offloading',
|
||||
'resources.form.placementStrategy': 'Placement Strategy',
|
||||
|
||||
@@ -109,7 +109,7 @@ export default {
|
||||
'common.ws.reconnect': '重新连接',
|
||||
'common.input.key': '键',
|
||||
'common.input.value': '值',
|
||||
'common.validate.value': '值必填',
|
||||
'common.validate.value': '{name}值必填',
|
||||
'common.input.type': '类型',
|
||||
'common.input.visible': '是否可见',
|
||||
'common.input.description': '描述',
|
||||
|
||||
@@ -7,6 +7,7 @@ export default {
|
||||
'resources.nodes': '节点',
|
||||
'resources.table.hostname': '主机名',
|
||||
'resources.table.key.tips': '存在相同的 key.',
|
||||
'resources.form.label': '标签',
|
||||
'resources.table.labels': '标签',
|
||||
'resources.form.advanced': '高级',
|
||||
'resources.form.enablePartialOffload': '允许 CPU 卸载',
|
||||
|
||||
@@ -146,7 +146,9 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
||||
id: 'common.validate.value'
|
||||
},
|
||||
{
|
||||
name: 'models.form.selector'
|
||||
name: intl.formatMessage({
|
||||
id: 'models.form.selector'
|
||||
})
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
@@ -3,6 +3,7 @@ import ModalFooter from '@/components/modal-footer';
|
||||
import SealInput from '@/components/seal-form/seal-input';
|
||||
import { useIntl } from '@umijs/max';
|
||||
import { Form, Modal } from 'antd';
|
||||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
import SimpleBar from 'simplebar-react';
|
||||
import 'simplebar-react/dist/simplebar.min.css';
|
||||
@@ -93,7 +94,32 @@ const UpdateLabels: React.FC<ViewModalProps> = (props) => {
|
||||
disabled
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item<FormData> name="labels">
|
||||
<Form.Item<FormData>
|
||||
name="labels"
|
||||
rules={[
|
||||
() => ({
|
||||
validator(rule, value) {
|
||||
if (_.keys(value).length > 0) {
|
||||
if (_.some(_.keys(value), (k: string) => !value[k])) {
|
||||
return Promise.reject(
|
||||
intl.formatMessage(
|
||||
{
|
||||
id: 'common.validate.value'
|
||||
},
|
||||
{
|
||||
name: intl.formatMessage({
|
||||
id: 'resources.form.label'
|
||||
})
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
})
|
||||
]}
|
||||
>
|
||||
<LabelSelector
|
||||
label={intl.formatMessage({
|
||||
id: 'resources.table.labels'
|
||||
|
||||
Reference in New Issue
Block a user