diff --git a/docs/en/develop/3-6-FormAction-introduction.md b/docs/en/develop/3-6-FormAction-introduction.md index b7e8fcca..c4dd34f0 100644 --- a/docs/en/develop/3-6-FormAction-introduction.md +++ b/docs/en/develop/3-6-FormAction-introduction.md @@ -175,7 +175,6 @@ English | [Chinese](../../zh/develop/3-6-FormAction-introduction.md) type: 'input', placeholder: t('Please input name'), required: true, - help: t('The name cannot be modified after creation'), }, { name: 'description', @@ -349,7 +348,7 @@ English | [Chinese](../../zh/develop/3-6-FormAction-introduction.md) - `labelCol` - Configure the layout of the labels on the left side of the form - - The default value is + - The default value is ```javascript get labelCol() { @@ -373,7 +372,7 @@ English | [Chinese](../../zh/develop/3-6-FormAction-introduction.md) - `wrapperCol` - Configure the layout of the content on the right side of the form - - The default value is + - The default value is ```javascript get wrapperCol() { diff --git a/docs/zh/develop/3-6-FormAction-introduction.md b/docs/zh/develop/3-6-FormAction-introduction.md index d719f243..3c7aedc1 100644 --- a/docs/zh/develop/3-6-FormAction-introduction.md +++ b/docs/zh/develop/3-6-FormAction-introduction.md @@ -175,7 +175,6 @@ type: 'input', placeholder: t('Please input name'), required: true, - help: t('The name cannot be modified after creation'), }, { name: 'description', diff --git a/releasenotes/notes/Support-Edit-Domain-Name-874d87160550c8f0.yaml b/releasenotes/notes/Support-Edit-Domain-Name-874d87160550c8f0.yaml new file mode 100644 index 00000000..c7aaab2c --- /dev/null +++ b/releasenotes/notes/Support-Edit-Domain-Name-874d87160550c8f0.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Support edit domain name: + + * Support edit domain name when editing domain. diff --git a/src/locales/en.json b/src/locales/en.json index 7e4926c4..4095478e 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -2463,7 +2463,6 @@ "The maximum batch size is {size}, that is, the size of the port range cannot exceed {size}.": "The maximum batch size is {size}, that is, the size of the port range cannot exceed {size}.", "The maximum transmission unit (MTU) value to address fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6.": "The maximum transmission unit (MTU) value to address fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6.", "The min size is {size} GiB": "The min size is {size} GiB", - "The name cannot be modified after creation": "The name cannot be modified after creation", "The name of the physical network to which a port is connected": "The name of the physical network to which a port is connected", "The name should be end with \".\"": "The name should be end with \".\"", "The name should contain letter or number, the length is 1 to 16, characters can only contain \"0-9, a-z, A-Z, -, _.\"": "The name should contain letter or number, the length is 1 to 16, characters can only contain \"0-9, a-z, A-Z, -, _.\"", diff --git a/src/locales/ko-kr.json b/src/locales/ko-kr.json index b5bf09d8..7493f89f 100644 --- a/src/locales/ko-kr.json +++ b/src/locales/ko-kr.json @@ -2463,7 +2463,6 @@ "The maximum batch size is {size}, that is, the size of the port range cannot exceed {size}.": "최대 batch 크기는 {size}입니다. 즉, 포트 범위의 크기는 {size}를 초과할 수 없습니다.", "The maximum transmission unit (MTU) value to address fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6.": "분할을 처리하기 위한 최대 전송 단위(MTU) 값입니다. IPv4의 경우 최소값은 68이며, IPv6의 경우 최소값은 1280입니다.", "The min size is {size} GiB": "최소 크기는 {size} GiB입니다.", - "The name cannot be modified after creation": "생성 후에는 이름을 수정할 수 없습니다.", "The name of the physical network to which a port is connected": "포트가 연결된 물리 네트워크의 이름", "The name should be end with \".\"": "", "The name should contain letter or number, the length is 1 to 16, characters can only contain \"0-9, a-z, A-Z, -, _.\"": "이름은 문자나 숫자를 포함해야 하고, 길이는 1~16자 사이여야 하며, 문자는 \"0-9, a-z, A-Z, -, _.\"만 포함할 수 있습니다.", diff --git a/src/locales/zh-hans.json b/src/locales/zh-hans.json index e2d438b1..16428b1f 100644 --- a/src/locales/zh-hans.json +++ b/src/locales/zh-hans.json @@ -2463,7 +2463,6 @@ "The maximum batch size is {size}, that is, the size of the port range cannot exceed {size}.": "批量的上限为{size}个,即端口范围大小不可超过{size}。", "The maximum transmission unit (MTU) value to address fragmentation. Minimum value is 68 for IPv4, and 1280 for IPv6.": "地址片段的最大传输单位。IPv4最小68,IPv6最小1280。", "The min size is {size} GiB": "最小内存为 {size} GiB", - "The name cannot be modified after creation": "名称创建后不可修改", "The name of the physical network to which a port is connected": "端口连接到的物理网络的名称", "The name should be end with \".\"": "", "The name should contain letter or number, the length is 1 to 16, characters can only contain \"0-9, a-z, A-Z, -, _.\"": "名称应包含字母或数字,长度为 1 到 16,且字符只能包含“0-9、a-z、A-Z、-、_”。", diff --git a/src/pages/identity/containers/Domain/actions/Create.jsx b/src/pages/identity/containers/Domain/actions/Create.jsx index b9d401ff..0240d02a 100644 --- a/src/pages/identity/containers/Domain/actions/Create.jsx +++ b/src/pages/identity/containers/Domain/actions/Create.jsx @@ -57,7 +57,6 @@ export class Create extends ModalAction { type: 'input', placeholder: t('Please input name'), required: true, - extra: t('The name cannot be modified after creation'), validator: this.nameValidator, }, // { diff --git a/src/pages/identity/containers/Domain/actions/Edit.jsx b/src/pages/identity/containers/Domain/actions/Edit.jsx index b6974da6..48844375 100644 --- a/src/pages/identity/containers/Domain/actions/Edit.jsx +++ b/src/pages/identity/containers/Domain/actions/Edit.jsx @@ -15,10 +15,12 @@ import { inject, observer } from 'mobx-react'; import { ModalAction } from 'containers/Action'; import globalDomainStore from 'stores/keystone/domain'; +import { toJS } from 'mobx'; export class Edit extends ModalAction { init() { this.store = globalDomainStore; + this.store.fetchList(); } static id = 'domain-edit'; @@ -41,6 +43,22 @@ export class Edit extends ModalAction { }; } + get currentList() { + const { list: { data = [] } = {} } = this.store; + return data; + } + + nameValidator = (rule, value) => { + const data = toJS(this.currentList); + if (data.find((d) => d.name === value && d.id !== this.item.id)) { + return Promise.reject( + new Error(t('Invalid: Domain name cannot be duplicated')) + ); + } + + return Promise.resolve(true); + }; + get formItems() { return [ { @@ -48,9 +66,8 @@ export class Edit extends ModalAction { label: t('Name'), type: 'input', placeholder: t('Please input name'), - // required: true, - help: t('The name cannot be modified after creation'), - disabled: true, + required: true, + validator: this.nameValidator, }, { name: 'description', diff --git a/src/stores/keystone/domain.js b/src/stores/keystone/domain.js index 51c291ba..81b5bd6e 100644 --- a/src/stores/keystone/domain.js +++ b/src/stores/keystone/domain.js @@ -95,9 +95,9 @@ export class DomainStore extends Base { } @action - async edit({ id, description }) { + async edit({ id, description, name }) { const reqBody = { - domain: { description }, + domain: { description, name }, }; return this.submitting(this.client.patch(id, reqBody)); }