mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 20:38:55 +03:00
Add checkbox to GroupAddressPicker for determining visibility of group rooms
This commit is contained in:
parent
80d4873542
commit
edc744067f
5 changed files with 26 additions and 11 deletions
|
@ -49,20 +49,26 @@ export function showGroupInviteDialog(groupId) {
|
||||||
|
|
||||||
export function showGroupAddRoomDialog(groupId) {
|
export function showGroupAddRoomDialog(groupId) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
let addRoomsPublicly = false;
|
||||||
|
const onCheckboxClicked = (e) => {
|
||||||
|
addRoomsPublicly = e.target.checked;
|
||||||
|
};
|
||||||
const description = <div>
|
const description = <div>
|
||||||
<div>{ _t("Which rooms would you like to add to this community?") }</div>
|
<div>{ _t("Which rooms would you like to add to this community?") }</div>
|
||||||
<div className="warning">
|
|
||||||
{ _t(
|
|
||||||
"Warning: any room you add to a community will be publicly "+
|
|
||||||
"visible to anyone who knows the community ID",
|
|
||||||
) }
|
|
||||||
</div>
|
|
||||||
</div>;
|
</div>;
|
||||||
|
|
||||||
|
const checkboxContainer = <label className="mx_GroupAddressPicker_checkboxContainer">
|
||||||
|
<input type="checkbox" onClick={onCheckboxClicked} />
|
||||||
|
<div>
|
||||||
|
{ _t("Show these rooms to non-members on the community page and room list?") }
|
||||||
|
</div>
|
||||||
|
</label>;
|
||||||
|
|
||||||
const AddressPickerDialog = sdk.getComponent("dialogs.AddressPickerDialog");
|
const AddressPickerDialog = sdk.getComponent("dialogs.AddressPickerDialog");
|
||||||
Modal.createTrackedDialog('Add Rooms to Group', '', AddressPickerDialog, {
|
Modal.createTrackedDialog('Add Rooms to Group', '', AddressPickerDialog, {
|
||||||
title: _t("Add rooms to the community"),
|
title: _t("Add rooms to the community"),
|
||||||
description: description,
|
description: description,
|
||||||
|
extraNode: checkboxContainer,
|
||||||
placeholder: _t("Room name or alias"),
|
placeholder: _t("Room name or alias"),
|
||||||
button: _t("Add to community"),
|
button: _t("Add to community"),
|
||||||
pickerType: 'room',
|
pickerType: 'room',
|
||||||
|
@ -70,7 +76,7 @@ export function showGroupAddRoomDialog(groupId) {
|
||||||
onFinished: (success, addrs) => {
|
onFinished: (success, addrs) => {
|
||||||
if (!success) return;
|
if (!success) return;
|
||||||
|
|
||||||
_onGroupAddRoomFinished(groupId, addrs).then(resolve, reject);
|
_onGroupAddRoomFinished(groupId, addrs, addRoomsPublicly).then(resolve, reject);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -106,13 +112,13 @@ function _onGroupInviteFinished(groupId, addrs) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function _onGroupAddRoomFinished(groupId, addrs) {
|
function _onGroupAddRoomFinished(groupId, addrs, addRoomsPublicly) {
|
||||||
const matrixClient = MatrixClientPeg.get();
|
const matrixClient = MatrixClientPeg.get();
|
||||||
const groupStore = GroupStoreCache.getGroupStore(matrixClient, groupId);
|
const groupStore = GroupStoreCache.getGroupStore(matrixClient, groupId);
|
||||||
const errorList = [];
|
const errorList = [];
|
||||||
return Promise.all(addrs.map((addr) => {
|
return Promise.all(addrs.map((addr) => {
|
||||||
return groupStore
|
return groupStore
|
||||||
.addRoomToGroup(addr.address)
|
.addRoomToGroup(addr.address, addRoomsPublicly)
|
||||||
.catch(() => { errorList.push(addr.address); })
|
.catch(() => { errorList.push(addr.address); })
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const roomId = addr.address;
|
const roomId = addr.address;
|
||||||
|
|
|
@ -575,7 +575,7 @@ export default React.createClass({
|
||||||
|
|
||||||
_onAcceptInviteClick: function() {
|
_onAcceptInviteClick: function() {
|
||||||
this.setState({membershipBusy: true});
|
this.setState({membershipBusy: true});
|
||||||
MatrixClientPeg.get().acceptGroupInvite(this.props.groupId).then(() => {
|
this._groupStore.acceptGroupInvite().then(() => {
|
||||||
// don't reset membershipBusy here: wait for the membership change to come down the sync
|
// don't reset membershipBusy here: wait for the membership change to come down the sync
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
this.setState({membershipBusy: false});
|
this.setState({membershipBusy: false});
|
||||||
|
|
|
@ -34,6 +34,8 @@ module.exports = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
title: PropTypes.string.isRequired,
|
title: PropTypes.string.isRequired,
|
||||||
description: PropTypes.node,
|
description: PropTypes.node,
|
||||||
|
// Extra node inserted after picker input, dropdown and errors
|
||||||
|
extraNode: PropTypes.node,
|
||||||
value: PropTypes.string,
|
value: PropTypes.string,
|
||||||
placeholder: PropTypes.string,
|
placeholder: PropTypes.string,
|
||||||
roomId: PropTypes.string,
|
roomId: PropTypes.string,
|
||||||
|
@ -574,6 +576,7 @@ module.exports = React.createClass({
|
||||||
<div className="mx_ChatInviteDialog_inputContainer">{ query }</div>
|
<div className="mx_ChatInviteDialog_inputContainer">{ query }</div>
|
||||||
{ error }
|
{ error }
|
||||||
{ addressSelector }
|
{ addressSelector }
|
||||||
|
{ this.props.extraNode }
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_Dialog_buttons">
|
<div className="mx_Dialog_buttons">
|
||||||
<button className="mx_Dialog_primary" onClick={this.onButtonClick}>
|
<button className="mx_Dialog_primary" onClick={this.onButtonClick}>
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
"Name or matrix ID": "Name or matrix ID",
|
"Name or matrix ID": "Name or matrix ID",
|
||||||
"Invite to Community": "Invite to Community",
|
"Invite to Community": "Invite to Community",
|
||||||
"Which rooms would you like to add to this community?": "Which rooms would you like to add to this community?",
|
"Which rooms would you like to add to this community?": "Which rooms would you like to add to this community?",
|
||||||
"Warning: any room you add to a community will be publicly visible to anyone who knows the community ID": "Warning: any room you add to a community will be publicly visible to anyone who knows the community ID",
|
"Show these rooms to non-members on the community page and room list?": "Show these rooms to non-members on the community page and room list?",
|
||||||
"Add rooms to the community": "Add rooms to the community",
|
"Add rooms to the community": "Add rooms to the community",
|
||||||
"Room name or alias": "Room name or alias",
|
"Room name or alias": "Room name or alias",
|
||||||
"Add to community": "Add to community",
|
"Add to community": "Add to community",
|
||||||
|
|
|
@ -169,6 +169,12 @@ export default class GroupStore extends EventEmitter {
|
||||||
.then(this._fetchMembers.bind(this));
|
.then(this._fetchMembers.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
acceptGroupInvite() {
|
||||||
|
return this._matrixClient.acceptGroupInvite(this.groupId)
|
||||||
|
// The user might be able to see more rooms now
|
||||||
|
.then(this._fetchRooms.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
addRoomToGroupSummary(roomId, categoryId) {
|
addRoomToGroupSummary(roomId, categoryId) {
|
||||||
return this._matrixClient
|
return this._matrixClient
|
||||||
.addRoomToGroupSummary(this.groupId, roomId, categoryId)
|
.addRoomToGroupSummary(this.groupId, roomId, categoryId)
|
||||||
|
|
Loading…
Reference in a new issue