fix: fix project name check
Project names in the same domain can not be repeated, fix the name check when creating and editing project Change-Id: I357b4464aad23da3901b05c9940672a04b0a1861
This commit is contained in:
parent
2d6eeec796
commit
2075632e36
@ -1331,7 +1331,7 @@
|
||||
"Invalid: Please input a valid ipv4": "Invalid: Please input a valid ipv4",
|
||||
"Invalid: Please input a valid ipv6.": "Invalid: Please input a valid ipv6.",
|
||||
"Invalid: Project name can not be chinese": "Invalid: Project name can not be chinese",
|
||||
"Invalid: Project name can not be duplicated": "Invalid: Project name can not be duplicated",
|
||||
"Invalid: Project names in the domain can not be repeated": "Invalid: Project names in the domain can not be repeated",
|
||||
"Invalid: Quota value(s) cannot be less than the current usage value(s): { used } used.": "Invalid: Quota value(s) cannot be less than the current usage value(s): { used } used.",
|
||||
"Invalid: User Group name can not be duplicated": "Invalid: User Group name can not be duplicated",
|
||||
"Invalid: User name can not be duplicated": "Invalid: User name can not be duplicated",
|
||||
|
@ -1331,7 +1331,7 @@
|
||||
"Invalid: Please input a valid ipv4": "잘못됨: 유효한 ipv4를 입력하십시오",
|
||||
"Invalid: Please input a valid ipv6.": "잘못됨: 유효한 ipv6을 입력하십시오.",
|
||||
"Invalid: Project name can not be chinese": "잘못됨: 프로젝트 이름은 중국어일 수 없습니다.",
|
||||
"Invalid: Project name can not be duplicated": "잘못됨: 프로젝트 이름은 중복될 수 없습니다.",
|
||||
"Invalid: Project names in the domain can not be repeated": "유효하지 않음: 도메인의 프로젝트 이름은 반복될 수 없습니다.",
|
||||
"Invalid: Quota value(s) cannot be less than the current usage value(s): { used } used.": "잘못됨: 할당량 값은 현재 사용 값보다 작을 수 없습니다: { used } 사용됨.",
|
||||
"Invalid: User Group name can not be duplicated": "잘못됨: 사용자 그룹 이름은 중복될 수 없습니다.",
|
||||
"Invalid: User name can not be duplicated": "잘못됨: 사용자 이름은 중복될 수 없습니다.",
|
||||
|
@ -1331,7 +1331,7 @@
|
||||
"Invalid: Please input a valid ipv4": "无效:请输入有效的IPV4",
|
||||
"Invalid: Please input a valid ipv6.": "无效:请输入有效的IPV6",
|
||||
"Invalid: Project name can not be chinese": "无效:项目名称不可使用中文",
|
||||
"Invalid: Project name can not be duplicated": "无效:项目名称不可重复",
|
||||
"Invalid: Project names in the domain can not be repeated": "无效:域下的项目名称不能重复",
|
||||
"Invalid: Quota value(s) cannot be less than the current usage value(s): { used } used.": "无效:配额必须大于已使用数量{ used }且为整数",
|
||||
"Invalid: User Group name can not be duplicated": "无效:用户组名称不可重复",
|
||||
"Invalid: User name can not be duplicated": "无效:用户名称不可重复",
|
||||
|
@ -74,12 +74,20 @@ export class Create extends ModalAction {
|
||||
if (!nameRegexWithoutChinese.test(value)) {
|
||||
return Promise.reject(t('Invalid: Project name can not be chinese'));
|
||||
}
|
||||
const domainId = this.formRef.current.getFieldValue('domain_id');
|
||||
if (!domainId) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
const {
|
||||
list: { data },
|
||||
} = this.projectStore;
|
||||
const nameUsed = data.filter((it) => it.name === value);
|
||||
const nameUsed = data.filter(
|
||||
(it) => it.name === value && it.domain_id === domainId
|
||||
);
|
||||
if (nameUsed[0]) {
|
||||
return Promise.reject(t('Invalid: Project name can not be duplicated'));
|
||||
return Promise.reject(
|
||||
t('Invalid: Project names in the domain can not be repeated')
|
||||
);
|
||||
}
|
||||
return Promise.resolve();
|
||||
};
|
||||
@ -96,6 +104,7 @@ export class Create extends ModalAction {
|
||||
validator: this.checkName,
|
||||
extra: t('Project') + t('Name can not be duplicated'),
|
||||
maxLength: 30,
|
||||
dependencies: ['domain_id'],
|
||||
},
|
||||
domainFormItem,
|
||||
{
|
||||
|
@ -54,10 +54,15 @@ export class EditForm extends ModalAction {
|
||||
list: { data },
|
||||
} = this.store;
|
||||
const nameUsed = data.find(
|
||||
(i) => i.name === value && i.id !== this.item.id
|
||||
(i) =>
|
||||
i.name === value &&
|
||||
i.id !== this.item.id &&
|
||||
i.domain_id === this.item.domain_id
|
||||
);
|
||||
if (nameUsed) {
|
||||
return Promise.reject(t('Invalid: Project name can not be duplicated'));
|
||||
return Promise.reject(
|
||||
t('Invalid: Project names in the domain can not be repeated')
|
||||
);
|
||||
}
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user