Skip to content

Commit

Permalink
fix: modify cluster name validate message (#209)
Browse files Browse the repository at this point in the history
Signed-off-by: liuying <[email protected]>

Signed-off-by: liuying <[email protected]>
Co-authored-by: liuying <[email protected]>
  • Loading branch information
kubeclipper-bot and lysign authored Oct 17, 2022
1 parent 8ddad51 commit 0c45f0e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 56 deletions.
27 changes: 1 addition & 26 deletions src/pages/cluster/containers/Cluster/actions/Create/Cluster.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/pages/cluster/containers/Cluster/actions/Create/Node.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
},
Expand Down

0 comments on commit 0c45f0e

Please sign in to comment.