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

This commit is contained in:
wenbo.dong 2017-09-14 15:31:28 +08:00
commit 7d761ab16e
5 changed files with 27 additions and 23 deletions

View File

@ -58,7 +58,7 @@ class ErrMsg extends Component {
break;
case 'noProject':
title = '该分组还没有项目呢';
desc = <span>请点击右上角 <Icon type="plus-circle" /> 按钮新建项目</span>;
desc = <span>请点击右上角添加项目按钮新建项目</span>;
break;
case 'noData':
title = '暂无数据';

View File

@ -192,7 +192,7 @@ export default class Run extends Component {
const href = URL.format({
protocol: urlObj.protocol || 'http',
host: urlObj.host,
pathname: path,
pathname: urlObj.pathname? urlObj.pathname + path : path,
query: this.getQueryObj(query)
});

View File

@ -1,17 +1,17 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Row, Col, Button } from 'antd';
import { Link } from 'react-router-dom';
import { addProject, fetchProjectList, delProject, changeUpdateModal } from '../../../reducer/modules/project';
import { Row, Col, Button, Tooltip } from 'antd';
import { Link } from 'react-router-dom';
import { addProject, fetchProjectList, delProject, changeUpdateModal } from '../../../reducer/modules/project';
import ProjectCard from '../../../components/ProjectCard/ProjectCard.js';
import ErrMsg from '../../../components/ErrMsg/ErrMsg.js';
import { autobind } from 'core-decorators';
import { setBreadcrumb } from '../../../reducer/modules/user';
import { setBreadcrumb } from '../../../reducer/modules/user';
import './ProjectList.scss'
@connect(
@connect(
state => {
return {
projectList: state.project.projectList,
@ -76,7 +76,7 @@ class ProjectList extends Component {
}
componentWillReceiveProps(nextProps) {
this.props.setBreadcrumb([{name: '' + (nextProps.currGroup.group_name || '')}]);
this.props.setBreadcrumb([{ name: '' + (nextProps.currGroup.group_name || '') }]);
// 切换分组
if (this.props.currGroup !== nextProps.currGroup) {
@ -100,24 +100,30 @@ class ProjectList extends Component {
render() {
const projectData = this.state.projectData;
return (
<div style={{paddingTop: '20px'}} className="m-panel card-panel card-panel-s project-list" >
return (
<div style={{ paddingTop: '20px' }} className="m-panel card-panel card-panel-s project-list" >
<Row className="project-list-header">
<Col span={16} style={{textAlign: 'left'}}>
<Col span={16} style={{ textAlign: 'left' }}>
{this.props.currGroup.group_name}分组 {projectData.length} 个项目
</Col>
<Col>
<Link to="/add-project"> <Button type="primary" >添加项目</Button></Link>
<Tooltip title="您没有权限,请联系该分组组长或管理员">
{this.props.currGroup.role ?
<Button type="primary" ><Link to="/add-project">添加项目</Link></Button> :
<Button type="primary" disabled >添加项目</Button>}
</Tooltip>
</Col>
</Row>
</Row>
<Row gutter={16}>
{projectData.length ? projectData.map((item, index) => {
return (
<Col span={8} key={index}>
<ProjectCard projectData={item} callbackResult={this.receiveRes} />
</Col>);
}) : <ErrMsg type="noProject"/>}
}) : <ErrMsg type="noProject" />}
</Row>
</div>
);

View File

@ -231,14 +231,14 @@ class ProjectMessage extends Component {
validator(rule, value, callback) {
if (value) {
if (value.length === 0) {
callback('请输入环境名');
callback('请输入环境');
} else if (!/\S/.test(value)) {
callback('请输入环境名');
callback('请输入环境');
} else {
return callback();
}
} else {
callback('请输入环境名');
callback('请输入环境');
}
}
}]
@ -266,8 +266,6 @@ class ProjectMessage extends Component {
callback('请输入环境域名!');
} else if (/\s/.test(value)) {
callback('环境域名不允许出现空格!');
} else if (/\//.test(value)) {
callback('环境域名不允许出现‘\/!');
} else {
return callback();
}

View File

@ -76,13 +76,13 @@ class interfaceController extends baseController {
return ctx.body = yapi.commons.resReturn(null, 400, '接口请求路径不能为空');
}
let http_path = url.parse(params.path);
let http_path = url.parse(params.path, true);
params.path = http_path.pathname;
if (!yapi.commons.verifyPath(http_path.path)) {
if (!yapi.commons.verifyPath(http_path.pathname)) {
return ctx.body = yapi.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/');
}
params.req_query = params.req_query || [];
if(!params.req_query){
params.req_query = [];
Object.keys(http_path.query).forEach((item)=>{