2017-07-28 05:31:59 +09:00
|
|
|
import PropTypes from 'prop-types';
|
2023-05-24 00:15:17 +09:00
|
|
|
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
2017-09-22 11:59:17 +09:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
2017-07-28 05:31:59 +09:00
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
2023-05-24 00:15:17 +09:00
|
|
|
|
2023-05-09 10:11:56 +09:00
|
|
|
import { IconButton } from '../../../components/icon_button';
|
2017-07-28 05:31:59 +09:00
|
|
|
|
2017-07-28 06:01:50 +09:00
|
|
|
export default class ActionsModal extends ImmutablePureComponent {
|
2017-07-28 05:31:59 +09:00
|
|
|
|
|
|
|
static propTypes = {
|
2017-09-22 11:59:17 +09:00
|
|
|
status: ImmutablePropTypes.map,
|
2017-07-28 05:31:59 +09:00
|
|
|
actions: PropTypes.array,
|
|
|
|
onClick: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
|
|
|
renderAction = (action, i) => {
|
|
|
|
if (action === null) {
|
2017-09-22 11:59:17 +09:00
|
|
|
return <li key={`sep-${i}`} className='dropdown-menu__separator' />;
|
2017-07-28 05:31:59 +09:00
|
|
|
}
|
|
|
|
|
2023-10-25 02:45:08 +09:00
|
|
|
const { icon = null, iconComponent = null, text, meta = null, active = false, href = '#' } = action;
|
2017-07-28 05:31:59 +09:00
|
|
|
|
|
|
|
return (
|
|
|
|
<li key={`${text}-${i}`}>
|
2019-10-25 05:44:42 +09:00
|
|
|
<a href={href} target='_blank' rel='noopener noreferrer' onClick={this.props.onClick} data-index={i} className={classNames({ active })}>
|
2023-10-25 02:45:08 +09:00
|
|
|
{icon && <IconButton title={text} icon={icon} iconComponent={iconComponent} role='presentation' tabIndex={-1} inverted />}
|
2017-07-28 05:31:59 +09:00
|
|
|
<div>
|
2017-09-22 11:59:17 +09:00
|
|
|
<div className={classNames({ 'actions-modal__item-label': !!meta })}>{text}</div>
|
2017-07-28 05:31:59 +09:00
|
|
|
<div>{meta}</div>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
);
|
2023-01-30 09:45:35 +09:00
|
|
|
};
|
2017-07-28 05:31:59 +09:00
|
|
|
|
|
|
|
render () {
|
|
|
|
return (
|
|
|
|
<div className='modal-root__modal actions-modal'>
|
2019-04-22 21:55:50 +09:00
|
|
|
<ul className={classNames({ 'with-status': !!status })}>
|
2017-07-28 05:31:59 +09:00
|
|
|
{this.props.actions.map(this.renderAction)}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|