mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-15 05:10:47 +08:00
Mertge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
6b81d7e046
@ -201,6 +201,7 @@ class MemberList extends Component {
|
||||
<Select value={ record.role+'-'+record.uid} className="select" onChange={this.changeUserRole}>
|
||||
<Option value={ 'owner-'+record.uid}>组长</Option>
|
||||
<Option value={'dev-'+record.uid}>开发者</Option>
|
||||
<Option value={'guest-'+record.uid}>访客</Option>
|
||||
</Select>
|
||||
<Popconfirm placement="topRight" title="你确定要删除吗? " onConfirm={this.deleteConfirm(record.uid)} okText="确定" cancelText="">
|
||||
<Button type="danger" icon="minus" className="btn-danger" />
|
||||
@ -213,6 +214,8 @@ class MemberList extends Component {
|
||||
return '组长';
|
||||
} else if (record.role === 'dev') {
|
||||
return '开发者';
|
||||
} else if (record.role === 'guest') {
|
||||
return '访客';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@ -222,6 +225,7 @@ class MemberList extends Component {
|
||||
let userinfo = this.state.userInfo;
|
||||
let ownerinfo = [];
|
||||
let devinfo = [];
|
||||
let guestinfo = [];
|
||||
for(let i = 0;i<userinfo.length;i++){
|
||||
if(userinfo[i].role === "owner"){
|
||||
ownerinfo.push(userinfo[i]);
|
||||
@ -229,8 +233,11 @@ class MemberList extends Component {
|
||||
if(userinfo[i].role === "dev"){
|
||||
devinfo.push(userinfo[i]);
|
||||
}
|
||||
if(userinfo[i].role === "guest"){
|
||||
guestinfo.push(userinfo[i]);
|
||||
}
|
||||
userinfo = [...ownerinfo,...devinfo];
|
||||
}
|
||||
userinfo = [...ownerinfo,...devinfo,...guestinfo];
|
||||
return (
|
||||
<div className="m-panel">
|
||||
<Modal
|
||||
@ -251,6 +258,7 @@ class MemberList extends Component {
|
||||
<Select size="large" defaultValue="dev" className="select" onChange={this.changeNewMemberRole}>
|
||||
<Option value="owner">组长</Option>
|
||||
<Option value="dev">开发者</Option>
|
||||
<Option value="guest">访客</Option>
|
||||
</Select>
|
||||
</Col>
|
||||
</Row>
|
||||
|
@ -109,7 +109,7 @@ class ProjectList extends Component {
|
||||
<Col>
|
||||
|
||||
<Tooltip title="您没有权限,请联系该分组组长或管理员">
|
||||
{this.props.currGroup.role!== 'member' ?
|
||||
{ /(admin)|(owner)|(dev)/.test(this.props.currGroup.role) ?
|
||||
<Button type="primary" ><Link to="/add-project">添加项目</Link></Button> :
|
||||
<Button type="primary" disabled >添加项目</Button>}
|
||||
</Tooltip>
|
||||
|
@ -136,7 +136,7 @@ class ProjectData extends Component {
|
||||
<div className="m-panel">
|
||||
<div className="postman-dataImport">
|
||||
<div className="dataImportCon">
|
||||
<div ><h3>数据导入</h3></div>
|
||||
<div ><h3>数据导入 <a target="_blank" rel="noopener noreferrer" title="点击查看文档" href="https://yapi.ymfe.org/data.html" ><Icon type="question-circle-o" /></a></h3></div>
|
||||
<div className="dataImportTile">
|
||||
<Select placeholder="请选择导入数据的方式" onChange={this.handleImportType}>
|
||||
{Object.keys(importDataModule).map((name) => {
|
||||
|
@ -186,6 +186,7 @@ class ProjectMember extends Component {
|
||||
<Select value={record.role+'-'+record.uid} className="select" onChange={this.changeUserRole}>
|
||||
<Option value={'owner-'+record.uid}>组长</Option>
|
||||
<Option value={'dev-'+record.uid}>开发者</Option>
|
||||
<Option value={'guest-'+record.uid}>访客</Option>
|
||||
</Select>
|
||||
<Popconfirm placement="topRight" title="你确定要删除吗? " onConfirm={this.deleteConfirm(record.uid)} okText="确定" cancelText="">
|
||||
<Button type="danger" icon="minus" className="btn-danger" />
|
||||
@ -198,6 +199,8 @@ class ProjectMember extends Component {
|
||||
return '组长';
|
||||
} else if (record.role === 'dev') {
|
||||
return '开发者';
|
||||
} else if (record.role === 'guest') {
|
||||
return '访客';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
@ -225,6 +228,7 @@ class ProjectMember extends Component {
|
||||
<Select size="large" defaultValue="dev" className="select" onChange={this.changeNewMemberRole}>
|
||||
<Option value="owner">组长</Option>
|
||||
<Option value="dev">开发者</Option>
|
||||
<Option value="guest">访客</Option>
|
||||
</Select>
|
||||
</Col>
|
||||
</Row>
|
||||
@ -237,6 +241,7 @@ class ProjectMember extends Component {
|
||||
<p className="item-name">{item.username}{item.uid === this.props.uid ? <Badge count={'我'} style={{ backgroundColor: '#689bd0', fontSize: '13px', marginLeft: '8px', borderRadius: '4px' }} /> : null}</p>
|
||||
{item.role === 'owner' ? <p className="item-role">组长</p> : null}
|
||||
{item.role === 'dev' ? <p className="item-role">开发者</p> : null}
|
||||
{item.role === 'guest' ? <p className="item-role">访客</p> : null}
|
||||
</div>);
|
||||
}): <ErrMsg type="noMemberInGroup"/>}
|
||||
</Card>
|
||||
|
@ -3,7 +3,7 @@ import React, { Component } from 'react'
|
||||
import axios from 'axios'
|
||||
import PropTypes from 'prop-types'
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { Form, Switch, Button, message } from 'antd';
|
||||
import { Form, Switch, Button, message, Icon } from 'antd';
|
||||
import mockEditor from 'client/containers/Project/Interface/InterfaceList/mockEditor';
|
||||
const FormItem = Form.Item;
|
||||
|
||||
@ -92,9 +92,10 @@ class AdvMock extends Component {
|
||||
}
|
||||
};
|
||||
return <div style={{ padding: '20px 10px' }}>
|
||||
|
||||
<Form onSubmit={this.handleSubmit}>
|
||||
<FormItem
|
||||
label="是否开启"
|
||||
label={<span>是否开启 <a target="_blank" rel="noopener noreferrer" title="点击查看文档" href="https://yapi.ymfe.org/mock.html#高级Mock" ><Icon type="question-circle-o" /></a></span>}
|
||||
{...formItemLayout}
|
||||
>
|
||||
<Switch checked={this.state.enable} onChange={this.onChange} checkedChildren="开" unCheckedChildren="关" />
|
||||
|
64
npm-shrinkwrap.json
generated
64
npm-shrinkwrap.json
generated
@ -5312,14 +5312,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz",
|
||||
"integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=",
|
||||
"requires": {
|
||||
"safe-buffer": "5.0.1"
|
||||
}
|
||||
},
|
||||
"string-width": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
|
||||
@ -5330,6 +5322,14 @@
|
||||
"strip-ansi": "3.0.1"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz",
|
||||
"integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=",
|
||||
"requires": {
|
||||
"safe-buffer": "5.0.1"
|
||||
}
|
||||
},
|
||||
"stringstream": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
|
||||
@ -12638,22 +12638,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"require_optional": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/require_optional/-/require_optional-1.0.1.tgz",
|
||||
"integrity": "sha1-TPNaQkf2TKPfjC7yCMxJSxyo/C4=",
|
||||
"requires": {
|
||||
"resolve-from": "2.0.0",
|
||||
"semver": "5.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"resolve-from": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/resolve-from/-/resolve-from-2.0.0.tgz",
|
||||
"integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c="
|
||||
}
|
||||
}
|
||||
},
|
||||
"require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/require-directory/-/require-directory-2.1.1.tgz",
|
||||
@ -12678,6 +12662,22 @@
|
||||
"resolve-from": "1.0.1"
|
||||
}
|
||||
},
|
||||
"require_optional": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/require_optional/-/require_optional-1.0.1.tgz",
|
||||
"integrity": "sha1-TPNaQkf2TKPfjC7yCMxJSxyo/C4=",
|
||||
"requires": {
|
||||
"resolve-from": "2.0.0",
|
||||
"semver": "5.4.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"resolve-from": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/resolve-from/-/resolve-from-2.0.0.tgz",
|
||||
"integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c="
|
||||
}
|
||||
}
|
||||
},
|
||||
"requires-port": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/requires-port/-/requires-port-1.0.0.tgz",
|
||||
@ -13351,14 +13351,6 @@
|
||||
"resolved": "https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz",
|
||||
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM="
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/string_decoder/-/string_decoder-1.0.3.tgz",
|
||||
"integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=",
|
||||
"requires": {
|
||||
"safe-buffer": "5.1.1"
|
||||
}
|
||||
},
|
||||
"string-convert": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/string-convert/-/string-convert-0.2.1.tgz",
|
||||
@ -13445,6 +13437,14 @@
|
||||
"strip-ansi": "3.0.1"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/string_decoder/-/string_decoder-1.0.3.tgz",
|
||||
"integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=",
|
||||
"requires": {
|
||||
"safe-buffer": "5.1.1"
|
||||
}
|
||||
},
|
||||
"stringstream": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://repo.corp.qunar.com/artifactory/api/npm/npm-qunar/stringstream/-/stringstream-0.0.5.tgz",
|
||||
|
@ -93,6 +93,7 @@ class baseController {
|
||||
let interfaceInst = yapi.getInst(interfaceModel);
|
||||
let interfaceData = await interfaceInst.get(id)
|
||||
result.interfaceData = interfaceData;
|
||||
// 项目创建者相当于 owner
|
||||
if (interfaceData.uid === this.getUid()) {
|
||||
return 'owner';
|
||||
}
|
||||
@ -115,8 +116,10 @@ class baseController {
|
||||
if (memberData && memberData.role) {
|
||||
if (memberData.role === 'owner') {
|
||||
return 'owner';
|
||||
} else {
|
||||
} else if (memberData.role === 'dev') {
|
||||
return 'dev';
|
||||
} else {
|
||||
return 'guest';
|
||||
}
|
||||
}
|
||||
type = 'group';
|
||||
@ -134,8 +137,10 @@ class baseController {
|
||||
if (groupMemberData && groupMemberData.role) {
|
||||
if (groupMemberData.role === 'owner') {
|
||||
return 'owner';
|
||||
} else {
|
||||
} else if (groupMemberData.role === 'dev') {
|
||||
return 'dev'
|
||||
} else {
|
||||
return 'guest'
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -151,7 +156,7 @@ class baseController {
|
||||
*
|
||||
* @param {*} id type对应的id
|
||||
* @param {*} type enum[interface, project, group]
|
||||
* @param {*} action enum[ danger , edit ] danger只有owner或管理员才能操作,edit只要是dev或以上就能执行
|
||||
* @param {*} action enum[ danger, edit, view ] danger只有owner或管理员才能操作,edit只要是dev或以上就能执行
|
||||
*/
|
||||
async checkAuth(id, type, action) {
|
||||
let role = await this.getProjectRole(id, type);
|
||||
@ -163,6 +168,10 @@ class baseController {
|
||||
if (role === 'admin' || role === 'owner' || role === 'dev') {
|
||||
return true;
|
||||
}
|
||||
} else if (action === 'view') {
|
||||
if (role === 'admin' || role === 'owner' || role === 'dev' || role === 'guest') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ class groupController extends baseController {
|
||||
* @foldnumber 10
|
||||
* @param {String} id 项目分组id
|
||||
* @param {String} member_uid 项目分组成员uid
|
||||
* @param {String} role 成员角色,owner or dev
|
||||
* @param {String} role 成员角色,owner or dev or guest
|
||||
* @returns {Object}
|
||||
* @example
|
||||
*/
|
||||
@ -145,7 +145,7 @@ class groupController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '分组id不能为空');
|
||||
}
|
||||
|
||||
params.role = params.role === 'owner' ? 'owner' : 'dev';
|
||||
params.role = ['owner', 'dev', 'guest'].find(v => v === params.role) || 'dev';
|
||||
|
||||
var check = await groupInst.checkMemberRepeat(params.id, params.member_uid);
|
||||
if (check > 0) {
|
||||
@ -197,7 +197,7 @@ class groupController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
|
||||
}
|
||||
|
||||
params.role = params.role === 'owner' ? 'owner' : 'dev';
|
||||
params.role = ['owner', 'dev', 'guest'].find(v => v === params.role) || 'dev';
|
||||
|
||||
try {
|
||||
let result = await groupInst.changeMemberRole(params.id, params.member_uid, params.role);
|
||||
|
@ -205,7 +205,7 @@ class interfaceController extends baseController {
|
||||
let result = await this.Model.get(params.id);
|
||||
let project = await this.projectModel.getBaseInfo(result.project_id);
|
||||
if (project.project_type === 'private') {
|
||||
if (await this.checkAuth(project._id, 'project', 'edit') !== true) {
|
||||
if (await this.checkAuth(project._id, 'project', 'view') !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 406, '没有权限');
|
||||
}
|
||||
}
|
||||
@ -232,7 +232,7 @@ class interfaceController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 407, '不存在的项目');
|
||||
}
|
||||
if (project.project_type === 'private') {
|
||||
if (await this.checkAuth(project._id, 'project', 'edit') !== true) {
|
||||
if (await this.checkAuth(project._id, 'project', 'view') !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 406, '没有权限');
|
||||
}
|
||||
}
|
||||
@ -257,7 +257,7 @@ class interfaceController extends baseController {
|
||||
let catdata = await this.catModel.get(catid);
|
||||
let project = await this.projectModel.getBaseInfo(catdata.project_id);
|
||||
if (project.project_type === 'private') {
|
||||
if (await this.checkAuth(project._id, 'project', 'edit') !== true) {
|
||||
if (await this.checkAuth(project._id, 'project', 'view') !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 406, '没有权限');
|
||||
}
|
||||
}
|
||||
@ -278,7 +278,7 @@ class interfaceController extends baseController {
|
||||
|
||||
let project = await this.projectModel.getBaseInfo(project_id);
|
||||
if (project.project_type === 'private') {
|
||||
if (await this.checkAuth(project._id, 'project', 'edit') !== true) {
|
||||
if (await this.checkAuth(project._id, 'project', 'view') !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 406, '没有权限');
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class interfaceColController extends baseController{
|
||||
let id = ctx.query.project_id;
|
||||
let project = await this.projectModel.getBaseInfo(id);
|
||||
if (project.project_type === 'private') {
|
||||
if (await this.checkAuth(project._id, 'project', 'edit') !== true) {
|
||||
if (await this.checkAuth(project._id, 'project', 'view') !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 406, '没有权限');
|
||||
}
|
||||
}
|
||||
@ -124,7 +124,7 @@ class interfaceColController extends baseController{
|
||||
let project = await this.projectModel.getBaseInfo(colData.project_id);
|
||||
|
||||
if (project.project_type === 'private') {
|
||||
if (await this.checkAuth(project._id, 'project', 'edit') !== true) {
|
||||
if (await this.checkAuth(project._id, 'project', 'view') !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 406, '没有权限');
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ class projectController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目成员已存在');
|
||||
}
|
||||
|
||||
params.role = params.role === 'owner' ? 'owner' : 'dev';
|
||||
params.role = ['owner', 'dev', 'guest'].find(v => v === params.role) || 'dev';
|
||||
|
||||
let userdata = await this.getUserdata(params.member_uid, params.role);
|
||||
if (userdata === null) {
|
||||
@ -309,7 +309,7 @@ class projectController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '不存在的项目');
|
||||
}
|
||||
if (result.project_type === 'private') {
|
||||
if (await this.checkAuth(result._id, 'project', 'edit') !== true) {
|
||||
if (await this.checkAuth(result._id, 'project', 'view') !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 406, '没有权限');
|
||||
}
|
||||
}
|
||||
@ -342,7 +342,7 @@ class projectController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组id不能为空');
|
||||
}
|
||||
|
||||
let auth = await this.checkAuth(group_id, 'group', 'edit')
|
||||
let auth = await this.checkAuth(group_id, 'group', 'view')
|
||||
try {
|
||||
let result = await this.Model.list(group_id);
|
||||
let follow = await this.followModel.list(this.getUid());
|
||||
@ -358,6 +358,7 @@ class projectController extends baseController {
|
||||
let f = _.find(follow, (fol) => {
|
||||
return fol.projectid === item._id
|
||||
})
|
||||
// 排序:收藏的项目放前面
|
||||
if (f) {
|
||||
item.follow = true;
|
||||
project_list.unshift(item);
|
||||
@ -440,7 +441,7 @@ class projectController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
|
||||
}
|
||||
|
||||
params.role = params.role === 'owner' ? 'owner' : 'dev';
|
||||
params.role = ['owner', 'dev', 'guest'].find(v => v === params.role) || 'dev';
|
||||
|
||||
try {
|
||||
let result = await projectInst.changeMemberRole(params.id, params.member_uid, params.role);
|
||||
|
@ -105,7 +105,7 @@ module.exports = async (ctx, next) => {
|
||||
ctx.set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE")
|
||||
return ctx.body = 'ok'
|
||||
}
|
||||
return ctx.body = yapi.commons.resReturn(null, 404, '不存在的api');
|
||||
return ctx.body = yapi.commons.resReturn(null, 404, `不存在的api, 当前请求path为 ${newpath}, 请求方法为 ${ctx.method} ,请确认是否定义此请求。`);
|
||||
}
|
||||
interfaceData = [
|
||||
await interfaceInst.get(findInterface._id)
|
||||
|
Loading…
Reference in New Issue
Block a user