Skip to content

Commit b82d932

Browse files
committed
Logout button
1 parent 2121ddc commit b82d932

5 files changed

Lines changed: 86 additions & 1 deletion

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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 LogoutPromptController = require("../../../../src/controllers/organisms/LogoutPrompt");
22+
23+
module.exports = React.createClass({
24+
displayName: 'LogoutPrompt',
25+
mixins: [LogoutPromptController],
26+
27+
render: function() {
28+
return (
29+
<div className="mx_LogoutPrompt">
30+
Sign out?<br />
31+
<button onClick={this.logOut}>Sign Out</button>
32+
<button onClick={this.cancelPrompt}>Cancel</button>
33+
</div>
34+
);
35+
},
36+
});
37+

‎skins/base/views/organisms/UserSettings.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var UserSettingsController = require("../../../../src/controllers/organisms/User
2222
var EditableText = ComponentBroker.get('atoms/EditableText');
2323
var ChangeAvatar = ComponentBroker.get('molecules/ChangeAvatar');
2424
var ChangePassword = ComponentBroker.get('molecules/ChangePassword');
25+
var LogoutPrompt = ComponentBroker.get('organisms/LogoutPrompt');
2526
var Loader = require("react-loader");
2627

2728
var Modal = require("../../../../src/Modal")
@@ -47,6 +48,14 @@ module.exports = React.createClass({
4748
Modal.createDialog(ChangePassword);
4849
},
4950

51+
onLogoutClicked: function(ev) {
52+
this.logoutModal = Modal.createDialog(LogoutPrompt, {onCancel: this.onLogoutPromptCancel});
53+
},
54+
55+
onLogoutPromptCancel: function() {
56+
this.logoutModal.closeDialog();
57+
},
58+
5059
render: function() {
5160
switch (this.state.phase) {
5261
case this.Phases.Loading:
@@ -88,6 +97,9 @@ module.exports = React.createClass({
8897
<div className="mx_UserSettings_ClientVersion">
8998
Version {this.state.clientVersion}
9099
</div>
100+
<div className="mx_UserSettings_Logout">
101+
<button onClick={this.onLogoutClicked}>Sign Out</button>
102+
</div>
91103
</div>
92104
</div>
93105
</div>

‎src/ComponentBroker.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ require('../skins/base/views/molecules/ChangePassword');
9595
// new for vector
9696
require('../skins/base/views/organisms/LeftPanel');
9797
require('../skins/base/views/organisms/RightPanel');
98+
require('../skins/base/views/organisms/LogoutPrompt');
9899
require('../skins/base/views/molecules/RoomCreate');
99100
require('../skins/base/views/molecules/RoomDropTarget');
100101
require('../skins/base/views/molecules/DirectoryMenu');
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 dis = require("../../dispatcher");
20+
21+
module.exports = {
22+
logOut: function() {
23+
dis.dispatch({action: 'logout'});
24+
if (this.props.onFinished) {
25+
this.props.onFinished();
26+
}
27+
},
28+
29+
cancelPrompt: function() {
30+
if (this.props.onFinished) {
31+
this.props.onFinished();
32+
}
33+
}
34+
};
35+

‎src/controllers/organisms/UserSettings.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ module.exports = {
6868
},
6969
function(err) { console.err(err); }
7070
);
71-
},
71+
}
7272
}

0 commit comments

Comments
 (0)