more refactoring of permissions editor. still does not work

This commit is contained in:
or-else
2017-08-08 18:33:30 +03:00
parent 83fe8ea02b
commit 0dde03cf6f
+48 -25
View File
@@ -1654,6 +1654,8 @@
access: null, access: null,
modeGiven: null, modeGiven: null,
modeWant: null, modeWant: null,
modeGiven2: null, // P2P topic, the other user mode given
modeWant2: null, // P2P topic, the other user mode want
auth: null, auth: null,
anon: null, anon: null,
contactList: [], contactList: [],
@@ -1689,12 +1691,23 @@
resetSubs: function(topic) { resetSubs: function(topic) {
var contacts = []; var contacts = [];
topic.subscribers(function(sub){ if (topic.getType() === "p2p") {
contacts.push(sub); // Fetch the other party in the p2p conversation.
}, this); var user2 = topic.subscriber(this.props.topic);
this.setState({ this.setState({
contactList: contacts modeGiven2: user2.acs.getGiven(),
}); modeWant2: user2.acs.getWant(),
});
console.log("Processed resetSub");
console.log(user2);
} else {
topic.subscribers(function(sub){
contacts.push(sub);
}, this);
this.setState({
contactList: contacts
});
}
}, },
resetDesc: function(topic) { resetDesc: function(topic) {
@@ -1727,6 +1740,7 @@
}, },
onSubsUpdated: function() { onSubsUpdated: function() {
console.log("onSubsUpdated");
var topic = Tinode.getTopic(this.props.topic); var topic = Tinode.getTopic(this.props.topic);
if (!topic) { if (!topic) {
return; return;
@@ -1764,7 +1778,7 @@
this.props.onChangePermissions(this.props.topic, checked ? "-P" : "+P"); this.props.onChangePermissions(this.props.topic, checked ? "-P" : "+P");
}, },
handlePermissionsChanged: function(perm, uid) { handlePermissionsChanged: function(perm) {
switch (this.state.showPermissionEditorFor) { switch (this.state.showPermissionEditorFor) {
case 'auth': case 'auth':
this.props.onTopicDescUpdate(this.props.topic, null, null, {auth: perm}); this.props.onTopicDescUpdate(this.props.topic, null, null, {auth: perm});
@@ -1777,7 +1791,7 @@
this.props.onChangePermissions(this.props.topic, perm); this.props.onChangePermissions(this.props.topic, perm);
break; break;
case 'given': case 'given':
this.props.onChangePermissions(this.props.topic, perm, uid); this.props.onChangePermissions(this.props.topic, perm, this.props.topic);
break; break;
} }
@@ -1798,8 +1812,8 @@
titleCompare = 'Granted'; titleCompare = 'Granted';
break; break;
case 'given': case 'given':
toEdit = this.state.modeGiven; toEdit = this.state.modeGiven2;
toCompare = this.state.modeWant; toCompare = this.state.modeWant2;
titleEdit = 'Granted'; titleEdit = 'Granted';
titleCompare = 'Requested'; titleCompare = 'Requested';
break; break;
@@ -1913,18 +1927,34 @@
<label>Address:</label> <label>Address:</label>
<tt>{this.state.address}</tt> <tt>{this.state.address}</tt>
</div> </div>
<div className="panel-form-row">
<label>Permissions:</label>
<tt className="clickable"
onClick={this.handleLaunchPermissionsEditor.bind(this, 'want')}>
{this.state.access}
</tt>
</div>
<div className="panel-form-row"> <div className="panel-form-row">
<label>Muted:</label> <label>Muted:</label>
<CheckBox name="P" checked={this.state.muted} <CheckBox name="P" checked={this.state.muted}
onChange={this.handleMuted} /> onChange={this.handleMuted} />
</div> </div>
{this.state.groupTopic ?
<div className="panel-form-row">
<label>Your permissions:</label>
<tt className="clickable"
onClick={this.handleLaunchPermissionsEditor.bind(this, 'want')}>
{this.state.access}
</tt>
</div>
:
<div>
<div><label className="small">Permissions:</label></div>
<div className="quoted">
<div>Yours: <tt className="clickable"
onClick={this.handleLaunchPermissionsEditor.bind(this, 'want')}>
{this.state.access}
</tt></div>
<div>{this.state.fullName}&prime;s: <tt className="clickable"
onClick={this.handleLaunchPermissionsEditor.bind(this, 'given')}>
{this.state.modeGiven}
</tt></div>
</div>
</div>
}
{this.state.auth || this.state.anon ? {this.state.auth || this.state.anon ?
<div> <div>
<div><label className="small">Default access mode:</label></div> <div><label className="small">Default access mode:</label></div>
@@ -2099,13 +2129,11 @@
} }
if (topic.isSubscribed()) { if (topic.isSubscribed()) {
console.log("topic " + props.topic + " is subscribed");
this.handleDescChange(topic); this.handleDescChange(topic);
topic.messages(function(msg) { topic.messages(function(msg) {
msgs = msgs.concat(msg); msgs = msgs.concat(msg);
}); });
} else { } else {
console.log("topic " + props.topic + " is NOT subscribed");
topic.subscribe({get: {desc: {}, sub: {}, data: {}}}); topic.subscribe({get: {desc: {}, sub: {}, data: {}}});
} }
@@ -2645,9 +2673,8 @@
var instance = this; var instance = this;
var topic = peerName ? Tinode.newTopicWith(peerName) : Tinode.newTopic(); var topic = peerName ? Tinode.newTopicWith(peerName) : Tinode.newTopic();
var params = {get: {desc: {}, data: {}}}; var params = {get: {desc: {}, data: {}, sub: {}}};
if (!peerName) { if (!peerName) {
params.get.sub = {};
params.set = {desc: {public: pub}}; params.set = {desc: {public: pub}};
} }
@@ -2665,10 +2692,6 @@
}); });
}, },
//handleManageGroupMembers: function(topicName) {
// FIXME(gene): launch group member manager
//onAddMember},
handleTopicUpdateRequest: function(topicName, pub, priv, permissions) { handleTopicUpdateRequest: function(topicName, pub, priv, permissions) {
var topic = Tinode.getTopic(topicName); var topic = Tinode.getTopic(topicName);
if (topic) { if (topic) {