diff --git a/src/pages/cluster/containers/Cluster/actions/Create/Cluster.jsx b/src/pages/cluster/containers/Cluster/actions/Create/Cluster.jsx index 07f20dd5..53be35f6 100644 --- a/src/pages/cluster/containers/Cluster/actions/Create/Cluster.jsx +++ b/src/pages/cluster/containers/Cluster/actions/Create/Cluster.jsx @@ -17,15 +17,13 @@ import { observer } from 'mobx-react'; import BaseForm from 'components/Form'; import { toJS } from 'mobx'; import { rootStore } from 'stores'; -import { message } from 'antd'; -import { fqdn, subdomain, path } from 'utils/regex'; +import { fqdn, path } from 'utils/regex'; import { isIPv4, isIpv6, isDomain, isDomainPath, isIpPort, - isNumber, } from 'utils/validate'; import { clusterParams, @@ -303,29 +301,6 @@ export default class Cluster extends BaseForm { return Promise.resolve(true); }; - checkName = (rule, value) => { - const { isPrev } = this.state; - - if (!value) { - if (isPrev) return Promise.resolve(true); - - message.error(t('Please input cluster name')); - return Promise.reject(t('Please input cluster name')); - } - - if (isNumber(value)) { - return Promise.reject(t('The name cannot be all numbers')); - } - - if (!subdomain.test(value)) { - return Promise.reject( - t('The enter does not meet the subdomain specification!') - ); - } - - return Promise.resolve(true); - }; - checkCertSANs = (rule, value = []) => { const checkFunc = (item) => { if (!item) return true; diff --git a/src/pages/cluster/containers/Cluster/actions/Create/Node.jsx b/src/pages/cluster/containers/Cluster/actions/Create/Node.jsx index ce7f38af..d8f02829 100644 --- a/src/pages/cluster/containers/Cluster/actions/Create/Node.jsx +++ b/src/pages/cluster/containers/Cluster/actions/Create/Node.jsx @@ -25,6 +25,7 @@ import LabelInput from 'components/FormItem/LabelInput'; import { message } from 'antd'; import { subdomain } from 'utils/regex'; import SelectNodes from 'pages/cluster/components/SelectNodes'; +import { nameMessage } from 'utils/validate'; const { nodeStore, regionStore } = rootStore; @@ -245,9 +246,7 @@ export default class Node extends BaseForm { } if (!subdomain.test(value)) { - return Promise.reject( - t('The enter does not meet the subdomain specification!') - ); + return Promise.reject(nameMessage); } return Promise.resolve(true); diff --git a/src/pages/cluster/containers/Template/cluster/actions/Create/Cluster.jsx b/src/pages/cluster/containers/Template/cluster/actions/Create/Cluster.jsx index 6407a9e9..8eda037f 100644 --- a/src/pages/cluster/containers/Template/cluster/actions/Create/Cluster.jsx +++ b/src/pages/cluster/containers/Template/cluster/actions/Create/Cluster.jsx @@ -17,15 +17,13 @@ import { observer } from 'mobx-react'; import BaseForm from 'components/Form'; import { toJS } from 'mobx'; import { rootStore } from 'stores'; -import { message } from 'antd'; -import { fqdn, subdomain } from 'utils/regex'; +import { fqdn } from 'utils/regex'; import { isIPv4, isIpv6, isDomain, isDomainPath, isIpPort, - isNumber, } from 'utils/validate'; import { clusterParams, @@ -324,29 +322,6 @@ export default class Cluster extends BaseForm { return Promise.resolve(true); }; - checkName = (rule, value) => { - const { isPrev } = this.state; - - if (!value) { - if (isPrev) return Promise.resolve(true); - - message.error(t('Please input cluster name')); - return Promise.reject(t('Please input cluster name')); - } - - if (isNumber(value)) { - return Promise.reject(t('The name cannot be all numbers')); - } - - if (!subdomain.test(value)) { - return Promise.reject( - t('The enter does not meet the subdomain specification!') - ); - } - - return Promise.resolve(true); - }; - checkCertSANs = (rule, value = []) => { const checkFunc = (item) => { if (!item) return true; @@ -518,7 +493,7 @@ export default class Cluster extends BaseForm { { name: 'templateName', label: t('Template Name'), - type: 'input', + type: 'input-name', placeholder: t('Please input Template name'), required: true, },