Merge "fix: fix edit unique project name & etc."

This commit is contained in:
Zuul 2021-09-02 03:30:03 +00:00 committed by Gerrit Code Review
commit bbef970619
2 changed files with 10 additions and 8 deletions

View File

@ -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',
},
], ],
}, },
]; ];

View File

@ -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();