/* * Copyright 2007-2017 Charles du Jeu - Abstrium SAS * This file is part of Pydio. * * Pydio is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pydio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Pydio. If not, see . * * The latest code can be found at . */ const {Component, PropTypes} = require('react') const {PydioContextConsumer} = require('pydio').requireLib('boot') import SearchForm from './SearchForm' import UsersList from './UsersList' import Loaders from './Loaders' /** * Ready to use Form + Result List for search users */ class SearchPanel extends Component{ constructor(props, context){ super(props.context); this.state = {items: []}; } onSearch(value){ if(!value){ this.setState({items: []}); return; } let params = {value: value, existing_only:'true'}; if(this.props.params){ params = {...params, ...this.props.params}; } Loaders.listUsers(params, (children) => {this.setState({items:children})}); } render(){ const {mode, item, getMessage} = this.props; return (
{mode === "selector" && item._parent && {this.props.onFolderClicked(item._parent)}}/>} {mode === 'book' &&
{this.props.title}
}
); } } SearchPanel.propTypes = { /** * Optional parameters added to listUsers() request */ params : PropTypes.object, /** * Label displayed in the toolbar */ searchLabel : PropTypes.string, /** * Callback triggered when a search result is clicked */ onItemClicked : PropTypes.func, /** * Currently selected item, required for navigation */ item : PropTypes.object, /** * Callback triggered if the result is a collection */ onFolderClicked : PropTypes.func }; SearchPanel = PydioContextConsumer(SearchPanel); export {SearchPanel as default}