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

This commit is contained in:
Zuul 2022-06-06 11:12:43 +00:00 committed by Gerrit Code Review
commit 61097bff8a
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;
}