 
 {React, ReactDOM, Actions, Store, Table, rtypes, rclass, Redux}  = require('./smc-react')
 {Col, Row, Button, ButtonGroup, ButtonToolbar, FormControl, FormGroup, InputGroup, Panel, Well} = require('react-bootstrap')
-{Icon, Loading, TimeAgo, FileLink, r_join, Space, Tip} = require('./r_misc')
+{Icon, Loading, TimeAgo, FileLink, r_join, SearchInput, Space, Tip} = require('./r_misc')
 {User} = require('./users')
 {file_action_buttons} = require('./project_files')
 {ProjectTitleAuto} = require('./projects')

        search           : rtypes.string
        actions          : rtypes.object.isRequired
        selected         : rtypes.object

    clear_and_focus_input: ->
        ReactDOM.findDOMNode(@refs.project_log_search).focus()
        @props.actions.setState(search:'', page:0)

    render_clear_button: ->
        s = if @props.search?.length > 0 then 'warning' else "default"
        <Button onClick={@clear_and_focus_input} bsStyle={s}>
            <Icon name='times-circle' />
        </Button>

    do_open_selected: (e) ->
        e.preventDefault()
        e = @props.selected?.event
        if not e?
            return

            when 'open'
                target = e.filename
                if target?
                    @props.actions.open_file
                        path       : target
                        foreground : not info.ctrl_down
            when 'set'
                @props.actions.set_active_tab('settings')

    on_change: (value) ->
        @props.actions.setState(search : value, page : 0)

    render: ->
        <SearchInput
            autoFocus   = {true}
            autoSelect  = {true}
            placeholder = 'Search log...'
            value       = {@props.search}
            on_change   = {@on_change}
            on_submit   = {@open_selected}
            on_up       = {@props.decrement_cursor}
            on_down     = {@props.increment_cursor}
            on_escape   = {=> @props.actions.setState(search:'', page:0)}
        />

selected_item =
    backgroundColor : '#08c'
