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

This commit is contained in:
suxiaoxin 2017-07-25 14:19:00 +08:00
commit 2b361459c1
10 changed files with 87 additions and 24 deletions

View File

@ -45,7 +45,7 @@ export default class App extends Component {
<div className="router-main"> <div className="router-main">
<Header /> <Header />
<Route path="/" component={Home} exact /> <Route path="/" component={Home} exact />
<Route path="/ProjectGroups" component={requireAuthentication(ProjectGroups)} /> <Route path="/group/:groupName" component={requireAuthentication(ProjectGroups)} />
<Route path="/Interface" component={requireAuthentication(Interface)} /> <Route path="/Interface" component={requireAuthentication(Interface)} />
<Route path="/user" component={requireAuthentication(User)} /> <Route path="/user" component={requireAuthentication(User)} />
<Route path="/News" component={requireAuthentication(News)} /> <Route path="/News" component={requireAuthentication(News)} />

View File

@ -21,10 +21,12 @@ export function fetchNewsData (uid,page,limit) {
page: page, page: page,
limit: variable.PAGE_LIMIT?variable.PAGE_LIMIT:limit limit: variable.PAGE_LIMIT?variable.PAGE_LIMIT:limit
} }
console.log(param); // console.log(param);
return { return {
type: FETCH_NEWS_DATA, type: FETCH_NEWS_DATA,
payload: axios.get('/log/list',param) payload: axios.get('/log/list',{
params: param
})
}; };
} }

View File

@ -1,3 +1,7 @@
export default { export default {
PAGE_LIMIT: 10 // 默认每页展示10条数据 PAGE_LIMIT: 10, // 默认每页展示10条数据
// layout
ROW_MIN_WIDTH: '9.7rem', // 适应小屏幕分辨率
ROW_MAX_WIDTH: '11.7rem' // 适应大屏幕分辨率
} }

View File

@ -38,7 +38,7 @@ class News extends Component {
} }
componentWillMount(){ componentWillMount(){
console.log(this.props.uid); console.log(this.props.uid);
this.props.fetchNewsData(1,1,10).then(function(data){ this.props.fetchNewsData(107,1,10).then(function(data){
console.log(data); console.log(data);
}) })
} }

View File

@ -4,7 +4,8 @@ import { connect } from 'react-redux'
import { Button, Icon, Modal, Input, message, Menu, Row, Col } from 'antd' import { Button, Icon, Modal, Input, message, Menu, Row, Col } from 'antd'
import { autobind } from 'core-decorators'; import { autobind } from 'core-decorators';
import axios from 'axios'; import axios from 'axios';
import { withRouter } from 'react-router';
const { TextArea } = Input;
const Search = Input.Search; const Search = Input.Search;
const confirm = Modal.confirm; const confirm = Modal.confirm;
const TYPE_EDIT = 'edit'; const TYPE_EDIT = 'edit';
@ -28,6 +29,7 @@ import './GroupList.scss'
setGroupList setGroupList
} }
) )
@withRouter
export default class GroupList extends Component { export default class GroupList extends Component {
static propTypes = { static propTypes = {
@ -35,7 +37,9 @@ export default class GroupList extends Component {
currGroup: PropTypes.object, currGroup: PropTypes.object,
fetchGroupList: PropTypes.func, fetchGroupList: PropTypes.func,
setCurrGroup: PropTypes.func, setCurrGroup: PropTypes.func,
setGroupList: PropTypes.func setGroupList: PropTypes.func,
match: PropTypes.object,
history: PropTypes.object
} }
state = { state = {
@ -53,8 +57,19 @@ export default class GroupList extends Component {
} }
componentWillMount() { componentWillMount() {
const groupName = this.props.match.params.groupName;
this.props.fetchGroupList().then(() => { this.props.fetchGroupList().then(() => {
const currGroup = this.props.groupList[0] || { group_name: '', group_desc: '' }; let currGroup = this.props.groupList[0] || { group_name: '', group_desc: '' };
if(this.props.groupList.length && groupName){
for(let i = 0;i<this.props.groupList.length;i++){
if(this.props.groupList[i].group_name === groupName){
currGroup = this.props.groupList[i];
}else{
this.props.history.replace(`${currGroup.group_name}`);
}
}
}
console.log(currGroup);
this.setState({groupList: this.props.groupList}); this.setState({groupList: this.props.groupList});
this.props.setCurrGroup(currGroup) this.props.setCurrGroup(currGroup)
}); });
@ -141,6 +156,7 @@ export default class GroupList extends Component {
const groupId = e.key; const groupId = e.key;
const currGroup = this.props.groupList.find((group) => { return +group._id === +groupId }); const currGroup = this.props.groupList.find((group) => { return +group._id === +groupId });
this.props.setCurrGroup(currGroup); this.props.setCurrGroup(currGroup);
this.props.history.replace(`${currGroup.group_name}`);
} }
@autobind @autobind
@ -229,7 +245,7 @@ export default class GroupList extends Component {
<Row gutter={6} className="modal-input"> <Row gutter={6} className="modal-input">
<Col span="5"><div className="label">简介</div></Col> <Col span="5"><div className="label">简介</div></Col>
<Col span="15"> <Col span="15">
<Input placeholder="请输入分组描述" onChange={this.inputNewGroupDesc}></Input> <TextArea rows = {3} placeholder="请输入分组描述" onChange={this.inputNewGroupDesc}></TextArea>
</Col> </Col>
</Row> </Row>
</Modal> </Modal>

View File

@ -23,6 +23,7 @@
} }
.group-operate { .group-operate {
height: 48px; height: 48px;
min-width: 263px;
padding: 10px 6px; padding: 10px 6px;
background: #fff; background: #fff;
.search { .search {

View File

@ -50,7 +50,8 @@ class UpDateModal extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
protocol: 'http:\/\/' protocol: 'http:\/\/',
envProtocolChange: 'http:\/\/'
} }
} }
static propTypes = { static propTypes = {
@ -84,18 +85,19 @@ class UpDateModal extends Component {
e.preventDefault(); e.preventDefault();
const { form, updateProject, changeUpdateModal, currGroup, projectList, handleUpdateIndex, fetchProjectList, changeTableLoading } = this.props; const { form, updateProject, changeUpdateModal, currGroup, projectList, handleUpdateIndex, fetchProjectList, changeTableLoading } = this.props;
form.validateFields((err, values) => { form.validateFields((err, values) => {
console.log(err); console.log(values);
if (!err) { if (!err) {
console.log(projectList[handleUpdateIndex]); // console.log(projectList[handleUpdateIndex]);
let assignValue = Object.assign(projectList[handleUpdateIndex], values); let assignValue = Object.assign(projectList[handleUpdateIndex], values);
values.protocol = this.state.protocol.split(':')[0]; values.protocol = this.state.protocol.split(':')[0];
assignValue.env = assignValue.envs.map((item, index) => { assignValue.env = assignValue.envs.map((item, index) => {
console.log(values['envs-protocol-'+index]);
return { return {
name: values['envs-name-'+index], name: values['envs-name-'+index],
domain: values['envs-domain-'+index] domain: values['envs-protocol-'+index] + values['envs-domain-'+index]
} }
}); });
console.log(assignValue); // console.log(assignValue);
changeTableLoading(true); changeTableLoading(true);
updateProject(assignValue).then((res) => { updateProject(assignValue).then((res) => {
@ -119,6 +121,13 @@ class UpDateModal extends Component {
}); });
} }
envProtocolChange = (value) => {
console.log(value);
// this.setState({
// envProtocolChange: value
// })
}
// 项目的修改操作 - 删除一项环境配置 // 项目的修改操作 - 删除一项环境配置
remove = (id) => { remove = (id) => {
const { form } = this.props; const { form } = this.props;
@ -174,7 +183,7 @@ class UpDateModal extends Component {
getFieldDecorator('envs', { initialValue: envMessage }); getFieldDecorator('envs', { initialValue: envMessage });
const envs = getFieldValue('envs'); const envs = getFieldValue('envs');
const formItems = envs.map((k, index) => { const formItems = envs.map((k, index) => {
console.log(k); // console.log(k);
const secondIndex = 'next' + index; // 为保证key的唯一性 const secondIndex = 'next' + index; // 为保证key的唯一性
return ( return (
<Row key={index} type="flex" justify="space-between" align={index === 0 ? 'middle' : 'top'}> <Row key={index} type="flex" justify="space-between" align={index === 0 ? 'middle' : 'top'}>
@ -220,7 +229,7 @@ class UpDateModal extends Component {
> >
{getFieldDecorator(`envs-domain-${index}`, { {getFieldDecorator(`envs-domain-${index}`, {
validateTrigger: ['onChange', 'onBlur'], validateTrigger: ['onChange', 'onBlur'],
initialValue: envMessage.length !== 0 ? k.domain : '', initialValue: envMessage.length !== 0 ? k.domain.split('\/\/')[1] : '',
rules: [{ rules: [{
required: false, required: false,
whitespace: true, whitespace: true,
@ -240,7 +249,18 @@ class UpDateModal extends Component {
} }
}] }]
})( })(
<Input placeholder="请输入环境域名" style={{ width: '90%', marginRight: 8 }} /> <Input placeholder="请输入环境域名" style={{ width: '90%', marginRight: 8 }} addonBefore={
getFieldDecorator(`envs-protocol-${index}`, {
initialValue: 'http:\/\/',
rules: [{
required: true
}]
})(
<Select>
<Option value="http://">{'http:\/\/'}</Option>
<Option value="https://">{'https:\/\/'}</Option>
</Select>
)}/>
)} )}
</FormItem> </FormItem>
</Col> </Col>

View File

@ -2,7 +2,8 @@ import {
LOGIN, LOGIN,
LOGIN_OUT, LOGIN_OUT,
LOGIN_TYPE, LOGIN_TYPE,
GET_LOGIN_STATE GET_LOGIN_STATE,
REGISTER
} from '../../constants/action-types'; } from '../../constants/action-types';
const LOADING_STATUS = 0; const LOADING_STATUS = 0;
@ -13,8 +14,8 @@ const initialState = {
isLogin: false, isLogin: false,
userName: null, userName: null,
uid: null, uid: null,
loginState:LOADING_STATUS, loginState: LOADING_STATUS,
loginWrapActiveKey:"1" loginWrapActiveKey: "1"
}; };
export default (state = initialState, action) => { export default (state = initialState, action) => {
@ -51,6 +52,15 @@ export default (state = initialState, action) => {
loginWrapActiveKey: action.index loginWrapActiveKey: action.index
}; };
} }
case REGISTER: {
return {
...state,
isLogin: true,
loginState: MEMBER_STATUS,
uid: action.payload.data.data.uid,
userName: action.payload.data.data.username
};
}
default: default:
return state; return state;
} }

View File

@ -2,7 +2,8 @@ import {
LOGIN, LOGIN,
LOGIN_OUT, LOGIN_OUT,
LOGIN_TYPE, LOGIN_TYPE,
GET_LOGIN_STATE GET_LOGIN_STATE,
REGISTER
} from '../../constants/action-types'; } from '../../constants/action-types';
const LOADING_STATUS = 0; const LOADING_STATUS = 0;
@ -13,8 +14,8 @@ const initialState = {
isLogin: false, isLogin: false,
userName: null, userName: null,
uid: null, uid: null,
loginState:LOADING_STATUS, loginState: LOADING_STATUS,
loginWrapActiveKey:"1" loginWrapActiveKey: "1"
}; };
export default (state = initialState, action) => { export default (state = initialState, action) => {
@ -51,6 +52,15 @@ export default (state = initialState, action) => {
loginWrapActiveKey: action.index loginWrapActiveKey: action.index
}; };
} }
case REGISTER: {
return {
...state,
isLogin: true,
loginState: MEMBER_STATUS,
uid: action.payload.data.data.uid,
userName: action.payload.data.data.username
};
}
default: default:
return state; return state;
} }

View File

@ -9,7 +9,7 @@ export default () => {
<div className="router-main"> <div className="router-main">
<Header/> <Header/>
<Route path="/" component={ Home } exact /> <Route path="/" component={ Home } exact />
<Route path="/ProjectGroups" component={ ProjectGroups } /> <Route path="/group/:groupName" component={ ProjectGroups } />
<Route path="/Interface" component={ Interface } /> <Route path="/Interface" component={ Interface } />
<Route path="/user" component={User} /> <Route path="/user" component={User} />
<Route path="/News" component={ News } /> <Route path="/News" component={ News } />