strong-testimonials
/
admin
/
wpchill
/
apps
/
notification-system
/
notification
/
notification-actions.jsx
notification-actions.jsx
9 months ago
notifications-footer.jsx
1 year ago
notifications-head.jsx
1 year ago
notifications-list.jsx
1 year ago
notification-actions.jsx
34 lines
| 1 | import { Button } from '@wordpress/components'; |
| 2 | import he from 'he'; |
| 3 | |
| 4 | export function NotificationActions( { actions, id, onDismiss } ) { |
| 5 | const handleClick = ( action ) => { |
| 6 | if ( action.callback && typeof window[ action.callback ] === 'function' ) { |
| 7 | window[ action.callback ]( action, id ); |
| 8 | } |
| 9 | |
| 10 | if ( action.dismiss ) { |
| 11 | onDismiss( id, action.permanent ); |
| 12 | } |
| 13 | }; |
| 14 | |
| 15 | return ( |
| 16 | <div className="notification-actions-wrapp"> |
| 17 | { actions.map( ( action, index ) => ( |
| 18 | <Button |
| 19 | key={ index } |
| 20 | className={ action.class || 'notification-action' } |
| 21 | { ...( action.url ? { href: he.decode( action.url ) } : {} ) } |
| 22 | { ...( action.id ? { id: action.id } : {} ) } |
| 23 | target={ action.target || '' } |
| 24 | text={ he.decode( action.label || '' ) } |
| 25 | variant={ action.variant || 'secondary' } |
| 26 | style={ action.style || {} } |
| 27 | size={ action.size || 'small' } |
| 28 | onClick={ () => handleClick( action ) } |
| 29 | /> |
| 30 | ) ) } |
| 31 | </div> |
| 32 | ); |
| 33 | } |
| 34 |