Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #297 from matrix-org/matthew/new-3pid-invite
Browse files Browse the repository at this point in the history
implement new UX for 3pid invites
  • Loading branch information
ara4n committed Jun 2, 2016
2 parents 0747ca3 + 3b34311 commit 0ef0120
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
17 changes: 14 additions & 3 deletions src/components/views/rooms/InviteMemberList.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = React.createClass({
propTypes: {
roomId: React.PropTypes.string.isRequired,
onInvite: React.PropTypes.func.isRequired, // fn(inputText)
onThirdPartyInvite: React.PropTypes.func.isRequired, // fn(inputText)
onSearchQueryChanged: React.PropTypes.func // fn(inputText)
},

Expand All @@ -49,10 +50,19 @@ module.exports = React.createClass({
}
},

componentDidMount: function() {
// initialise the email tile
this.onSearchQueryChanged('');
},

onInvite: function(ev) {
this.props.onInvite(this._input);
},

onThirdPartyInvite: function(ev) {
this.props.onThirdPartyInvite(this._input);
},

onSearchQueryChanged: function(input) {
this._input = input;
var EntityTile = sdk.getComponent("rooms.EntityTile");
Expand All @@ -68,9 +78,10 @@ module.exports = React.createClass({

this._emailEntity = new Entities.newEntity(
<EntityTile key="dynamic_invite_tile" suppressOnHover={true} showInviteButton={true}
avatarJsx={ <BaseAvatar name="@" width={36} height={36} /> }
className="mx_EntityTile_invitePlaceholder"
presenceState="online" onClick={this.onInvite} name={label} />,
avatarJsx={ <BaseAvatar name="@" width={36} height={36} /> }
className="mx_EntityTile_invitePlaceholder"
presenceState="online" onClick={this.onThirdPartyInvite} name={"Invite by email"}
/>,
function(query) {
return true; // always show this
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/rooms/MemberInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ module.exports = React.createClass({
action: 'leave_room',
room_id: this.props.member.roomId,
});
this.props.onFinished();
this.props.onFinished();
},

getInitialState: function() {
Expand Down
16 changes: 16 additions & 0 deletions src/components/views/rooms/MemberList.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ module.exports = React.createClass({
});
}, 500),

onThirdPartyInvite: function(inputText) {
var TextInputDialog = sdk.getComponent("dialogs.TextInputDialog");
Modal.createDialog(TextInputDialog, {
title: "Invite members by email",
description: "Please enter the email addresses to be invited (comma separated)",
value: inputText,
button: "Invite",
onFinished: (should_invite, addresses)=>{
if (should_invite) {
this.onInvite(addresses);
}
}
});
},

onInvite: function(inputText) {
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
var NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog");
Expand Down Expand Up @@ -514,6 +529,7 @@ module.exports = React.createClass({
inviteMemberListSection = (
<InviteMemberList roomId={this.props.roomId}
onSearchQueryChanged={this.onSearchQueryChanged}
onThirdPartyInvite={this.onThirdPartyInvite}
onInvite={this.onInvite} />
);
}
Expand Down
13 changes: 8 additions & 5 deletions src/components/views/rooms/SearchableEntityList.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var SearchableEntityList = React.createClass({
getInitialState: function() {
return {
query: "",
focused: false,
truncateAt: this.props.truncateAt,
results: this.getSearchResults("", this.props.entities)
};
Expand Down Expand Up @@ -101,7 +102,7 @@ var SearchableEntityList = React.createClass({

getSearchResults: function(query, entities) {
if (!query || query.length === 0) {
return this.props.emptyQueryShowsAll ? entities : []
return this.props.emptyQueryShowsAll ? entities : [ entities[0] ]
}
return entities.filter(function(e) {
return e.matches(query);
Expand All @@ -128,19 +129,21 @@ var SearchableEntityList = React.createClass({

render: function() {
var inputBox;

if (this.props.showInputBox) {
inputBox = (
<form onSubmit={this.onQuerySubmit} autoComplete="off">
<input className="mx_SearchableEntityList_query" id="mx_SearchableEntityList_query" type="text"
onChange={this.onQueryChanged} value={this.state.query}
onFocus={ ()=>{ this.setState({ focused: true }) } }
onBlur={ ()=>{ this.setState({ focused: false }) } }
placeholder={this.props.searchPlaceholderText} />
</form>
);
}

var list;
if (this.state.results.length) {
if (this.state.results.length > 1 || this.state.focused) {
if (this.props.truncateAt) { // caller wants list truncated
var TruncatedList = sdk.getComponent("elements.TruncatedList");
list = (
Expand Down Expand Up @@ -172,10 +175,10 @@ var SearchableEntityList = React.createClass({
}

return (
<div className={ "mx_SearchableEntityList " + (this.state.query.length ? "mx_SearchableEntityList_expanded" : "") }>
<div className={ "mx_SearchableEntityList " + (list ? "mx_SearchableEntityList_expanded" : "") }>
{ inputBox }
{ list }
{ this.state.query.length ? <div className="mx_SearchableEntityList_hrWrapper"><hr/></div> : '' }
{ list ? <div className="mx_SearchableEntityList_hrWrapper"><hr/></div> : '' }
</div>
);
}
Expand Down

0 comments on commit 0ef0120

Please sign in to comment.