diff --git a/src/component-index.js b/src/component-index.js index 869d60f204..67c09e61a6 100644 --- a/src/component-index.js +++ b/src/component-index.js @@ -46,6 +46,7 @@ module.exports.components['views.create_room.Presets'] = require('./components/v module.exports.components['views.create_room.RoomAlias'] = require('./components/views/create_room/RoomAlias'); module.exports.components['views.dialogs.ErrorDialog'] = require('./components/views/dialogs/ErrorDialog'); module.exports.components['views.dialogs.LogoutPrompt'] = require('./components/views/dialogs/LogoutPrompt'); +module.exports.components['views.dialogs.NeedToRegisterDialog'] = require('./components/views/dialogs/NeedToRegisterDialog'); module.exports.components['views.dialogs.QuestionDialog'] = require('./components/views/dialogs/QuestionDialog'); module.exports.components['views.dialogs.SetDisplayNameDialog'] = require('./components/views/dialogs/SetDisplayNameDialog'); module.exports.components['views.dialogs.TextInputDialog'] = require('./components/views/dialogs/TextInputDialog'); diff --git a/src/components/views/dialogs/NeedToRegisterDialog.js b/src/components/views/dialogs/NeedToRegisterDialog.js new file mode 100644 index 0000000000..2ad246503f --- /dev/null +++ b/src/components/views/dialogs/NeedToRegisterDialog.js @@ -0,0 +1,76 @@ +/* +Copyright 2016 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. +*/ + +/* + * Usage: + * Modal.createDialog(NeedToRegisterDialog, { + * title: "some text", (default: "Registration required") + * description: "some more text", + * onClose: someFunction, + * }); + */ + +var React = require("react"); +var dis = require("../../../dispatcher"); + +module.exports = React.createClass({ + displayName: 'NeedToRegisterDialog', + propTypes: { + title: React.PropTypes.string, + description: React.PropTypes.oneOfType([ + React.PropTypes.element, + React.PropTypes.string, + ]), + onFinished: React.PropTypes.func.isRequired, + }, + + getDefaultProps: function() { + return { + title: "Registration required", + description: "A registered account is required for this action", + }; + }, + + onRegisterClicked: function() { + dis.dispatch({ + action: "start_upgrade_registration", + }); + if (this.props.onFinished) { + this.props.onFinished(); + } + }, + + render: function() { + return ( +
+
+ {this.props.title} +
+
+ {this.props.description} +
+
+ + +
+
+ ); + } +}); diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js index b15e5bdc94..76f3fd5624 100644 --- a/src/components/views/rooms/MemberList.js +++ b/src/components/views/rooms/MemberList.js @@ -142,9 +142,18 @@ module.exports = React.createClass({ onInvite: function(inputText) { var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + var NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog"); var self = this; inputText = inputText.trim(); // react requires es5-shim so we know trim() exists + if (MatrixClientPeg.get().isGuest()) { + Modal.createDialog(NeedToRegisterDialog, { + title: "Unable to Invite", + description: "Guest user can't invite new users. Please register to be able to invite new users into a room." + }); + return; + } + // email addresses and user IDs do not allow space, comma, semicolon so split // on them for bulk inviting. var separators =[ ";", " ", "," ];