fix: 修复接口全部删除后添加按钮也消失了

This commit is contained in:
喻希里 2017-09-05 15:14:13 +08:00
parent 3223184a53
commit 4441dc4a8f
2 changed files with 35 additions and 31 deletions

View File

@ -79,6 +79,7 @@ class Interface extends Component {
render() { render() {
const { action } = this.props.match.params; const { action } = this.props.match.params;
const activeKey = action === 'api' ? 'api' : 'colOrCase'; const activeKey = action === 'api' ? 'api' : 'colOrCase';
// console.log(matchPath(this.props.location.pathname, contentRouter));
return <div className="web-content g-row" style={{ marginBottom: "15px" }}> return <div className="web-content g-row" style={{ marginBottom: "15px" }}>
<Row gutter={16} > <Row gutter={16} >
<Col span={6}> <Col span={6}>

View File

@ -14,7 +14,9 @@ const TreeNode = Tree.TreeNode;
@connect( @connect(
state => { state => {
return { return {
list: state.inter.list, list: state.inter.list,
inter: state.inter.curdata, inter: state.inter.curdata,
@ -213,8 +215,38 @@ class InterfaceMenu extends Component {
render() { render() {
const matchParams = this.props.match.params; const matchParams = this.props.match.params;
let menuList = this.props.list; let menuList = this.props.list;
const searchBox = <div className="interface-filter">
<Input onChange={this.onFilter} value={this.state.filter} placeholder="Filter by name" style={{ width: "70%" }} />
<Tag color="#108ee9" onClick={() => this.changeModal('add_cat_modal_visible', true)} style={{ marginLeft: "15px" }} ><Icon type="plus" /></Tag>
<Modal
title="添加接口"
visible={this.state.visible}
onCancel={() => this.changeModal('visible', false)}
footer={null}
>
<AddInterfaceForm catdata={this.props.curProject.cat} catid={this.state.curCatid} onCancel={() => this.changeModal('visible', false)} onSubmit={this.handleAddInterface} />
</Modal>
<Modal
title="添加分类"
visible={this.state.add_cat_modal_visible}
onCancel={() => this.changeModal('add_cat_modal_visible', false)}
footer={null}
>
<AddInterfaceCatForm onCancel={() => this.changeModal('add_cat_modal_visible', false)} onSubmit={this.handleAddInterfaceCat} />
</Modal>
<Modal
title="修改分类"
visible={this.state.change_cat_modal_visible}
onCancel={() => this.changeModal('change_cat_modal_visible', false)}
footer={null}
>
<AddInterfaceCatForm catdata={this.state.curCatdata} onCancel={() => this.changeModal('change_cat_modal_visible', false)} onSubmit={this.handleChangeInterfaceCat} />
</Modal>
</div>
if(menuList.length === 0){ if(menuList.length === 0){
return null; return searchBox;
} }
const defaultExpandedKeys = () => { const defaultExpandedKeys = () => {
const { router, inter, list } = this.props, rNull = { expands: [], selects: [] }; const { router, inter, list } = this.props, rNull = { expands: [], selects: [] };
@ -307,36 +339,7 @@ class InterfaceMenu extends Component {
} }
} }
return <div> return <div>
<div className="interface-filter"> {searchBox}
<Input onChange={this.onFilter} value={this.state.filter} placeholder="Filter by name" style={{ width: "70%" }} />
<Tag color="#108ee9" onClick={() => this.changeModal('add_cat_modal_visible', true)} style={{ marginLeft: "15px" }} ><Icon type="plus" /></Tag>
<Modal
title="添加接口"
visible={this.state.visible}
onCancel={() => this.changeModal('visible', false)}
footer={null}
>
<AddInterfaceForm catdata={this.props.curProject.cat} catid={this.state.curCatid} onCancel={() => this.changeModal('visible', false)} onSubmit={this.handleAddInterface} />
</Modal>
<Modal
title="添加分类"
visible={this.state.add_cat_modal_visible}
onCancel={() => this.changeModal('add_cat_modal_visible', false)}
footer={null}
>
<AddInterfaceCatForm onCancel={() => this.changeModal('add_cat_modal_visible', false)} onSubmit={this.handleAddInterfaceCat} />
</Modal>
<Modal
title="修改分类"
visible={this.state.change_cat_modal_visible}
onCancel={() => this.changeModal('change_cat_modal_visible', false)}
footer={null}
>
<AddInterfaceCatForm catdata={this.state.curCatdata} onCancel={() => this.changeModal('change_cat_modal_visible', false)} onSubmit={this.handleChangeInterfaceCat} />
</Modal>
</div>
{menuList.length > 0 ? {menuList.length > 0 ?
<Tree <Tree
className="interface-list" className="interface-list"