fix: Fix action hint without name

Fix action hint without name

Change-Id: Ie1e88b2749399dbe0291d739e18a25aaaf0faaac
This commit is contained in:
Jingwei.Zhang 2021-08-25 13:29:55 +08:00
parent 1d4952cf60
commit f1c3df26a4
29 changed files with 78 additions and 49 deletions

View File

@ -175,18 +175,30 @@ export default class BaseForm extends React.Component {
} }
get successText() { get successText() {
if (this.instanceName) {
return firstUpperCase(
t('{action} successfully, instance: {name}.', {
action: this.name.toLowerCase(),
name: this.instanceName,
})
);
}
return firstUpperCase( return firstUpperCase(
t('{action} successfully, instance: {name}.', { t('{action} successfully.', {
action: this.name.toLowerCase(), action: this.name.toLowerCase(),
name: this.instanceName,
}) })
); );
} }
get errorText() { get errorText() {
return t('Unable to {action}, instance: {name}.', { if (this.instanceName) {
return t('Unable to {action}, instance: {name}.', {
action: this.name.toLowerCase(),
name: this.instanceName,
});
}
return t('Unable to {action}.', {
action: this.name.toLowerCase(), action: this.name.toLowerCase(),
name: this.instanceName,
}); });
} }

View File

@ -148,18 +148,30 @@ export default class BaseStepForm extends React.Component {
} }
get successText() { get successText() {
if (this.instanceName) {
return firstUpperCase(
t('{action} successfully, instance: {name}.', {
action: this.name.toLowerCase(),
name: this.instanceName,
})
);
}
return firstUpperCase( return firstUpperCase(
t('{action} successfully, instance: {name}.', { t('{action} successfully.', {
action: this.name.toLowerCase(), action: this.name.toLowerCase(),
name: this.instanceName,
}) })
); );
} }
get errorText() { get errorText() {
return t('Unable to {action}, instance: {name}.', { if (this.instanceName) {
return t('Unable to {action}, instance: {name}.', {
action: this.name.toLowerCase(),
name: this.instanceName,
});
}
return t('Unable to {action}.', {
action: this.name.toLowerCase(), action: this.name.toLowerCase(),
name: this.instanceName,
}); });
} }

View File

@ -89,12 +89,14 @@ export default class ConfirmAction {
unescape = (message) => unescapeHtml(message); unescape = (message) => unescapeHtml(message);
getNameOne = (data) => data.name; getItemId = (data) => data.id;
getItemName = (data) => data.name || `- (${this.getItemId(data)})`;
getName = (data) => getName = (data) =>
isArray(data) isArray(data)
? data.map((it) => this.getNameOne(it)).join(', ') ? data.map((it) => this.getItemName(it)).join(', ')
: this.getNameOne(data); : this.getItemName(data);
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
allowedCheckFunc = (data) => true; allowedCheckFunc = (data) => true;
@ -154,7 +156,14 @@ export default class ConfirmAction {
); );
}; };
performErrorMsg = (data) => { performErrorMsg = (data, isBatch) => {
if (isBatch) {
if (!this.messageHasItemName) {
return '';
}
const name = this.getName(data);
return t('instance: {name}.', { name });
}
if (!this.messageHasItemName) { if (!this.messageHasItemName) {
return t('You are not allowed to {action}.', { return t('You are not allowed to {action}.', {
action: this.actionNameDisplay || this.title, action: this.actionNameDisplay || this.title,
@ -184,8 +193,14 @@ export default class ConfirmAction {
onSubmit = (data) => Promise.resolve(); onSubmit = (data) => Promise.resolve();
getBatchPerformTitle() { getBatchPerformTitle() {
if (this.messageHasItemName) {
return t(
'There are resources that cannot {action} in the selected resources, such as:',
{ action: this.passiveAction.toLowerCase() }
);
}
return t( return t(
'There are resources that cannot {action} in the selected resources, such as:', 'There are resources that cannot {action} in the selected resources.',
{ action: this.passiveAction.toLowerCase() } { action: this.passiveAction.toLowerCase() }
); );
} }
@ -208,7 +223,7 @@ export default class ConfirmAction {
failedItems.push(items[index]); failedItems.push(items[index]);
} }
}); });
const errorMsg = this.unescape(this.performErrorMsg(failedItems)); const errorMsg = this.unescape(this.performErrorMsg(failedItems, true));
const title = this.getBatchPerformTitle(); const title = this.getBatchPerformTitle();
const msg = ( const msg = (
<div> <div>

View File

@ -70,7 +70,7 @@ export default class ModalAction extends BaseForm {
} }
get instanceName() { get instanceName() {
return this.item.name || this.values.name; return (this.item || {}).name || (this.values || {}).name;
} }
get isAsyncAction() { get isAsyncAction() {

View File

@ -238,7 +238,6 @@
"Click to show detail": "Click to show detail", "Click to show detail": "Click to show detail",
"Clone Volume": "Clone Volume", "Clone Volume": "Clone Volume",
"Clone volume": "Clone volume", "Clone volume": "Clone volume",
"Close": "Close",
"Close External Gateway": "Close External Gateway", "Close External Gateway": "Close External Gateway",
"Close all notifications.": "Close all notifications.", "Close all notifications.": "Close all notifications.",
"Close external gateway": "Close external gateway", "Close external gateway": "Close external gateway",
@ -1039,7 +1038,6 @@
"One entry per line(e.g. {ip})": "One entry per line(e.g. {ip})", "One entry per line(e.g. {ip})": "One entry per line(e.g. {ip})",
"Online Resize": "Online Resize", "Online Resize": "Online Resize",
"Only a MAC address or an OpenFlow based datapath_id of the switch are accepted in this field": "Only a MAC address or an OpenFlow based datapath_id of the switch are accepted in this field", "Only a MAC address or an OpenFlow based datapath_id of the switch are accepted in this field": "Only a MAC address or an OpenFlow based datapath_id of the switch are accepted in this field",
"Open": "Open",
"Open External Gateway": "Open External Gateway", "Open External Gateway": "Open External Gateway",
"Operating Status": "Operating Status", "Operating Status": "Operating Status",
"Operating System": "Operating System", "Operating System": "Operating System",
@ -1553,6 +1551,7 @@
"The {action} instruction has been issued, instance: {name}. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.": "The {action} instruction has been issued, instance: {name}. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.", "The {action} instruction has been issued, instance: {name}. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.": "The {action} instruction has been issued, instance: {name}. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.",
"The {action} instruction has been issued. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.": "The {action} instruction has been issued. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.", "The {action} instruction has been issued. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.": "The {action} instruction has been issued. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.",
"There are resources that cannot {action} in the selected resources, such as:": "There are resources that cannot {action} in the selected resources, such as:", "There are resources that cannot {action} in the selected resources, such as:": "There are resources that cannot {action} in the selected resources, such as:",
"There are resources that cannot {action} in the selected resources.": "There are resources that cannot {action} in the selected resources.",
"There are resources under the project and cannot be deleted.": "There are resources under the project and cannot be deleted.", "There are resources under the project and cannot be deleted.": "There are resources under the project and cannot be deleted.",
"This service will automatically query the configuration (CPU, memory, etc.) and mac address of the physical machine, and the ironic-inspector service will automatically register this information in the node information.": "This service will automatically query the configuration (CPU, memory, etc.) and mac address of the physical machine, and the ironic-inspector service will automatically register this information in the node information.", "This service will automatically query the configuration (CPU, memory, etc.) and mac address of the physical machine, and the ironic-inspector service will automatically register this information in the node information.": "This service will automatically query the configuration (CPU, memory, etc.) and mac address of the physical machine, and the ironic-inspector service will automatically register this information in the node information.",
"This will delete all child objects of the load balancer.": "This will delete all child objects of the load balancer.", "This will delete all child objects of the load balancer.": "This will delete all child objects of the load balancer.",
@ -1577,8 +1576,6 @@
"USER": "USER", "USER": "USER",
"UUID": "UUID", "UUID": "UUID",
"Ubuntu": "Ubuntu", "Ubuntu": "Ubuntu",
"Unable to batch {action} {name}.": "Unable to batch {action} {name}.",
"Unable to batch {action}, instance: {name}.": "Unable to batch {action}, instance: {name}.",
"Unable to create instance: batch creation is not supported when specifying IP.": "Unable to create instance: batch creation is not supported when specifying IP.", "Unable to create instance: batch creation is not supported when specifying IP.": "Unable to create instance: batch creation is not supported when specifying IP.",
"Unable to create instance: insufficient quota to create resources.": "Unable to create instance: insufficient quota to create resources.", "Unable to create instance: insufficient quota to create resources.": "Unable to create instance: insufficient quota to create resources.",
"Unable to create volume: insufficient quota to create resources.": "Unable to create volume: insufficient quota to create resources.", "Unable to create volume: insufficient quota to create resources.": "Unable to create volume: insufficient quota to create resources.",
@ -1854,6 +1851,7 @@
"ingress": "ingress", "ingress": "ingress",
"instance": "instance", "instance": "instance",
"instance snapshot": "instance snapshot", "instance snapshot": "instance snapshot",
"instance: {name}.": "instance: {name}.",
"instances": "instances", "instances": "instances",
"jump to the console": "jump to the console", "jump to the console": "jump to the console",
"keypair": "keypair", "keypair": "keypair",

View File

@ -238,7 +238,6 @@
"Click to show detail": "点击查看详情", "Click to show detail": "点击查看详情",
"Clone Volume": "克隆云硬盘", "Clone Volume": "克隆云硬盘",
"Clone volume": "克隆云硬盘", "Clone volume": "克隆云硬盘",
"Close": "关闭",
"Close External Gateway": "关闭公网网关", "Close External Gateway": "关闭公网网关",
"Close all notifications.": "关闭所有消息提示", "Close all notifications.": "关闭所有消息提示",
"Close external gateway": "关闭公网网关", "Close external gateway": "关闭公网网关",
@ -1039,7 +1038,6 @@
"One entry per line(e.g. {ip})": "每行一条(例如: {ip})", "One entry per line(e.g. {ip})": "每行一条(例如: {ip})",
"Online Resize": "在线修改配置", "Online Resize": "在线修改配置",
"Only a MAC address or an OpenFlow based datapath_id of the switch are accepted in this field": "只可填写交换机的Mac地址或者交换机基于openflow的数据路径ID", "Only a MAC address or an OpenFlow based datapath_id of the switch are accepted in this field": "只可填写交换机的Mac地址或者交换机基于openflow的数据路径ID",
"Open": "开",
"Open External Gateway": "开启公网网关", "Open External Gateway": "开启公网网关",
"Operating Status": "操作状态", "Operating Status": "操作状态",
"Operating System": "操作系统", "Operating System": "操作系统",
@ -1553,6 +1551,7 @@
"The {action} instruction has been issued, instance: {name}. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.": "{action}指令已下发,实例名称:{name}。 \n 您可等待几秒关注列表数据的变更或是手动刷新数据,以获取最终展示结果。", "The {action} instruction has been issued, instance: {name}. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.": "{action}指令已下发,实例名称:{name}。 \n 您可等待几秒关注列表数据的变更或是手动刷新数据,以获取最终展示结果。",
"The {action} instruction has been issued. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.": "{action}指令已下发。 \n 您可等待几秒关注列表数据的变更或是手动刷新数据,以获取最终展示结果。", "The {action} instruction has been issued. \n You can wait for a few seconds to follow the changes of the list data or manually refresh the data to get the final display result.": "{action}指令已下发。 \n 您可等待几秒关注列表数据的变更或是手动刷新数据,以获取最终展示结果。",
"There are resources that cannot {action} in the selected resources, such as:": "您选中的资源中有无法{action}的资源,如:", "There are resources that cannot {action} in the selected resources, such as:": "您选中的资源中有无法{action}的资源,如:",
"There are resources that cannot {action} in the selected resources.": "您选中的资源中有无法{action}的资源。",
"There are resources under the project and cannot be deleted.": "项目下存在资源,无法执行删除操作。", "There are resources under the project and cannot be deleted.": "项目下存在资源,无法执行删除操作。",
"This service will automatically query the configuration (CPU, memory, etc.) and mac address of the physical machine, and the ironic-inspector service will automatically register this information in the node information.": "此服务将对在对物理机的配置CPU、内存等和 mac 地址进行自动查询, 并且 ironic-inspector 服务会将这些信息自动注册入节点信息中。", "This service will automatically query the configuration (CPU, memory, etc.) and mac address of the physical machine, and the ironic-inspector service will automatically register this information in the node information.": "此服务将对在对物理机的配置CPU、内存等和 mac 地址进行自动查询, 并且 ironic-inspector 服务会将这些信息自动注册入节点信息中。",
"This will delete all child objects of the load balancer.": "这会删除所有LB下的资源", "This will delete all child objects of the load balancer.": "这会删除所有LB下的资源",
@ -1577,8 +1576,6 @@
"USER": "用户", "USER": "用户",
"UUID": "", "UUID": "",
"Ubuntu": "", "Ubuntu": "",
"Unable to batch {action} {name}.": "无法批量{action} {name}。",
"Unable to batch {action}, instance: {name}.": "无法批量{action},实例名称:{name}。",
"Unable to create instance: batch creation is not supported when specifying IP.": "无法创建云主机指定IP时不支持批量创建云主机。", "Unable to create instance: batch creation is not supported when specifying IP.": "无法创建云主机指定IP时不支持批量创建云主机。",
"Unable to create instance: insufficient quota to create resources.": "无法创建云主机:超过配额。", "Unable to create instance: insufficient quota to create resources.": "无法创建云主机:超过配额。",
"Unable to create volume: insufficient quota to create resources.": "无法创建云硬盘:超过配额。", "Unable to create volume: insufficient quota to create resources.": "无法创建云硬盘:超过配额。",
@ -1854,6 +1851,7 @@
"ingress": "入方向", "ingress": "入方向",
"instance": "云主机", "instance": "云主机",
"instance snapshot": "云主机快照", "instance snapshot": "云主机快照",
"instance: {name}.": "实例名称:{name}。",
"instances": "云主机", "instances": "云主机",
"jump to the console": "跳转到控制台", "jump to the console": "跳转到控制台",
"keypair": "密钥", "keypair": "密钥",

View File

@ -42,7 +42,7 @@ export default class Delete extends ConfirmAction {
policy = 'baremetal:port:delete'; policy = 'baremetal:port:delete';
getNameOne = (data) => data.name || data.uuid; getItemId = (data) => data.uuid;
allowedCheckFunc = () => true; allowedCheckFunc = () => true;

View File

@ -42,7 +42,7 @@ export default class Delete extends ConfirmAction {
policy = 'baremetal:portgroup:delete'; policy = 'baremetal:portgroup:delete';
getNameOne = (data) => data.name || data.uuid; getItemId = (data) => data.uuid;
allowedCheckFunc = () => true; allowedCheckFunc = () => true;

View File

@ -30,7 +30,7 @@ export default class ClearMaintenance extends ConfirmAction {
policy = 'baremetal:node:clear_maintenance'; policy = 'baremetal:node:clear_maintenance';
getNameOne = (data) => data.name || data.uuid; getItemId = (data) => data.uuid;
allowedCheckFunc = (item) => item.maintenance; allowedCheckFunc = (item) => item.maintenance;

View File

@ -42,7 +42,7 @@ export default class Delete extends ConfirmAction {
policy = 'baremetal:node:delete'; policy = 'baremetal:node:delete';
getNameOne = (data) => data.name || data.uuid; getItemId = (data) => data.uuid;
allowedCheckFunc = () => true; allowedCheckFunc = () => true;

View File

@ -31,7 +31,7 @@ export default class Inspect extends ConfirmAction {
policy = 'baremetal:node:set_provision_state'; policy = 'baremetal:node:set_provision_state';
getNameOne = (data) => data.name || data.uuid; getItemId = (data) => data.uuid;
allowedCheckFunc = (item) => item.provision_state === 'manageable'; allowedCheckFunc = (item) => item.provision_state === 'manageable';

View File

@ -34,7 +34,7 @@ export default class PowerOn extends ConfirmAction {
policy = 'baremetal:node:set_power_state'; policy = 'baremetal:node:set_power_state';
getNameOne = (data) => data.name || data.uuid; getItemId = (data) => data.uuid;
allowedCheckFunc = (item) => item.power_state === 'power off'; allowedCheckFunc = (item) => item.power_state === 'power off';

View File

@ -34,7 +34,7 @@ export default class PowerOff extends ConfirmAction {
policy = 'baremetal:node:set_power_state'; policy = 'baremetal:node:set_power_state';
getNameOne = (data) => data.name || data.uuid; getItemId = (data) => data.uuid;
allowedCheckFunc = (item) => item.power_state === 'power on'; allowedCheckFunc = (item) => item.power_state === 'power on';

View File

@ -28,7 +28,7 @@ export default class EnableAction extends ConfirmAction {
return t('Enable'); return t('Enable');
} }
getNameOne = (data) => data.host; getItemName = (data) => data.host;
get actionName() { get actionName() {
return t('Enable compute host'); return t('Enable compute host');

View File

@ -32,7 +32,7 @@ export default class Reset extends ConfirmAction {
return t('Reset To Initial Value'); return t('Reset To Initial Value');
} }
getNameOne = (data) => data.key; getItemName = (data) => data.key;
policy = 'skyline:system_admin'; policy = 'skyline:system_admin';

View File

@ -36,7 +36,7 @@ export default class Enable extends ConfirmAction {
return t('enable cinder service'); return t('enable cinder service');
} }
getName = (data) => data.binary; getItemName = (data) => data.binary;
policy = 'volume_extension:services:update'; policy = 'volume_extension:services:update';

View File

@ -28,7 +28,7 @@ export default class EnableAction extends ConfirmAction {
return t('Enable'); return t('Enable');
} }
getName = (data) => data.host; getItemName = (data) => data.host;
get actionName() { get actionName() {
return t('enable compute service'); return t('enable compute service');

View File

@ -36,7 +36,7 @@ export default class Disable extends ConfirmAction {
return t('disable neutron agent'); return t('disable neutron agent');
} }
getName = (data) => data.binary; getItemName = (data) => data.binary;
policy = 'update_agent'; policy = 'update_agent';

View File

@ -36,7 +36,7 @@ export default class Enable extends ConfirmAction {
return t('enable neutron agent'); return t('enable neutron agent');
} }
getName = (data) => data.binary; getItemName = (data) => data.binary;
policy = 'update_agent'; policy = 'update_agent';

View File

@ -38,7 +38,7 @@ export default class DeleteAction extends ConfirmAction {
policy = 'delete_floatingip_port_forwarding'; policy = 'delete_floatingip_port_forwarding';
getNameOne = (data) => { getItemName = (data) => {
const { const {
floating_ip_address, floating_ip_address,
external_port, external_port,

View File

@ -38,7 +38,7 @@ export default class Release extends ConfirmAction {
allowedCheckFunc = (item) => allowedCheckFunc = (item) =>
!_.isNull(item.fixed_ip_address) && item.status !== 'DOWN'; !_.isNull(item.fixed_ip_address) && item.status !== 'DOWN';
getNameOne = (data) => data.floating_ip_address; getItemName = (data) => data.floating_ip_address;
onSubmit = (value) => globalFloatingIpsStore.disassociateFip(value); onSubmit = (value) => globalFloatingIpsStore.disassociateFip(value);
} }

View File

@ -41,7 +41,7 @@ export default class Release extends ConfirmAction {
policy = 'delete_floatingip'; policy = 'delete_floatingip';
getNameOne = (data) => data.floating_ip_address; getItemName = (data) => data.floating_ip_address;
onChangeType(choosed, data) { onChangeType(choosed, data) {
if (isArray(data)) { if (isArray(data)) {

View File

@ -38,7 +38,7 @@ export default class DeleteAction extends ConfirmAction {
policy = 'update_router'; policy = 'update_router';
getNameOne = (data) => { getItemName = (data) => {
const { destination, nexthop } = data; const { destination, nexthop } = data;
return `${destination}(${nexthop})`; return `${destination}(${nexthop})`;
}; };

View File

@ -38,7 +38,7 @@ export default class DeleteAction extends ConfirmAction {
policy = 'delete_security_group_rule'; policy = 'delete_security_group_rule';
getNameOne = (item) => { getItemName = (item) => {
if (item.name) { if (item.name) {
return item.name; return item.name;
} }

View File

@ -37,7 +37,7 @@ export default class DeleteAction extends ConfirmAction {
return t('delete allowed address pair'); return t('delete allowed address pair');
} }
getNameOne = (data) => data.ip_address; getItemName = (data) => data.ip_address;
policy = 'update_port'; policy = 'update_port';

View File

@ -40,7 +40,7 @@ export default class DeleteAction extends ConfirmAction {
return t('be released'); return t('be released');
} }
getNameOne = (data) => data.ip_address; getItemName = (data) => data.ip_address;
policy = 'update_port'; policy = 'update_port';

View File

@ -36,8 +36,6 @@ export default class DeleteAction extends ConfirmAction {
return t('delete virtual adapter'); return t('delete virtual adapter');
} }
getNameOne = (data) => data.name || data.id;
policy = 'delete_port'; policy = 'delete_port';
allowedCheckFunc = (item) => { allowedCheckFunc = (item) => {

View File

@ -39,8 +39,6 @@ export default class Detach extends ConfirmAction {
policy = 'os_compute_api:os-attach-interfaces:delete'; policy = 'os_compute_api:os-attach-interfaces:delete';
getNameOne = (data) => data.name || data.id;
hasMoreInterfaces(instance) { hasMoreInterfaces(instance) {
let count = 0; let count = 0;
const { addresses } = instance; const { addresses } = instance;

View File

@ -42,8 +42,6 @@ export default class DeleteAction extends ConfirmAction {
policy = 'volume:delete'; policy = 'volume:delete';
getNameOne = (data) => data.name || data.id;
canDelete = (item) => canDelete = (item) =>
['available', 'error', 'error_extending'].indexOf(item.status) >= 0; ['available', 'error', 'error_extending'].indexOf(item.status) >= 0;