import React, {Component, PropTypes} from 'react' import {Menu, SearchBar, ListensToFluxStore} from 'nylas-component-kit' import SearchStore from './search-store' import SearchActions from './search-actions' class ThreadSearchBar extends Component { static displayName = 'ThreadSearchBar'; static propTypes = { query: PropTypes.string, isSearching: PropTypes.bool, suggestions: PropTypes.array, } _onSelectSuggestion = (suggestion) => { if (suggestion.thread) { SearchActions.querySubmitted(`"${suggestion.thread.subject}"`) } else { SearchActions.querySubmitted(suggestion.value); } } _onSearchQueryChanged = (query) => { SearchActions.queryChanged(query); if (query === '') { this._onClearSearchQuery(); } } _onSubmitSearchQuery = (query) => { SearchActions.querySubmitted(query); } _onClearSearchQuery = () => { SearchActions.querySubmitted(''); } _onClearSearchSuggestions = () => { SearchActions.searchBlurred() } _renderSuggestion = (suggestion) => { if (suggestion.contact) { return