Merge "fix: fix edit unique project name & etc."
This commit is contained in:
commit
bbef970619
@ -137,6 +137,11 @@ export default class ProjectSelect extends ModalAction {
|
|||||||
title: t('ID'),
|
title: t('ID'),
|
||||||
dataIndex: 'id',
|
dataIndex: 'id',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: t('Enabled'),
|
||||||
|
dataIndex: 'enabled',
|
||||||
|
valueRender: 'yesNo',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
import { inject, observer } from 'mobx-react';
|
import { inject, observer } from 'mobx-react';
|
||||||
import { ModalAction } from 'containers/Action';
|
import { ModalAction } from 'containers/Action';
|
||||||
import globalProjectStore from 'stores/keystone/project';
|
import globalProjectStore from 'stores/keystone/project';
|
||||||
import { regex } from 'utils/validate';
|
|
||||||
import { statusTypes } from 'utils/constants';
|
import { statusTypes } from 'utils/constants';
|
||||||
|
|
||||||
class EditForm extends ModalAction {
|
class EditForm extends ModalAction {
|
||||||
init() {
|
init() {
|
||||||
this.store = globalProjectStore;
|
this.store = globalProjectStore;
|
||||||
|
this.store.fetchList();
|
||||||
}
|
}
|
||||||
|
|
||||||
static id = 'project-edit';
|
static id = 'project-edit';
|
||||||
@ -51,16 +51,13 @@ class EditForm extends ModalAction {
|
|||||||
if (!value) {
|
if (!value) {
|
||||||
return Promise.reject(t('Please input'));
|
return Promise.reject(t('Please input'));
|
||||||
}
|
}
|
||||||
const { nameRegexWithoutChinese } = regex;
|
|
||||||
if (!nameRegexWithoutChinese.test(value)) {
|
|
||||||
return Promise.reject(t('Invalid: Project name can not be chinese'));
|
|
||||||
}
|
|
||||||
const {
|
const {
|
||||||
list: { data },
|
list: { data },
|
||||||
} = this.store;
|
} = this.store;
|
||||||
const { name } = this.item;
|
const nameUsed = data.find(
|
||||||
const nameUsed = data.filter((it) => it.name === value);
|
(i) => i.name === value && i.id !== this.item.id
|
||||||
if (nameUsed[0] && nameUsed[0].name !== name) {
|
);
|
||||||
|
if (nameUsed) {
|
||||||
return Promise.reject(t('Invalid: Project name can not be duplicated'));
|
return Promise.reject(t('Invalid: Project name can not be duplicated'));
|
||||||
}
|
}
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
|
Loading…
Reference in New Issue
Block a user