[Animbus]fix: Fix danger button style in batch actions

1. Fix danger button style in table batch actions
2. Update reboot vm button to danger
3. Update resize vm button to danger

Change-Id: Ibabc1259e4914042214842acecde4c16f7e6d19e
This commit is contained in:
Jingwei.Zhang 2022-06-06 10:10:46 +08:00
parent 6b34ad1b05
commit 39259b4fbd
6 changed files with 16 additions and 5 deletions

View File

@ -64,6 +64,7 @@ export class ActionButton extends Component {
isAllowed: PropTypes.bool,
needHide: PropTypes.bool,
buttonType: PropTypes.string,
isDanger: PropTypes.bool,
items: PropTypes.array,
isBatch: PropTypes.bool,
path: PropTypes.string,
@ -83,6 +84,7 @@ export class ActionButton extends Component {
confirm: false,
needHide: true,
buttonType: 'link',
isDanger: false,
isLink: false,
items: [],
isBatch: false,
@ -493,7 +495,7 @@ export class ActionButton extends Component {
name,
id,
title,
danger,
isDanger,
style,
maxLength,
isFirstAction,
@ -509,7 +511,7 @@ export class ActionButton extends Component {
const button = (
<Button
type={buttonType}
danger={danger}
danger={isDanger}
onClick={this.onClick}
key={id}
disabled={!isAllowed}

View File

@ -62,7 +62,7 @@ function DropdownActionButton({
const newConf = updateConf(it, selectedItems);
const { isDanger, name } = newConf;
newConf.onFinishAction = onFinishAction;
newConf.danger = !!isDanger;
newConf.isDanger = !!isDanger;
if (!selectedItems.length) {
return (
<Menu.Item key={key} disabled style={{ textAlign: 'center' }}>
@ -126,13 +126,14 @@ export default function TableBatchButtons(props) {
showedActions = actionList;
}
batchButtons = showedActions.map((it) => {
const { isDanger = false, buttonType = 'default' } = it;
if (!selectedItems || selectedItems.length === 0) {
return (
<Tooltip
title={t('Please select {name} first', { name: resourceName })}
key={`tooltip-${generateId()}`}
>
<Button type="default" disabled>
<Button type={buttonType} disabled danger={isDanger}>
{it.buttonText || it.title}
</Button>
</Tooltip>

View File

@ -32,7 +32,7 @@ function getActionConf(action) {
name: buttonText || title,
actionType,
action,
danger: isDanger,
isDanger,
};
}

View File

@ -35,6 +35,10 @@ export default class RebootAction extends ConfirmAction {
return t('reboot instance');
}
get isDanger() {
return true;
}
get passiveAction() {
return t('be rebooted');
}

View File

@ -29,6 +29,8 @@ export class Resize extends ModalAction {
static title = t('Resize');
static isDanger = true;
init() {
this.store = globalFlavorStore;
}

View File

@ -30,6 +30,8 @@ export class ResizeOnline extends ModalAction {
static title = t('Online Resize');
static isDanger = true;
init() {
this.store = globalFlavorStore;
}