dev_forge
Jasder 5 years ago
commit 9f1277f7c1

@ -329,7 +329,7 @@ class ApplicationController < ActionController::Base
def current_user def current_user
# User.current # User.current
if Rails.env.development? if Rails.env.development?
user_id = 36390 user_id = 50207
else else
user_id = 130328 user_id = 130328
end end

@ -86,6 +86,7 @@ class Detail extends Component{
praises_count:undefined , praises_count:undefined ,
forked_count:undefined, forked_count:undefined,
http_url: undefined, http_url: undefined,
author:undefined,
branchs:undefined, branchs:undefined,
branchList:undefined, branchList:undefined,
@ -132,6 +133,7 @@ class Detail extends Component{
isReporter:result.data.permission && result.data.permission === "Reporter", isReporter:result.data.permission && result.data.permission === "Reporter",
isDeveloper:result.data.permission && result.data.permission === "Developer", isDeveloper:result.data.permission && result.data.permission === "Developer",
http_url: result.data.clone_url, http_url: result.data.clone_url,
author:result.data.author,
watchers_count:result.data.watchers_count, watchers_count:result.data.watchers_count,
praises_count:result.data.praises_count, praises_count:result.data.praises_count,
@ -278,7 +280,7 @@ class Detail extends Component{
isManager && isManager &&
<li className={url.indexOf("setting")>0 ? "active" : ""}><Link to={`/projects/${projectsId}/setting`}>仓库设置</Link></li> <li className={url.indexOf("setting")>0 ? "active" : ""}><Link to={`/projects/${projectsId}/setting`}>仓库设置</Link></li>
} }
{/* <li className={url.indexOf("setting")>0 ? "active" : ""}><Link to={`/projects/${projectsId}/setting`}>仓库设置</Link></li> */} <li className={url.indexOf("setting")>0 ? "active" : ""}><Link to={`/projects/${projectsId}/setting`}>仓库设置</Link></li>
</ul> </ul>
</div> </div>
</div> </div>

@ -16,6 +16,14 @@ class Branch extends Component{
} }
render(){ render(){
const { branchList } = this.props;
const branchListRender = (
branchList && branchList.map((item,key)=>{
return(
<Option value={item.name}>{item.name}</Option>
)
})
)
return( return(
<div className="normalBox"> <div className="normalBox">
<div className="normalBox-title font-16"> <div className="normalBox-title font-16">
@ -24,7 +32,7 @@ class Branch extends Component{
<p className="pl15 pt15">请选择一个默认的分支用于合并请求和提交</p> <p className="pl15 pt15">请选择一个默认的分支用于合并请求和提交</p>
<div className="addPanel"> <div className="addPanel">
<Select className="branchSelect"> <Select className="branchSelect">
<Option value="0">master</Option> {branchListRender}
</Select> </Select>
<a className="small_submitBtn ml20" onClick={this.resetSetting}>更新仓库设置</a> <a className="small_submitBtn ml20" onClick={this.resetSetting}>更新仓库设置</a>
</div> </div>

@ -43,7 +43,6 @@ class Collaborator extends Component{
// 获取项目协作者 // 获取项目协作者
getMember=(project_id)=>{ getMember=(project_id)=>{
const { page } = this.state; const { page } = this.state;
const url = `/projects/${project_id}/members.json`; const url = `/projects/${project_id}/members.json`;
axios.get(url,{ axios.get(url,{
params:{ params:{
@ -60,26 +59,16 @@ class Collaborator extends Component{
console.log(error); console.log(error);
}) })
} }
// 选择用户 // 输入用户
changeInputUser=(e)=>{ changeInputUser=(e)=>{
console.log(e);
this.setState({
user:e
})
this.getUserList(e); this.getUserList(e);
} }
changeUser=(e)=>{ // 选择用户
console.log("click",e); selectInputUser=(e,option)=>{
this.setState({
user_id:e,
})
}
serachUser=(e)=>{
console.log("select",e);
this.setState({ this.setState({
user:e.item.props.children user_id:e
}) })
this.getUserList(option.props.children);
} }
getUserList=(e)=>{ getUserList=(e)=>{
const url = `/users/list.json`; const url = `/users/list.json`;
@ -98,6 +87,25 @@ class Collaborator extends Component{
}) })
} }
// 增加协作者
addCollaborator=()=>{
const { project_id } = this.props;
const { user_id } = this.state;
const url = `/projects/${project_id}/members.json`;
axios.post(url,{
user_id
}).then(result=>{
if(result){
this.setState({
isSpin:true
})
this.getMember(project_id);
}
}).catch(error=>{
console.log(error);
})
}
// 修改权限 // 修改权限
changeOperaiton=(e,id)=>{ changeOperaiton=(e,id)=>{
const { project_id } = this.props; const { project_id } = this.props;
@ -110,36 +118,44 @@ class Collaborator extends Component{
role:e.key role:e.key
}).then(result=>{ }).then(result=>{
if(result){ if(result){
this.props.showNotification('权限修改成功!');
this.getMember(project_id);
this.setState({ this.setState({
isSpin:false isSpin:true
}) })
this.props.showNotification('权限修改成功!');
this.getMember(project_id);
} }
}).catch(error=>{ }).catch(error=>{
console.log(error); console.log(error);
}) })
} }
// 增加协作者 // 删除协作者
addCollaborator=()=>{ deleteUser=(id)=>{
const { projectsId } = this.props.match.params; this.props.confirm({
content:"确认将此成员从项目中移除?",
onOk:()=>{
const { project_id } = this.props; const { project_id } = this.props;
const { user_id } = this.state; const url = `/projects/${project_id}/members/remove.json`;
const url = `/projects/${projectsId}/members.json`; axios.delete(url,{
axios.post(url,{ user_id:id
user_id
}).then(result=>{ }).then(result=>{
if(result){ if(result){
this.setState({
isSpin:true
})
this.props.showNotification("成员删除成功!");
this.getMember(project_id); this.getMember(project_id);
} }
}).catch(error=>{ }).catch(error=>{
console.log(error); console.log(error);
}) })
} }
})
}
render(){ render(){
const { user , userDataSource , listData , isSpin } = this.state; const { userDataSource , listData , isSpin } = this.state;
// 获取当前项目的拥有者
const { author } = this.props;
const menu =(id)=> ( const menu =(id)=> (
<Menu> <Menu>
{ {
@ -154,7 +170,7 @@ class Collaborator extends Component{
const source = userDataSource && userDataSource.map((item,key)=>{ const source = userDataSource && userDataSource.map((item,key)=>{
return( return(
<Option key={key} value={`${item.user_id}`} onClick={this.serachUser}>{item.username}</Option> <Option key={key} value={`${item.user_id}`}>{item.username}</Option>
) )
}) })
return( return(
@ -172,12 +188,21 @@ class Collaborator extends Component{
<div className="collaboratorItem"> <div className="collaboratorItem">
<span><Link to={``} className="color-blue">{item.name}</Link></span> <span><Link to={``} className="color-blue">{item.name}</Link></span>
<span> <span>
{
author && author.login === item.login ?
<label>{operation && operation[0].name}</label>
:
<Dropdown overlay={menu(`${item.id}`)} placement={"bottomCenter"}> <Dropdown overlay={menu(`${item.id}`)} placement={"bottomCenter"}>
<span>{operation && operation[0].name}<Icon type="down" /></span> <span>{operation && operation[0].name}<Icon type="down" /></span>
</Dropdown> </Dropdown>
}
</span> </span>
<span style={{justifyContent:"center"}}> <span style={{justifyContent:"center"}}>
<a className="red_btn">删除</a> {
author && author.login !== item.login &&
<a className="red_btn" onClick={()=>this.deleteUser(item.id)}>删除</a>
}
</span> </span>
</div> </div>
) )
@ -189,12 +214,11 @@ class Collaborator extends Component{
</Spin> </Spin>
<div className="addPanel"> <div className="addPanel">
<AutoComplete <AutoComplete
value={user}
dataSource={source} dataSource={source}
style={{ width: 200 }} style={{ width: 200 }}
onChange={this.changeInputUser} onChange={this.changeInputUser}
onSelect={this.selectInputUser}
placeholder="搜索用户" placeholder="搜索用户"
onSelect={this.changeUser}
/> />
<a className="small_submitBtn ml20" onClick={this.addCollaborator}>增加协作者</a> <a className="small_submitBtn ml20" onClick={this.addCollaborator}>增加协作者</a>
</div> </div>

@ -31,16 +31,16 @@ class Index extends Component{
<ul className="settingNav"> <ul className="settingNav">
<li className={flag?"active":""}><Link to={`/projects/${projectsId}/setting`}>仓库</Link></li> <li className={flag?"active":""}><Link to={`/projects/${projectsId}/setting`}>仓库</Link></li>
<li className={pathname.indexOf('setting/collaborator')>-1?"active":""}><Link to={`/projects/${projectsId}/setting/collaborator`}>协作者</Link></li> <li className={pathname.indexOf('setting/collaborator')>-1?"active":""}><Link to={`/projects/${projectsId}/setting/collaborator`}>协作者</Link></li>
<li className={pathname.indexOf('setting/branch')>-1?"active":""}><Link to={`/projects/${projectsId}/setting/branch`}>分支列表</Link></li> {/* <li className={pathname.indexOf('setting/branch')>-1?"active":""}><Link to={`/projects/${projectsId}/setting/branch`}>分支列表</Link></li> */}
</ul> </ul>
<div className="main"> <div className="main">
<Switch {...this.props}> <Switch {...this.props}>
{/* 分支列表 */} {/* 分支列表 */}
<Route path="/projects/:projectsId/setting/branch" {/* <Route path="/projects/:projectsId/setting/branch"
render={ render={
(props) => (<Branch {...this.props} {...props} {...this.state}/>) (props) => (<Branch {...this.props} {...props} {...this.state}/>)
} }
></Route> ></Route> */}
{/* 协作者 */} {/* 协作者 */}
<Route path="/projects/:projectsId/setting/collaborator" <Route path="/projects/:projectsId/setting/collaborator"
render={ render={

@ -10,6 +10,7 @@ class Setting extends Component{
this.state={ this.state={
CategoryList:undefined, CategoryList:undefined,
LanguageList:undefined, LanguageList:undefined,
private_check:undefined
} }
} }
@ -39,6 +40,9 @@ class Setting extends Component{
this.props.form.setFieldsValue({ this.props.form.setFieldsValue({
...result.data ...result.data
}) })
this.setState({
private_check:result.data.private
})
} }
}).catch(error=>{ }).catch(error=>{
console.log(error); console.log(error);
@ -74,10 +78,12 @@ class Setting extends Component{
this.props.form.validateFields((err,values)=>{ this.props.form.validateFields((err,values)=>{
if(!err){ if(!err){
const { project_id } = this.props; const { project_id } = this.props;
const { private_check } = this.state;
const url = `/projects/${project_id}.json`; const url = `/projects/${project_id}.json`;
axios.put(url,{ axios.put(url,{
name:values.project_name, name:values.project_name,
description:values.project_description, description:values.project_description,
private:private_check,
...values ...values
}).then(result=>{ }).then(result=>{
if(result){ if(result){
@ -97,7 +103,8 @@ class Setting extends Component{
this.props.confirm({ this.props.confirm({
content:"删除后无法恢复,是否确认删除本仓库?", content:"删除后无法恢复,是否确认删除本仓库?",
onOk:()=>{ onOk:()=>{
const url = ``; const { project_id } = this.props;
const url = `/projects/${project_id}.json`;
axios.delete(url).then(result=>{ axios.delete(url).then(result=>{
this.props.showNotification("仓库删除成功!"); this.props.showNotification("仓库删除成功!");
this.props.history.push("/projects"); this.props.history.push("/projects");
@ -107,11 +114,17 @@ class Setting extends Component{
} }
}) })
} }
changePrivate=(e)=>{
console.log(e);
this.setState({
private_check:e.target.checked
})
}
render(){ render(){
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
const { CategoryList , LanguageList } = this.state; const { CategoryList , LanguageList , private_check } = this.state;
return( return(
<div> <div>
<div className="normalBox"> <div className="normalBox">
@ -138,7 +151,7 @@ class Setting extends Component{
{getFieldDecorator('private', { {getFieldDecorator('private', {
rules: [], rules: [],
})( })(
<Checkbox >将仓库设为私有</Checkbox> <Checkbox checked={private_check} onChange={this.changePrivate}>将仓库设为私有</Checkbox>
)} )}
</Form.Item > </Form.Item >
</div> </div>

@ -90,7 +90,7 @@
line-height: 38px; line-height: 38px;
border:1px solid #db2828; border:1px solid #db2828;
border-radius: 4px; border-radius: 4px;
color: #db2828; color: #db2828!important;
padding:0px 15px; padding:0px 15px;
font-size: 16px; font-size: 16px;
} }

Loading…
Cancel
Save