bigbuffet-rw/app/soapbox/features/account_timeline/components/header.js

179 lines
4.7 KiB
JavaScript
Raw Normal View History

import PropTypes from 'prop-types';
2020-03-27 13:59:38 -07:00
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
2022-03-17 18:17:28 -07:00
import { withRouter } from 'react-router-dom';
2022-01-10 14:01:24 -08:00
import InnerHeader from '../../account/components/header';
2020-03-27 13:59:38 -07:00
import MovedNote from './moved_note';
2022-03-17 18:17:28 -07:00
export default @withRouter
class Header extends ImmutablePureComponent {
2020-03-27 13:59:38 -07:00
static propTypes = {
2022-03-23 10:14:42 -07:00
account: ImmutablePropTypes.record,
2020-03-27 13:59:38 -07:00
identity_proofs: ImmutablePropTypes.list,
onFollow: PropTypes.func.isRequired,
onBlock: PropTypes.func.isRequired,
onMention: PropTypes.func.isRequired,
onDirect: PropTypes.func.isRequired,
onChat: PropTypes.func,
2020-03-27 13:59:38 -07:00
onReblogToggle: PropTypes.func.isRequired,
onReport: PropTypes.func.isRequired,
onMute: PropTypes.func.isRequired,
onBlockDomain: PropTypes.func.isRequired,
onUnblockDomain: PropTypes.func.isRequired,
onEndorseToggle: PropTypes.func.isRequired,
2020-03-27 13:59:38 -07:00
onAddToList: PropTypes.func.isRequired,
username: PropTypes.string,
2022-03-17 18:17:28 -07:00
history: PropTypes.object,
2020-03-27 13:59:38 -07:00
};
handleFollow = () => {
this.props.onFollow(this.props.account);
}
handleBlock = () => {
this.props.onBlock(this.props.account);
}
handleMention = () => {
2022-03-17 18:17:28 -07:00
this.props.onMention(this.props.account, this.props.history);
2020-03-27 13:59:38 -07:00
}
handleDirect = () => {
2022-03-17 18:17:28 -07:00
this.props.onDirect(this.props.account, this.props.history);
2020-03-27 13:59:38 -07:00
}
handleReport = () => {
this.props.onReport(this.props.account);
}
handleReblogToggle = () => {
this.props.onReblogToggle(this.props.account);
}
handleSubscriptionToggle = () => {
this.props.onSubscriptionToggle(this.props.account);
}
handleNotifyToggle = () => {
this.props.onNotifyToggle(this.props.account);
}
2020-03-27 13:59:38 -07:00
handleMute = () => {
this.props.onMute(this.props.account);
}
handleBlockDomain = () => {
const domain = this.props.account.get('acct').split('@')[1];
if (!domain) return;
this.props.onBlockDomain(domain);
}
handleUnblockDomain = () => {
const domain = this.props.account.get('acct').split('@')[1];
if (!domain) return;
this.props.onUnblockDomain(domain);
}
handleChat = () => {
2022-03-17 18:17:28 -07:00
this.props.onChat(this.props.account, this.props.history);
}
handleEndorseToggle = () => {
this.props.onEndorseToggle(this.props.account);
}
2020-03-27 13:59:38 -07:00
handleAddToList = () => {
this.props.onAddToList(this.props.account);
}
handleDeactivateUser = () => {
this.props.onDeactivateUser(this.props.account);
}
handleDeleteUser = () => {
this.props.onDeleteUser(this.props.account);
}
2021-03-15 19:50:16 -07:00
handleVerifyUser = () => {
this.props.onVerifyUser(this.props.account);
}
handleUnverifyUser = () => {
this.props.onUnverifyUser(this.props.account);
}
handlePromoteToAdmin = () => {
this.props.onPromoteToAdmin(this.props.account);
}
handlePromoteToModerator = () => {
this.props.onPromoteToModerator(this.props.account);
}
handleDemoteToUser = () => {
this.props.onDemoteToUser(this.props.account);
}
handleSuggestUser = () => {
this.props.onSuggestUser(this.props.account);
}
handleUnsuggestUser = () => {
this.props.onUnsuggestUser(this.props.account);
}
handleShowNote = () => {
this.props.onShowNote(this.props.account);
}
render() {
2020-03-27 13:59:38 -07:00
const { account, identity_proofs } = this.props;
const moved = (account) ? account.get('moved') : false;
return (
2022-03-21 11:09:01 -07:00
<>
2020-03-27 13:59:38 -07:00
{ moved && <MovedNote from={account} to={account.get('moved')} /> }
<InnerHeader
account={account}
identity_proofs={identity_proofs}
onFollow={this.handleFollow}
onBlock={this.handleBlock}
onMention={this.handleMention}
onDirect={this.handleDirect}
onChat={this.handleChat}
2020-03-27 13:59:38 -07:00
onReblogToggle={this.handleReblogToggle}
onSubscriptionToggle={this.handleSubscriptionToggle}
onNotifyToggle={this.handleNotifyToggle}
2020-03-27 13:59:38 -07:00
onReport={this.handleReport}
onMute={this.handleMute}
onBlockDomain={this.handleBlockDomain}
onUnblockDomain={this.handleUnblockDomain}
onEndorseToggle={this.handleEndorseToggle}
onAddToList={this.handleAddToList}
onDeactivateUser={this.handleDeactivateUser}
onDeleteUser={this.handleDeleteUser}
2021-03-15 19:50:16 -07:00
onVerifyUser={this.handleVerifyUser}
onUnverifyUser={this.handleUnverifyUser}
onPromoteToAdmin={this.handlePromoteToAdmin}
onPromoteToModerator={this.handlePromoteToModerator}
onDemoteToUser={this.handleDemoteToUser}
onSuggestUser={this.handleSuggestUser}
onUnsuggestUser={this.handleUnsuggestUser}
onShowNote={this.handleShowNote}
2020-03-27 13:59:38 -07:00
username={this.props.username}
/>
2022-03-21 11:09:01 -07:00
</>
2020-03-27 13:59:38 -07:00
);
}
}