/** @jsx h */ import { h, Component } from 'preact'; import Dropdown, { DropdownItem } from 'components/dropdown'; import Button from 'components/button'; import { PROVIDER_NAMES, IS_STORAGE_AVAILABLE, IS_THIRD_PARTY } from 'common/constants'; import { requestDeletion } from 'utils/email'; import { getHandleClickProps } from 'common/accessibility'; import UserId from './__user-id'; export default class AuthPanel extends Component { constructor(props) { super(props); this.toggleBlockedVisibility = this.toggleBlockedVisibility.bind(this); this.toggleCommentsAvailability = this.toggleCommentsAvailability.bind(this); this.onSortChange = this.onSortChange.bind(this); } onSortChange(e) { if (this.props.onSortChange) { this.props.onSortChange(e.target.value); } } toggleBlockedVisibility() { if (!this.state.isBlockedVisible) { if (this.props.onBlockedUsersShow) this.props.onBlockedUsersShow(); } else if (this.props.onBlockedUsersHide) this.props.onBlockedUsersHide(); this.setState({ isBlockedVisible: !this.state.isBlockedVisible }); } toggleCommentsAvailability() { if (this.props.isCommentsDisabled) { if (this.props.onCommentsEnable) { this.props.onCommentsEnable(); } } else { if (this.props.onCommentsDisable) { this.props.onCommentsDisable(); } } } getUserTitle() { const { user } = this.props; return {user.name}; } render(props, { isBlockedVisible }) { const { user, providers = [], sort, isCommentsDisabled } = props; const sortArray = getSortArray(sort); let loggedIn = !!user.id; return (