diff --git a/src/locales/en.json b/src/locales/en.json index 77d634b2..57d81b6a 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -134,6 +134,7 @@ "Auto": "Auto", "Auto Inspect": "Auto Inspect", "Auto allocate mac address": "Auto allocate mac address", + "Automatic backup": "Automatic backup", "Automatically Assigned Address": "Automatically Assigned Address", "Availability Zone": "Availability Zone", "Availability Zone Hints": "Availability Zone Hints", @@ -808,6 +809,7 @@ "Instance Info": "Instance Info", "Instance Status": "Instance Status", "Instances": "Instances", + "Instances \"{ name }\" are locked, can not delete them.": "Instances \"{ name }\" are locked, can not delete them.", "Interface": "Interface", "Interface Info": "Interface Info", "Interface Name:": "Interface Name:", @@ -932,6 +934,7 @@ "Manager user": "Manager user", "Manager user group": "Manager user group", "Manu": "Manu", + "Manual backup": "Manual backup", "Manual input": "Manual input", "Manually Assigned Address": "Manually Assigned Address", "Manually Specify": "Manually Specify", @@ -1720,15 +1723,12 @@ "X86 Architecture": "X86 Architecture", "YAML File": "YAML File", "Yes": "Yes", - "You are not allowed to delete instance \"{ name }\".": "You are not allowed to delete instance \"{ name }\".", "You are not allowed to delete router \"{ name }\".": "You are not allowed to delete router \"{ name }\".", "You are not allowed to delete snapshot \"{ name }\", which is used by creating volume \"{volumes}\".": "You are not allowed to delete snapshot \"{ name }\", which is used by creating volume \"{volumes}\".", "You are not allowed to delete snapshot \"{ name }\".": "You are not allowed to delete snapshot \"{ name }\".", "You are not allowed to jump to the console.": "You are not allowed to jump to the console.", - "You are not allowed to stop instance \"{ name }\".": "You are not allowed to stop instance \"{ name }\".", "You are not allowed to { action } \"{ name }\".": "You are not allowed to { action } \"{ name }\".", "You are not allowed to { action } {name}.": "You are not allowed to { action } {name}.", - "You are not allowed to {action} \"{ name }\".": "You are not allowed to {action} \"{ name }\".", "You are not allowed to {action}, instance: {name}.": "You are not allowed to {action}, instance: {name}.", "You are not allowed to {action}.": "You are not allowed to {action}.", "You are trying to edit a network that not belong to current project. Please do not continue unless you are quit sure what you are doing.": "You are trying to edit a network that not belong to current project. Please do not continue unless you are quit sure what you are doing.", diff --git a/src/locales/zh.json b/src/locales/zh.json index 0dd1c357..abf0a7c5 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -134,6 +134,7 @@ "Auto": "自动", "Auto Inspect": "自动检测", "Auto allocate mac address": "自动分配MAC地址", + "Automatic backup": "自动备份", "Automatically Assigned Address": "自动分配地址", "Availability Zone": "可用域", "Availability Zone Hints": "预期可用域", @@ -808,6 +809,7 @@ "Instance Info": "云主机信息", "Instance Status": "云主机状态", "Instances": "云主机", + "Instances \"{ name }\" are locked, can not delete them.": "云主机\"{ name }\"被锁定,无法删除。", "Interface": "网卡", "Interface Info": "接口信息", "Interface Name:": "网卡ID:", @@ -932,6 +934,7 @@ "Manager user": "管理用户", "Manager user group": "管理用户组", "Manu": "手动", + "Manual backup": "手动备份", "Manual input": "手动输入", "Manually Assigned Address": "手动分配地址", "Manually Specify": "手动指定", @@ -1720,15 +1723,12 @@ "X86 Architecture": "X86架构", "YAML File": "YAML文件", "Yes": "是", - "You are not allowed to delete instance \"{ name }\".": "无法删除云主机\"{ name }\"。", "You are not allowed to delete router \"{ name }\".": "无法删除路由器\"{ name }\"。", "You are not allowed to delete snapshot \"{ name }\", which is used by creating volume \"{volumes}\".": "无法删除创建了云硬盘 \"{volumes}\" 的快照 \"{ name }\"。", "You are not allowed to delete snapshot \"{ name }\".": "无法删除快照\"{ name }\"。", "You are not allowed to jump to the console.": "无法跳转到控制台。", - "You are not allowed to stop instance \"{ name }\".": "无法关闭云主机\"{ name }\"。", "You are not allowed to { action } \"{ name }\".": "无法{ action }\"{ name }\"。", "You are not allowed to { action } {name}.": "无法{ action }{ name }。", - "You are not allowed to {action} \"{ name }\".": "无法{ action }\"{ name }\"。", "You are not allowed to {action}, instance: {name}.": "无法{ action }, 实例名称:{ name }。", "You are not allowed to {action}.": "无法{ action }。", "You are trying to edit a network that not belong to current project. Please do not continue unless you are quit sure what you are doing.": "你正在尝试编辑非当前 project 的 network 资源,除非你非常确认自己在做什么,否则请不要继续。", diff --git a/src/pages/compute/containers/Instance/actions/Delete.jsx b/src/pages/compute/containers/Instance/actions/Delete.jsx index 441a564b..fa19308b 100644 --- a/src/pages/compute/containers/Instance/actions/Delete.jsx +++ b/src/pages/compute/containers/Instance/actions/Delete.jsx @@ -76,13 +76,14 @@ export default class DeleteAction extends ConfirmAction { }; performErrorMsg = (failedItems) => { - const instance = isArray(failedItems) ? failedItems[0] : failedItems; - let errorMsg = t('You are not allowed to delete instance "{ name }".', { - name: instance.name, + const instances = isArray(failedItems) ? failedItems : [failedItems]; + const names = this.getName(instances); + let errorMsg = t('Instance "{ name }" is locked, can not delete it.', { + names, }); - if (!isNotLocked(instance)) { - errorMsg = t('Instance "{ name }" is locked, can not delete it.', { - name: instance.name, + if (names.length > 1) { + errorMsg = t('Instances "{ name }" are locked, can not delete them.', { + names, }); } return errorMsg; diff --git a/src/pages/compute/containers/Instance/actions/Reboot.jsx b/src/pages/compute/containers/Instance/actions/Reboot.jsx index 8fa16e3e..0d60a844 100644 --- a/src/pages/compute/containers/Instance/actions/Reboot.jsx +++ b/src/pages/compute/containers/Instance/actions/Reboot.jsx @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import React from 'react'; import { ConfirmAction } from 'containers/Action'; import { isArray } from 'lodash'; import { isNotLockedOrAdmin, checkStatus } from 'resources/instance'; @@ -52,22 +53,28 @@ export default class RebootAction extends ConfirmAction { }; performErrorMsg = (failedItems) => { - const instance = isArray(failedItems) ? failedItems[0] : failedItems; - let errorMsg = t('You are not allowed to { action } "{ name }".', { - action: this.actionName, - name: instance.name, - }); - if (!this.canReboot(instance)) { - errorMsg = t( - 'Instance "{ name }" status is not in active or shutoff, can not reboot it.', - { name: instance.name } + const items = isArray(failedItems) ? failedItems : [failedItems]; + const statusErrorItems = items.filter((it) => !this.canReboot(it)); + const lockedItems = items.filter( + (it) => !isNotLockedOrAdmin(it, this.isAdminPage) + ); + const msgs = []; + if (statusErrorItems.length) { + msgs.push( + t( + 'Instance "{ name }" status is not in active or shutoff, can not reboot it.', + { name: this.getName(statusErrorItems) } + ) ); - } else if (!isNotLockedOrAdmin(instance, this.isAdminPage)) { - errorMsg = t('Instance "{ name }" is locked, can not reboot it.', { - name: instance.name, - }); } - return errorMsg; + if (lockedItems.length) { + msgs.push( + t('Instance "{ name }" is locked, can not reboot it.', { + name: this.getName(lockedItems), + }) + ); + } + return msgs.map((it) =>

{it}

); }; onSubmit = (item) => { diff --git a/src/pages/compute/containers/Instance/actions/SoftDelete.jsx b/src/pages/compute/containers/Instance/actions/SoftDelete.jsx index de70a15b..892ffd4f 100644 --- a/src/pages/compute/containers/Instance/actions/SoftDelete.jsx +++ b/src/pages/compute/containers/Instance/actions/SoftDelete.jsx @@ -126,19 +126,19 @@ export default class SoftDelete extends ConfirmAction { }; performErrorMsg = (failedItems) => { - const instance = isArray(failedItems) ? failedItems[0] : failedItems; - let errorMsg = t('You are not allowed to delete instance "{ name }".', { - name: instance.name, + const items = isArray(failedItems) ? failedItems : [failedItems]; + const name = this.getName(items); + let errorMsg = t('Instance "{ name }" is locked, can not delete it.', { + name, }); - if (!isNotLockedOrAdmin(instance, this.isAdminPage)) { - errorMsg = t('Instance "{ name }" is locked, can not delete it.', { - name: instance.name, + if (items.length > 1) { + errorMsg = t('Instances "{ name }" are locked, can not delete them.', { + name, }); } return errorMsg; }; - // eslint-disable-next-line no-unused-vars onSubmit = (item) => { const { id, isHardDeleted = false, expiredTime } = item || this.item; if (isHardDeleted) { diff --git a/src/pages/compute/containers/Instance/actions/SoftReboot.jsx b/src/pages/compute/containers/Instance/actions/SoftReboot.jsx index 8418a1e0..9fc67f9e 100644 --- a/src/pages/compute/containers/Instance/actions/SoftReboot.jsx +++ b/src/pages/compute/containers/Instance/actions/SoftReboot.jsx @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import React from 'react'; import { ConfirmAction } from 'containers/Action'; import { isArray } from 'lodash'; import { @@ -56,22 +57,27 @@ export default class SoftRebootAction extends ConfirmAction { }; performErrorMsg = (failedItems) => { - const instance = isArray(failedItems) ? failedItems[0] : failedItems; - let errorMsg = t('You are not allowed to { action } "{ name }".', { - action: this.actionName, - name: instance.name, - }); - if (!this.isActive(instance)) { - errorMsg = t( - 'Instance "{ name }" status is not active, can not soft reboot it.', - { name: instance.name } + const items = isArray(failedItems) ? failedItems : [failedItems]; + const notActiveItems = items.filter((it) => !this.isActive(it)); + const lockedItems = items.filter( + (it) => !isNotLockedOrAdmin(it, this.isAdminPage) + ); + const msgs = []; + if (notActiveItems.length) { + msgs.push( + t('Instance "{ name }" status is not active, can not soft reboot it.', { + name: this.getName(notActiveItems), + }) ); - } else if (!isNotLockedOrAdmin(instance, this.isAdminPage)) { - errorMsg = t('Instance "{ name }" is locked, can not soft reboot it.', { - name: instance.name, - }); } - return errorMsg; + if (lockedItems.length) { + msgs.push( + t('Instance "{ name }" is locked, can not soft reboot it.', { + name: this.getName(lockedItems), + }) + ); + } + return msgs.map((it) =>

{it}

); }; onSubmit = (item) => { diff --git a/src/pages/compute/containers/Instance/actions/Start.jsx b/src/pages/compute/containers/Instance/actions/Start.jsx index 184e6a3f..4643723a 100644 --- a/src/pages/compute/containers/Instance/actions/Start.jsx +++ b/src/pages/compute/containers/Instance/actions/Start.jsx @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import React from 'react'; import { ConfirmAction } from 'containers/Action'; import { isArray } from 'lodash'; import { isNotLockedOrAdmin, checkStatus } from 'resources/instance'; @@ -56,22 +57,25 @@ export default class StartAction extends ConfirmAction { }; performErrorMsg = (failedItems) => { - const instance = isArray(failedItems) ? failedItems[0] : failedItems; - let errorMsg = t('You are not allowed to {action} "{ name }".', { - action: this.actionName, - name: instance.name, - }); - if (!isNotLockedOrAdmin(instance, this.isAdminPage)) { - errorMsg = t('Instance "{ name }" is locked, can not start it.', { - name: instance.name, - }); - } else if (!this.canStart(instance)) { - errorMsg = t( - 'Instance "{ name }" status is not shutoff, can not start it.', - { name: instance.name } + const items = isArray(failedItems) ? failedItems : [failedItems]; + const lockedItems = items.filter((it) => !isNotLockedOrAdmin(it)); + const statusErrorItems = items.filter((it) => !this.canStart(it)); + const msgs = []; + if (lockedItems.length) { + msgs.push( + t('Instance "{ name }" is locked, can not start it.', { + name: this.getName(lockedItems), + }) ); } - return errorMsg; + if (statusErrorItems.length) { + msgs.push( + t('Instance "{ name }" status is not shutoff, can not start it.', { + name: this.getName(statusErrorItems), + }) + ); + } + return msgs.map((it) =>

{it}

); }; onSubmit = (item) => { diff --git a/src/pages/compute/containers/Instance/actions/Stop.jsx b/src/pages/compute/containers/Instance/actions/Stop.jsx index 5542190f..17384499 100644 --- a/src/pages/compute/containers/Instance/actions/Stop.jsx +++ b/src/pages/compute/containers/Instance/actions/Stop.jsx @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import React from 'react'; import { ConfirmAction } from 'containers/Action'; import { isArray } from 'lodash'; import { isNotLockedOrAdmin, checkStatus } from 'resources/instance'; @@ -56,21 +57,28 @@ export default class Stop extends ConfirmAction { }; performErrorMsg = (failedItems) => { - const instance = isArray(failedItems) ? failedItems[0] : failedItems; - let errorMsg = t('You are not allowed to stop instance "{ name }".', { - name: instance.name, - }); - if (!this.isRunning(instance)) { - errorMsg = t( - 'Instance "{ name }" status is not in active or suspended, can not stop it.', - { name: instance.name } + const items = isArray(failedItems) ? failedItems : [failedItems]; + const notRunningItems = items.filter((it) => !this.isRunning(it)); + const lockedItems = items.filter( + (it) => !isNotLockedOrAdmin(it, this.isAdminPage) + ); + const msgs = []; + if (notRunningItems.length) { + msgs.push( + t( + 'Instance "{ name }" status is not in active or suspended, can not stop it.', + { name: this.getName(notRunningItems) } + ) ); - } else if (!isNotLockedOrAdmin(instance, this.isAdminPage)) { - errorMsg = t('Instance "{ name }" is locked, can not stop it.', { - name: instance.name, - }); } - return errorMsg; + if (lockedItems.length) { + msgs.push( + t('Instance "{ name }" is locked, can not stop it.', { + name: this.getName(lockedItems), + }) + ); + } + return msgs.map((it) =>

{it}

); }; onSubmit = (item) => {