Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Weblate 2018-06-05 09:37:06 +00:00
commit 0ca7fb4abc
5 changed files with 100 additions and 49 deletions

View file

@ -432,11 +432,14 @@ export default React.createClass({
this._changeAvatarComponent = null; this._changeAvatarComponent = null;
this._initGroupStore(this.props.groupId, true); this._initGroupStore(this.props.groupId, true);
this._dispatcherRef = dis.register(this._onAction);
}, },
componentWillUnmount: function() { componentWillUnmount: function() {
this._unmounted = true; this._unmounted = true;
this._matrixClient.removeListener("Group.myMembership", this._onGroupMyMembership); this._matrixClient.removeListener("Group.myMembership", this._onGroupMyMembership);
dis.unregister(this._dispatcherRef);
}, },
componentWillReceiveProps: function(newProps) { componentWillReceiveProps: function(newProps) {
@ -563,12 +566,22 @@ export default React.createClass({
this._closeSettings(); this._closeSettings();
}, },
_onAction(payload) {
switch (payload.action) {
// NOTE: close_settings is an app-wide dispatch; as it is dispatched from MatrixChat
case 'close_settings':
this.setState({
editing: false,
profileForm: null,
});
break;
default:
break;
}
},
_closeSettings() { _closeSettings() {
this.setState({ dis.dispatch({action: 'close_settings'});
editing: false,
profileForm: null,
});
dis.dispatch({action: 'panel_disable'});
}, },
_onNameChange: function(value) { _onNameChange: function(value) {

View file

@ -255,6 +255,22 @@ const LoggedInView = React.createClass({
), true); ), true);
}, },
_onClick: function(ev) {
// When the panels are disabled, clicking on them results in a mouse event
// which bubbles to certain elements in the tree. When this happens, close
// any settings page that is currently open (user/room/group).
if (this.props.leftDisabled &&
this.props.rightDisabled &&
(
ev.target.className === 'mx_MatrixChat' ||
ev.target.className === 'mx_MatrixChat_middlePanel' ||
ev.target.className === 'mx_RoomView'
)
) {
dis.dispatch({ action: 'close_settings' });
}
},
render: function() { render: function() {
const LeftPanel = sdk.getComponent('structures.LeftPanel'); const LeftPanel = sdk.getComponent('structures.LeftPanel');
const RightPanel = sdk.getComponent('structures.RightPanel'); const RightPanel = sdk.getComponent('structures.RightPanel');
@ -295,7 +311,7 @@ const LoggedInView = React.createClass({
case PageTypes.UserSettings: case PageTypes.UserSettings:
page_element = <UserSettings page_element = <UserSettings
onClose={this.props.onUserSettingsClose} onClose={this.props.onCloseAllSettings}
brand={this.props.config.brand} brand={this.props.config.brand}
referralBaseUrl={this.props.config.referralBaseUrl} referralBaseUrl={this.props.config.referralBaseUrl}
teamToken={this.props.teamToken} teamToken={this.props.teamToken}
@ -380,7 +396,7 @@ const LoggedInView = React.createClass({
} }
return ( return (
<div className='mx_MatrixChat_wrapper' aria-hidden={this.props.hideToSRUsers}> <div className='mx_MatrixChat_wrapper' aria-hidden={this.props.hideToSRUsers} onClick={this._onClick}>
{ topBar } { topBar }
<DragDropContext onDragEnd={this._onDragEnd}> <DragDropContext onDragEnd={this._onDragEnd}>
<div className={bodyClasses}> <div className={bodyClasses}>

View file

@ -566,6 +566,27 @@ export default React.createClass({
this._setPage(PageTypes.UserSettings); this._setPage(PageTypes.UserSettings);
this.notifyNewScreen('settings'); this.notifyNewScreen('settings');
break; break;
case 'close_settings':
this.setState({
leftDisabled: false,
rightDisabled: false,
middleDisabled: false,
});
if (this.state.page_type === PageTypes.UserSettings) {
// We do this to get setPage and notifyNewScreen
if (this.state.currentRoomId) {
this._viewRoom({
room_id: this.state.currentRoomId,
});
} else if (this.state.currentGroupId) {
this._viewGroup({
group_id: this.state.currentGroupId,
});
} else {
this._viewHome();
}
}
break;
case 'view_create_room': case 'view_create_room':
this._createRoom(); this._createRoom();
break; break;
@ -583,19 +604,10 @@ export default React.createClass({
this.notifyNewScreen('groups'); this.notifyNewScreen('groups');
break; break;
case 'view_group': case 'view_group':
{ this._viewGroup(payload);
const groupId = payload.group_id;
this.setState({
currentGroupId: groupId,
currentGroupIsNew: payload.group_is_new,
});
this._setPage(PageTypes.GroupView);
this.notifyNewScreen('group/' + groupId);
}
break; break;
case 'view_home_page': case 'view_home_page':
this._setPage(PageTypes.HomePage); this._viewHome();
this.notifyNewScreen('home');
break; break;
case 'view_set_mxid': case 'view_set_mxid':
this._setMxId(payload); this._setMxId(payload);
@ -638,7 +650,8 @@ export default React.createClass({
middleDisabled: payload.middleDisabled || false, middleDisabled: payload.middleDisabled || false,
rightDisabled: payload.rightDisabled || payload.sideDisabled || false, rightDisabled: payload.rightDisabled || payload.sideDisabled || false,
}); });
break; } break;
}
case 'set_theme': case 'set_theme':
this._onSetTheme(payload.value); this._onSetTheme(payload.value);
break; break;
@ -787,7 +800,6 @@ export default React.createClass({
// @param {string=} roomInfo.room_id ID of the room to join. One of room_id or room_alias must be given. // @param {string=} roomInfo.room_id ID of the room to join. One of room_id or room_alias must be given.
// @param {string=} roomInfo.room_alias Alias of the room to join. One of room_id or room_alias must be given. // @param {string=} roomInfo.room_alias Alias of the room to join. One of room_id or room_alias must be given.
// @param {boolean=} roomInfo.auto_join If true, automatically attempt to join the room if not already a member. // @param {boolean=} roomInfo.auto_join If true, automatically attempt to join the room if not already a member.
// @param {boolean=} roomInfo.show_settings Makes RoomView show the room settings dialog.
// @param {string=} roomInfo.event_id ID of the event in this room to show: this will cause a switch to the // @param {string=} roomInfo.event_id ID of the event in this room to show: this will cause a switch to the
// context of that particular event. // context of that particular event.
// @param {boolean=} roomInfo.highlighted If true, add event_id to the hash of the URL // @param {boolean=} roomInfo.highlighted If true, add event_id to the hash of the URL
@ -854,6 +866,21 @@ export default React.createClass({
}); });
}, },
_viewGroup: function(payload) {
const groupId = payload.group_id;
this.setState({
currentGroupId: groupId,
currentGroupIsNew: payload.group_is_new,
});
this._setPage(PageTypes.GroupView);
this.notifyNewScreen('group/' + groupId);
},
_viewHome: function() {
this._setPage(PageTypes.HomePage);
this.notifyNewScreen('home');
},
_setMxId: function(payload) { _setMxId: function(payload) {
const SetMxIdDialog = sdk.getComponent('views.dialogs.SetMxIdDialog'); const SetMxIdDialog = sdk.getComponent('views.dialogs.SetMxIdDialog');
const close = Modal.createTrackedDialog('Set MXID', '', SetMxIdDialog, { const close = Modal.createTrackedDialog('Set MXID', '', SetMxIdDialog, {
@ -1612,19 +1639,8 @@ export default React.createClass({
this._setPageSubtitle(subtitle); this._setPageSubtitle(subtitle);
}, },
onUserSettingsClose: function() { onCloseAllSettings() {
// XXX: use browser history instead to find the previous room? dis.dispatch({ action: 'close_settings' });
// or maintain a this.state.pageHistory in _setPage()?
if (this.state.currentRoomId) {
dis.dispatch({
action: 'view_room',
room_id: this.state.currentRoomId,
});
} else {
dis.dispatch({
action: 'view_home_page',
});
}
}, },
onServerConfigChange(config) { onServerConfigChange(config) {
@ -1683,7 +1699,7 @@ export default React.createClass({
return ( return (
<LoggedInView ref={this._collectLoggedInView} matrixClient={MatrixClientPeg.get()} <LoggedInView ref={this._collectLoggedInView} matrixClient={MatrixClientPeg.get()}
onRoomCreated={this.onRoomCreated} onRoomCreated={this.onRoomCreated}
onUserSettingsClose={this.onUserSettingsClose} onCloseAllSettings={this.onCloseAllSettings}
onRegistered={this.onRegistered} onRegistered={this.onRegistered}
currentRoomId={this.state.currentRoomId} currentRoomId={this.state.currentRoomId}
teamToken={this._teamToken} teamToken={this._teamToken}

View file

@ -182,6 +182,7 @@ module.exports = React.createClass({
isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(), isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(),
forwardingEvent: RoomViewStore.getForwardingEvent(), forwardingEvent: RoomViewStore.getForwardingEvent(),
shouldPeek: RoomViewStore.shouldPeek(), shouldPeek: RoomViewStore.shouldPeek(),
editingRoomSettings: RoomViewStore.isEditingSettings(),
}; };
// Temporary logging to diagnose https://github.com/vector-im/riot-web/issues/4307 // Temporary logging to diagnose https://github.com/vector-im/riot-web/issues/4307
@ -1139,7 +1140,7 @@ module.exports = React.createClass({
}, },
onSettingsClick: function() { onSettingsClick: function() {
this.showSettings(true); dis.dispatch({ action: 'open_room_settings' });
}, },
onSettingsSaveClick: function() { onSettingsSaveClick: function() {
@ -1172,24 +1173,20 @@ module.exports = React.createClass({
}); });
// still editing room settings // still editing room settings
} else { } else {
this.setState({ dis.dispatch({ action: 'close_settings' });
editingRoomSettings: false,
});
} }
}).finally(() => { }).finally(() => {
this.setState({ this.setState({
uploadingRoomSettings: false, uploadingRoomSettings: false,
editingRoomSettings: false,
}); });
dis.dispatch({ action: 'close_settings' });
}).done(); }).done();
}, },
onCancelClick: function() { onCancelClick: function() {
console.log("updateTint from onCancelClick"); console.log("updateTint from onCancelClick");
this.updateTint(); this.updateTint();
this.setState({ dis.dispatch({ action: 'close_settings' });
editingRoomSettings: false,
});
if (this.state.forwardingEvent) { if (this.state.forwardingEvent) {
dis.dispatch({ dis.dispatch({
action: 'forward_event', action: 'forward_event',
@ -1406,13 +1403,6 @@ module.exports = React.createClass({
});*/ });*/
}, },
showSettings: function(show) {
// XXX: this is a bit naughty; we should be doing this via props
if (show) {
this.setState({editingRoomSettings: true});
}
},
/** /**
* called by the parent component when PageUp/Down/etc is pressed. * called by the parent component when PageUp/Down/etc is pressed.
* *

View file

@ -44,6 +44,8 @@ const INITIAL_STATE = {
forwardingEvent: null, forwardingEvent: null,
quotingEvent: null, quotingEvent: null,
isEditingSettings: false,
}; };
/** /**
@ -116,6 +118,16 @@ class RoomViewStore extends Store {
replyingToEvent: payload.event, replyingToEvent: payload.event,
}); });
break; break;
case 'open_room_settings':
this._setState({
isEditingSettings: true,
});
break;
case 'close_settings':
this._setState({
isEditingSettings: false,
});
break;
} }
} }
@ -301,6 +313,10 @@ class RoomViewStore extends Store {
return this._state.replyingToEvent; return this._state.replyingToEvent;
} }
isEditingSettings() {
return this._state.isEditingSettings;
}
shouldPeek() { shouldPeek() {
return this._state.shouldPeek; return this._state.shouldPeek;
} }