From 92b91ba0676de7b45493ac0bdbb24bd3f6add004 Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Mon, 19 Sep 2022 13:51:06 +0800 Subject: [PATCH] fix: fix edit image 1. Set the min_disk/min_ram to be required when edit image, and fix the zero min_ram value in the request body. 2. Set the hw_cpu_policy/hw_cpu_thread_policy to be required when create/edit image, to avoid loss the value. Closes-Bug: #1990092 Change-Id: I58b42824d041a4b615e6db31ddcef23da8a8494c --- src/locales/en.json | 1 + src/locales/zh.json | 1 + .../compute/containers/Image/actions/Create.jsx | 2 ++ src/pages/compute/containers/Image/actions/Edit.jsx | 12 ++++++++++-- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 03550626..121aedf4 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1132,6 +1132,7 @@ "If nova-compute on the host is disabled, it will be forbidden to be selected as the target host.": "If nova-compute on the host is disabled, it will be forbidden to be selected as the target host.", "If set then all tenants will be able to see this share.": "If set then all tenants will be able to see this share.", "If the capacity of the disk is large,the type modify operation may takes several hours. Please be cautious.": "If the capacity of the disk is large,the type modify operation may takes several hours. Please be cautious.", + "If the value is set to 0, it means unlimited": "If the value is set to 0, it means unlimited", "If the volume associated with the snapshot has changed the volume type, please modify this option manually; if the volume associated with the snapshot keeps the volume type unchanged, please ignore this option. (no need to change).": "If the volume associated with the snapshot has changed the volume type, please modify this option manually; if the volume associated with the snapshot keeps the volume type unchanged, please ignore this option. (no need to change).", "If you are not authorized to access any project, or if the project you are involved in has been deleted or disabled, contact the platform administrator to reassign the project": "If you are not authorized to access any project, or if the project you are involved in has been deleted or disabled, contact the platform administrator to reassign the project", "If you are not sure which authentication method to use, please contact your administrator.": "If you are not sure which authentication method to use, please contact your administrator.", diff --git a/src/locales/zh.json b/src/locales/zh.json index 9d0dff7f..0b44d395 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -1132,6 +1132,7 @@ "If nova-compute on the host is disabled, it will be forbidden to be selected as the target host.": "如果计算节点上的nova-compute被禁用,将禁止其作为目标节点。", "If set then all tenants will be able to see this share.": "如果设置,则所有租户都将能够看到此共享。", "If the capacity of the disk is large,the type modify operation may takes several hours. Please be cautious.": "如果云硬盘容量较大,修改云硬盘类型可能需要花费几个小时,请您谨慎操作。", + "If the value is set to 0, it means unlimited": "如果值为0,则表示无限制", "If the volume associated with the snapshot has changed the volume type, please modify this option manually; if the volume associated with the snapshot keeps the volume type unchanged, please ignore this option. (no need to change).": "若快照关联的云硬盘修改过云硬盘类型,请手动修改此选项;若快照关联的云硬盘保持云硬盘类型不变,请忽略此选项(不需要做变更)。", "If you are not authorized to access any project, or if the project you are involved in has been deleted or disabled, contact the platform administrator to reassign the project": "您未被授权访问任何项目,或您参与中的项目已被删除或禁用,可联系平台管理员重新分配项目", "If you are not sure which authentication method to use, please contact your administrator.": "如果您不确定使用哪种认证方式,请联系管理员。", diff --git a/src/pages/compute/containers/Image/actions/Create.jsx b/src/pages/compute/containers/Image/actions/Create.jsx index 0d211b34..13effb5a 100644 --- a/src/pages/compute/containers/Image/actions/Create.jsx +++ b/src/pages/compute/containers/Image/actions/Create.jsx @@ -321,6 +321,7 @@ export class CreateForm extends FormAction { type: 'select', options: getOptionsWithNoSet(cpuPolicyList), hidden: !more, + required: more, }, { name: 'hw_cpu_thread_policy', @@ -328,6 +329,7 @@ export class CreateForm extends FormAction { type: 'select', options: getOptionsWithNoSet(cpuThreadPolicyList), hidden: !more, + required: more, }, ]; } diff --git a/src/pages/compute/containers/Image/actions/Edit.jsx b/src/pages/compute/containers/Image/actions/Edit.jsx index 8aabf5b5..fa4e7528 100644 --- a/src/pages/compute/containers/Image/actions/Edit.jsx +++ b/src/pages/compute/containers/Image/actions/Edit.jsx @@ -16,7 +16,7 @@ import { inject, observer } from 'mobx-react'; import { ModalAction } from 'containers/Action'; import globalImageStore from 'stores/glance/image'; import { imageOS, isOwner } from 'resources/glance/image'; -import { has, get } from 'lodash'; +import { has, get, isNumber } from 'lodash'; import { isActive } from 'resources/nova/instance'; import { NoSetValue, getOptionsWithNoSet } from 'utils/index'; import { cpuPolicyList, cpuThreadPolicyList } from 'resources/nova/flavor'; @@ -93,6 +93,7 @@ export class Edit extends ModalAction { get formItems() { const { more } = this.state; + const zeroTip = t('If the value is set to 0, it means unlimited'); return [ { name: 'name', @@ -130,6 +131,8 @@ export class Edit extends ModalAction { min: 0, max: 500, display: this.enableCinder, + required: this.enableCinder, + extra: this.enableCinder ? zeroTip : null, }, { name: 'min_ram', @@ -137,6 +140,8 @@ export class Edit extends ModalAction { type: 'input-int', min: 0, max: 500, + required: true, + extra: zeroTip, }, { name: 'visibility', @@ -179,6 +184,7 @@ export class Edit extends ModalAction { type: 'select', options: getOptionsWithNoSet(cpuPolicyList), hidden: !more, + required: more, }, { name: 'hw_cpu_thread_policy', @@ -186,6 +192,7 @@ export class Edit extends ModalAction { type: 'select', options: getOptionsWithNoSet(cpuThreadPolicyList), hidden: !more, + required: more, }, ]; } @@ -198,6 +205,7 @@ export class Edit extends ModalAction { hw_cpu_policy, hw_cpu_thread_policy, min_ram, + min_disk, ...rest } = values; const newValues = { @@ -205,7 +213,7 @@ export class Edit extends ModalAction { visibility: visibility ? 'public' : 'private', ...rest, }; - if (min_ram) { + if (isNumber(min_ram)) { newValues.min_ram = min_ram * 1024; } if (hw_cpu_policy !== NoSetValue) {