mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
05ee224be8
@ -0,0 +1,59 @@
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types'
|
||||
import { withRouter } from 'react-router'
|
||||
import { fetchInterfaceColList, fetchInterfaceCaseList, setColData } from '../../../../reducer/modules/interfaceCol'
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
interfaceColList: state.interfaceCol.interfaceColList,
|
||||
currColId: state.interfaceCol.currColId,
|
||||
currCaseId: state.interfaceCol.currCaseId,
|
||||
isShowCol: state.interfaceCol.isShowCol
|
||||
}
|
||||
},
|
||||
{
|
||||
fetchInterfaceColList,
|
||||
fetchInterfaceCaseList,
|
||||
setColData
|
||||
}
|
||||
)
|
||||
@withRouter
|
||||
export default class InterfaceCaseContent extends Component {
|
||||
|
||||
static propTypes = {
|
||||
match: PropTypes.object,
|
||||
interfaceColList: PropTypes.array,
|
||||
fetchInterfaceColList: PropTypes.func,
|
||||
fetchInterfaceCaseList: PropTypes.func,
|
||||
setColData: PropTypes.func,
|
||||
history: PropTypes.object,
|
||||
currColId: PropTypes.number,
|
||||
currCaseId: PropTypes.number,
|
||||
isShowCol: PropTypes.bool
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
async componentWillMount() {
|
||||
const result = await this.props.fetchInterfaceColList(this.props.match.params.id)
|
||||
let { currColId, currCaseId, isShowCol } = this.props;
|
||||
const params = this.props.match.params;
|
||||
const { actionId } = params;
|
||||
currColId = +currColId || result.payload.data.data[0]._id;
|
||||
currCaseId = +actionId || +currCaseId || result.payload.data.data[0].caseList[0]._id;
|
||||
if (isShowCol) {
|
||||
this.props.history.push('/project/' + params.id + '/interface/col/' + currColId)
|
||||
} else {
|
||||
this.props.history.push('/project/' + params.id + '/interface/case/' + currCaseId)
|
||||
}
|
||||
this.props.setColData({currColId: +currColId, currCaseId: +currCaseId})
|
||||
}
|
||||
|
||||
render() {
|
||||
return <h1>hello caseContent</h1>
|
||||
}
|
||||
}
|
@ -50,7 +50,7 @@ export default class InterfaceColContent extends Component {
|
||||
} else {
|
||||
this.props.history.push('/project/' + params.id + '/interface/case/' + currCaseId)
|
||||
}
|
||||
this.props.setColData({currColId, currCaseId})
|
||||
this.props.setColData({currColId: +currColId, currCaseId: +currCaseId})
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -45,7 +45,8 @@ export default class InterfaceColMenu extends Component {
|
||||
state = {
|
||||
addColModalVisible: false,
|
||||
addColName: '',
|
||||
addColDesc: ''
|
||||
addColDesc: '',
|
||||
expandedKeys: []
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -84,25 +85,25 @@ export default class InterfaceColMenu extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
async onSelect(key) {
|
||||
const type = key.split('_')[0];
|
||||
const id = key.split('_')[1];
|
||||
onSelect = (keys) => {
|
||||
const type = keys[0].split('_')[0];
|
||||
const id = keys[0].split('_')[1];
|
||||
if (type === 'col') {
|
||||
this.props.setColData({
|
||||
isShowCol: true,
|
||||
currColId: id
|
||||
currColId: +id
|
||||
})
|
||||
} else {
|
||||
this.props.setColData({
|
||||
isShowCol: false,
|
||||
currCaseId: id
|
||||
currCaseId: +id
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { currColId, currCaseId, isShowCol } = this.props;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="interface-filter">
|
||||
@ -113,15 +114,17 @@ export default class InterfaceColMenu extends Component {
|
||||
</div>
|
||||
<Tree
|
||||
className="col-list-tree"
|
||||
defaultExpandedKeys={[''+currColId, ''+currCaseId]}
|
||||
defaultSelectedKeys={[isShowCol ? ''+currColId : ''+currCaseId]}
|
||||
expandedKeys={this.state.expandedKeys}
|
||||
selectedKeys={[isShowCol ? 'col_'+currColId : 'case_'+currCaseId]}
|
||||
onSelect={this.onSelect}
|
||||
autoExpandParent
|
||||
onExpand={keys => this.setState({expandedKeys: keys})}
|
||||
>
|
||||
{
|
||||
this.props.interfaceColList.map((col) => (
|
||||
<TreeNode
|
||||
key={'col_' + col._id}
|
||||
title={<span><Icon type="folder-open" /><span>{col.name}</span></span>}
|
||||
title={<span><Icon type="folder-open" style={{marginRight: 5}} /><span>{col.name}</span></span>}
|
||||
>
|
||||
{
|
||||
col.caseList && col.caseList.map((interfaceCase) => (
|
||||
|
@ -0,0 +1,17 @@
|
||||
import React, { Component } from 'react'
|
||||
import '../Setting.scss';
|
||||
|
||||
class ProjectMember extends Component {
|
||||
|
||||
|
||||
render () {
|
||||
|
||||
return (
|
||||
<div className="m-panel">
|
||||
Test
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default ProjectMember;
|
@ -0,0 +1,359 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Form, Input, Icon, Tooltip, Select, Button, Row, Col, message, Card } from 'antd';
|
||||
import PropTypes from 'prop-types';
|
||||
import { updateProject, delProject, getProjectMsg } from '../../../../reducer/modules/project';
|
||||
import { fetchGroupMsg } from '../../../../reducer/modules/group';
|
||||
import { connect } from 'react-redux';
|
||||
const { TextArea } = Input;
|
||||
const FormItem = Form.Item;
|
||||
const Option = Select.Option;
|
||||
import '../Setting.scss';
|
||||
|
||||
// layout
|
||||
const formItemLayout = {
|
||||
labelCol: {
|
||||
lg: { span: 3 },
|
||||
xs: { span: 24 },
|
||||
sm: { span: 6 }
|
||||
},
|
||||
wrapperCol: {
|
||||
lg: { span: 21 },
|
||||
xs: { span: 24 },
|
||||
sm: { span: 14 }
|
||||
},
|
||||
className: 'form-item'
|
||||
};
|
||||
let uuid = 0; // 环境配置的计数
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
projectList: state.project.projectList,
|
||||
projectMsg: state.project.projectMsg
|
||||
}
|
||||
},
|
||||
{
|
||||
updateProject,
|
||||
delProject,
|
||||
getProjectMsg,
|
||||
fetchGroupMsg
|
||||
}
|
||||
)
|
||||
class ProjectMessage extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
protocol: 'http:\/\/',
|
||||
envProtocolChange: 'http:\/\/',
|
||||
projectMsg: {}
|
||||
}
|
||||
}
|
||||
static propTypes = {
|
||||
projectId: PropTypes.number,
|
||||
form: PropTypes.object,
|
||||
updateProject: PropTypes.func,
|
||||
delProject: PropTypes.func,
|
||||
getProjectMsg: PropTypes.func,
|
||||
fetchGroupMsg: PropTypes.func,
|
||||
projectList: PropTypes.array,
|
||||
projectMsg: PropTypes.object
|
||||
}
|
||||
|
||||
// 修改线上域名的协议类型 (http/https)
|
||||
protocolChange = (value) => {
|
||||
this.setState({
|
||||
protocol: value,
|
||||
currGroup: ''
|
||||
})
|
||||
}
|
||||
|
||||
// 确认修改
|
||||
handleOk = (e) => {
|
||||
e.preventDefault();
|
||||
const { form, updateProject, projectMsg } = this.props;
|
||||
form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
let assignValue = Object.assign(projectMsg, values);
|
||||
values.protocol = this.state.protocol.split(':')[0];
|
||||
assignValue.env = assignValue.envs.map((item, index) => {
|
||||
return {
|
||||
name: values['envs-name-' + index],
|
||||
domain: values['envs-protocol-' + index] + values['envs-domain-' + index]
|
||||
}
|
||||
});
|
||||
// console.log(assignValue);
|
||||
|
||||
updateProject(assignValue).then((res) => {
|
||||
console.log(res);
|
||||
if (res.payload.data.errcode == 0) {
|
||||
message.success('修改成功! ');
|
||||
} else {
|
||||
message.error(res.payload.data.errmsg);
|
||||
}
|
||||
}).catch(() => {
|
||||
});
|
||||
form.resetFields();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 项目的修改操作 - 删除一项环境配置
|
||||
remove = (id) => {
|
||||
const { form } = this.props;
|
||||
// can use data-binding to get
|
||||
const envs = form.getFieldValue('envs');
|
||||
// We need at least one passenger
|
||||
if (envs.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// can use data-binding to set
|
||||
form.setFieldsValue({
|
||||
envs: envs.filter(key => {
|
||||
const realKey = key._id ? key._id : key
|
||||
return realKey !== id;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 项目的修改操作 - 添加一项环境配置
|
||||
add = () => {
|
||||
uuid++;
|
||||
const { form } = this.props;
|
||||
// can use data-binding to get
|
||||
const envs = form.getFieldValue('envs');
|
||||
const nextKeys = envs.concat(uuid);
|
||||
// can use data-binding to set
|
||||
// important! notify form to detect changes
|
||||
form.setFieldsValue({
|
||||
envs: nextKeys
|
||||
});
|
||||
}
|
||||
|
||||
handleDelete = () => {
|
||||
console.log(this.props); // 出问题了
|
||||
this.props.delProject(this.props.projectId).then((res) => {
|
||||
if (res.payload.data.errcode == 0) {
|
||||
message.success('删除成功!');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async componentWillMount() {
|
||||
await this.props.getProjectMsg(this.props.projectId);
|
||||
const groupMsg = await this.props.fetchGroupMsg(this.props.projectMsg.group_id);
|
||||
this.setState({
|
||||
currGroup: groupMsg.payload.data.data.group_name
|
||||
})
|
||||
}
|
||||
|
||||
render () {
|
||||
const { getFieldDecorator, getFieldValue } = this.props.form;
|
||||
const { projectMsg } = this.props;
|
||||
let initFormValues = {};
|
||||
let envMessage = [];
|
||||
const { name, basepath, desc, env } = projectMsg;
|
||||
initFormValues = { name, basepath, desc, env };
|
||||
if (env && env.length !== 0) {
|
||||
envMessage = env;
|
||||
}
|
||||
|
||||
getFieldDecorator('envs', { initialValue: envMessage });
|
||||
const envs = getFieldValue('envs');
|
||||
const envSettingItems = envs.map((k, index) => {
|
||||
const secondIndex = 'next' + index; // 为保证key的唯一性
|
||||
return (
|
||||
<Row key={index} type="flex" justify="space-between" align={index === 0 ? 'middle' : 'top'}>
|
||||
<Col span={10} offset={2}>
|
||||
<FormItem
|
||||
label={index === 0 ? (
|
||||
<span>环境名称</span>) : ''}
|
||||
required={false}
|
||||
key={index}
|
||||
>
|
||||
{getFieldDecorator(`envs-name-${index}`, {
|
||||
validateTrigger: ['onChange', 'onBlur'],
|
||||
initialValue: envMessage.length !== 0 ? k.name : '',
|
||||
rules: [{
|
||||
required: false,
|
||||
whitespace: true,
|
||||
validator(rule, value, callback) {
|
||||
if (value) {
|
||||
if (value.length === 0) {
|
||||
callback('请输入环境域名');
|
||||
} else if (!/\S/.test(value)) {
|
||||
callback('请输入环境域名');
|
||||
} else if (/prd/.test(value)) {
|
||||
callback('环境域名不能是"prd"');
|
||||
} else {
|
||||
return callback();
|
||||
}
|
||||
} else {
|
||||
callback('请输入环境域名');
|
||||
}
|
||||
}
|
||||
}]
|
||||
})(
|
||||
<Input placeholder="请输入环境名称" style={{ width: '90%', marginRight: 8 }} />
|
||||
)}
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col span={10}>
|
||||
<FormItem
|
||||
label={index === 0 ? (
|
||||
<span>环境域名</span>) : ''}
|
||||
required={false}
|
||||
key={secondIndex}
|
||||
>
|
||||
{getFieldDecorator(`envs-domain-${index}`, {
|
||||
validateTrigger: ['onChange', 'onBlur'],
|
||||
initialValue: envMessage.length !== 0 && k.domain ? k.domain.split('\/\/')[1] : '',
|
||||
rules: [{
|
||||
required: false,
|
||||
whitespace: true,
|
||||
message: "请输入环境域名",
|
||||
validator(rule, value, callback) {
|
||||
if (value) {
|
||||
if (value.length === 0) {
|
||||
callback('请输入环境域名');
|
||||
} else if (!/\S/.test(value)) {
|
||||
callback('请输入环境域名');
|
||||
} else {
|
||||
return callback();
|
||||
}
|
||||
} else {
|
||||
callback('请输入环境域名');
|
||||
}
|
||||
}
|
||||
}]
|
||||
})(
|
||||
<Input placeholder="请输入环境域名" style={{ width: '90%', marginRight: 8 }} addonBefore={
|
||||
getFieldDecorator(`envs-protocol-${index}`, {
|
||||
initialValue: envMessage.length !== 0 && k.domain ? k.domain.split('\/\/')[0] + '\/\/' : 'http\:\/\/',
|
||||
rules: [{
|
||||
required: true
|
||||
}]
|
||||
})(
|
||||
<Select>
|
||||
<Option value="http://">{'http:\/\/'}</Option>
|
||||
<Option value="https://">{'https:\/\/'}</Option>
|
||||
</Select>
|
||||
)} />
|
||||
)}
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col span={2}>
|
||||
{/* 新增的项中,只有最后一项有删除按钮 */}
|
||||
{(envs.length > 0 && k._id) || (envs.length == index + 1) ? (
|
||||
<Icon
|
||||
className="dynamic-delete-button"
|
||||
type="minus-circle-o"
|
||||
onClick={() => {
|
||||
return this.remove(k._id ? k._id : k);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<div className="m-panel">
|
||||
<Form>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="项目名称"
|
||||
>
|
||||
{getFieldDecorator('name', {
|
||||
initialValue: initFormValues.name,
|
||||
rules: [{
|
||||
required: true, message: '请输入项目名称!'
|
||||
}]
|
||||
})(
|
||||
<Input />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="所属分组"
|
||||
>
|
||||
<Input value={this.state.currGroup} disabled={true} />
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label={(
|
||||
<span>
|
||||
基本路径
|
||||
<Tooltip title="基本路径为空表示根路径">
|
||||
<Icon type="question-circle-o" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
)}
|
||||
>
|
||||
{getFieldDecorator('basepath', {
|
||||
initialValue: initFormValues.basepath,
|
||||
rules: [{
|
||||
required: false, message: '请输入项目基本路径! '
|
||||
}]
|
||||
})(
|
||||
<Input />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="描述"
|
||||
>
|
||||
{getFieldDecorator('desc', {
|
||||
initialValue: initFormValues.desc,
|
||||
rules: [{
|
||||
required: false, message: '请输入描述!'
|
||||
}]
|
||||
})(
|
||||
<TextArea rows={4} />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="所属分组"
|
||||
>
|
||||
{envSettingItems}
|
||||
</FormItem>
|
||||
|
||||
<FormItem {...formItemLayout}>
|
||||
<Button type="dashed" onClick={this.add} style={{ width: '60%' }}>
|
||||
<Icon type="plus" /> 添加环境配置
|
||||
</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<Row>
|
||||
<Col sm={{ offset: 6 }} lg={{ offset: 3 }}>
|
||||
<Button className="m-btn" icon="plus" type="primary"
|
||||
onClick={this.handleOk}
|
||||
>修改项目</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<hr className="breakline" />
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="危险操作"
|
||||
>
|
||||
<Card noHovering={true} className="card-danger">
|
||||
<div className="card-danger-content">
|
||||
<h3>删除项目</h3>
|
||||
<p>项目一旦删除,将无法恢复数据,请慎重操作!</p>
|
||||
</div>
|
||||
<Button type="danger" ghost className="card-danger-btn" onClick={this.handleDelete}>删除</Button>
|
||||
</Card>
|
||||
</FormItem>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Form.create()(ProjectMessage);
|
@ -1,360 +1,26 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Form, Input, Icon, Tooltip, Select, Button, Row, Col, message, Card } from 'antd';
|
||||
import { Tabs } from 'antd';
|
||||
import PropTypes from 'prop-types';
|
||||
import { updateProject, delProject, getProjectMsg } from '../../../reducer/modules/project';
|
||||
import { fetchGroupMsg } from '../../../reducer/modules/group';
|
||||
import { connect } from 'react-redux';
|
||||
const { TextArea } = Input;
|
||||
const FormItem = Form.Item;
|
||||
const Option = Select.Option;
|
||||
const TabPane = Tabs.TabPane;
|
||||
import ProjectMessage from './ProjectMessage/ProjectMessage.js';
|
||||
import ProjectMember from './ProjectMember/ProjectMember.js';
|
||||
import './Setting.scss';
|
||||
|
||||
// layout
|
||||
const formItemLayout = {
|
||||
labelCol: {
|
||||
lg: { span: 3 },
|
||||
xs: { span: 24 },
|
||||
sm: { span: 6 }
|
||||
},
|
||||
wrapperCol: {
|
||||
lg: { span: 21 },
|
||||
xs: { span: 24 },
|
||||
sm: { span: 14 }
|
||||
},
|
||||
className: 'form-item'
|
||||
};
|
||||
let uuid = 0; // 环境配置的计数
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
projectList: state.project.projectList,
|
||||
projectMsg: state.project.projectMsg
|
||||
}
|
||||
},
|
||||
{
|
||||
updateProject,
|
||||
delProject,
|
||||
getProjectMsg,
|
||||
fetchGroupMsg
|
||||
}
|
||||
)
|
||||
class Setting extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
protocol: 'http:\/\/',
|
||||
envProtocolChange: 'http:\/\/',
|
||||
projectMsg: {}
|
||||
}
|
||||
}
|
||||
static propTypes = {
|
||||
match: PropTypes.object,
|
||||
form: PropTypes.object,
|
||||
updateProject: PropTypes.func,
|
||||
delProject: PropTypes.func,
|
||||
getProjectMsg: PropTypes.func,
|
||||
fetchGroupMsg: PropTypes.func,
|
||||
projectList: PropTypes.array,
|
||||
projectMsg: PropTypes.object
|
||||
match: PropTypes.object
|
||||
}
|
||||
|
||||
// 修改线上域名的协议类型 (http/https)
|
||||
protocolChange = (value) => {
|
||||
this.setState({
|
||||
protocol: value,
|
||||
currGroup: ''
|
||||
})
|
||||
}
|
||||
|
||||
// 确认修改
|
||||
handleOk = (e) => {
|
||||
e.preventDefault();
|
||||
const { form, updateProject, projectMsg } = this.props;
|
||||
form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
let assignValue = Object.assign(projectMsg, values);
|
||||
values.protocol = this.state.protocol.split(':')[0];
|
||||
assignValue.env = assignValue.envs.map((item, index) => {
|
||||
return {
|
||||
name: values['envs-name-' + index],
|
||||
domain: values['envs-protocol-' + index] + values['envs-domain-' + index]
|
||||
}
|
||||
});
|
||||
// console.log(assignValue);
|
||||
|
||||
updateProject(assignValue).then((res) => {
|
||||
console.log(res);
|
||||
if (res.payload.data.errcode == 0) {
|
||||
message.success('修改成功! ');
|
||||
} else {
|
||||
message.error(res.payload.data.errmsg);
|
||||
}
|
||||
}).catch(() => {
|
||||
});
|
||||
form.resetFields();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 项目的修改操作 - 删除一项环境配置
|
||||
remove = (id) => {
|
||||
const { form } = this.props;
|
||||
// can use data-binding to get
|
||||
const envs = form.getFieldValue('envs');
|
||||
// We need at least one passenger
|
||||
if (envs.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// can use data-binding to set
|
||||
form.setFieldsValue({
|
||||
envs: envs.filter(key => {
|
||||
const realKey = key._id ? key._id : key
|
||||
return realKey !== id;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 项目的修改操作 - 添加一项环境配置
|
||||
add = () => {
|
||||
uuid++;
|
||||
const { form } = this.props;
|
||||
// can use data-binding to get
|
||||
const envs = form.getFieldValue('envs');
|
||||
const nextKeys = envs.concat(uuid);
|
||||
// can use data-binding to set
|
||||
// important! notify form to detect changes
|
||||
form.setFieldsValue({
|
||||
envs: nextKeys
|
||||
});
|
||||
}
|
||||
|
||||
handleDelete = () => {
|
||||
console.log(this.props); // 出问题了
|
||||
this.props.delProject(this.props.match.params.id).then((res) => {
|
||||
if (res.payload.data.errcode == 0) {
|
||||
message.success('删除成功!');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async componentWillMount() {
|
||||
await this.props.getProjectMsg(this.props.match.params.id);
|
||||
const groupMsg = await this.props.fetchGroupMsg(this.props.projectMsg.group_id);
|
||||
this.setState({
|
||||
currGroup: groupMsg.payload.data.data.group_name
|
||||
})
|
||||
}
|
||||
|
||||
render () {
|
||||
const { getFieldDecorator, getFieldValue } = this.props.form;
|
||||
// const that = this;
|
||||
const { projectMsg } = this.props;
|
||||
let initFormValues = {};
|
||||
let envMessage = [];
|
||||
const { name, basepath, desc, env } = projectMsg;
|
||||
initFormValues = { name, basepath, desc, env };
|
||||
if (env && env.length !== 0) {
|
||||
envMessage = env;
|
||||
}
|
||||
|
||||
getFieldDecorator('envs', { initialValue: envMessage });
|
||||
const envs = getFieldValue('envs');
|
||||
const envSettingItems = envs.map((k, index) => {
|
||||
const secondIndex = 'next' + index; // 为保证key的唯一性
|
||||
return (
|
||||
<Row key={index} type="flex" justify="space-between" align={index === 0 ? 'middle' : 'top'}>
|
||||
<Col span={10} offset={2}>
|
||||
<FormItem
|
||||
label={index === 0 ? (
|
||||
<span>环境名称</span>) : ''}
|
||||
required={false}
|
||||
key={index}
|
||||
>
|
||||
{getFieldDecorator(`envs-name-${index}`, {
|
||||
validateTrigger: ['onChange', 'onBlur'],
|
||||
initialValue: envMessage.length !== 0 ? k.name : '',
|
||||
rules: [{
|
||||
required: false,
|
||||
whitespace: true,
|
||||
validator(rule, value, callback) {
|
||||
if (value) {
|
||||
if (value.length === 0) {
|
||||
callback('请输入环境域名');
|
||||
} else if (!/\S/.test(value)) {
|
||||
callback('请输入环境域名');
|
||||
} else if (/prd/.test(value)) {
|
||||
callback('环境域名不能是"prd"');
|
||||
} else {
|
||||
return callback();
|
||||
}
|
||||
} else {
|
||||
callback('请输入环境域名');
|
||||
}
|
||||
}
|
||||
}]
|
||||
})(
|
||||
<Input placeholder="请输入环境名称" style={{ width: '90%', marginRight: 8 }} />
|
||||
)}
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col span={10}>
|
||||
<FormItem
|
||||
label={index === 0 ? (
|
||||
<span>环境域名</span>) : ''}
|
||||
required={false}
|
||||
key={secondIndex}
|
||||
>
|
||||
{getFieldDecorator(`envs-domain-${index}`, {
|
||||
validateTrigger: ['onChange', 'onBlur'],
|
||||
initialValue: envMessage.length !== 0 && k.domain ? k.domain.split('\/\/')[1] : '',
|
||||
rules: [{
|
||||
required: false,
|
||||
whitespace: true,
|
||||
message: "请输入环境域名",
|
||||
validator(rule, value, callback) {
|
||||
if (value) {
|
||||
if (value.length === 0) {
|
||||
callback('请输入环境域名');
|
||||
} else if (!/\S/.test(value)) {
|
||||
callback('请输入环境域名');
|
||||
} else {
|
||||
return callback();
|
||||
}
|
||||
} else {
|
||||
callback('请输入环境域名');
|
||||
}
|
||||
}
|
||||
}]
|
||||
})(
|
||||
<Input placeholder="请输入环境域名" style={{ width: '90%', marginRight: 8 }} addonBefore={
|
||||
getFieldDecorator(`envs-protocol-${index}`, {
|
||||
initialValue: envMessage.length !== 0 && k.domain ? k.domain.split('\/\/')[0] + '\/\/' : 'http\:\/\/',
|
||||
rules: [{
|
||||
required: true
|
||||
}]
|
||||
})(
|
||||
<Select>
|
||||
<Option value="http://">{'http:\/\/'}</Option>
|
||||
<Option value="https://">{'https:\/\/'}</Option>
|
||||
</Select>
|
||||
)} />
|
||||
)}
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col span={2}>
|
||||
{/* 新增的项中,只有最后一项有删除按钮 */}
|
||||
{(envs.length > 0 && k._id) || (envs.length == index + 1) ? (
|
||||
<Icon
|
||||
className="dynamic-delete-button"
|
||||
type="minus-circle-o"
|
||||
onClick={() => {
|
||||
return this.remove(k._id ? k._id : k);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
});
|
||||
const id = this.props.match.params.id;
|
||||
return (
|
||||
<div className="g-row m-container">
|
||||
<Form>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="项目名称"
|
||||
>
|
||||
{getFieldDecorator('name', {
|
||||
initialValue: initFormValues.name,
|
||||
rules: [{
|
||||
required: true, message: '请输入项目名称!'
|
||||
}]
|
||||
})(
|
||||
<Input />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="所属分组"
|
||||
>
|
||||
<Input value={this.state.currGroup} disabled={true} />
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label={(
|
||||
<span>
|
||||
基本路径
|
||||
<Tooltip title="基本路径为空表示根路径">
|
||||
<Icon type="question-circle-o" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
)}
|
||||
>
|
||||
{getFieldDecorator('basepath', {
|
||||
initialValue: initFormValues.basepath,
|
||||
rules: [{
|
||||
required: false, message: '请输入项目基本路径! '
|
||||
}]
|
||||
})(
|
||||
<Input />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="描述"
|
||||
>
|
||||
{getFieldDecorator('desc', {
|
||||
initialValue: initFormValues.desc,
|
||||
rules: [{
|
||||
required: false, message: '请输入描述!'
|
||||
}]
|
||||
})(
|
||||
<TextArea rows={4} />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="所属分组"
|
||||
>
|
||||
{envSettingItems}
|
||||
</FormItem>
|
||||
|
||||
<FormItem {...formItemLayout}>
|
||||
<Button type="dashed" onClick={this.add} style={{ width: '60%' }}>
|
||||
<Icon type="plus" /> 添加环境配置
|
||||
</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
<Row>
|
||||
<Col sm={{ offset: 6 }} lg={{ offset: 3 }}>
|
||||
<Button className="m-btn" icon="plus" type="primary"
|
||||
onClick={this.handleOk}
|
||||
>修改项目</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<hr className="breakline" />
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="危险操作"
|
||||
>
|
||||
<Card noHovering={true} className="card-danger">
|
||||
<div className="card-danger-content">
|
||||
<h3>删除项目</h3>
|
||||
<p>项目一旦删除,将无法恢复数据,请慎重操作!</p>
|
||||
</div>
|
||||
<Button type="danger" ghost className="card-danger-btn" onClick={this.handleDelete}>删除</Button>
|
||||
</Card>
|
||||
</FormItem>
|
||||
<div className="g-row">
|
||||
<Tabs type="card" className="m-tab">
|
||||
<TabPane tab="项目信息" key="1"><ProjectMessage projectId={+id}/></TabPane>
|
||||
<TabPane tab="成员列表" key="2"><ProjectMember projectId={+id}/></TabPane>
|
||||
</Tabs>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Form.create()(Setting);
|
||||
export default Setting;
|
||||
|
@ -45,7 +45,7 @@ export default (state = initialState, action) => {
|
||||
case SET_COL_DATA: {
|
||||
return {
|
||||
...state,
|
||||
...action.payload.data
|
||||
...action.payload
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
@ -2,6 +2,8 @@ import projectModel from '../models/project.js';
|
||||
import yapi from '../yapi.js';
|
||||
import baseController from './base.js';
|
||||
import interfaceModel from '../models/interface.js';
|
||||
import interfaceColModel from '../models/interfaceCol.js';
|
||||
import interfaceCaseModel from '../models/interfaceCase.js';
|
||||
import groupModel from '../models/group';
|
||||
import commons from '../utils/commons.js';
|
||||
import userModel from '../models/user.js';
|
||||
|
@ -48,6 +48,14 @@ var _interface = require('../models/interface.js');
|
||||
|
||||
var _interface2 = _interopRequireDefault(_interface);
|
||||
|
||||
var _interfaceCol = require('../models/interfaceCol.js');
|
||||
|
||||
var _interfaceCol2 = _interopRequireDefault(_interfaceCol);
|
||||
|
||||
var _interfaceCase = require('../models/interfaceCase.js');
|
||||
|
||||
var _interfaceCase2 = _interopRequireDefault(_interfaceCase);
|
||||
|
||||
var _group = require('../models/group');
|
||||
|
||||
var _group2 = _interopRequireDefault(_group);
|
||||
@ -812,8 +820,8 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 9:
|
||||
interfaceInst = _yapi2.default.getInst(_interface2.default);
|
||||
interfaceColInst = _yapi2.default.getInst(interfaceColModel);
|
||||
interfaceCaseInst = _yapi2.default.getInst(interfaceCaseModel);
|
||||
interfaceColInst = _yapi2.default.getInst(_interfaceCol2.default);
|
||||
interfaceCaseInst = _yapi2.default.getInst(_interfaceCase2.default);
|
||||
_context8.next = 14;
|
||||
return interfaceInst.delByProjectId(_id);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user