From 59c71c69b2d75c5630e5031feceb50eb458864bb Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Mon, 24 Feb 2020 14:01:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=8F=E4=BD=9C=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/forge/Main/CoderRootDirectory.js | 28 +-- public/react/src/forge/Main/Detail.js | 2 +- .../react/src/forge/Settings/Collaborator.js | 101 ++++++++--- public/react/src/forge/Settings/Setting.js | 164 +++++++++++------- public/react/src/forge/Settings/setting.css | 29 ++++ 5 files changed, 215 insertions(+), 109 deletions(-) diff --git a/public/react/src/forge/Main/CoderRootDirectory.js b/public/react/src/forge/Main/CoderRootDirectory.js index 8f59c7aa9..6f4805af6 100644 --- a/public/react/src/forge/Main/CoderRootDirectory.js +++ b/public/react/src/forge/Main/CoderRootDirectory.js @@ -44,22 +44,22 @@ class CoderRootDirectory extends Component{ }) } - getUserInfo=()=>{ - const url = `/users/me.json`; - axios.get(url).then(result=>{ - if(result && result.data.login){ - this.setState({ - current_user:result.data - }) - this.getProjectRoot(); - } - }).catch(error=>{ - console.log(error) - }) - } + // getUserInfo=()=>{ + // const url = `/users/me.json`; + // axios.get(url).then(result=>{ + // if(result && result.data.login){ + // this.setState({ + // current_user:result.data + // }) + // this.getProjectRoot(); + // } + // }).catch(error=>{ + // console.log(error) + // }) + // } componentDidMount=()=>{ - this.getUserInfo(); + // this.getUserInfo(); let { search } = this.props.history.location; let branchName = undefined; if(search && search.indexOf("branch")>-1){ diff --git a/public/react/src/forge/Main/Detail.js b/public/react/src/forge/Main/Detail.js index e325415c3..bdc31c545 100644 --- a/public/react/src/forge/Main/Detail.js +++ b/public/react/src/forge/Main/Detail.js @@ -277,7 +277,7 @@ class Detail extends Component{ {/* 仓库设置 */} () + (props) => () } > {/* 工单详情 */} diff --git a/public/react/src/forge/Settings/Collaborator.js b/public/react/src/forge/Settings/Collaborator.js index da501a913..597a78e8b 100644 --- a/public/react/src/forge/Settings/Collaborator.js +++ b/public/react/src/forge/Settings/Collaborator.js @@ -5,17 +5,44 @@ import axios from 'axios'; const { Option } = AutoComplete; const MENU_LIST = ['管理员','可读权限','可写权限']; +const LIMIT = 15; class Collaborator extends Component{ constructor(props){ super(props); 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)=>{ - console.log(e); + this.setState({ + user:e + }) const url = `/users/list.json`; axios.get(url,{ params:{ @@ -35,8 +62,24 @@ class Collaborator extends Component{ changeOperaiton=(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(){ - const { userDataSource } = this.state; + const { user , userDataSource } = this.state; const menu =(id)=> ( @@ -56,32 +99,36 @@ class Collaborator extends Component{ ) }) return( -
-
- 协作者 -
-
-
- caicai - - - 管理员 - - - - 删除 - +
+
+
+ 协作者 +
+
+
+ caicai + + + 管理员 + + + + 删除 + +
+
+
- +
) } diff --git a/public/react/src/forge/Settings/Setting.js b/public/react/src/forge/Settings/Setting.js index 48750b896..70bf45b0e 100644 --- a/public/react/src/forge/Settings/Setting.js +++ b/public/react/src/forge/Settings/Setting.js @@ -8,8 +8,6 @@ class Setting extends Component{ constructor(props){ super(props); this.state={ - Language:"1", - Category:"1", CategoryList:undefined, LanguageList:undefined, } @@ -78,12 +76,16 @@ class Setting extends Component{ const { projectsId } = this.props.match.params; const url = `/projects/${projectsId}.json`; axios.patch(url,{ - name:values.project_name, - description:values.project_description, - ...values + params:{ + name:values.project_name, + description:values.project_description, + ...values + } }).then(result=>{ if(result){ - this.props.showNotification(`仓库信息修改成功!`) + this.props.showNotification(`仓库信息修改成功!`); + const { getDetail } = this.props; + getDetail && getDetail(); } }).catch(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(){ const { getFieldDecorator } = this.props.form; - const { Category , Language , CategoryList , LanguageList } = this.state; + const { CategoryList , LanguageList } = this.state; return( -
-
- 基本设置 -
-
- - {getFieldDecorator('project_name', { - rules: [{ - required: true, message: '请输入项目名称' - }], - })( - - )} - -
- 可见性 - - {getFieldDecorator('private', { - rules: [], - })( - 将仓库设为私有 - )} - +
+
+
+ 基本设置
- - {getFieldDecorator('project_description', { - rules: [], - })( -