mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
58 lines
1.1 KiB
JavaScript
58 lines
1.1 KiB
JavaScript
import React, { Component } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import { connect } from 'react-redux'
|
|
import { Card, Button } from 'antd'
|
|
import { autobind } from 'core-decorators';
|
|
|
|
import {
|
|
fetchGroupList,
|
|
fetchCurrGroup,
|
|
addGroup
|
|
} from '../../../actions/group.js'
|
|
|
|
import './GroupList.scss'
|
|
|
|
@connect(
|
|
state => ({
|
|
groupList: state.group.groupList,
|
|
currGroup: state.group.currGroup
|
|
}),
|
|
{
|
|
fetchGroupList,
|
|
fetchCurrGroup,
|
|
addGroup
|
|
}
|
|
)
|
|
export default class GroupList extends Component {
|
|
constructor(props) {
|
|
super(props)
|
|
}
|
|
|
|
static propTypes = {
|
|
groupList: PropTypes.array,
|
|
currGroup: PropTypes.string,
|
|
addGroup: PropTypes.func
|
|
}
|
|
|
|
@autobind
|
|
addGroup() {
|
|
this.props.addGroup('group');
|
|
}
|
|
|
|
render () {
|
|
const { groupList, currGroup } = this.props;
|
|
|
|
return (
|
|
<Card title="Groups">
|
|
<Button type="primary" onClick={this.addGroup}>添加分组</Button>
|
|
<div>{currGroup}</div>
|
|
{
|
|
groupList.map((group, index) => (
|
|
<div key={index}>{group}</div>
|
|
))
|
|
}
|
|
</Card>
|
|
)
|
|
}
|
|
}
|