Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev

This commit is contained in:
suxiaoxin 2017-09-26 20:11:23 +08:00
commit 2e452e03d5
9 changed files with 149 additions and 77 deletions

View File

@ -50,13 +50,15 @@ function timeago(timestamp) {
}
} else {
return new Date(timestamp);
return "刚刚";
}
}
// timeago(new Date().getTime() - 40);
@connect(
state => {
console.log(11);
return {
newsData: state.news.newsData,
curpage: state.news.curpage,
@ -106,10 +108,8 @@ class TimeTree extends Component {
}
componentWillMount() {
this.props.fetchNewsData(this.props.typeid, this.props.type, 1, 8)
}
render() {
let data = this.props.newsData ? this.props.newsData.list : [];
let logType = {
@ -121,7 +121,7 @@ class TimeTree extends Component {
other: "其他"
};
if (data && data.length) {
console.log(data);
data = data.map(function (item, i) {
return (<Timeline.Item dot={<Link to={`/user/profile/${item.uid}`}><Avatar src={`/api/user/avatar?uid=${item.uid}`} /></Link>} key={i}>
<div className="logMesHeade">

View File

@ -3,29 +3,48 @@ import GroupList from './GroupList/GroupList.js';
import ProjectList from './ProjectList/ProjectList.js';
import MemberList from './MemberList/MemberList.js';
import GroupLog from './GroupLog/GroupLog.js';
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { Route, Switch, Redirect } from 'react-router-dom';
import { Tabs, Layout } from 'antd';
const { Content, Sider } = Layout;
const TabPane = Tabs.TabPane;
import { fetchNewsData } from '../../reducer/modules/news.js';
import './Group.scss';
@connect(
state => {
return {
curGroupId: state.group.currGroup._id
}
},
{
fetchNewsData: fetchNewsData
}
)
export default class Group extends Component {
constructor(props) {
super(props)
}
static propTypes = {
fetchNewsData: PropTypes.func,
curGroupId: PropTypes.number
}
onTabClick(key){
if(key == 3){
this.props.fetchNewsData(this.props.curGroupId, "group", 1, 8)
}
}
render () {
const GroupContent = (
<Layout style={{minHeight: 'calc(100vh - 100px)', marginLeft: '24px', marginTop: '24px'}}>
<Sider style={{ height: '100%', overflowY: 'scroll'}} width={300}>
<Sider style={{ height: '100%' }} width={300}>
<div className="logo" />
<GroupList></GroupList>
</Sider>
<Layout>
<Content style={{ height: '100%', margin: '0 24px 0 16px', overflow: 'initial',backgroundColor: '#fff'}}>
<Tabs type="card" className="m-tab" style={{height: '100%'}}>
<Tabs onTabClick={this.onTabClick.bind(this)} type="card" className="m-tab" style={{height: '100%'}}>
<TabPane tab="项目列表" key="1"><ProjectList/></TabPane>
<TabPane tab="成员列表" key="2"><MemberList/></TabPane>
<TabPane tab="分组动态" key="3"><GroupLog/></TabPane>

View File

@ -10,6 +10,7 @@ const Search = Input.Search;
const TYPE_EDIT = 'edit';
const confirm = Modal.confirm;
import UsernameAutoComplete from '../../../components/UsernameAutoComplete/UsernameAutoComplete.js';
import { fetchNewsData } from '../../../reducer/modules/news.js';
import {
fetchGroupList,
setCurrGroup,
@ -27,7 +28,8 @@ import './GroupList.scss'
{
fetchGroupList,
setCurrGroup,
setGroupList
setGroupList,
fetchNewsData
}
)
@withRouter
@ -41,7 +43,8 @@ export default class GroupList extends Component {
setGroupList: PropTypes.func,
match: PropTypes.object,
history: PropTypes.object,
curUserRole: PropTypes.string
curUserRole: PropTypes.string,
fetchNewsData: PropTypes.func
}
state = {
@ -122,6 +125,7 @@ export default class GroupList extends Component {
await this.props.fetchGroupList();
this.setState({ groupList: this.props.groupList });
this.props.setCurrGroup(res.data.data)
this.props.fetchNewsData(this.props.currGroup._id, "group", 1, 8)
} else {
message.error(res.data.errmsg)
}
@ -140,6 +144,7 @@ export default class GroupList extends Component {
await this.props.fetchGroupList();
this.setState({ groupList: this.props.groupList });
this.props.setCurrGroup({ group_name, group_desc, _id: id });
this.props.fetchNewsData(this.props.currGroup._id, "group", 1, 8)
}
}
@autobind
@ -165,6 +170,7 @@ export default class GroupList extends Component {
const currGroup = this.props.groupList.find((group) => { return +group._id === +groupId });
this.props.setCurrGroup(currGroup);
this.props.history.replace(`${currGroup._id}`);
this.props.fetchNewsData(groupId, "group", 1, 8)
}
@autobind

View File

@ -5,7 +5,6 @@ import PropTypes from 'prop-types'
// import { Button } from 'antd'
@connect(
state => {
console.log(state);
return {
uid: state.user.uid + '',
curGroupId: state.group.currGroup._id

View File

@ -83,7 +83,7 @@ class Interface extends Component {
// console.log(matchPath(this.props.location.pathname, contentRouter));
return (
<Layout style={{minHeight: 'calc(100vh - 156px)', marginLeft: '24px', marginTop: '24px'}}>
<Sider style={{ height: '100%', overflowY: 'scroll'}} width={300}>
<Sider style={{ height: '100%' }} width={300}>
<div className="left-menu">
<Tabs type="card" activeKey={activeKey} onChange={this.onChange}>
<Tabs.TabPane tab="接口列表" key="api">

View File

@ -5,7 +5,7 @@ import PropTypes from 'prop-types'
import { fetchInterfaceColList, fetchInterfaceCaseList, setColData } from '../../../../reducer/modules/interfaceCol'
import { autobind } from 'core-decorators';
import axios from 'axios';
import { Input, Icon, Button, Modal, message, Tooltip, Tree, Dropdown, Menu, Form } from 'antd';
import { Input, Icon, Button, Modal, message, Tooltip, Tree, Form } from 'antd';
const TreeNode = Tree.TreeNode;
const FormItem = Form.Item;
@ -197,20 +197,20 @@ export default class InterfaceColMenu extends Component {
const { currColId, currCaseId, isShowCol } = this.props;
const { colModalType, colModalVisible, filterValue } = this.state;
const menu = (col) => {
return (
<Menu>
<Menu.Item>
<span onClick={() => this.showColModal('edit', col)}>修改集合</span>
</Menu.Item>
<Menu.Item>
<span onClick={() => {
this.showDelColConfirm(col._id)
}}>删除集合</span>
</Menu.Item>
</Menu>
)
};
// const menu = (col) => {
// return (
// <Menu>
// <Menu.Item>
// <span onClick={() => this.showColModal('edit', col)}>修改集合</span>
// </Menu.Item>
// <Menu.Item>
// <span onClick={() => {
// this.showDelColConfirm(col._id)
// }}>删除集合</span>
// </Menu.Item>
// </Menu>
// )
// };
let isFilterCat = false;
@ -237,7 +237,7 @@ export default class InterfaceColMenu extends Component {
return true;
}
isFilterCat = false;
let caseList = col.caseList.filter(item=>{
return item.casename.indexOf(filterValue) !== -1
})
@ -248,9 +248,13 @@ export default class InterfaceColMenu extends Component {
title={
<div className="menu-title">
<span><Icon type="folder-open" style={{marginRight: 5}} /><span>{col.name}</span></span>
<Dropdown overlay={menu(col)} trigger={['click']} onClick={e => e.stopPropagation()}>
<div className="btns">
<Icon type='delete' className="interface-delete-icon" onClick={() => {this.showDelColConfirm(col._id)}} />
<Icon type='edit' className="interface-delete-icon" onClick={() => {this.showColModal('edit', col)}} />
</div>
{/*<Dropdown overlay={menu(col)} trigger={['click']} onClick={e => e.stopPropagation()}>
<Icon className="opts-icon" type='ellipsis'/>
</Dropdown>
</Dropdown>*/}
</div>
}
>

View File

@ -22,11 +22,17 @@
margin-left: 5px;
display: none;
}
.btns {
display: none;
}
}
.menu-title:hover {
.case-delete-icon {
display: block;
}
.btns {
display: block;
}
}
}

View File

@ -3,7 +3,7 @@ import { connect } from 'react-redux';
import PropTypes from 'prop-types'
import { fetchInterfaceList, fetchInterfaceData, deleteInterfaceData, deleteInterfaceCatData, initInterface } from '../../../../reducer/modules/interface.js';
import { getProject } from '../../../../reducer/modules/project.js';
import { Menu, Input, Icon, Button, Modal, message, Tree, Dropdown } from 'antd';
import { Input, Icon, Button, Modal, message, Tree } from 'antd';
import AddInterfaceForm from './AddInterfaceForm';
import AddInterfaceCatForm from './AddInterfaceCatForm';
import axios from 'axios'
@ -322,56 +322,59 @@ class InterfaceMenu extends Component {
// case 'DELETE': color = 'red'; break;
// default: color = "yellow";
// }
const menu = (item) => {
return <Menu>
<Menu.Item>
<span onClick={() => { this.showConfirm(item._id) }}>删除接口</span>
</Menu.Item>
<Menu.Item>
<span onClick={() => {
this.copyInterface(item)
}}>复制接口</span>
</Menu.Item>
</Menu>
};
// const menu = (item) => {
// return <Menu>
// <Menu.Item>
// <span onClick={() => { this.showConfirm(item._id) }}>删除接口</span>
// </Menu.Item>
// <Menu.Item>
// <span onClick={() => {
// this.copyInterface(item)
// }}>复制接口</span>
// </Menu.Item>
// </Menu>
// };
return <TreeNode
title={<div onMouseEnter={() => this.enterItem(item._id)} onMouseLeave={this.leaveItem} >
title={<div className="container-title" onMouseEnter={() => this.enterItem(item._id)} onMouseLeave={this.leaveItem} >
<Link className="interface-item" to={"/project/" + matchParams.id + "/interface/api/" + item._id} >{item.title}</Link>
{/*<Icon type='delete' className="interface-delete-icon" onClick={() => { this.showConfirm(item._id) }} style={{ display: this.state.delIcon == item._id ? 'block' : 'none' }} />*/}
<Dropdown overlay={menu(item)} trigger={['click']} onClick={e => e.stopPropagation()}>
<div className="btns">
<Icon type='delete' className="interface-delete-icon" onClick={() => { this.showConfirm(item._id) }} style={{ display: this.state.delIcon == item._id ? 'block' : 'none' }} />
<Icon type='copy' className="interface-delete-icon" onClick={() => { this.copyInterface(item) }} style={{ display: this.state.delIcon == item._id ? 'block' : 'none' }} />
</div>
{/*<Dropdown overlay={menu(item)} trigger={['click']} onClick={e => e.stopPropagation()}>
<Icon type='ellipsis' className="interface-delete-icon" style={{ opacity: this.state.delIcon == item._id ? 1 : 0 }}/>
</Dropdown>
</Dropdown>*/}
</div>}
key={'' + item._id} />
}
const menu = (item) => {
return <Menu>
<Menu.Item>
<span onClick={() => {
this.changeModal('visible', true);
this.setState({
curCatid: item._id
})
}}>添加接口</span>
</Menu.Item>
<Menu.Item>
<span onClick={() => {
this.changeModal('change_cat_modal_visible', true);
this.setState({
curCatdata: item
})
}}>修改分类</span>
</Menu.Item>
<Menu.Item>
<span onClick={() => {
this.showDelCatConfirm(item._id)
}}>删除分类</span>
</Menu.Item>
</Menu>
};
// const menu = (item) => {
// return <Menu>
// <Menu.Item>
// <span onClick={() => {
// this.changeModal('visible', true);
// this.setState({
// curCatid: item._id
// })
// }}>添加接口</span>
// </Menu.Item>
// <Menu.Item>
// <span onClick={() => {
// this.changeModal('change_cat_modal_visible', true);
// this.setState({
// curCatdata: item
// })
// }}>修改分类</span>
// </Menu.Item>
// <Menu.Item>
// <span onClick={() => {
// this.showDelCatConfirm(item._id)
// }}>删除分类</span>
// </Menu.Item>
// </Menu>
// };
@ -414,11 +417,27 @@ class InterfaceMenu extends Component {
>
<TreeNode className="item-all-interface" title={<Link style={{ fontSize: '14px' }} to={"/project/" + matchParams.id + "/interface/api"}><Icon type="folder" style={{ marginRight: 5 }} />全部接口</Link>} key="root" />
{menuList.map((item) => {
return <TreeNode title={<div>
return <TreeNode title={<div className="container-title" onMouseEnter={() => this.enterItem(item._id)} onMouseLeave={this.leaveItem} >
<Link className="interface-item" to={"/project/" + matchParams.id + "/interface/api/cat_" + item._id} ><Icon type="folder-open" style={{ marginRight: 5 }} />{item.name}</Link>
<Dropdown overlay={menu(item)} trigger={['click']} onClick={e => e.stopPropagation()}>
<div className="btns">
<Icon type='delete' className="interface-delete-icon" onClick={() => { this.showDelCatConfirm(item._id) }} style={{ display: this.state.delIcon == item._id ? 'block' : 'none' }}/>
<Icon type='edit' className="interface-delete-icon" style={{ display: this.state.delIcon == item._id ? 'block' : 'none' }} onClick={() => {
this.changeModal('change_cat_modal_visible', true);
this.setState({
curCatdata: item
})
}} />
<Icon type='plus' className="interface-delete-icon" style={{ display: this.state.delIcon == item._id ? 'block' : 'none' }} onClick={() => {
this.changeModal('visible', true);
this.setState({
curCatid: item._id
});
}} />
</div>
{/*<Dropdown overlay={menu(item)} trigger={['click']} onClick={e => e.stopPropagation()}>
<Icon type='ellipsis' className="interface-delete-icon" />
</Dropdown>
</Dropdown>*/}
</div>}
key={'cat_' + item._id}
className={`interface-item-nav ${item.list.length?"":"cat_switch_hidden"}`}

View File

@ -71,6 +71,25 @@
.ant-tree li .ant-tree-node-content-wrapper {
width: calc(100% - 28px);
position: relative;
.container-title {
overflow: hidden;
text-overflow:ellipsis;
white-space: nowrap;
}
.btns {
background-color: #eef7fe;
position: absolute;
top: 50%;
right: 0;
transform: translateY(-60%);
transition: all .2s;
}
}
.ant-tree li .ant-tree-node-selected {
.btns {
background-color: #d5ebfc;
transition: all .2s;
}
}
.interface-delete-icon{
@ -78,7 +97,7 @@
right: 0;
float: right;
line-height: 25px;
width: 30px;
width: 24px;
font-weight: bold;
}
.anticon-ellipsis {