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

Commit

Permalink
Move 'show join button' functionality out
Browse files Browse the repository at this point in the history
And have it as a prop to the directory search box instead, so the
room directory can do more complex logic.
  • Loading branch information
dbkr committed Sep 29, 2016
1 parent 66ef1e8 commit 9a633ee
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/components/views/elements/DirectorySearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class DirectorySearchBox extends React.Component {
this.setState({value: ev.target.value});

if (this.props.onChange) {
this.props.onChange(this.state.value);
this.props.onChange(ev.target.value);
}
}

Expand All @@ -72,21 +72,14 @@ export default class DirectorySearchBox extends React.Component {
}
}

_contentLooksLikeAlias() {
if (!this.input) return false;

// liberal test for things that look like room aliases
return /^#.+:/.test(this.state.value);
}

render() {
const searchbox_classes = {
mx_DirectorySearchBox: true,
};
searchbox_classes[this.props.className] = true;

let join_button;
if (this._contentLooksLikeAlias()) {
if (this.props.showJoinButton) {
join_button = <span className="mx_DirectorySearchBox_joinButton"
onClick={this._onJoinButtonClick}
>
Expand All @@ -100,7 +93,7 @@ export default class DirectorySearchBox extends React.Component {
className="mx_DirectorySearchBox_input"
ref={this._collectInput}
onChange={this._onChange} onKeyUp={this._onKeyUp}
placeholder="Find a room by keyword or room alias (#matrix:matrix.org)"
placeholder={this.props.placeholder}
/>
{join_button}
<span className="mx_DirectorySearchBox_clear_wrapper">
Expand All @@ -116,4 +109,6 @@ DirectorySearchBox.propTypes = {
onChange: React.PropTypes.func,
onClear: React.PropTypes.func,
onJoinClick: React.PropTypes.func,
placeholder: React.PropTypes.string,
showJoinButton: React.PropTypes.bool,
};

0 comments on commit 9a633ee

Please sign in to comment.