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

View File

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

View File

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

View File

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

View File

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

View File

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