mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-09 05:00:30 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
d5f0507896
@ -19,24 +19,24 @@ function json_parse(data) {
|
||||
}
|
||||
}
|
||||
|
||||
function isValidJson(json){
|
||||
if(!json) return false;
|
||||
if(typeof json === 'object') return true;
|
||||
try{
|
||||
if(typeof json === 'string'){
|
||||
function isValidJson(json) {
|
||||
if (!json) return false;
|
||||
if (typeof json === 'object') return true;
|
||||
try {
|
||||
if (typeof json === 'string') {
|
||||
json5.parse(json);
|
||||
return true;
|
||||
}
|
||||
}catch(e){
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function isJsonData(headers, res){
|
||||
if(isValidJson(res)){
|
||||
function isJsonData(headers, res) {
|
||||
if (isValidJson(res)) {
|
||||
return true;
|
||||
}
|
||||
if(!headers || typeof headers !== 'object') return false;
|
||||
if (!headers || typeof headers !== 'object') return false;
|
||||
let isResJson = false;
|
||||
Object.keys(headers).map(key => {
|
||||
if (/content-type/i.test(key) && /application\/json/i.test(headers[key])) {
|
||||
@ -192,7 +192,7 @@ export default class Run extends Component {
|
||||
const href = URL.format({
|
||||
protocol: urlObj.protocol || 'http',
|
||||
host: urlObj.host,
|
||||
pathname: urlObj.pathname? urlObj.pathname + path : path,
|
||||
pathname: urlObj.pathname ? urlObj.pathname + path : path,
|
||||
query: this.getQueryObj(query)
|
||||
});
|
||||
|
||||
@ -207,7 +207,7 @@ export default class Run extends Component {
|
||||
file: bodyType === 'file' ? 'single-file' : null,
|
||||
success: (res, header) => {
|
||||
try {
|
||||
if(isJsonData(header)){
|
||||
if (isJsonData(header)) {
|
||||
res = json_parse(res);
|
||||
}
|
||||
|
||||
@ -243,9 +243,9 @@ export default class Run extends Component {
|
||||
},
|
||||
error: (err, header) => {
|
||||
try {
|
||||
if(isJsonData(header)){
|
||||
if (isJsonData(header)) {
|
||||
err = json_parse(err);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
message.error(e.message)
|
||||
}
|
||||
@ -554,20 +554,24 @@ export default class Run extends Component {
|
||||
}
|
||||
</div>
|
||||
|
||||
<Card title="请求部分" noHovering className="req-part">
|
||||
<Card title={<Tooltip placement="top" title="在项目设置配置domain">请求部分 <Icon type="question-circle-o" /></Tooltip>} noHovering className="req-part">
|
||||
<div className="url">
|
||||
|
||||
<InputGroup compact style={{ display: 'flex' }}>
|
||||
<Select disabled value={method} style={{ flexBasis: 60 }} onChange={this.changeMethod} >
|
||||
<Option value="GET">GET</Option>
|
||||
<Option value="POST">POST</Option>
|
||||
</Select>
|
||||
|
||||
<Select value={caseEnv} style={{ flexBasis: 180, flexGrow: 1 }} onSelect={this.selectDomain}>
|
||||
{
|
||||
domains.map((item, index) => (<Option value={item.name} key={index}>{item.name + ':' + item.domain}</Option>))
|
||||
}
|
||||
</Select>
|
||||
|
||||
<Input disabled value={path + search} onChange={this.changePath} spellCheck="false" style={{ flexBasis: 180, flexGrow: 1 }} />
|
||||
</InputGroup>
|
||||
|
||||
<Tooltip placement="bottom" title="请求真实接口">
|
||||
<Button
|
||||
disabled={!hasPlugin}
|
||||
@ -635,21 +639,21 @@ export default class Run extends Component {
|
||||
<Panel
|
||||
header={
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||
<div>BODY</div>
|
||||
<div>BODY</div>
|
||||
</div>
|
||||
}
|
||||
key="3"
|
||||
className={HTTP_METHOD[method].request_body?'POST':'hidden'}
|
||||
className={HTTP_METHOD[method].request_body ? 'POST' : 'hidden'}
|
||||
>
|
||||
|
||||
<div style={{ display: HTTP_METHOD[method].request_body && bodyType !== 'form' && bodyType !== 'file'? 'block': 'none' }}>
|
||||
<div id="body-other-edit" style={{ marginTop: 10, minHeight:150 }} className="pretty-editor"></div>
|
||||
<div style={{ display: HTTP_METHOD[method].request_body && bodyType !== 'form' && bodyType !== 'file' ? 'block' : 'none' }}>
|
||||
<div id="body-other-edit" style={{ marginTop: 10, minHeight: 150 }} className="pretty-editor"></div>
|
||||
</div>
|
||||
|
||||
{
|
||||
HTTP_METHOD[method].request_body && bodyType === 'form' &&
|
||||
<div>
|
||||
{
|
||||
{
|
||||
bodyForm.map((item, index) => {
|
||||
return (
|
||||
<div key={index} className="key-value-wrap">
|
||||
|
@ -1,7 +1,8 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { Table, Select, Button, Modal, Row, Col, message, Popconfirm } from 'antd';
|
||||
import {Table, Select, Button, Modal, Row, Col, message, Popconfirm } from 'antd';
|
||||
import { Link } from 'react-router-dom'
|
||||
import './MemberList.scss';
|
||||
import { autobind } from 'core-decorators';
|
||||
import { fetchGroupMemberList, fetchGroupMsg, addMember, delMember, changeMemberRole } from '../../../reducer/modules/group.js'
|
||||
@ -9,7 +10,7 @@ import ErrMsg from '../../../components/ErrMsg/ErrMsg.js';
|
||||
import UsernameAutoComplete from '../../../components/UsernameAutoComplete/UsernameAutoComplete.js';
|
||||
const Option = Select.Option;
|
||||
|
||||
const arrayAddKey = (arr) => {
|
||||
function arrayAddKey (arr) {
|
||||
return arr.map((item, index) => {
|
||||
return {
|
||||
...item,
|
||||
@ -136,6 +137,9 @@ class MemberList extends Component {
|
||||
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if(this._groupId !== this._groupId){
|
||||
return null;
|
||||
}
|
||||
if (this.props.currGroup !== nextProps.currGroup) {
|
||||
this.props.fetchGroupMemberList(nextProps.currGroup._id).then((res) => {
|
||||
this.setState({
|
||||
@ -151,7 +155,7 @@ class MemberList extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const currGroupId = this.props.currGroup._id;
|
||||
const currGroupId = this._groupId = this.props.currGroup._id;
|
||||
this.props.fetchGroupMsg(currGroupId).then((res) => {
|
||||
this.setState({
|
||||
role: res.payload.data.data.role
|
||||
@ -178,8 +182,12 @@ class MemberList extends Component {
|
||||
key: 'username',
|
||||
render: (text, record) => {
|
||||
return (<div className="m-user">
|
||||
<img src={location.protocol + '//' + location.host + '/api/user/avatar?uid=' + record.uid} className="m-user-img" />
|
||||
<p className="m-user-name">{text}</p>
|
||||
<Link to={`/user/profile/${record.uid}`}>
|
||||
<img src={location.protocol + '//' + location.host + '/api/user/avatar?uid=' + record.uid} className="m-user-img" />
|
||||
</Link>
|
||||
<Link to={`/user/profile/${record.uid}`}>
|
||||
<p className="m-user-name">{text}</p>
|
||||
</Link>
|
||||
</div>);
|
||||
}
|
||||
}, {
|
||||
@ -190,8 +198,8 @@ class MemberList extends Component {
|
||||
if (this.state.role === 'owner' || this.state.role === 'admin') {
|
||||
return (
|
||||
<div>
|
||||
<Select defaultValue={record.role+'-'+record.uid} className="select" onChange={this.changeUserRole}>
|
||||
<Option value={'owner-'+record.uid}>组长</Option>
|
||||
<Select value={ record.role+'-'+record.uid} className="select" onChange={this.changeUserRole}>
|
||||
<Option value={ 'owner-'+record.uid}>组长</Option>
|
||||
<Option value={'dev-'+record.uid}>开发者</Option>
|
||||
</Select>
|
||||
<Popconfirm placement="topRight" title="你确定要删除吗? " onConfirm={this.deleteConfirm(record.uid)} okText="确定" cancelText="">
|
||||
@ -211,6 +219,18 @@ class MemberList extends Component {
|
||||
}
|
||||
}
|
||||
}];
|
||||
let userinfo = this.state.userInfo;
|
||||
let ownerinfo = [];
|
||||
let devinfo = [];
|
||||
for(let i = 0;i<userinfo.length;i++){
|
||||
if(userinfo[i].role === "owner"){
|
||||
ownerinfo.push(userinfo[i]);
|
||||
}
|
||||
if(userinfo[i].role === "dev"){
|
||||
devinfo.push(userinfo[i]);
|
||||
}
|
||||
}
|
||||
userinfo = [...ownerinfo,...devinfo];
|
||||
return (
|
||||
<div className="m-panel">
|
||||
<Modal
|
||||
@ -235,7 +255,7 @@ class MemberList extends Component {
|
||||
</Col>
|
||||
</Row>
|
||||
</Modal>
|
||||
<Table columns={columns} dataSource={this.state.userInfo} pagination={false} locale={{emptyText: <ErrMsg type="noMemberInGroup"/>}} />
|
||||
<Table columns={columns} dataSource={userinfo} pagination={false} locale={{emptyText: <ErrMsg type="noMemberInGroup"/>}} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class ProjectList extends Component {
|
||||
<Col>
|
||||
|
||||
<Tooltip title="您没有权限,请联系该分组组长或管理员">
|
||||
{this.props.currGroup.role ?
|
||||
{this.props.currGroup.role!== 'member' ?
|
||||
<Button type="primary" ><Link to="/add-project">添加项目</Link></Button> :
|
||||
<Button type="primary" disabled >添加项目</Button>}
|
||||
</Tooltip>
|
||||
|
@ -198,6 +198,7 @@ class InterfaceEditForm extends Component {
|
||||
|
||||
let editor = this.editor = new Editor('#desc');
|
||||
editor.create();
|
||||
editor.txt.html(this.state.desc)
|
||||
}
|
||||
|
||||
addParams = (name, data) => {
|
||||
@ -281,7 +282,7 @@ class InterfaceEditForm extends Component {
|
||||
{getFieldDecorator('req_query[' + index + '].desc', {
|
||||
initialValue: data.desc
|
||||
})(
|
||||
<Input placeholder="备注" />
|
||||
<Input.TextArea autosize={true} placeholder="备注" />
|
||||
)}
|
||||
</Col>
|
||||
<Col span="1" >
|
||||
@ -308,14 +309,14 @@ class InterfaceEditForm extends Component {
|
||||
{getFieldDecorator('req_headers[' + index + '].value', {
|
||||
initialValue: data.value
|
||||
})(
|
||||
<Input placeholder="参数值" />
|
||||
<Input placeholder="参数值" />
|
||||
)}
|
||||
</Col>
|
||||
<Col span="10" >
|
||||
{getFieldDecorator('req_headers[' + index + '].desc', {
|
||||
initialValue: data.desc
|
||||
})(
|
||||
<Input placeholder="备注" />
|
||||
<Input.TextArea autosize={true} placeholder="备注" />
|
||||
)}
|
||||
</Col>
|
||||
<Col span="2" >
|
||||
@ -358,7 +359,7 @@ class InterfaceEditForm extends Component {
|
||||
{getFieldDecorator('req_body_form[' + index + '].desc', {
|
||||
initialValue: data.desc
|
||||
})(
|
||||
<Input placeholder="备注" />
|
||||
<Input.TextArea autosize={true} placeholder="备注" />
|
||||
)}
|
||||
</Col>
|
||||
<Col span="1" >
|
||||
@ -380,7 +381,7 @@ class InterfaceEditForm extends Component {
|
||||
{getFieldDecorator('req_params[' + index + '].desc', {
|
||||
initialValue: data.desc
|
||||
})(
|
||||
<Input placeholder="备注" />
|
||||
<Input.TextArea autosize={true} placeholder="备注" />
|
||||
)}
|
||||
</Col>
|
||||
|
||||
|
@ -16,7 +16,6 @@ const TreeNode = Tree.TreeNode;
|
||||
@connect(
|
||||
|
||||
state => {
|
||||
|
||||
return {
|
||||
list: state.inter.list,
|
||||
inter: state.inter.curdata,
|
||||
@ -98,6 +97,14 @@ class InterfaceMenu extends Component {
|
||||
this.handleRequest()
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps){
|
||||
if (this.props.list !== nextProps.list) {
|
||||
this.setState({
|
||||
list: nextProps.list
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
onSelect = (selectedKeys) => {
|
||||
const { history, match } = this.props;
|
||||
|
@ -183,7 +183,7 @@ class ProjectMember extends Component {
|
||||
if (this.state.role === 'owner' || this.state.role === 'admin') {
|
||||
return (
|
||||
<div>
|
||||
<Select defaultValue={record.role+'-'+record.uid} className="select" onChange={this.changeUserRole}>
|
||||
<Select value={record.role+'-'+record.uid} className="select" onChange={this.changeUserRole}>
|
||||
<Option value={'owner-'+record.uid}>组长</Option>
|
||||
<Option value={'dev-'+record.uid}>开发者</Option>
|
||||
</Select>
|
||||
|
@ -97,15 +97,14 @@ class List extends Component {
|
||||
data = this.state.data;
|
||||
}
|
||||
let columns = [{
|
||||
title: 'UID',
|
||||
dataIndex: '_id',
|
||||
key: '_id',
|
||||
width: 100
|
||||
}, {
|
||||
title: '用户名',
|
||||
dataIndex: 'username',
|
||||
key: 'username',
|
||||
width: 180
|
||||
width: 180,
|
||||
render: (username, item)=>{
|
||||
console.log(item)
|
||||
return <Link to={"/user/profile/" + item._id} >{item.username}</Link>
|
||||
}
|
||||
}, {
|
||||
title: 'Email',
|
||||
dataIndex: 'email',
|
||||
@ -126,8 +125,7 @@ class List extends Component {
|
||||
width: "90px",
|
||||
render: (item) => {
|
||||
return (
|
||||
<span>
|
||||
<Link to={"/user/profile/" + item._id} >查看</Link>
|
||||
<span>
|
||||
<span className="ant-divider" />
|
||||
<Popconfirm title="确认删除此用户?" onConfirm={() => { this.confirm(item._id) }} okText="确定" cancelText="取消">
|
||||
<a href="#">删除</a>
|
||||
|
@ -16,10 +16,10 @@ function mock(mockJSON, context) {
|
||||
if (!p.hasOwnProperty(i)) {
|
||||
continue;
|
||||
}
|
||||
if (typeof p[i] === 'object') {
|
||||
if (p[i] && typeof p[i] === 'object') {
|
||||
c[i] = (p[i].constructor === Array) ? [] : {};
|
||||
parse(p[i], c[i]);
|
||||
} else {
|
||||
} else if(p[i] && typeof p[i] === 'string'){
|
||||
p[i] = handleStr(p[i]);
|
||||
var filters = i.split(mockSplit), newFilters = [].concat(filters);
|
||||
c[i] = p[i];
|
||||
@ -34,6 +34,8 @@ function mock(mockJSON, context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
c[i] = p[i];
|
||||
}
|
||||
}
|
||||
return c;
|
||||
|
@ -43,9 +43,7 @@ function postman(importDataModule){
|
||||
if(query&&query.length){
|
||||
for(let item in query){
|
||||
res.push({
|
||||
name: query[item].key,
|
||||
desc: query[item].description,
|
||||
required: query[item].enable
|
||||
name: query[item].name
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "yapi",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "YAPI",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
Loading…
Reference in New Issue
Block a user