From c2e4c6feafc007a9c8a15529e9532c42f66e26ae Mon Sep 17 00:00:00 2001 From: zhuyue Date: Wed, 1 Sep 2021 18:26:08 +0800 Subject: [PATCH] fix: fix edit unique project name & etc. 1. add 'enabled' column for switch project 2. fix edit unique project name Change-Id: I50f2cf73d21094d10b127cac561d9b1b892efc49 --- src/components/Layout/GlobalHeader/ProjectTable.jsx | 5 +++++ .../identity/containers/Project/actions/Edit.jsx | 13 +++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/components/Layout/GlobalHeader/ProjectTable.jsx b/src/components/Layout/GlobalHeader/ProjectTable.jsx index ef7b6e98..afe906fa 100644 --- a/src/components/Layout/GlobalHeader/ProjectTable.jsx +++ b/src/components/Layout/GlobalHeader/ProjectTable.jsx @@ -137,6 +137,11 @@ export default class ProjectSelect extends ModalAction { title: t('ID'), dataIndex: 'id', }, + { + title: t('Enabled'), + dataIndex: 'enabled', + valueRender: 'yesNo', + }, ], }, ]; diff --git a/src/pages/identity/containers/Project/actions/Edit.jsx b/src/pages/identity/containers/Project/actions/Edit.jsx index 7ac72b9b..85cf2b06 100644 --- a/src/pages/identity/containers/Project/actions/Edit.jsx +++ b/src/pages/identity/containers/Project/actions/Edit.jsx @@ -15,12 +15,12 @@ import { inject, observer } from 'mobx-react'; import { ModalAction } from 'containers/Action'; import globalProjectStore from 'stores/keystone/project'; -import { regex } from 'utils/validate'; import { statusTypes } from 'utils/constants'; class EditForm extends ModalAction { init() { this.store = globalProjectStore; + this.store.fetchList(); } static id = 'project-edit'; @@ -51,16 +51,13 @@ class EditForm extends ModalAction { if (!value) { 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 { list: { data }, } = this.store; - const { name } = this.item; - const nameUsed = data.filter((it) => it.name === value); - if (nameUsed[0] && nameUsed[0].name !== name) { + const nameUsed = data.find( + (i) => i.name === value && i.id !== this.item.id + ); + if (nameUsed) { return Promise.reject(t('Invalid: Project name can not be duplicated')); } return Promise.resolve();