// Edit account parameters. import React from 'react'; import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'; import InPlaceEdit from './in-place-edit.jsx'; import { NO_ACCESS_MODE } from '../config.js'; const messages = defineMessages({ clear_messages: { id: 'action_clear_messages', defaultMessage: 'Clear Messages', description: 'Flat button [Clear Messages] (soft-delete messages)' }, clear_messages_warning: { id: 'clear_messages_warning', defaultMessage: 'Are you sure you want to clear all messages? It cannot be undone.', description: 'Alert dialog warning when deleting all messages.' }, delete_messages: { id: 'action_delete_messages', defaultMessage: 'Clear Messages for All', description: 'Flat button [Clear for All] (hard-delete all messages)' }, delete_messages_warning: { id: 'delete_messages_warning', defaultMessage: 'Are you sure you want to delete all messages for everyone? It cannot be undone.', description: 'Alert dialog warning when hard-deleting all messages.' }, topic_delete: { id: 'topic_delete', defaultMessage: 'Delete Conversation', description: 'Alert title when deleting the topic.' }, topic_delete_warning: { id: 'topic_delete_warning', defaultMessage: 'Are you sure you want to delete this conversation? It cannot be undone.', description: 'Alert warning when deleting entire topic' }, leave_chat: { id: 'action_leave_chat', defaultMessage: 'Leave Conversation', description: 'Flat button [Leave Conversation]' }, leave_chat_warning: { id: 'leave_chat_warning', defaultMessage: 'Are you sure you want to leave this conversation?', description: 'Alert dialog warning when unsubscribing from a chat.' }, block_contact: { id: 'action_block_contact', defaultMessage: "Block Contact", description: "Flat button [Block Contact]" }, block_contact_warning: { id: 'block_contact_warning', defaultMessage: 'Are you sure you want to block this contact?', description: 'Alert dialog warning when blocking a contact.' }, report_chat: { id: 'action_report_chat', defaultMessage: 'Report Conversation', description: 'Flat button [Report Group]' }, report_chat_warning: { id: 'report_chat_warning', defaultMessage: 'Are you sure you want to block and report this conversation?', description: 'Alert dialog warning when reporting a conversation for abuse' }, other_user: { id: 'label_other_user', defaultMessage: 'Other', description: 'Label for the other user when the user is unnamed' }, }); class TopicSecurity extends React.PureComponent { constructor(props) { super(props); this.handleDeleteTopic = this.handleDeleteTopic.bind(this); this.handleDeleteMessages = this.handleDeleteMessages.bind(this); this.handleLeave = this.handleLeave.bind(this); this.handleBlock = this.handleBlock.bind(this); this.handleReport = this.handleReport.bind(this); } handleDeleteTopic(e) { e.preventDefault(); const {formatMessage} = this.props.intl; this.props.onShowAlert( formatMessage(messages.topic_delete), // title formatMessage(messages.topic_delete_warning), // content (() => { this.props.onDeleteTopic(this.props.topic); }), // onConfirm null, // "OK" true, // Show Reject button null // "Cancel" ); } handleDeleteMessages(e) { e.preventDefault(); const {formatMessage} = this.props.intl; this.props.onShowAlert( formatMessage(this.props.deleter ? messages.delete_messages : messages.clear_messages), // title formatMessage(this.props.deleter ? messages.delete_messages_warning : messages.clear_messages_warning), // content (() => { this.props.onDeleteMessages(this.props.topic); }), // onConfirm null, // "OK" true, // Show Reject button null // "Cancel" ); } handleLeave(e) { e.preventDefault(); const {formatMessage} = this.props.intl; this.props.onShowAlert( formatMessage(messages.leave_chat), // title formatMessage(messages.leave_chat_warning), // content (() => { this.props.onLeaveTopic(this.props.topic); }), // onConfirm null, // "OK" true, // Show Reject button null // "Cancel" ); } handleBlock(e) { e.preventDefault(); const {formatMessage} = this.props.intl; this.props.onShowAlert( formatMessage(messages.block_contact), // title formatMessage(messages.block_contact_warning), // content (() => { this.props.onBlockTopic(this.props.topic); }), // onConfirm null, // "OK" true, // Show Reject button null // "Cancel" ); } handleReport(e) { e.preventDefault(); const {formatMessage} = this.props.intl; this.props.onShowAlert( formatMessage(messages.report_chat), // title formatMessage(messages.report_chat_warning), // content (() => { this.props.onReportTopic(this.props.topic); }), // onConfirm null, // "OK" true, // Show Reject button null // "Cancel" ); } render() { const {formatMessage} = this.props.intl; return (
{!this.props.channel ? delete_outline  { formatMessage(this.props.deleter ? messages.delete_messages : messages.clear_messages) } : null } {this.props.owner ? delete  {formatMessage(messages.topic_delete)} : exit_to_app  {formatMessage(messages.leave_chat)} } {!this.props.groupTopic ? block  {formatMessage(messages.block_contact)} : null } {!this.props.owner ? report  {formatMessage(messages.report_chat)} : null }
{this.props.groupTopic ? <>
{e.preventDefault(); this.props.onLaunchPermissionsEditor('want')}}> {this.props.access}
{!this.props.channel ?
Auth: { e.preventDefault(); if (this.props.owner) { this.props.onLaunchPermissionsEditor('auth'); } }}>{this.props.auth}
Anon: { e.preventDefault(); if (this.props.owner) { this.props.onLaunchPermissionsEditor('anon'); } }}>{this.props.anon}
: null } :
{e.preventDefault(); this.props.onLaunchPermissionsEditor('want')}}> {this.props.access}
{this.props.fullName ? this.props.fullName : formatMessage(messages.other_user)}:   {e.preventDefault(); this.props.onLaunchPermissionsEditor('given')}}> {this.props.modeGiven2}
}
); } }; export default injectIntl(TopicSecurity);