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 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 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, 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, \"-'_()[].:^\".",
|
"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 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 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, 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, \"'-_()[].:^”。",
|
"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() {
|
get subnetList() {
|
||||||
const { fixedNetwork: { selectedRowKeys = [] } = {} } = this.state;
|
const selectedRowKeys =
|
||||||
|
this.props.context?.fixedNetwork?.selectedRowKeys || [];
|
||||||
return (this.subnetNetworkStore.list.data || []).filter(
|
return (this.subnetNetworkStore.list.data || []).filter(
|
||||||
(it) => selectedRowKeys[0] === it.network_id
|
(it) => selectedRowKeys[0] === it.network_id
|
||||||
);
|
);
|
||||||
@ -75,10 +76,6 @@ export class StepNetwork extends Base {
|
|||||||
return acceptedDrivers;
|
return acceptedDrivers;
|
||||||
}
|
}
|
||||||
|
|
||||||
get nameForStateUpdate() {
|
|
||||||
return ['fixedNetwork'];
|
|
||||||
}
|
|
||||||
|
|
||||||
get defaultValue() {
|
get defaultValue() {
|
||||||
let values = {};
|
let values = {};
|
||||||
|
|
||||||
@ -112,20 +109,14 @@ export class StepNetwork extends Base {
|
|||||||
floating_ip_enabled,
|
floating_ip_enabled,
|
||||||
};
|
};
|
||||||
if (fixed_network) {
|
if (fixed_network) {
|
||||||
values.fixedNetwork = {
|
values.fixedNetwork = this.props.context.fixedNetwork || {
|
||||||
selectedRowKeys: [fixed_network],
|
selectedRowKeys: [fixed_network],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (fixed_subnet) {
|
if (fixed_subnet) {
|
||||||
const { subnetInitValue } = this.state;
|
values.fixedSubnet = {
|
||||||
|
selectedRowKeys: [fixed_subnet],
|
||||||
if (subnetInitValue) {
|
};
|
||||||
values.fixedSubnet = subnetInitValue;
|
|
||||||
} else {
|
|
||||||
values.fixedSubnet = {
|
|
||||||
selectedRowKeys: [fixed_subnet],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +125,6 @@ export class StepNetwork extends Base {
|
|||||||
|
|
||||||
get formItems() {
|
get formItems() {
|
||||||
const { extra: { network_driver } = {} } = this.props;
|
const { extra: { network_driver } = {} } = this.props;
|
||||||
const { subnetInitValue } = this.state;
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -208,18 +198,10 @@ export class StepNetwork extends Base {
|
|||||||
],
|
],
|
||||||
columns: networkColumns(this),
|
columns: networkColumns(this),
|
||||||
onChange: (value) => {
|
onChange: (value) => {
|
||||||
this.setState(
|
this.updateContext({
|
||||||
{
|
fixedNetwork: value,
|
||||||
fixedNetwork: value,
|
});
|
||||||
subnetInitValue: {
|
this.updateFormValue('fixedSubnet', null);
|
||||||
selectedRowKeys: [],
|
|
||||||
selectedRows: [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
() => {
|
|
||||||
this.formRef.current.resetFields(['fixedSubnet']);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -227,7 +209,6 @@ export class StepNetwork extends Base {
|
|||||||
label: t('Fixed Subnet'),
|
label: t('Fixed Subnet'),
|
||||||
type: 'select-table',
|
type: 'select-table',
|
||||||
data: this.subnetList,
|
data: this.subnetList,
|
||||||
initValue: subnetInitValue,
|
|
||||||
filterParams: [
|
filterParams: [
|
||||||
{
|
{
|
||||||
label: t('Name'),
|
label: t('Name'),
|
||||||
|
@ -114,9 +114,11 @@ export class StepCreate extends StepAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const body = {
|
const body = {
|
||||||
|
...rest,
|
||||||
labels: requestLabels,
|
labels: requestLabels,
|
||||||
external_network_id: externalNetwork.selectedRowKeys[0],
|
external_network_id: externalNetwork.selectedRowKeys[0],
|
||||||
...rest,
|
fixed_network: fixedNetwork ? fixedNetwork.selectedRowKeys[0] : null,
|
||||||
|
fixed_subnet: fixedSubnet ? fixedSubnet.selectedRowKeys[0] : null,
|
||||||
};
|
};
|
||||||
if (flavor) {
|
if (flavor) {
|
||||||
body.flavor_id = flavor.selectedRowKeys[0];
|
body.flavor_id = flavor.selectedRowKeys[0];
|
||||||
@ -130,12 +132,6 @@ export class StepCreate extends StepAction {
|
|||||||
if (keypair) {
|
if (keypair) {
|
||||||
body.keypair_id = keypair.selectedRowKeys[0];
|
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) {
|
if (this.isEdit) {
|
||||||
return this.store.update({ id: this.params.id }, body);
|
return this.store.update({ id: this.params.id }, body);
|
||||||
}
|
}
|
||||||
|
@ -58,15 +58,31 @@ export class StepInfo extends Base {
|
|||||||
return values;
|
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() {
|
get formItems() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: 'name',
|
name: 'name',
|
||||||
label: t('Cluster Name'),
|
label: t('Cluster Name'),
|
||||||
type: 'input-name',
|
type: 'input',
|
||||||
placeholder: t('Please input cluster name'),
|
placeholder: t('Please input cluster name'),
|
||||||
isInstance: true,
|
|
||||||
required: true,
|
required: true,
|
||||||
|
validator: this.clusterNameValidator,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'clusterTemplate',
|
name: 'clusterTemplate',
|
||||||
|
@ -25,6 +25,20 @@ export class StepLabel extends Base {
|
|||||||
return t('Labels');
|
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() {
|
get formItems() {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -38,4 +52,4 @@ export class StepLabel extends Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default inject('rootStore')(observer(StepLabel));
|
export default inject('rootStore')(observer(StepLabel));
|
||||||
|
@ -80,11 +80,11 @@ export class StepNodeSpec extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get formItems() {
|
get formItems() {
|
||||||
const { context: { clusterTemplate = {} } = {} } = this.props;
|
const { context: { clusterTemplate = {}, keypair } = {} } = this.props;
|
||||||
const { selectedRows = [] } = clusterTemplate;
|
const { selectedRows = [] } = clusterTemplate;
|
||||||
const { master_flavor_id, flavor_id, keypair_id, selfKeypair } =
|
const { master_flavor_id, flavor_id, keypair_id, selfKeypair } =
|
||||||
selectedRows[0] || {};
|
selectedRows[0] || {};
|
||||||
const { initKeyPair } = this.state;
|
const { initKeyPair = keypair } = this.state;
|
||||||
const templateHasSelfKeypair = keypair_id && selfKeypair;
|
const templateHasSelfKeypair = keypair_id && selfKeypair;
|
||||||
const templateInitKeypair = {
|
const templateInitKeypair = {
|
||||||
selectedRowKeys: [keypair_id],
|
selectedRowKeys: [keypair_id],
|
||||||
|
Loading…
Reference in New Issue
Block a user