/** * repo action panel * @author yoyoyohamapi * @ignore created 2018-07-18 19:07:25 */ import * as React from 'react' import { connect, DispatchProp } from 'react-redux' import { Row, Col, Select, Input } from 'antd' import { LoadingState } from '@reobservable/core' import { RepoState } from '@models/repo' interface StateMapper { repo: RepoState, loading: LoadingState } const Option = Select.Option const Search = Input.Search const ORDER_LIST = [{ text: '按 star 数目排序', value: 'stars' }, { text: '按 fork 数目排序', value: 'forks' }] interface Props { sort: string, query: string, disabledSearch: boolean } const ActionPanel: React.SFC = props => { const { dispatch, sort, disabledSearch } = props const handleSearch = (query: string) => { if (query === props.query) { dispatch({type: 'repo/fetch'}) } else { dispatch({ type: 'repo/change', payload: { query } }) } dispatch({ type: 'repo/patch', payload: { pagination: { page: 1 } } }) } const handleSortChange = (sort: string) => { dispatch({ type: 'repo/change', payload: { sort } }) } return ( ) } const mapStateToProps = ({repo, loading}: StateMapper): Props => ({ sort: repo.sort, query: repo.query, disabledSearch: loading.services['repo/fetch'] }) export default connect(mapStateToProps)(ActionPanel)