Skip to content

Commit b9e2b59

Browse files
committed
Merge remote-tracking branch 'origin/develop' into matthew/status
2 parents 8ad9728 + c74e6c3 commit b9e2b59

12 files changed

Lines changed: 291 additions & 232 deletions

File tree

‎config.sample.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"integrations_rest_url": "https://scalar.vector.im/api",
77
"bug_report_endpoint_url": "https://riot.im/bugreports/submit",
88
"features": {
9-
"feature_groups": "labs"
10-
"feature_pinning": "labs",
9+
"feature_groups": "labs",
10+
"feature_pinning": "labs"
1111
},
1212
"default_federate": true,
1313
"welcomePageUrl": "home.html",

‎src/components/structures/LeftPanel.js‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
import React from 'react';
2020
import { DragDropContext } from 'react-dnd';
2121
import HTML5Backend from 'react-dnd-html5-backend';
22+
import classNames from 'classnames';
2223
import KeyCode from 'matrix-react-sdk/lib/KeyCode';
2324
import sdk from 'matrix-react-sdk';
2425
import dis from 'matrix-react-sdk/lib/dispatcher';
@@ -55,7 +56,7 @@ var LeftPanel = React.createClass({
5556
// We just need to update if any of these things change.
5657
if (
5758
this.props.collapsed !== nextProps.collapsed ||
58-
this.props.opacity !== nextProps.opacity
59+
this.props.disabled !== nextProps.disabled
5960
) {
6061
return true;
6162
}
@@ -176,14 +177,16 @@ var LeftPanel = React.createClass({
176177
topBox = <SearchBox collapsed={ this.props.collapsed } onSearch={ this.onSearch } />;
177178
}
178179

179-
let classes = "mx_LeftPanel mx_fadable";
180-
if (this.props.collapsed) {
181-
classes += " collapsed";
182-
}
180+
let classes = classNames(
181+
"mx_LeftPanel", "mx_fadable",
182+
{
183+
"collapsed": this.props.collapsed,
184+
"mx_fadable_faded": this.props.disabled,
185+
}
186+
);
183187

184188
return (
185-
<aside className={classes} style={{ opacity: this.props.opacity }}
186-
onKeyDown={ this._onKeyDown } onFocus={ this._onFocus } onBlur={ this._onBlur }>
189+
<aside className={classes} onKeyDown={ this._onKeyDown } onFocus={ this._onFocus } onBlur={ this._onBlur }>
187190
{ topBox }
188191
<CallPreview ConferenceHandler={VectorConferenceHandler} />
189192
<RoomList

‎src/components/structures/RightPanel.js‎

Lines changed: 60 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ limitations under the License.
1818

1919
import React from 'react';
2020
import PropTypes from 'prop-types';
21+
import classNames from 'classnames';
2122
import { _t } from 'matrix-react-sdk/lib/languageHandler';
2223
import sdk from 'matrix-react-sdk';
2324
import dis from 'matrix-react-sdk/lib/dispatcher';
24-
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
25+
import MatrixClient from 'matrix-js-sdk';
2526
import Analytics from 'matrix-react-sdk/lib/Analytics';
2627
import rate_limited_func from 'matrix-react-sdk/lib/ratelimitedfunc';
2728
import AccessibleButton from 'matrix-react-sdk/lib/components/views/elements/AccessibleButton';
2829
import { showGroupInviteDialog, showGroupAddRoomDialog } from 'matrix-react-sdk/lib/GroupAddressPicker';
30+
import GroupStoreCache from 'matrix-react-sdk/lib/stores/GroupStoreCache';
2931

3032
class HeaderButton extends React.Component {
3133
constructor() {
@@ -80,6 +82,10 @@ module.exports = React.createClass({
8082
collapsed: React.PropTypes.bool, // currently unused property to request for a minimized view of the panel
8183
},
8284

85+
contextTypes: {
86+
matrixClient: PropTypes.instanceOf(MatrixClient),
87+
},
88+
8389
Phase: {
8490
RoomMemberList: 'RoomMemberList',
8591
GroupMemberList: 'GroupMemberList',
@@ -92,37 +98,60 @@ module.exports = React.createClass({
9298

9399
componentWillMount: function() {
94100
this.dispatcherRef = dis.register(this.onAction);
95-
const cli = MatrixClientPeg.get();
101+
const cli = this.context.matrixClient;
96102
cli.on("RoomState.members", this.onRoomStateMember);
103+
this._initGroupStore(this.props.groupId);
97104
},
98105

99106
componentWillUnmount: function() {
100107
dis.unregister(this.dispatcherRef);
101-
if (MatrixClientPeg.get()) {
102-
MatrixClientPeg.get().removeListener("RoomState.members", this.onRoomStateMember);
108+
if (this.context.matrixClient) {
109+
this.context.matrixClient.removeListener("RoomState.members", this.onRoomStateMember);
103110
}
111+
this._unregisterGroupStore();
104112
},
105113

106114
getInitialState: function() {
107-
if (this.props.groupId) {
108-
return {
109-
phase: this.Phase.GroupMemberList,
110-
};
111-
} else {
112-
return {
113-
phase: this.Phase.RoomMemberList,
114-
};
115+
return {
116+
phase: this.props.groupId ? this.Phase.GroupMemberList : this.Phase.RoomMemberList,
117+
isUserPrivilegedInGroup: null,
115118
}
116119
},
117120

121+
componentWillReceiveProps(newProps) {
122+
if (newProps.groupId !== this.props.groupId) {
123+
this._unregisterGroupStore();
124+
this._initGroupStore(newProps.groupId);
125+
}
126+
},
127+
128+
_initGroupStore(groupId) {
129+
this._groupStore = GroupStoreCache.getGroupStore(
130+
this.context.matrixClient, this.props.groupId,
131+
);
132+
this._groupStore.registerListener(this.onGroupStoreUpdated);
133+
},
134+
135+
_unregisterGroupStore() {
136+
if (this._groupStore) {
137+
this._groupStore.unregisterListener(this.onGroupStoreUpdated);
138+
}
139+
},
140+
141+
onGroupStoreUpdated: function(){
142+
this.setState({
143+
isUserPrivilegedInGroup: this._groupStore.isUserPrivileged(),
144+
});
145+
},
146+
118147
onCollapseClick: function() {
119148
dis.dispatch({
120149
action: 'hide_right_panel',
121150
});
122151
},
123152

124153
onInviteButtonClick: function() {
125-
if (MatrixClientPeg.get().isGuest()) {
154+
if (this.context.matrixClient.isGuest()) {
126155
dis.dispatch({action: 'view_set_mxid'});
127156
return;
128157
}
@@ -222,13 +251,13 @@ module.exports = React.createClass({
222251
if ((this.state.phase == this.Phase.RoomMemberList || this.state.phase === this.Phase.RoomMemberInfo)
223252
&& this.props.roomId
224253
) {
225-
const cli = MatrixClientPeg.get();
254+
const cli = this.context.matrixClient;
226255
const room = cli.getRoom(this.props.roomId);
227256
let userIsInRoom;
228257
if (room) {
229258
membersBadge = room.getJoinedMembers().length;
230259
userIsInRoom = room.hasMembershipState(
231-
MatrixClientPeg.get().credentials.userId, 'join',
260+
this.context.matrixClient.credentials.userId, 'join',
232261
);
233262
}
234263

@@ -243,6 +272,11 @@ module.exports = React.createClass({
243272
}
244273
}
245274

275+
const isPhaseGroup = [
276+
this.Phase.GroupMemberInfo,
277+
this.Phase.GroupMemberList
278+
].includes(this.state.phase);
279+
246280
let headerButtons = [];
247281
if (this.props.roomId) {
248282
headerButtons = [
@@ -266,7 +300,7 @@ module.exports = React.createClass({
266300
} else if (this.props.groupId) {
267301
headerButtons = [
268302
<HeaderButton key="_groupMembersButton" title={_t('Members')} iconSrc="img/icons-people.svg"
269-
isHighlighted={this.state.phase === this.Phase.GroupMemberList}
303+
isHighlighted={isPhaseGroup}
270304
clickPhase={this.Phase.GroupMemberList}
271305
analytics={['Right Panel', 'Group Member List Button', 'click']}
272306
/>,
@@ -317,8 +351,8 @@ module.exports = React.createClass({
317351
panel = <div className="mx_RightPanel_blank"></div>;
318352
}
319353

320-
if (this.props.groupId) {
321-
inviteGroup = this.state.phase === this.Phase.GroupMemberList ? (
354+
if (this.props.groupId && this.state.isUserPrivilegedInGroup) {
355+
inviteGroup = isPhaseGroup ? (
322356
<AccessibleButton className="mx_RightPanel_invite" onClick={ this.onInviteButtonClick } >
323357
<div className="mx_RightPanel_icon" >
324358
<TintableSvg src="img/icon-invite-people.svg" width="35" height="35" />
@@ -335,13 +369,16 @@ module.exports = React.createClass({
335369
);
336370
}
337371

338-
let classes = "mx_RightPanel mx_fadable";
339-
if (this.props.collapsed) {
340-
classes += " collapsed";
341-
}
372+
let classes = classNames(
373+
"mx_RightPanel", "mx_fadable",
374+
{
375+
"collapsed": this.props.collapsed,
376+
"mx_fadable_faded": this.props.disabled,
377+
}
378+
);
342379

343380
return (
344-
<aside className={classes} style={{ opacity: this.props.opacity }}>
381+
<aside className={classes}>
345382
<div className="mx_RightPanel_header">
346383
<div className="mx_RightPanel_headerButtonGroup">
347384
{headerButtons}

‎src/components/structures/RoomDirectory.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@ module.exports = React.createClass({
8989
});
9090

9191
// dis.dispatch({
92-
// action: 'ui_opacity',
93-
// sideOpacity: 0.3,
94-
// middleOpacity: 0.3,
92+
// action: 'panel_disable',
93+
// sideDisabled: true,
94+
// middleDisabled: true,
9595
// });
9696
},
9797

9898
componentWillUnmount: function() {
9999
// dis.dispatch({
100-
// action: 'ui_opacity',
101-
// sideOpacity: 1.0,
102-
// middleOpacity: 1.0,
100+
// action: 'panel_disable',
101+
// sideDisabled: false,
102+
// middleDisabled: false,
103103
// });
104104
if (this.filterTimeout) {
105105
clearTimeout(this.filterTimeout);

‎src/components/views/dialogs/DevtoolsDialog.js‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class SendCustomEvent extends React.Component {
5757
_buttons() {
5858
return <div className="mx_Dialog_buttons">
5959
<button onClick={this.onBack}>{ _t('Back') }</button>
60-
{!this.state.message && <button onClick={this._send}>{ _t('Send') }</button>}
60+
{ !this.state.message && <button onClick={this._send}>{ _t('Send') }</button> }
6161
</div>;
6262
}
6363

@@ -83,7 +83,7 @@ class SendCustomEvent extends React.Component {
8383
}
8484

8585
_additionalFields() {
86-
return <div/>;
86+
return <div />;
8787
}
8888

8989
_onChange(e) {
@@ -94,15 +94,15 @@ class SendCustomEvent extends React.Component {
9494
if (this.state.message) {
9595
return <div>
9696
<div className="mx_Dialog_content">
97-
{this.state.message}
97+
{ this.state.message }
9898
</div>
99-
{this._buttons()}
99+
{ this._buttons() }
100100
</div>;
101101
}
102102

103103
return <div>
104104
<div className="mx_Dialog_content">
105-
{this._additionalFields()}
105+
{ this._additionalFields() }
106106
<div className="mx_TextInputDialog_label">
107107
<label htmlFor="eventType"> { _t('Event Type') } </label>
108108
</div>
@@ -117,7 +117,7 @@ class SendCustomEvent extends React.Component {
117117
<textarea id="evContent" onChange={this._onChange} value={this.state.input_evContent} className="mx_TextInputDialog_input" cols="63" rows="5" />
118118
</div>
119119
</div>
120-
{this._buttons()}
120+
{ this._buttons() }
121121
</div>;
122122
}
123123
}
@@ -223,7 +223,7 @@ class RoomStateExplorer extends React.Component {
223223
if (this.state.event) {
224224
return <div className="mx_ViewSource">
225225
<div className="mx_Dialog_content">
226-
<pre>{JSON.stringify(this.state.event.event, null, 2)}</pre>
226+
<pre>{ JSON.stringify(this.state.event.event, null, 2) }</pre>
227227
</div>
228228
<div className="mx_Dialog_buttons">
229229
<button onClick={this.onBack}>{ _t('Back') }</button>
@@ -237,7 +237,7 @@ class RoomStateExplorer extends React.Component {
237237
if (this.state.eventType === null) {
238238
Object.keys(this.roomStateEvents).forEach((evType) => {
239239
// Skip this entry if does not contain search query
240-
if (this.state.query && !evType.includes(this.state.query)) return;
240+
if (this.state.query && !evType.toLowerCase().includes(this.state.query.toLowerCase())) return;
241241

242242
const stateGroup = this.roomStateEvents[evType];
243243
const stateKeys = Object.keys(stateGroup);
@@ -258,7 +258,7 @@ class RoomStateExplorer extends React.Component {
258258
const stateGroup = this.roomStateEvents[evType];
259259
Object.keys(stateGroup).forEach((stateKey) => {
260260
// Skip this entry if does not contain search query
261-
if (this.state.query && !stateKey.includes(this.state.query)) return;
261+
if (this.state.query && !stateKey.toLowerCase().includes(this.state.query.toLowerCase())) return;
262262

263263
const ev = stateGroup[stateKey];
264264
rows.push(<button className="mx_DevTools_RoomStateExplorer_button" key={stateKey}
@@ -271,7 +271,7 @@ class RoomStateExplorer extends React.Component {
271271
return <div>
272272
<div className="mx_Dialog_content">
273273
<input onChange={this.onQuery} placeholder={_t('Filter results')} size="64" className="mx_TextInputDialog_input mx_DevTools_RoomStateExplorer_query" value={this.state.query} />
274-
{rows}
274+
{ rows }
275275
</div>
276276
<div className="mx_Dialog_buttons">
277277
<button onClick={this.onBack}>{ _t('Back') }</button>

0 commit comments

Comments
 (0)