fix: fix user group name check

User group names in the domain can not be repeated, update the name check when creating and editing user group

Change-Id: I174318b9b3c3dd6639a96a0f45e6d5a9935c06f8
This commit is contained in:
zhangjingwei 2023-11-09 10:13:40 +08:00
parent 663f8a2665
commit 9b9c5248a9
5 changed files with 19 additions and 7 deletions

View File

@ -1333,7 +1333,7 @@
"Invalid: Project name can not be chinese": "Invalid: Project name can not be chinese",
"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 Group names in the domain can not be repeated": "Invalid: User Group names in the domain can not be repeated",
"Invalid: User names in the domain can not be repeated": "Invalid: User names in the domain can not be repeated",
"Ip Address": "Ip Address",
"Iran (Islamic Republic of)": "Iran (Islamic Republic of)",

View File

@ -1333,7 +1333,7 @@
"Invalid: Project name can not be chinese": "잘못됨: 프로젝트 이름은 중국어일 수 없습니다.",
"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 Group names in the domain can not be repeated": "유효하지 않음: 도메인의 사용자 그룹 이름은 반복될 수 없습니다.",
"Invalid: User names in the domain can not be repeated": "유효하지 않음: 도메인의 사용자 이름은 반복될 수 없습니다.",
"Ip Address": "IP 주소",
"Iran (Islamic Republic of)": "",

View File

@ -1333,7 +1333,7 @@
"Invalid: Project name can not be chinese": "无效:项目名称不可使用中文",
"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 Group names in the domain can not be repeated": "无效:域下的用户组名称不能重复",
"Invalid: User names in the domain can not be repeated": "无效:域下的用户名称不能重复",
"Ip Address": "IP地址",
"Iran (Islamic Republic of)": "伊朗",

View File

@ -50,11 +50,17 @@ export class Create extends ModalAction {
if (!value) {
return Promise.reject(t('Please input'));
}
const domainId = this.formRef.current.getFieldValue('domain_id');
if (!domainId) {
return Promise.resolve();
}
const { list: { data = [] } = {} } = this.store;
const nameUsed = data.find((it) => it.name === value);
const nameUsed = data.find(
(it) => it.name === value && it.domain_id === domainId
);
if (nameUsed) {
return Promise.reject(
t('Invalid: User Group name can not be duplicated')
t('Invalid: User Group names in the domain can not be repeated')
);
}
return Promise.resolve();
@ -72,6 +78,7 @@ export class Create extends ModalAction {
validator: this.checkName,
extra: t('User Groups') + t('Name can not be duplicated'),
maxLength: 30,
dependencies: ['domain_id'],
},
domainFormItem,
{

View File

@ -47,10 +47,15 @@ export class EditForm extends ModalAction {
list: { data },
} = this.store;
const { id } = this.item;
const nameUsed = data.find((it) => it.name === value && it.id !== id);
const nameUsed = data.find(
(it) =>
it.name === value &&
it.id !== id &&
it.domain_id === this.item.domain_id
);
if (nameUsed) {
return Promise.reject(
t('Invalid: User Group name can not be duplicated')
t('Invalid: User Group names in the domain can not be repeated')
);
}
return Promise.resolve();