Re-use SearchBox from filter rooms for filter room members
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
150c941340
commit
5052039b36
3 changed files with 20 additions and 17 deletions
|
@ -26,6 +26,7 @@ import dis from '../../dispatcher';
|
||||||
import VectorConferenceHandler from '../../VectorConferenceHandler';
|
import VectorConferenceHandler from '../../VectorConferenceHandler';
|
||||||
import TagPanelButtons from './TagPanelButtons';
|
import TagPanelButtons from './TagPanelButtons';
|
||||||
import SettingsStore from '../../settings/SettingsStore';
|
import SettingsStore from '../../settings/SettingsStore';
|
||||||
|
import {_t} from "../../languageHandler";
|
||||||
|
|
||||||
|
|
||||||
const LeftPanel = React.createClass({
|
const LeftPanel = React.createClass({
|
||||||
|
@ -212,6 +213,7 @@ const LeftPanel = React.createClass({
|
||||||
);
|
);
|
||||||
|
|
||||||
const searchBox = (<SearchBox
|
const searchBox = (<SearchBox
|
||||||
|
placeholder={ _t('Filter room names') }
|
||||||
onSearch={ this.onSearch }
|
onSearch={ this.onSearch }
|
||||||
onCleared={ this.onSearchCleared }
|
onCleared={ this.onSearchCleared }
|
||||||
collapsed={this.props.collapsed} />);
|
collapsed={this.props.collapsed} />);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
|
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -14,12 +15,9 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { _t } from '../../languageHandler';
|
import PropTypes from 'prop-types';
|
||||||
import { KeyCode } from '../../Keyboard';
|
import { KeyCode } from '../../Keyboard';
|
||||||
import sdk from '../../index';
|
|
||||||
import dis from '../../dispatcher';
|
import dis from '../../dispatcher';
|
||||||
import { throttle } from 'lodash';
|
import { throttle } from 'lodash';
|
||||||
import AccessibleButton from '../../components/views/elements/AccessibleButton';
|
import AccessibleButton from '../../components/views/elements/AccessibleButton';
|
||||||
|
@ -28,8 +26,10 @@ module.exports = React.createClass({
|
||||||
displayName: 'SearchBox',
|
displayName: 'SearchBox',
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
onSearch: React.PropTypes.func,
|
onSearch: PropTypes.func,
|
||||||
onCleared: React.PropTypes.func,
|
onCleared: PropTypes.func,
|
||||||
|
className: PropTypes.string,
|
||||||
|
placeholder: PropTypes.string.isRequired,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
|
@ -102,8 +102,8 @@ module.exports = React.createClass({
|
||||||
const clearButton = this.state.searchTerm.length > 0 ?
|
const clearButton = this.state.searchTerm.length > 0 ?
|
||||||
(<AccessibleButton key="button"
|
(<AccessibleButton key="button"
|
||||||
className="mx_SearchBox_closeButton"
|
className="mx_SearchBox_closeButton"
|
||||||
onClick={ () => {this._clearSearch("button")} }>
|
onClick={ () => {this._clearSearch("button"); } }>
|
||||||
</AccessibleButton>) : undefined;
|
</AccessibleButton>) : undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mx_SearchBox mx_textinput">
|
<div className="mx_SearchBox mx_textinput">
|
||||||
|
@ -116,7 +116,7 @@ module.exports = React.createClass({
|
||||||
onFocus={ this._onFocus }
|
onFocus={ this._onFocus }
|
||||||
onChange={ this.onChange }
|
onChange={ this.onChange }
|
||||||
onKeyDown={ this._onKeyDown }
|
onKeyDown={ this._onKeyDown }
|
||||||
placeholder={ _t('Filter room names') }
|
placeholder={ this.props.placeholder }
|
||||||
/>
|
/>
|
||||||
{ clearButton }
|
{ clearButton }
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -339,12 +339,11 @@ module.exports = React.createClass({
|
||||||
return nameA.localeCompare(nameB);
|
return nameA.localeCompare(nameB);
|
||||||
},
|
},
|
||||||
|
|
||||||
onSearchQueryChanged: function(ev) {
|
onSearchQueryChanged: function(searchQuery) {
|
||||||
const q = ev.target.value;
|
|
||||||
this.setState({
|
this.setState({
|
||||||
searchQuery: q,
|
searchQuery,
|
||||||
filteredJoinedMembers: this._filterMembers(this.state.members, 'join', q),
|
filteredJoinedMembers: this._filterMembers(this.state.members, 'join', searchQuery),
|
||||||
filteredInvitedMembers: this._filterMembers(this.state.members, 'invite', q),
|
filteredInvitedMembers: this._filterMembers(this.state.members, 'invite', searchQuery),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -438,6 +437,7 @@ module.exports = React.createClass({
|
||||||
return <div className="mx_MemberList"><Spinner /></div>;
|
return <div className="mx_MemberList"><Spinner /></div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const SearchBox = sdk.getComponent('structures.SearchBox');
|
||||||
const TruncatedList = sdk.getComponent("elements.TruncatedList");
|
const TruncatedList = sdk.getComponent("elements.TruncatedList");
|
||||||
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
|
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
|
||||||
|
|
||||||
|
@ -477,9 +477,10 @@ module.exports = React.createClass({
|
||||||
{ invitedSection }
|
{ invitedSection }
|
||||||
</div>
|
</div>
|
||||||
</GeminiScrollbarWrapper>
|
</GeminiScrollbarWrapper>
|
||||||
<input className="mx_MemberList_query mx_textinput_icon mx_textinput_search" id="mx_MemberList_query" type="text"
|
|
||||||
onChange={this.onSearchQueryChanged} value={this.state.searchQuery}
|
<SearchBox className="mx_MemberList_query mx_textinput_icon mx_textinput_search"
|
||||||
placeholder={_t('Filter room members')} />
|
placeholder={ _t('Filter room members') }
|
||||||
|
onSearch={ this.onSearchQueryChanged } />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue