From b82d932a519d03ae6d6f31176c311c1929d4706a Mon Sep 17 00:00:00 2001 From: David Baker Date: Sun, 19 Jul 2015 20:11:57 -0400 Subject: [PATCH] Logout button --- skins/base/views/organisms/LogoutPrompt.js | 37 ++++++++++++++++++++++ skins/base/views/organisms/UserSettings.js | 12 +++++++ src/ComponentBroker.js | 1 + src/controllers/organisms/LogoutPrompt.js | 35 ++++++++++++++++++++ src/controllers/organisms/UserSettings.js | 2 +- 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 skins/base/views/organisms/LogoutPrompt.js create mode 100644 src/controllers/organisms/LogoutPrompt.js diff --git a/skins/base/views/organisms/LogoutPrompt.js b/skins/base/views/organisms/LogoutPrompt.js new file mode 100644 index 000000000..dc76032a9 --- /dev/null +++ b/skins/base/views/organisms/LogoutPrompt.js @@ -0,0 +1,37 @@ +/* +Copyright 2015 OpenMarket Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +'use strict'; + +var React = require('react'); + +var LogoutPromptController = require("../../../../src/controllers/organisms/LogoutPrompt"); + +module.exports = React.createClass({ + displayName: 'LogoutPrompt', + mixins: [LogoutPromptController], + + render: function() { + return ( +
+ Sign out?
+ + +
+ ); + }, +}); + diff --git a/skins/base/views/organisms/UserSettings.js b/skins/base/views/organisms/UserSettings.js index 7bc6b0feb..e90953aec 100644 --- a/skins/base/views/organisms/UserSettings.js +++ b/skins/base/views/organisms/UserSettings.js @@ -22,6 +22,7 @@ var UserSettingsController = require("../../../../src/controllers/organisms/User var EditableText = ComponentBroker.get('atoms/EditableText'); var ChangeAvatar = ComponentBroker.get('molecules/ChangeAvatar'); var ChangePassword = ComponentBroker.get('molecules/ChangePassword'); +var LogoutPrompt = ComponentBroker.get('organisms/LogoutPrompt'); var Loader = require("react-loader"); var Modal = require("../../../../src/Modal") @@ -47,6 +48,14 @@ module.exports = React.createClass({ Modal.createDialog(ChangePassword); }, + onLogoutClicked: function(ev) { + this.logoutModal = Modal.createDialog(LogoutPrompt, {onCancel: this.onLogoutPromptCancel}); + }, + + onLogoutPromptCancel: function() { + this.logoutModal.closeDialog(); + }, + render: function() { switch (this.state.phase) { case this.Phases.Loading: @@ -88,6 +97,9 @@ module.exports = React.createClass({
Version {this.state.clientVersion}
+
+ +
diff --git a/src/ComponentBroker.js b/src/ComponentBroker.js index 342a53935..8a7bd6632 100644 --- a/src/ComponentBroker.js +++ b/src/ComponentBroker.js @@ -95,6 +95,7 @@ require('../skins/base/views/molecules/ChangePassword'); // new for vector require('../skins/base/views/organisms/LeftPanel'); require('../skins/base/views/organisms/RightPanel'); +require('../skins/base/views/organisms/LogoutPrompt'); require('../skins/base/views/molecules/RoomCreate'); require('../skins/base/views/molecules/RoomDropTarget'); require('../skins/base/views/molecules/DirectoryMenu'); diff --git a/src/controllers/organisms/LogoutPrompt.js b/src/controllers/organisms/LogoutPrompt.js new file mode 100644 index 000000000..8875a55cb --- /dev/null +++ b/src/controllers/organisms/LogoutPrompt.js @@ -0,0 +1,35 @@ +/* +Copyright 2015 OpenMarket Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +'use strict'; + +var dis = require("../../dispatcher"); + +module.exports = { + logOut: function() { + dis.dispatch({action: 'logout'}); + if (this.props.onFinished) { + this.props.onFinished(); + } + }, + + cancelPrompt: function() { + if (this.props.onFinished) { + this.props.onFinished(); + } + } +}; + diff --git a/src/controllers/organisms/UserSettings.js b/src/controllers/organisms/UserSettings.js index 3f5b980ed..4eb1fd590 100644 --- a/src/controllers/organisms/UserSettings.js +++ b/src/controllers/organisms/UserSettings.js @@ -68,5 +68,5 @@ module.exports = { }, function(err) { console.err(err); } ); - }, + } }