diff --git a/src/locales/en.json b/src/locales/en.json index 91d84e97..98f7a276 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -805,6 +805,7 @@ "Inspecting": "Inspecting", "Instance": "Instance", "Instance \"{ name }\" has already been locked.": "Instance \"{ name }\" has already been locked.", + "Instance \"{ name }\" is ironic, can not soft reboot it.": "Instance \"{ name }\" is ironic, can not soft reboot it.", "Instance \"{ name }\" is locked, can not delete it.": "Instance \"{ name }\" is locked, can not delete it.", "Instance \"{ name }\" is locked, can not pause it.": "Instance \"{ name }\" is locked, can not pause it.", "Instance \"{ name }\" is locked, can not reboot it.": "Instance \"{ name }\" is locked, can not reboot it.", @@ -915,6 +916,7 @@ "Load Balancers": "Load Balancers", "Load from local files": "Load from local files", "LoadBalancers Instances": "LoadBalancers Instances", + "Loading": "Loading", "Local": "Local", "Local Endpoint Group": "Local Endpoint Group", "Local Endpoint Group ID": "Local Endpoint Group ID", diff --git a/src/locales/zh.json b/src/locales/zh.json index e0f07884..6fb16dbd 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -805,6 +805,7 @@ "Inspecting": "检查", "Instance": "云主机", "Instance \"{ name }\" has already been locked.": "云主机\"{ name }\"已经锁定。", + "Instance \"{ name }\" is ironic, can not soft reboot it.": "云主机\"{ name }\"是裸机,无法软重启。", "Instance \"{ name }\" is locked, can not delete it.": "云主机\"{ name }\"被锁定,无法删除。", "Instance \"{ name }\" is locked, can not pause it.": "云主机\"{ name }\"被锁定,无法暂停。", "Instance \"{ name }\" is locked, can not reboot it.": "云主机\"{ name }\"被锁定,无法重启。", @@ -915,6 +916,7 @@ "Load Balancers": "负载均衡", "Load from local files": "从本地文件读取", "LoadBalancers Instances": "负载均衡", + "Loading": "加载中", "Local": "本端", "Local Endpoint Group": "本端端点组", "Local Endpoint Group ID": "本端端点组ID", diff --git a/src/pages/compute/containers/Instance/actions/SoftReboot.jsx b/src/pages/compute/containers/Instance/actions/SoftReboot.jsx index 9fc67f9e..a5cb5b81 100644 --- a/src/pages/compute/containers/Instance/actions/SoftReboot.jsx +++ b/src/pages/compute/containers/Instance/actions/SoftReboot.jsx @@ -62,6 +62,7 @@ export default class SoftRebootAction extends ConfirmAction { const lockedItems = items.filter( (it) => !isNotLockedOrAdmin(it, this.isAdminPage) ); + const ironicItems = items.filter((it) => isIronicInstance(it)); const msgs = []; if (notActiveItems.length) { msgs.push( @@ -77,6 +78,13 @@ export default class SoftRebootAction extends ConfirmAction { }) ); } + if (ironicItems.length) { + msgs.push( + t('Instance "{ name }" is ironic, can not soft reboot it.', { + name: this.getName(ironicItems), + }) + ); + } return msgs.map((it) =>

{it}

); }; diff --git a/src/pages/compute/containers/Instance/actions/index.jsx b/src/pages/compute/containers/Instance/actions/index.jsx index 18256295..a9bf3a45 100644 --- a/src/pages/compute/containers/Instance/actions/index.jsx +++ b/src/pages/compute/containers/Instance/actions/index.jsx @@ -95,6 +95,10 @@ const batchActions = [ Delete, ]; +const batchActionsForIronic = batchActions.slice(0, -2).concat(DeleteIronic); + +const batchActionsForOthers = batchActions.slice(0, -1); + const actionConfigs = { rowActions: { firstAction: Console, @@ -164,4 +168,10 @@ const adminActions = { primaryActions: [], }; -export default { actionConfigs, adminActions }; +export default { + actionConfigs, + adminActions, + batchActions, + batchActionsForIronic, + batchActionsForOthers, +}; diff --git a/src/pages/compute/containers/Instance/index.jsx b/src/pages/compute/containers/Instance/index.jsx index 239779f9..1b2092cc 100644 --- a/src/pages/compute/containers/Instance/index.jsx +++ b/src/pages/compute/containers/Instance/index.jsx @@ -106,9 +106,24 @@ export default class Instance extends Base { return 'created_at'; } + get batchActions() { + const { selectedRowKeys = [], data = [] } = this.store.list; + const slectedRows = selectedRowKeys.map((key) => { + return data.find((it) => it.id === key); + }); + const allIronic = slectedRows.every((it) => isIronicInstance(it)); + const noIronic = slectedRows.every((it) => !isIronicInstance(it)); + if (allIronic) { + return actionConfigs.batchActionsForIronic; + } + if (noIronic) { + return actionConfigs.batchActions; + } + return actionConfigs.batchActionsForOthers; + } + getCheckboxProps(record) { return { - disabled: isIronicInstance(record), name: record.name, }; } @@ -216,16 +231,24 @@ export default class Instance extends Base { }; get actionConfigs() { + const { batchActions } = this; if (this.isAdminPage) { - return actionConfigs.adminActions; + return { + ...actionConfigs.adminActions, + batchActions, + }; } if (this.isInFlavorDetailPage) { return { ...actionConfigs.actionConfigs, primaryActions: [], + batchActions, }; } - return actionConfigs.actionConfigs; + return { + ...actionConfigs.actionConfigs, + batchActions, + }; } get searchFilters() {