a bunch of small fixes in refactored UI
This commit is contained in:
+23
-4
@@ -91,6 +91,7 @@ class InfoView extends React.Component {
|
||||
owner: false,
|
||||
admin: false,
|
||||
sharer: false,
|
||||
deleter: false,
|
||||
muted: false,
|
||||
address: null,
|
||||
groupTopic: undefined,
|
||||
@@ -201,6 +202,7 @@ class InfoView extends React.Component {
|
||||
owner: acs && acs.isOwner(),
|
||||
admin: acs && acs.isAdmin(),
|
||||
sharer: acs && acs.isSharer(),
|
||||
deleter: acs && acs.isDeleter(),
|
||||
muted: acs && acs.isMuted(),
|
||||
|
||||
fullName: _clip(topic.public ? topic.public.fn : undefined, MAX_TITLE_LENGTH),
|
||||
@@ -268,10 +270,10 @@ class InfoView extends React.Component {
|
||||
handlePermissionsChanged(which, perm) {
|
||||
switch (which) {
|
||||
case 'auth':
|
||||
this.props.onTopicDescUpdate(this.props.topic, null, null, {auth: perm});
|
||||
this.props.onTopicDescUpdateRequest(this.props.topic, null, null, {auth: perm});
|
||||
break;
|
||||
case 'anon':
|
||||
this.props.onTopicDescUpdate(this.props.topic, null, null, {anon: perm});
|
||||
this.props.onTopicDescUpdateRequest(this.props.topic, null, null, {anon: perm});
|
||||
break;
|
||||
case 'mode':
|
||||
case 'want':
|
||||
@@ -284,6 +286,8 @@ class InfoView extends React.Component {
|
||||
this.props.onChangePermissions(this.props.topic, perm, this.state.userPermissionsEdited);
|
||||
break;
|
||||
}
|
||||
|
||||
this.handleBackNavigate();
|
||||
}
|
||||
|
||||
handleLaunchPermissionsEditor(which, uid) {
|
||||
@@ -346,7 +350,7 @@ class InfoView extends React.Component {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.log("Unknown permission editing mode '" + which + "'");
|
||||
console.error("Unknown permission editing mode '" + which + "'");
|
||||
return;
|
||||
}
|
||||
this.setState({
|
||||
@@ -483,8 +487,23 @@ class InfoView extends React.Component {
|
||||
:
|
||||
view == 'security' ?
|
||||
<TopicSecurity
|
||||
tinode={this.props.tinode}
|
||||
topic={this.props.topic}
|
||||
owner={this.state.owner}
|
||||
admin={this.state.admin}
|
||||
sharer={this.state.sharer}
|
||||
deleter={this.state.deleter}
|
||||
muted={this.state.muted}
|
||||
|
||||
groupTopic={this.state.groupTopic}
|
||||
channel={this.state.channel}
|
||||
access={this.state.access}
|
||||
modeGiven={this.state.modeGiven}
|
||||
modeWant={this.state.modeWant}
|
||||
modeGiven2={this.state.modeGiven2}
|
||||
modeWant2={this.state.modeWant2}
|
||||
auth={this.state.auth}
|
||||
anon={this.state.anon}
|
||||
|
||||
onShowAlert={this.props.onShowAlert}
|
||||
onDeleteMessages={this.props.onDeleteMessages}
|
||||
onLeaveTopic={this.props.onLeaveTopic}
|
||||
|
||||
@@ -74,48 +74,10 @@ const messages = defineMessages({
|
||||
},
|
||||
});
|
||||
|
||||
class TopicSecurity extends React.Component {
|
||||
class TopicSecurity extends React.PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
const topic = this.props.tinode.getTopic(this.props.topic);
|
||||
if (!topic) {
|
||||
return;
|
||||
}
|
||||
|
||||
const defacs = topic.getDefaultAccess() || {};
|
||||
const acs = topic.getAccessMode();
|
||||
|
||||
let modeGiven2 = NO_ACCESS_MODE;
|
||||
let modeWant2 = NO_ACCESS_MODE;
|
||||
if (topic.getType() == 'p2p') {
|
||||
// Fetch the other party in the p2p conversation.
|
||||
// Topic may not be ready yet, so check if user is found.
|
||||
const user2 = topic.subscriber(props.topic);
|
||||
if (user2 && user2.acs) {
|
||||
modeGiven2 = user2.acs.getGiven();
|
||||
modeWant2 = user2.acs.getWant();
|
||||
}
|
||||
}
|
||||
|
||||
this.state = {
|
||||
owner: acs && acs.isOwner(),
|
||||
admin: acs && acs.isAdmin(),
|
||||
sharer: acs && acs.isSharer(),
|
||||
deleter: acs && acs.isDeleter(),
|
||||
muted: acs && acs.isMuted(),
|
||||
|
||||
groupTopic: topic.isGroupType(),
|
||||
channel: topic.isChannelType(),
|
||||
access: acs ? acs.getMode() : undefined,
|
||||
modeGiven: acs ? acs.getGiven() : undefined,
|
||||
modeWant: acs ? acs.getWant() : undefined,
|
||||
modeGiven2: modeGiven2, // P2P topic, the other user mode given
|
||||
modeWant2: modeWant2, // P2P topic, the other user mode want
|
||||
auth: defacs ? defacs.auth : null,
|
||||
anon: defacs ? defacs.anon : null,
|
||||
};
|
||||
|
||||
this.handleDeleteTopic = this.handleDeleteTopic.bind(this);
|
||||
this.handleDeleteMessages = this.handleDeleteMessages.bind(this);
|
||||
this.handleLeave = this.handleLeave.bind(this);
|
||||
@@ -140,8 +102,8 @@ class TopicSecurity extends React.Component {
|
||||
e.preventDefault();
|
||||
const {formatMessage} = this.props.intl;
|
||||
this.props.onShowAlert(
|
||||
formatMessage(this.state.deleter ? messages.delete_messages : messages.clear_messages), // title
|
||||
formatMessage(this.state.deleter ? messages.delete_messages_warning : messages.clear_messages_warning), // content
|
||||
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
|
||||
@@ -193,16 +155,16 @@ class TopicSecurity extends React.Component {
|
||||
return (
|
||||
<div className="scrollable-panel">
|
||||
<div className="panel-form-column">
|
||||
{!this.state.channel ?
|
||||
{!this.props.channel ?
|
||||
<a href="#" className="flat-button" onClick={this.handleDeleteMessages}>
|
||||
<i className="material-icons">delete_outline</i> {
|
||||
formatMessage(this.state.deleter ? messages.delete_messages : messages.clear_messages)
|
||||
formatMessage(this.props.deleter ? messages.delete_messages : messages.clear_messages)
|
||||
}
|
||||
</a>
|
||||
:
|
||||
null
|
||||
}
|
||||
{this.state.owner ?
|
||||
{this.props.owner ?
|
||||
<a href="#" className="danger flat-button" onClick={this.handleDeleteTopic}>
|
||||
<i className="material-icons">delete</i> {formatMessage(messages.topic_delete)}
|
||||
</a>
|
||||
@@ -211,14 +173,14 @@ class TopicSecurity extends React.Component {
|
||||
<i className="material-icons">exit_to_app</i> {formatMessage(messages.leave_chat)}
|
||||
</a>
|
||||
}
|
||||
{!this.state.groupTopic ?
|
||||
{!this.props.groupTopic ?
|
||||
<a href="#" className="danger flat-button" onClick={this.handleBlock}>
|
||||
<i className="material-icons">block</i> {formatMessage(messages.block_contact)}
|
||||
</a>
|
||||
:
|
||||
null
|
||||
}
|
||||
{!this.state.owner ?
|
||||
{!this.props.owner ?
|
||||
<a href="#" className="danger flat-button" onClick={this.handleReport}>
|
||||
<i className="material-icons">report</i> {formatMessage(messages.report_chat)}
|
||||
</a>
|
||||
@@ -228,7 +190,7 @@ class TopicSecurity extends React.Component {
|
||||
</div>
|
||||
<div className="hr" />
|
||||
<div className="panel-form-column">
|
||||
{this.state.groupTopic ?
|
||||
{this.props.groupTopic ?
|
||||
<>
|
||||
<div className="group">
|
||||
<label>
|
||||
@@ -236,7 +198,7 @@ class TopicSecurity extends React.Component {
|
||||
description="Label for current user permissions" />
|
||||
</label> <tt className="clickable"
|
||||
onClick={(e) => {e.preventDefault(); this.props.onLaunchPermissionsEditor('want')}}>
|
||||
{this.state.access}
|
||||
{this.props.access}
|
||||
</tt>
|
||||
</div>
|
||||
<div className="group">
|
||||
@@ -248,10 +210,10 @@ class TopicSecurity extends React.Component {
|
||||
</div>
|
||||
<div className="quoted">
|
||||
<div>Auth: <tt className="clickable"
|
||||
onClick={(e) => {e.preventDefault(); this.props.onLaunchPermissionsEditor('auth')}}>{this.state.auth}</tt>
|
||||
onClick={(e) => {e.preventDefault(); this.props.onLaunchPermissionsEditor('auth')}}>{this.props.auth}</tt>
|
||||
</div>
|
||||
<div>Anon: <tt className="clickable"
|
||||
onClick={(e) => {e.preventDefault(); this.props.onLaunchPermissionsEditor('anon')}}>{this.state.anon}</tt>
|
||||
onClick={(e) => {e.preventDefault(); this.props.onLaunchPermissionsEditor('anon')}}>{this.props.anon}</tt>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -269,13 +231,13 @@ class TopicSecurity extends React.Component {
|
||||
<FormattedMessage id="label_you" defaultMessage="You:"
|
||||
description="Label for the current user" /> <tt className="clickable"
|
||||
onClick={(e) => {e.preventDefault(); this.props.onLaunchPermissionsEditor('want')}}>
|
||||
{this.state.access}
|
||||
{this.props.access}
|
||||
</tt>
|
||||
</div>
|
||||
<div>{this.state.fullName ? this.state.fullName : formatMessage(messages.other_user)}:
|
||||
<div>{this.props.fullName ? this.props.fullName : formatMessage(messages.other_user)}:
|
||||
<tt className="clickable"
|
||||
onClick={(e) => {e.preventDefault(); this.props.onLaunchPermissionsEditor('given')}}>
|
||||
{this.state.modeGiven2}
|
||||
{this.props.modeGiven2}
|
||||
</tt>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user