fix the validator of cluster name and labels
1. fix the validator of cluster name 2. replace the labels in cluster which from cluster template Closes-Bug: #1999398 Change-Id: I244282686cab18ec69930b8221701a9363f70b74
This commit is contained in:
parent
594db17643
commit
3ada93aae8
@ -2334,6 +2334,7 @@
|
||||
"The name should contain letter or number, the length is 1 to 16, characters can only contain \"0-9, a-z, A-Z, -, _.\"": "The name should contain letter or number, the length is 1 to 16, characters can only contain \"0-9, a-z, A-Z, -, _.\"",
|
||||
"The name should contain letter or number, the length is 2 to 64, characters can only contain \"0-9, a-z, A-Z, -, _.\"": "The name should contain letter or number, the length is 2 to 64, characters can only contain \"0-9, a-z, A-Z, -, _.\"",
|
||||
"The name should start with upper letter or lower letter, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_()[].:^\".": "The name should start with upper letter or lower letter, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_()[].:^\".",
|
||||
"The name should start with upper letter or lower letter, characters can only contain \"0-9, a-z, A-Z, -, _, .\"": "The name should start with upper letter or lower letter, characters can only contain \"0-9, a-z, A-Z, -, _, .\"",
|
||||
"The name should start with upper letter, lower letter or chinese, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_()[].\".": "The name should start with upper letter, lower letter or chinese, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_()[].\".",
|
||||
"The name should start with upper letter, lower letter or chinese, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_()[].:^\".": "The name should start with upper letter, lower letter or chinese, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_()[].:^\".",
|
||||
"The name should start with upper letter, lower letter or chinese, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_.\".": "The name should start with upper letter, lower letter or chinese, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_.\".",
|
||||
|
@ -2334,6 +2334,7 @@
|
||||
"The name should contain letter or number, the length is 1 to 16, characters can only contain \"0-9, a-z, A-Z, -, _.\"": "名称应包含字母或数字,长度为 1 到 16,且字符只能包含“0-9、a-z、A-Z、-、_”。",
|
||||
"The name should contain letter or number, the length is 2 to 64, characters can only contain \"0-9, a-z, A-Z, -, _.\"": "名称应包含字母或数字,长度为 2 到 64,且字符只能包含“0-9、a-z、A-Z、-、_”。",
|
||||
"The name should start with upper letter or lower letter, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_()[].:^\".": "名称应以大写字母或小写字母开头,最长为128字符,且只包含“0-9, a-z, A-Z, \"'-_()[].:^”。",
|
||||
"The name should start with upper letter or lower letter, characters can only contain \"0-9, a-z, A-Z, -, _, .\"": "名称应以大写字母或小写字母开头,且字符只能包含“0-9、a-z、A-Z、-、_、.”。",
|
||||
"The name should start with upper letter, lower letter or chinese, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_()[].\".": "名称应以大写字母,小写字母或中文开头,最长为128字符,且只包含“0-9, a-z, A-Z, \"'-_()[].”。",
|
||||
"The name should start with upper letter, lower letter or chinese, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_()[].:^\".": "名称应以大写字母,小写字母或中文开头,最长为128字符,且只包含“0-9, a-z, A-Z, \"'-_()[].:^”。",
|
||||
"The name should start with upper letter, lower letter or chinese, and be a string of 1 to 128, characters can only contain \"0-9, a-z, A-Z, \"-'_.\".": "名称应以大写字母,小写字母或中文开头,最长为128字符,且只包含“0-9, a-z, A-Z, \"-'_.”。",
|
||||
|
@ -50,7 +50,8 @@ export class StepNetwork extends Base {
|
||||
}
|
||||
|
||||
get subnetList() {
|
||||
const { fixedNetwork: { selectedRowKeys = [] } = {} } = this.state;
|
||||
const selectedRowKeys =
|
||||
this.props.context?.fixedNetwork?.selectedRowKeys || [];
|
||||
return (this.subnetNetworkStore.list.data || []).filter(
|
||||
(it) => selectedRowKeys[0] === it.network_id
|
||||
);
|
||||
@ -75,10 +76,6 @@ export class StepNetwork extends Base {
|
||||
return acceptedDrivers;
|
||||
}
|
||||
|
||||
get nameForStateUpdate() {
|
||||
return ['fixedNetwork'];
|
||||
}
|
||||
|
||||
get defaultValue() {
|
||||
let values = {};
|
||||
|
||||
@ -112,20 +109,14 @@ export class StepNetwork extends Base {
|
||||
floating_ip_enabled,
|
||||
};
|
||||
if (fixed_network) {
|
||||
values.fixedNetwork = {
|
||||
values.fixedNetwork = this.props.context.fixedNetwork || {
|
||||
selectedRowKeys: [fixed_network],
|
||||
};
|
||||
}
|
||||
if (fixed_subnet) {
|
||||
const { subnetInitValue } = this.state;
|
||||
|
||||
if (subnetInitValue) {
|
||||
values.fixedSubnet = subnetInitValue;
|
||||
} else {
|
||||
values.fixedSubnet = {
|
||||
selectedRowKeys: [fixed_subnet],
|
||||
};
|
||||
}
|
||||
values.fixedSubnet = {
|
||||
selectedRowKeys: [fixed_subnet],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +125,6 @@ export class StepNetwork extends Base {
|
||||
|
||||
get formItems() {
|
||||
const { extra: { network_driver } = {} } = this.props;
|
||||
const { subnetInitValue } = this.state;
|
||||
|
||||
return [
|
||||
{
|
||||
@ -208,18 +198,10 @@ export class StepNetwork extends Base {
|
||||
],
|
||||
columns: networkColumns(this),
|
||||
onChange: (value) => {
|
||||
this.setState(
|
||||
{
|
||||
fixedNetwork: value,
|
||||
subnetInitValue: {
|
||||
selectedRowKeys: [],
|
||||
selectedRows: [],
|
||||
},
|
||||
},
|
||||
() => {
|
||||
this.formRef.current.resetFields(['fixedSubnet']);
|
||||
}
|
||||
);
|
||||
this.updateContext({
|
||||
fixedNetwork: value,
|
||||
});
|
||||
this.updateFormValue('fixedSubnet', null);
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -227,7 +209,6 @@ export class StepNetwork extends Base {
|
||||
label: t('Fixed Subnet'),
|
||||
type: 'select-table',
|
||||
data: this.subnetList,
|
||||
initValue: subnetInitValue,
|
||||
filterParams: [
|
||||
{
|
||||
label: t('Name'),
|
||||
|
@ -114,9 +114,11 @@ export class StepCreate extends StepAction {
|
||||
}
|
||||
|
||||
const body = {
|
||||
...rest,
|
||||
labels: requestLabels,
|
||||
external_network_id: externalNetwork.selectedRowKeys[0],
|
||||
...rest,
|
||||
fixed_network: fixedNetwork ? fixedNetwork.selectedRowKeys[0] : null,
|
||||
fixed_subnet: fixedSubnet ? fixedSubnet.selectedRowKeys[0] : null,
|
||||
};
|
||||
if (flavor) {
|
||||
body.flavor_id = flavor.selectedRowKeys[0];
|
||||
@ -130,12 +132,6 @@ export class StepCreate extends StepAction {
|
||||
if (keypair) {
|
||||
body.keypair_id = keypair.selectedRowKeys[0];
|
||||
}
|
||||
if (fixedNetwork) {
|
||||
body.fixed_network = fixedNetwork.selectedRowKeys[0];
|
||||
}
|
||||
if (fixedSubnet) {
|
||||
body.fixed_subnet = fixedSubnet.selectedRowKeys[0];
|
||||
}
|
||||
if (this.isEdit) {
|
||||
return this.store.update({ id: this.params.id }, body);
|
||||
}
|
||||
|
@ -58,15 +58,31 @@ export class StepInfo extends Base {
|
||||
return values;
|
||||
}
|
||||
|
||||
clusterNameValidator = (rule, value) => {
|
||||
const pattern = /^[a-zA-Z][a-zA-Z0-9_.-]*$/;
|
||||
if (!value) {
|
||||
// eslint-disable-next-line prefer-promise-reject-errors
|
||||
return Promise.reject('');
|
||||
}
|
||||
if (!pattern.test(value)) {
|
||||
return Promise.reject(
|
||||
t(
|
||||
'The name should start with upper letter or lower letter, characters can only contain "0-9, a-z, A-Z, -, _, ."'
|
||||
)
|
||||
);
|
||||
}
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
||||
get formItems() {
|
||||
return [
|
||||
{
|
||||
name: 'name',
|
||||
label: t('Cluster Name'),
|
||||
type: 'input-name',
|
||||
type: 'input',
|
||||
placeholder: t('Please input cluster name'),
|
||||
isInstance: true,
|
||||
required: true,
|
||||
validator: this.clusterNameValidator,
|
||||
},
|
||||
{
|
||||
name: 'clusterTemplate',
|
||||
|
@ -25,6 +25,20 @@ export class StepLabel extends Base {
|
||||
return t('Labels');
|
||||
}
|
||||
|
||||
get defaultValue() {
|
||||
const values = {};
|
||||
const { context: { clusterTemplate = {} } = {} } = this.props;
|
||||
const { selectedRows = [] } = clusterTemplate;
|
||||
const { labels = {} } = selectedRows[0] || {};
|
||||
values.additionalLabels = Object.keys(labels || {}).map((key) => ({
|
||||
value: {
|
||||
key,
|
||||
value: labels[key],
|
||||
},
|
||||
}));
|
||||
return values;
|
||||
}
|
||||
|
||||
get formItems() {
|
||||
return [
|
||||
{
|
||||
|
@ -80,11 +80,11 @@ export class StepNodeSpec extends Base {
|
||||
}
|
||||
|
||||
get formItems() {
|
||||
const { context: { clusterTemplate = {} } = {} } = this.props;
|
||||
const { context: { clusterTemplate = {}, keypair } = {} } = this.props;
|
||||
const { selectedRows = [] } = clusterTemplate;
|
||||
const { master_flavor_id, flavor_id, keypair_id, selfKeypair } =
|
||||
selectedRows[0] || {};
|
||||
const { initKeyPair } = this.state;
|
||||
const { initKeyPair = keypair } = this.state;
|
||||
const templateHasSelfKeypair = keypair_id && selfKeypair;
|
||||
const templateInitKeypair = {
|
||||
selectedRowKeys: [keypair_id],
|
||||
|
Loading…
Reference in New Issue
Block a user