dev_forge
caicai8 5 years ago
parent a10a4e8f0c
commit 3a16636081

@ -24,43 +24,9 @@ const CoderRootBranch = Loadable({
loading: Loading,
})
class CoderRootIndex extends Component{
constructor(props){
super(props);
this.state={
branchs:undefined,
branchList:undefined,
branchLastCommit:undefined,
// http_url:undefined
}
}
componentDidMount=()=>{
this.getBranch();
}
// 获取分支列表
getBranch=()=>{
const { projectsId } = this.props.match.params;
console.log(this.props)
const url =`/projects/${projectsId}/branches.json`;
axios.get(url).then((result)=>{
if(result && result.data.length>0){
const branchs = [];
result.data.map((item,key)=>{
branchs.push({
index:key,
name:item.name
})
})
this.setState({
branchList:result.data,
branchs,
branchLastCommit:result.data[0],
// http_url:result.data[0].http_url
})
}
}).catch((error)=>{})
}
render(){
const {projectDetail} = this.props;
const { projectDetail } = this.props;
const { projectsId } = this.props.match.params;
const { pathname } = this.props.location;
return(

@ -86,8 +86,11 @@ class Detail extends Component{
praises_count:undefined ,
forked_count:undefined,
current_user:undefined,
http_url: undefined
http_url: undefined,
branchs:undefined,
branchList:undefined,
branchLastCommit:undefined,
}
}
@ -107,18 +110,18 @@ class Detail extends Component{
componentDidMount=()=>{
this.getUserInfo();
// this.getUserInfo();
this.getDetail();
}
componentDidUpdate=(provState)=>{
if(provState.match.params.projectsId !== this.props.match.params.projectsId){
this.getDetail();
}
}
// componentDidUpdate=(provState)=>{
// if(provState.match.params.projectsId !== this.props.match.params.projectsId){
// this.getDetail();
// }
// }
getDetail=()=>{
// const { login } = this.props.current_user;
const { current_user } = this.state;
const { current_user } = this.props;
const { projectsId } = this.props.match.params;
const url = `/${current_user&&current_user.login}/${projectsId}.json`;
axios.get(url).then((result)=>{
@ -135,6 +138,9 @@ class Detail extends Component{
praises_count:result.data.praises_count,
forked_count:result.data.forked_count,
})
if(result.data.project_id){
this.getBranch(result.data.project_id);
}
}
}).catch((error)=>{})
}
@ -205,13 +211,35 @@ class Detail extends Component{
console.log(error);
})
}
// 获取分支列表
getBranch=(id)=>{
const url =`/projects/${id}/branches.json`;
axios.get(url).then((result)=>{
if(result && result.data.length>0){
const branchs = [];
result.data.map((item,key)=>{
branchs.push({
index:key,
name:item.name
})
})
this.setState({
branchList:result.data,
branchs,
branchLastCommit:result.data[0],
// http_url:result.data[0].http_url
})
}
}).catch((error)=>{})
}
render(){
const { projectsId } = this.props.match.params;
const { projectDetail , watchers_count , praises_count , forked_count } = this.state;
const { projectDetail , watchers_count , praises_count , forked_count , project_id } = this.state;
const url = this.props.history.location.pathname;
const { isManager , isDeveloper } = this.props;
const { projectsId } = this.props.match.params;
return(
<div>
<div className="detailHeader-wrapper">

@ -16,7 +16,7 @@ class IndexItem extends Component{
<img className="p-r-photo" alt="" src={getImageUrl(`images/${item.author && item.author.image_url}`)} ></img>
<div className="p-r-Infos">
<div className="p-r-name">
<Link to={`/projects/${item.id}/coder`} className="hide-1 font-16 color-grey-3" style={{whiteSpace:"wrap"}}>{item.name}</Link>
<Link to={`/projects/${item.identifier}/coder`} className="hide-1 font-16 color-grey-3" style={{whiteSpace:"wrap"}}>{item.name}</Link>
<span className="p-r-tags">
{ item.forked_count ? <span><label>Fork</label><span>{ item.forked_count}</span></span>:"" }
<span><label>Start</label><span>{ item.praises_count }</span></span>

@ -1,38 +1,60 @@
import React , { Component } from 'react';
import { Link } from 'react-router-dom';
import { Input , AutoComplete , Dropdown , Menu , Icon } from 'antd';
import { Input , AutoComplete , Dropdown , Menu , Icon , Spin } from 'antd';
import axios from 'axios';
const { Option } = AutoComplete;
const MENU_LIST = ['管理员','可读权限','可写权限'];
const MENU_LIST = [{
id:"Manager",
name:'管理员'
},{
id:"Developer",
name:'开发人员'
},{
id:"Reporter",
name:'报告人员'
}];
const LIMIT = 15;
class Collaborator extends Component{
constructor(props){
super(props);
this.state={
listData:undefined,
user:undefined,
user_id:undefined,
userDataSource:undefined,
page:1
page:1,
isSpin:true
}
}
componentDidMount=()=>{
this.getMember();
if(this.props.project_id){
this.getMember(this.props.project_id);
}
}
componentDidUpdate=(prevState)=>{
if(this.props.project_id && this.props.project_id !== prevState.project_id){
this.getMember(this.props.project_id);
}
}
// 获取项目协作者
getMember=()=>{
getMember=(project_id)=>{
const { page } = this.state;
const { projectsId } = this.props.match.params;
const url = `/projects/${projectsId}/members.json`;
const url = `/projects/${project_id}/members.json`;
axios.get(url,{
params:{
page,limit:LIMIT
}
}).then(result=>{
if(result){
this.setState({
listData:result.data.members,
isSpin:false
})
}
}).catch(error=>{
console.log(error);
@ -40,9 +62,26 @@ class Collaborator extends Component{
}
// 选择用户
changeInputUser=(e)=>{
console.log(e);
this.setState({
user:e
})
this.getUserList(e);
}
changeUser=(e)=>{
console.log("click",e);
this.setState({
user_id:e,
})
}
serachUser=(e)=>{
console.log("select",e);
this.setState({
user:e.item.props.children
})
}
getUserList=(e)=>{
const url = `/users/list.json`;
axios.get(url,{
params:{
@ -51,7 +90,7 @@ class Collaborator extends Component{
}).then(result=>{
if(result){
this.setState({
userDataSource:result.data
userDataSource:result.data.users
})
}
}).catch(error=>{
@ -59,34 +98,54 @@ class Collaborator extends Component{
})
}
// 修改权限
changeOperaiton=(e,id)=>{
console.log(e,id);
const { project_id } = this.props;
this.setState({
isSpin:true
})
const url = `/projects/${project_id}/members/change_role.json`;
axios.put(url,{
user_id:id,
role:e.key
}).then(result=>{
if(result){
this.props.showNotification('权限修改成功!');
this.getMember(project_id);
this.setState({
isSpin:false
})
}
}).catch(error=>{
console.log(error);
})
}
// 增加协作者
addCollaborator=()=>{
const { projectsId } = this.props.match.params;
const { user } = this.state;
const { project_id } = this.props;
const { user_id } = this.state;
const url = `/projects/${projectsId}/members.json`;
axios.post(url,{
user_id:user
user_id
}).then(result=>{
if(result){
this.changeInputUser();
this.getMember(project_id);
}
}).catch(error=>{
console.log(error);
})
}
render(){
const { user , userDataSource } = this.state;
const { user , userDataSource , listData , isSpin } = this.state;
const menu =(id)=> (
<Menu>
{
MENU_LIST.map((item,key)=>{
return(
<Menu.Item key="key" onClick={(e)=>this.changeOperaiton(e,id)}>{item}</Menu.Item>
<Menu.Item key={item.id} value={item.id} onClick={(e)=>this.changeOperaiton(e,id)}>{item.name}</Menu.Item>
)
})
}
@ -95,7 +154,7 @@ class Collaborator extends Component{
const source = userDataSource && userDataSource.map((item,key)=>{
return(
<Option value={item.login}>{item.username}</Option>
<Option key={key} value={`${item.username}`} onClick={this.serachUser}>{item.username}</Option>
)
})
return(
@ -104,19 +163,30 @@ class Collaborator extends Component{
<div className="normalBox-title font-16">
协作者
</div>
<div className="collaboratorList">
<div className="collaboratorItem">
<span><Link to={``} className="color-blue">caicai</Link></span>
<span>
<Dropdown overlay={menu(1)} placement={"bottomCenter"}>
<span>管理员<Icon type="down" /></span>
</Dropdown>
</span>
<span style={{justifyContent:"center"}}>
<a className="red_btn">删除</a>
</span>
<Spin spinning={isSpin}>
<div className="collaboratorList">
{
listData && listData.map((item,key)=>{
const operation = MENU_LIST.filter(i=>i.id === item.role);
return(
<div className="collaboratorItem">
<span><Link to={``} className="color-blue">{item.name}</Link></span>
<span>
<Dropdown overlay={menu(`${item.id}`)} placement={"bottomCenter"}>
<span>{operation && operation[0].name}<Icon type="down" /></span>
</Dropdown>
</span>
<span style={{justifyContent:"center"}}>
<a className="red_btn">删除</a>
</span>
</div>
)
})
}
</div>
</div>
</Spin>
<div className="addPanel">
<AutoComplete
value={user}
@ -124,6 +194,7 @@ class Collaborator extends Component{
style={{ width: 200 }}
onChange={this.changeInputUser}
placeholder="搜索用户"
onSelect={this.changeUser}
/>
<a className="small_submitBtn ml20" onClick={this.addCollaborator}>增加协作者</a>
</div>

@ -73,14 +73,12 @@ class Setting extends Component{
resetSetting=()=>{
this.props.form.validateFields((err,values)=>{
if(!err){
const { projectsId } = this.props.match.params;
const url = `/projects/${projectsId}.json`;
axios.patch(url,{
params:{
const { project_id } = this.props;
const url = `/projects/${project_id}.json`;
axios.put(url,{
name:values.project_name,
description:values.project_description,
...values
}
}).then(result=>{
if(result){
this.props.showNotification(`仓库信息修改成功!`);

Loading…
Cancel
Save