You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
3.0 KiB
92 lines
3.0 KiB
7 years ago
|
import React from 'react';
|
||
|
import PropTypes from 'prop-types';
|
||
7 years ago
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||
7 years ago
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||
7 years ago
|
import StatusContent from 'flavours/glitch/components/status_content';
|
||
|
import Avatar from 'flavours/glitch/components/avatar';
|
||
|
import RelativeTimestamp from 'flavours/glitch/components/relative_timestamp';
|
||
|
import DisplayName from 'flavours/glitch/components/display_name';
|
||
7 years ago
|
import classNames from 'classnames';
|
||
3 years ago
|
import IconButton from 'flavours/glitch/components/icon_button';
|
||
7 years ago
|
|
||
7 years ago
|
export default class ActionsModal extends ImmutablePureComponent {
|
||
7 years ago
|
|
||
|
static propTypes = {
|
||
7 years ago
|
status: ImmutablePropTypes.map,
|
||
3 years ago
|
onClick: PropTypes.func,
|
||
7 years ago
|
actions: PropTypes.arrayOf(PropTypes.shape({
|
||
|
active: PropTypes.bool,
|
||
|
href: PropTypes.string,
|
||
|
icon: PropTypes.string,
|
||
3 years ago
|
meta: PropTypes.string,
|
||
7 years ago
|
name: PropTypes.string,
|
||
3 years ago
|
text: PropTypes.string,
|
||
7 years ago
|
})),
|
||
3 years ago
|
renderItemContents: PropTypes.func,
|
||
7 years ago
|
};
|
||
|
|
||
|
renderAction = (action, i) => {
|
||
|
if (action === null) {
|
||
7 years ago
|
return <li key={`sep-${i}`} className='dropdown-menu__separator' />;
|
||
7 years ago
|
}
|
||
|
|
||
3 years ago
|
const { icon = null, text, meta = null, active = false, href = '#' } = action;
|
||
|
let contents = this.props.renderItemContents && this.props.renderItemContents(action, i);
|
||
|
|
||
|
if (!contents) {
|
||
|
contents = (
|
||
|
<React.Fragment>
|
||
|
{icon && <IconButton title={text} icon={icon} role='presentation' tabIndex='-1' inverted />}
|
||
|
<div>
|
||
|
<div className={classNames({ 'actions-modal__item-label': !!meta })}>{text}</div>
|
||
|
<div>{meta}</div>
|
||
|
</div>
|
||
|
</React.Fragment>
|
||
|
);
|
||
|
}
|
||
7 years ago
|
|
||
|
return (
|
||
3 years ago
|
<li key={`${text}-${i}`}>
|
||
|
<a href={href} target='_blank' rel='noopener noreferrer' onClick={this.props.onClick} data-index={i} className={classNames('link', { active })}>
|
||
|
{contents}
|
||
3 years ago
|
</a>
|
||
7 years ago
|
</li>
|
||
|
);
|
||
2 years ago
|
};
|
||
7 years ago
|
|
||
|
render () {
|
||
|
const status = this.props.status && (
|
||
|
<div className='status light'>
|
||
|
<div className='boost-modal__status-header'>
|
||
|
<div className='boost-modal__status-time'>
|
||
5 years ago
|
<a href={this.props.status.get('url')} className='status__relative-time' target='_blank' rel='noopener noreferrer'>
|
||
7 years ago
|
<RelativeTimestamp timestamp={this.props.status.get('created_at')} />
|
||
|
</a>
|
||
|
</div>
|
||
|
|
||
5 years ago
|
<a href={this.props.status.getIn(['account', 'url'])} className='status__display-name' rel='noopener noreferrer'>
|
||
7 years ago
|
<div className='status__avatar'>
|
||
7 years ago
|
<Avatar account={this.props.status.get('account')} size={48} />
|
||
7 years ago
|
</div>
|
||
|
|
||
|
<DisplayName account={this.props.status.get('account')} />
|
||
|
</a>
|
||
|
</div>
|
||
|
|
||
|
<StatusContent status={this.props.status} />
|
||
|
</div>
|
||
|
);
|
||
|
|
||
|
return (
|
||
|
<div className='modal-root__modal actions-modal'>
|
||
|
{status}
|
||
|
|
||
6 years ago
|
<ul className={classNames({ 'with-status': !!status })}>
|
||
7 years ago
|
{this.props.actions.map(this.renderAction)}
|
||
|
</ul>
|
||
|
</div>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
}
|