dev_forge
Jasder 5 years ago
commit 9f1277f7c1

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

@ -86,6 +86,7 @@ class Detail extends Component{
praises_count:undefined ,
forked_count:undefined,
http_url: undefined,
author:undefined,
branchs:undefined,
branchList:undefined,
@ -132,6 +133,7 @@ class Detail extends Component{
isReporter:result.data.permission && result.data.permission === "Reporter",
isDeveloper:result.data.permission && result.data.permission === "Developer",
http_url: result.data.clone_url,
author:result.data.author,
watchers_count:result.data.watchers_count,
praises_count:result.data.praises_count,
@ -278,7 +280,7 @@ class Detail extends Component{
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>
</ul>
</div>
</div>

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

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

@ -31,16 +31,16 @@ class Index extends Component{
<ul className="settingNav">
<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/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>
<div className="main">
<Switch {...this.props}>
{/* 分支列表 */}
<Route path="/projects/:projectsId/setting/branch"
{/* <Route path="/projects/:projectsId/setting/branch"
render={
(props) => (<Branch {...this.props} {...props} {...this.state}/>)
}
></Route>
></Route> */}
{/* 协作者 */}
<Route path="/projects/:projectsId/setting/collaborator"
render={

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

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

Loading…
Cancel
Save