feat(xo-web/SortedTable): support link actions (#2893)
This commit is contained in:
parent
5928984069
commit
78e0c2d8fa
@ -90,7 +90,7 @@ export default class ActionButton extends Component {
|
|||||||
if (redirectOnSuccess) {
|
if (redirectOnSuccess) {
|
||||||
return this.context.router.push(
|
return this.context.router.push(
|
||||||
isFunction(redirectOnSuccess)
|
isFunction(redirectOnSuccess)
|
||||||
? redirectOnSuccess(result)
|
? redirectOnSuccess(result, handlerParam)
|
||||||
: redirectOnSuccess
|
: redirectOnSuccess
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -197,6 +197,7 @@ const actionsShape = propTypes.arrayOf(
|
|||||||
icon: propTypes.string.isRequired,
|
icon: propTypes.string.isRequired,
|
||||||
label: propTypes.node.isRequired,
|
label: propTypes.node.isRequired,
|
||||||
level: propTypes.oneOf(['primary', 'warning', 'danger']),
|
level: propTypes.oneOf(['primary', 'warning', 'danger']),
|
||||||
|
redirectOnSuccess: propTypes.oneOfType([propTypes.func, propTypes.string]),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -208,21 +209,23 @@ class IndividualAction extends Component {
|
|||||||
(disabled, item, userData) =>
|
(disabled, item, userData) =>
|
||||||
isFunction(disabled) ? disabled(item, userData) : disabled
|
isFunction(disabled) ? disabled(item, userData) : disabled
|
||||||
)
|
)
|
||||||
|
|
||||||
_executeAction = () => {
|
_executeAction = () => {
|
||||||
const p = this.props
|
const p = this.props
|
||||||
return p.handler(p.item, p.userData)
|
return p.handler(p.item, p.userData)
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { icon, label, level } = this.props
|
const { icon, item, label, level, redirectOnSuccess, userData } = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionRowButton
|
<ActionRowButton
|
||||||
btnStyle={level}
|
btnStyle={level}
|
||||||
|
data-item={item}
|
||||||
|
data-userData={userData}
|
||||||
disabled={this._getIsDisabled()}
|
disabled={this._getIsDisabled()}
|
||||||
handler={this._executeAction}
|
handler={this._executeAction}
|
||||||
icon={icon}
|
icon={icon}
|
||||||
|
redirectOnSuccess={redirectOnSuccess}
|
||||||
tooltip={label}
|
tooltip={label}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user