yapi/client/containers/ProjectGroups/GroupList/GroupList.js

58 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-07-12 11:43:10 +08:00
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
2017-07-12 15:41:11 +08:00
import { Card, Button } from 'antd'
import { autobind } from 'core-decorators';
2017-07-12 11:43:10 +08:00
import {
fetchGroupList,
2017-07-12 15:41:11 +08:00
fetchCurrGroup,
addGroup
2017-07-12 11:43:10 +08:00
} from '../../../actions/group.js'
import './GroupList.scss'
@connect(
state => ({
groupList: state.group.groupList,
2017-07-12 14:18:17 +08:00
currGroup: state.group.currGroup
2017-07-12 11:43:10 +08:00
}),
{
fetchGroupList,
2017-07-12 15:41:11 +08:00
fetchCurrGroup,
addGroup
2017-07-12 11:43:10 +08:00
}
)
export default class GroupList extends Component {
constructor(props) {
super(props)
}
static propTypes = {
groupList: PropTypes.array,
2017-07-12 15:41:11 +08:00
currGroup: PropTypes.string,
addGroup: PropTypes.func
}
@autobind
addGroup() {
this.props.addGroup('group');
2017-07-12 11:43:10 +08:00
}
render () {
const { groupList, currGroup } = this.props;
return (
<Card title="Groups">
2017-07-12 15:41:11 +08:00
<Button type="primary" onClick={this.addGroup}>添加分组</Button>
2017-07-12 11:43:10 +08:00
<div>{currGroup}</div>
{
groupList.map((group, index) => (
<div key={index}>{group}</div>
))
}
</Card>
)
}
}