Skip to content

Commit 7cbb43f

Browse files
committed
Merge branch 'vector' into voip
Conflicts: src/ComponentBroker.js
2 parents 78bea91 + 844a883 commit 7cbb43f

13 files changed

Lines changed: 632 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var React = require('react');
20+
21+
var EditableTextController = require("../../../../src/controllers/atoms/EditableText");
22+
23+
module.exports = React.createClass({
24+
displayName: 'EditableText',
25+
mixins: [EditableTextController],
26+
27+
onKeyUp: function(ev) {
28+
if (ev.key == "Enter") {
29+
this.onFinish(ev);
30+
} else if (ev.key == "Escape") {
31+
this.cancelEdit();
32+
}
33+
},
34+
35+
onClickDiv: function() {
36+
this.setState({
37+
phase: this.Phases.Edit,
38+
})
39+
},
40+
41+
onFocus: function(ev) {
42+
ev.target.setSelectionRange(0, ev.target.value.length);
43+
},
44+
45+
onFinish: function(ev) {
46+
this.setValue(ev.target.value);
47+
},
48+
49+
render: function() {
50+
var editable_el;
51+
52+
if (this.state.phase == this.Phases.Display) {
53+
editable_el = <div ref="display_div" onClick={this.onClickDiv}>{this.state.value}</div>;
54+
} else if (this.state.phase == this.Phases.Edit) {
55+
editable_el = (
56+
<div>
57+
<input type="text" defaultValue={this.state.value} onKeyUp={this.onKeyUp} onFocus={this.onFocus} onBlur={this.onFinish} autoFocus/>
58+
</div>
59+
);
60+
}
61+
62+
return (
63+
<div className="mx_EditableText">
64+
{editable_el}
65+
</div>
66+
);
67+
}
68+
});
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var React = require('react');
20+
21+
var CreateRoomButtonController = require("../../../../../src/controllers/atoms/create_room/CreateRoomButton");
22+
23+
module.exports = React.createClass({
24+
displayName: 'CreateRoomButton',
25+
mixins: [CreateRoomButtonController],
26+
27+
render: function() {
28+
return (
29+
<button className="mx_CreateRoomButton" onClick={this.onClick}>Create Room</button>
30+
);
31+
}
32+
});
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var React = require('react');
20+
21+
var PresetsController = require("../../../../../src/controllers/atoms/create_room/Presets");
22+
23+
module.exports = React.createClass({
24+
displayName: 'CreateRoomPresets',
25+
mixins: [PresetsController],
26+
27+
onValueChanged: function(ev) {
28+
this.setState({preset: ev.target.value})
29+
},
30+
31+
render: function() {
32+
return (
33+
<select className="mx_Presets" onChange={this.onValueChanged} defaultValue={this.state.preset}>
34+
<option value="private_chat">Private Chat</option>
35+
<option value="public_chat">Public Chat</option>
36+
</select>
37+
);
38+
}
39+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var React = require('react');
20+
21+
var RoomNameTextboxController = require("../../../../../src/controllers/atoms/create_room/RoomNameTextbox");
22+
23+
module.exports = React.createClass({
24+
displayName: 'RoomNameTextbox',
25+
mixins: [RoomNameTextboxController],
26+
27+
onValueChanged: function(ev) {
28+
this.setState({room_name: ev.target.value})
29+
},
30+
31+
render: function() {
32+
return (
33+
<input type="text" className="mx_RoomNameTextbox" placeholder="ex. MyNewRoom" onChange={this.onValueChanged}/>
34+
);
35+
}
36+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var React = require('react');
20+
21+
var UserSelectorController = require("../../../../src/controllers/molecules/UserSelector");
22+
23+
module.exports = React.createClass({
24+
displayName: 'UserSelector',
25+
mixins: [UserSelectorController],
26+
27+
onAddUserId: function() {
28+
this.addUser(this.refs.user_id_input.getDOMNode().value);
29+
},
30+
31+
render: function() {
32+
return (
33+
<div>
34+
<ul className="mx_UserSelector_UserIdList" ref="list">
35+
{this.state.selected_users.map(function(user_id, i) {
36+
return <li key={user_id}>{user_id}</li>
37+
})}
38+
</ul>
39+
<input type="text" ref="user_id_input" className="mx_UserSelector_userIdInput" placeholder="ex. @bob:example.com"/>
40+
<button onClick={this.onAddUserId} className="mx_UserSelector_AddUserId">Add User</button>
41+
</div>
42+
);
43+
}
44+
});
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var React = require('react');
20+
21+
var CreateRoomController = require("../../../../src/controllers/organisms/CreateRoom");
22+
23+
var ComponentBroker = require('../../../../src/ComponentBroker');
24+
25+
var CreateRoomButton = ComponentBroker.get("atoms/create_room/CreateRoomButton");
26+
var RoomNameTextbox = ComponentBroker.get("atoms/create_room/RoomNameTextbox");
27+
var Presets = ComponentBroker.get("atoms/create_room/Presets");
28+
var UserSelector = ComponentBroker.get("molecules/UserSelector");
29+
30+
31+
module.exports = React.createClass({
32+
displayName: 'CreateRoom',
33+
mixins: [CreateRoomController],
34+
35+
getPreset: function() {
36+
return this.refs.presets.getPreset();
37+
},
38+
39+
getName: function() {
40+
return this.refs.name_textbox.getName();
41+
},
42+
43+
getInvitedUsers: function() {
44+
return this.refs.user_selector.getUserIds();
45+
},
46+
47+
render: function() {
48+
var curr_phase = this.state.phase;
49+
if (curr_phase == this.phases.CREATING) {
50+
return (
51+
<div>Creating...</div>
52+
);
53+
} else {
54+
var error_box = "";
55+
if (curr_phase == this.phases.ERROR) {
56+
error_box = (
57+
<div className="mx_Error">
58+
An error occured: {this.state.error_string}
59+
</div>
60+
);
61+
}
62+
return (
63+
<div className="mx_CreateRoom">
64+
<label>Room Name <RoomNameTextbox ref="name_textbox" /></label>
65+
<Presets ref="presets"/>
66+
<UserSelector ref="user_selector"/>
67+
<CreateRoomButton onCreateRoom={this.onCreateRoom} />
68+
{error_box}
69+
</div>
70+
);
71+
}
72+
}
73+
});

‎src/ComponentBroker.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ require('../skins/base/views/atoms/LogoutButton');
6262
require('../skins/base/views/atoms/EnableNotificationsButton');
6363
require('../skins/base/views/atoms/MessageTimestamp');
6464
require('../skins/base/views/atoms/VideoFeed');
65+
require('../skins/base/views/atoms/create_room/CreateRoomButton');
66+
require('../skins/base/views/atoms/create_room/RoomNameTextbox');
67+
require('../skins/base/views/atoms/create_room/Presets');
68+
require('../skins/base/views/atoms/EditableText');
6569
require('../skins/base/views/molecules/MatrixToolbar');
6670
require('../skins/base/views/molecules/RoomTile');
6771
require('../skins/base/views/molecules/MessageTile');
@@ -83,6 +87,8 @@ require('../skins/base/views/organisms/RoomList');
8387
require('../skins/base/views/organisms/RoomView');
8488
require('../skins/base/views/templates/Login');
8589
require('../skins/base/views/organisms/Notifier');
90+
require('../skins/base/views/organisms/CreateRoom');
91+
require('../skins/base/views/molecules/UserSelector');
8692
// new for vector
8793
require('../skins/base/views/organisms/LeftPanel');
8894
require('../skins/base/views/organisms/RightPanel');
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var React = require('react');
20+
21+
module.exports = {
22+
propTypes: {
23+
onValueChanged: React.PropTypes.func,
24+
initalValue: React.PropTypes.string,
25+
},
26+
27+
Phases: {
28+
Display: "display",
29+
Edit: "edit",
30+
},
31+
32+
getDefaultProps: function() {
33+
return {
34+
onValueChanged: function() {},
35+
initalValue: '',
36+
};
37+
},
38+
39+
getInitialState: function() {
40+
return {
41+
value: this.props.initalValue,
42+
phase: this.Phases.Display,
43+
}
44+
},
45+
46+
getValue: function() {
47+
return this.state.value;
48+
},
49+
50+
setValue: function(val) {
51+
this.setState({
52+
value: val,
53+
phase: this.Phases.Display,
54+
});
55+
56+
this.onValueChanged();
57+
},
58+
59+
cancelEdit: function() {
60+
this.setState({
61+
phase: this.Phases.Display,
62+
});
63+
},
64+
65+
onValueChanged: function() {
66+
this.props.onValueChanged(this.state.value);
67+
},
68+
};

0 commit comments

Comments
 (0)