dev_forge
caicai8 5 years ago
parent a7dd5275e1
commit 59c71c69b2

@ -44,22 +44,22 @@ class CoderRootDirectory extends Component{
}) })
} }
getUserInfo=()=>{ // getUserInfo=()=>{
const url = `/users/me.json`; // const url = `/users/me.json`;
axios.get(url).then(result=>{ // axios.get(url).then(result=>{
if(result && result.data.login){ // if(result && result.data.login){
this.setState({ // this.setState({
current_user:result.data // current_user:result.data
}) // })
this.getProjectRoot(); // this.getProjectRoot();
} // }
}).catch(error=>{ // }).catch(error=>{
console.log(error) // console.log(error)
}) // })
} // }
componentDidMount=()=>{ componentDidMount=()=>{
this.getUserInfo(); // this.getUserInfo();
let { search } = this.props.history.location; let { search } = this.props.history.location;
let branchName = undefined; let branchName = undefined;
if(search && search.indexOf("branch")>-1){ if(search && search.indexOf("branch")>-1){

@ -277,7 +277,7 @@ class Detail extends Component{
{/* 仓库设置 */} {/* 仓库设置 */}
<Route path="/projects/:projectsId/setting" <Route path="/projects/:projectsId/setting"
render={ render={
(props) => (<Setting {...this.props} {...props} {...this.state}/>) (props) => (<Setting {...this.props} {...props} {...this.state} getDetail={this.getDetail}/>)
} }
></Route> ></Route>
{/* 工单详情 */} {/* 工单详情 */}

@ -5,17 +5,44 @@ import axios from 'axios';
const { Option } = AutoComplete; const { Option } = AutoComplete;
const MENU_LIST = ['管理员','可读权限','可写权限']; const MENU_LIST = ['管理员','可读权限','可写权限'];
const LIMIT = 15;
class Collaborator extends Component{ class Collaborator extends Component{
constructor(props){ constructor(props){
super(props); super(props);
this.state={ this.state={
userDataSource:undefined user:undefined,
userDataSource:undefined,
page:1
} }
} }
componentDidMount=()=>{
this.getMember();
}
// 获取项目协作者
getMember=()=>{
const { page } = this.state;
const { projectsId } = this.props.match.params;
const url = `/projects/${projectsId}/members.json`;
axios.get(url,{
params:{
page,limit:LIMIT
}
}).then(result=>{
if(result){
}
}).catch(error=>{
console.log(error);
})
}
// 选择用户 // 选择用户
changeInputUser=(e)=>{ changeInputUser=(e)=>{
console.log(e); this.setState({
user:e
})
const url = `/users/list.json`; const url = `/users/list.json`;
axios.get(url,{ axios.get(url,{
params:{ params:{
@ -35,8 +62,24 @@ class Collaborator extends Component{
changeOperaiton=(e,id)=>{ changeOperaiton=(e,id)=>{
console.log(e,id); console.log(e,id);
} }
// 增加协作者
addCollaborator=()=>{
const { projectsId } = this.props.match.params;
const { user } = this.state;
const url = `/projects/${projectsId}/members.json`;
axios.post(url,{
user_id:user
}).then(result=>{
if(result){
this.changeInputUser();
}
}).catch(error=>{
console.log(error);
})
}
render(){ render(){
const { userDataSource } = this.state; const { user , userDataSource } = this.state;
const menu =(id)=> ( const menu =(id)=> (
<Menu> <Menu>
@ -56,32 +99,36 @@ class Collaborator extends Component{
) )
}) })
return( return(
<div className="normalBox"> <div>
<div className="normalBox-title font-16"> <div className="normalBox">
协作者 <div className="normalBox-title font-16">
</div> 协作者
<div className="collaboratorList"> </div>
<div className="collaboratorItem"> <div className="collaboratorList">
<span><Link to={``} className="color-blue">caicai</Link></span> <div className="collaboratorItem">
<span> <span><Link to={``} className="color-blue">caicai</Link></span>
<Dropdown overlay={menu(1)} placement={"bottomCenter"}> <span>
<span>管理员<Icon type="down" /></span> <Dropdown overlay={menu(1)} placement={"bottomCenter"}>
</Dropdown> <span>管理员<Icon type="down" /></span>
</span> </Dropdown>
<span style={{justifyContent:"center"}}> </span>
<a className="red_btn">删除</a> <span style={{justifyContent:"center"}}>
</span> <a className="red_btn">删除</a>
</span>
</div>
</div>
<div className="addPanel">
<AutoComplete
value={user}
dataSource={source}
style={{ width: 200 }}
onChange={this.changeInputUser}
placeholder="搜索用户"
/>
<a className="small_submitBtn ml20" onClick={this.addCollaborator}>增加协作者</a>
</div> </div>
</div> </div>
<div className="addPanel">
<AutoComplete
dataSource={source}
style={{ width: 200 }}
onChange={this.changeInputUser}
placeholder="搜索用户"
/>
<a className="small_submitBtn ml20" onClick={this.addCollaborator}>增加协作者</a>
</div>
</div> </div>
) )
} }

@ -8,8 +8,6 @@ class Setting extends Component{
constructor(props){ constructor(props){
super(props); super(props);
this.state={ this.state={
Language:"1",
Category:"1",
CategoryList:undefined, CategoryList:undefined,
LanguageList:undefined, LanguageList:undefined,
} }
@ -78,12 +76,16 @@ class Setting extends Component{
const { projectsId } = this.props.match.params; const { projectsId } = this.props.match.params;
const url = `/projects/${projectsId}.json`; const url = `/projects/${projectsId}.json`;
axios.patch(url,{ axios.patch(url,{
name:values.project_name, params:{
description:values.project_description, name:values.project_name,
...values description:values.project_description,
...values
}
}).then(result=>{ }).then(result=>{
if(result){ if(result){
this.props.showNotification(`仓库信息修改成功!`) this.props.showNotification(`仓库信息修改成功!`);
const { getDetail } = this.props;
getDetail && getDetail();
} }
}).catch(error=>{ }).catch(error=>{
console.log(error); console.log(error);
@ -92,78 +94,106 @@ class Setting extends Component{
}) })
} }
// 删除本仓库
deleteProject=()=>{
this.props.confirm({
content:"删除后无法恢复,是否确认删除本仓库?",
onOk:()=>{
const url = ``;
axios.delete(url).then(result=>{
this.props.showNotification("仓库删除成功!");
this.props.history.push("/projects");
}).catch(error=>{
console.log(error);
})
}
})
}
render(){ render(){
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
const { Category , Language , CategoryList , LanguageList } = this.state; const { CategoryList , LanguageList } = this.state;
return( return(
<div className="normalBox"> <div>
<div className="normalBox-title font-16"> <div className="normalBox">
基本设置 <div className="normalBox-title font-16">
</div> 基本设置
<Form className="baseForm">
<Form.Item
label="项目名称"
>
{getFieldDecorator('project_name', {
rules: [{
required: true, message: '请输入项目名称'
}],
})(
<Input placeholder="请输入项目名称"/>
)}
</Form.Item >
<div className="df" style={{alignItems:"center"}}>
<span className="mr20 mb15 font-16">可见性</span>
<Form.Item
label=""
>
{getFieldDecorator('private', {
rules: [],
})(
<Checkbox >将仓库设为私有</Checkbox>
)}
</Form.Item >
</div> </div>
<Form.Item <Form className="baseForm">
label="仓库描述" <Form.Item
> label="项目名称"
{getFieldDecorator('project_description', { >
rules: [], {getFieldDecorator('project_name', {
})(
<TextArea placeholder="请输入仓库描述" style={{height:"80px"}}/>
)}
</Form.Item >
<Form.Item
label="项目类别"
>
{getFieldDecorator('project_category_id', {
rules: [{ rules: [{
required: true, message: '请选择大类别' required: true, message: '请输入项目名称'
}], }],
})( })(
<Select> <Input placeholder="请输入项目名称"/>
{CategoryList}
</Select>
)} )}
</Form.Item> </Form.Item >
<Form.Item <div className="df" style={{alignItems:"center"}}>
label="项目语言" <span className="mr20 mb15 font-16">可见性</span>
> <Form.Item
{getFieldDecorator('project_language_id', { label=""
rules: [{ >
required: true, message: '请选择项目语言' {getFieldDecorator('private', {
}], rules: [],
})(
<Checkbox >将仓库设为私有</Checkbox>
)}
</Form.Item >
</div>
<Form.Item
label="仓库描述"
>
{getFieldDecorator('project_description', {
rules: [],
})( })(
<Select> <TextArea placeholder="请输入仓库描述" style={{height:"80px"}}/>
{LanguageList}
</Select>
)} )}
</Form.Item> </Form.Item >
<p className="clearfix"> <Form.Item
<a className="submitBtn" onClick={this.resetSetting}>更新仓库设置</a> label="项目类别"
</p> >
</Form> {getFieldDecorator('project_category_id', {
rules: [{
required: true, message: '请选择大类别'
}],
})(
<Select>
{CategoryList}
</Select>
)}
</Form.Item>
<Form.Item
label="项目语言"
>
{getFieldDecorator('project_language_id', {
rules: [{
required: true, message: '请选择项目语言'
}],
})(
<Select>
{LanguageList}
</Select>
)}
</Form.Item>
<p className="clearfix">
<a className="submitBtn" onClick={this.resetSetting}>更新仓库设置</a>
</p>
</Form>
</div>
<div className="dangerousBox">
<div className="dangerousTitle">危险操作区</div>
<div className="flex-a-center padding15-10">
<div>
<p className="font-bd font-16">删除本仓库</p>
<p className="mt10">删除仓库是永久性的, 无法撤消</p>
</div>
<a onClick={this.deleteProject} className="red_deleteBtn">删除本仓库</a>
</div>
</div>
</div> </div>
) )
} }

@ -72,4 +72,33 @@
.branchSelect{ .branchSelect{
width: 200px; width: 200px;
height: 32px; height: 32px;
}
.dangerousBox{
border:1px solid #efc16b;
border-radius: 4px;
margin-top: 20px;
}
.dangerousTitle{
padding:10px;
background: #f9edbe;
line-height: 18px;
}
.red_deleteBtn{
display: block;
height: 38px;
line-height: 38px;
border:1px solid #db2828;
border-radius: 4px;
color: #db2828;
padding:0px 15px;
font-size: 16px;
}
.flex-a-center{
display: flex;
justify-content: space-between;
align-items: center;
}
.padding15-10{
padding:15px 10px;
} }
Loading…
Cancel
Save