fix: Fix batch actions

Add batch actions for ironic

Change-Id: I3ed5cb85ae4f03568b9bdc3f303efa3127bc3dd1
This commit is contained in:
xusongfu 2021-08-02 18:31:07 +08:00
parent 1f80bdee8d
commit 3fda776217
5 changed files with 49 additions and 4 deletions

View File

@ -805,6 +805,7 @@
"Inspecting": "Inspecting", "Inspecting": "Inspecting",
"Instance": "Instance", "Instance": "Instance",
"Instance \"{ name }\" has already been locked.": "Instance \"{ name }\" has already been locked.", "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 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 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.", "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 Balancers": "Load Balancers",
"Load from local files": "Load from local files", "Load from local files": "Load from local files",
"LoadBalancers Instances": "LoadBalancers Instances", "LoadBalancers Instances": "LoadBalancers Instances",
"Loading": "Loading",
"Local": "Local", "Local": "Local",
"Local Endpoint Group": "Local Endpoint Group", "Local Endpoint Group": "Local Endpoint Group",
"Local Endpoint Group ID": "Local Endpoint Group ID", "Local Endpoint Group ID": "Local Endpoint Group ID",

View File

@ -805,6 +805,7 @@
"Inspecting": "检查", "Inspecting": "检查",
"Instance": "云主机", "Instance": "云主机",
"Instance \"{ name }\" has already been locked.": "云主机\"{ name }\"已经锁定。", "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 delete it.": "云主机\"{ name }\"被锁定,无法删除。",
"Instance \"{ name }\" is locked, can not pause it.": "云主机\"{ name }\"被锁定,无法暂停。", "Instance \"{ name }\" is locked, can not pause it.": "云主机\"{ name }\"被锁定,无法暂停。",
"Instance \"{ name }\" is locked, can not reboot it.": "云主机\"{ name }\"被锁定,无法重启。", "Instance \"{ name }\" is locked, can not reboot it.": "云主机\"{ name }\"被锁定,无法重启。",
@ -915,6 +916,7 @@
"Load Balancers": "负载均衡", "Load Balancers": "负载均衡",
"Load from local files": "从本地文件读取", "Load from local files": "从本地文件读取",
"LoadBalancers Instances": "负载均衡", "LoadBalancers Instances": "负载均衡",
"Loading": "加载中",
"Local": "本端", "Local": "本端",
"Local Endpoint Group": "本端端点组", "Local Endpoint Group": "本端端点组",
"Local Endpoint Group ID": "本端端点组ID", "Local Endpoint Group ID": "本端端点组ID",

View File

@ -62,6 +62,7 @@ export default class SoftRebootAction extends ConfirmAction {
const lockedItems = items.filter( const lockedItems = items.filter(
(it) => !isNotLockedOrAdmin(it, this.isAdminPage) (it) => !isNotLockedOrAdmin(it, this.isAdminPage)
); );
const ironicItems = items.filter((it) => isIronicInstance(it));
const msgs = []; const msgs = [];
if (notActiveItems.length) { if (notActiveItems.length) {
msgs.push( 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) => <p>{it}</p>); return msgs.map((it) => <p>{it}</p>);
}; };

View File

@ -95,6 +95,10 @@ const batchActions = [
Delete, Delete,
]; ];
const batchActionsForIronic = batchActions.slice(0, -2).concat(DeleteIronic);
const batchActionsForOthers = batchActions.slice(0, -1);
const actionConfigs = { const actionConfigs = {
rowActions: { rowActions: {
firstAction: Console, firstAction: Console,
@ -164,4 +168,10 @@ const adminActions = {
primaryActions: [], primaryActions: [],
}; };
export default { actionConfigs, adminActions }; export default {
actionConfigs,
adminActions,
batchActions,
batchActionsForIronic,
batchActionsForOthers,
};

View File

@ -106,9 +106,24 @@ export default class Instance extends Base {
return 'created_at'; 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) { getCheckboxProps(record) {
return { return {
disabled: isIronicInstance(record),
name: record.name, name: record.name,
}; };
} }
@ -216,16 +231,24 @@ export default class Instance extends Base {
}; };
get actionConfigs() { get actionConfigs() {
const { batchActions } = this;
if (this.isAdminPage) { if (this.isAdminPage) {
return actionConfigs.adminActions; return {
...actionConfigs.adminActions,
batchActions,
};
} }
if (this.isInFlavorDetailPage) { if (this.isInFlavorDetailPage) {
return { return {
...actionConfigs.actionConfigs, ...actionConfigs.actionConfigs,
primaryActions: [], primaryActions: [],
batchActions,
}; };
} }
return actionConfigs.actionConfigs; return {
...actionConfigs.actionConfigs,
batchActions,
};
} }
get searchFilters() { get searchFilters() {