From bffbed9742d93473e0416bc5d22f5f32af44999d Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Tue, 25 Feb 2020 12:15:26 +0800 Subject: [PATCH 1/4] =?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 --- public/react/src/forge/Main/Detail.js | 2 +- .../react/src/forge/Settings/Collaborator.js | 58 ++++++++----------- public/react/src/forge/Settings/Setting.js | 3 +- public/react/src/forge/Settings/setting.css | 2 +- 4 files changed, 27 insertions(+), 38 deletions(-) diff --git a/public/react/src/forge/Main/Detail.js b/public/react/src/forge/Main/Detail.js index e504f7693..e39059df8 100644 --- a/public/react/src/forge/Main/Detail.js +++ b/public/react/src/forge/Main/Detail.js @@ -278,7 +278,7 @@ class Detail extends Component{ isManager &&
  • 0 ? "active" : ""}>仓库设置
  • } - {/*
  • 0 ? "active" : ""}>仓库设置
  • */} +
  • 0 ? "active" : ""}>仓库设置
  • diff --git a/public/react/src/forge/Settings/Collaborator.js b/public/react/src/forge/Settings/Collaborator.js index 2eaa5e1d1..75e692579 100644 --- a/public/react/src/forge/Settings/Collaborator.js +++ b/public/react/src/forge/Settings/Collaborator.js @@ -60,26 +60,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 +88,22 @@ 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.getMember(project_id); + } + }).catch(error=>{ + console.log(error); + }) + } + // 修改权限 changeOperaiton=(e,id)=>{ const { project_id } = this.props; @@ -120,23 +126,6 @@ class Collaborator extends Component{ 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); - } - }).catch(error=>{ - console.log(error); - }) - } render(){ const { user , userDataSource , listData , isSpin } = this.state; @@ -154,7 +143,7 @@ class Collaborator extends Component{ const source = userDataSource && userDataSource.map((item,key)=>{ return( - + ) }) return( @@ -189,12 +178,11 @@ class Collaborator extends Component{
    增加协作者
    diff --git a/public/react/src/forge/Settings/Setting.js b/public/react/src/forge/Settings/Setting.js index cc6106836..4f83f1c30 100644 --- a/public/react/src/forge/Settings/Setting.js +++ b/public/react/src/forge/Settings/Setting.js @@ -97,7 +97,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"); diff --git a/public/react/src/forge/Settings/setting.css b/public/react/src/forge/Settings/setting.css index a6d68bab3..95b03efec 100644 --- a/public/react/src/forge/Settings/setting.css +++ b/public/react/src/forge/Settings/setting.css @@ -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; } From 55294df6dd3f8f781ca45e85598a34105bb5cb6c Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Tue, 25 Feb 2020 13:32:29 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=88=90=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/forge/Settings/Collaborator.js | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/public/react/src/forge/Settings/Collaborator.js b/public/react/src/forge/Settings/Collaborator.js index 75e692579..c33ca672b 100644 --- a/public/react/src/forge/Settings/Collaborator.js +++ b/public/react/src/forge/Settings/Collaborator.js @@ -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:{ @@ -97,6 +96,9 @@ class Collaborator extends Component{ user_id }).then(result=>{ if(result){ + this.setState({ + isSpin:true + }) this.getMember(project_id); } }).catch(error=>{ @@ -116,16 +118,40 @@ 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); }) } + + // 删除协作者 + 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); + }) + } + }) + } render(){ const { user , userDataSource , listData , isSpin } = this.state; @@ -166,7 +192,7 @@ class Collaborator extends Component{ - 删除 + this.deleteUser(item.id)}>删除 ) From b8f717561eba3f67ce4bf4a1bf1c0a869ff1aa37 Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Tue, 25 Feb 2020 14:40:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BB=93=E5=BA=93=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 +- public/react/src/forge/Main/Detail.js | 2 ++ public/react/src/forge/Settings/Branch.js | 10 +++++++- .../react/src/forge/Settings/Collaborator.js | 24 +++++++++++++------ public/react/src/forge/Settings/Index.js | 6 ++--- public/react/src/forge/Settings/Setting.js | 16 +++++++++++-- 6 files changed, 46 insertions(+), 14 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fe77a99f7..cb39a24f7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/public/react/src/forge/Main/Detail.js b/public/react/src/forge/Main/Detail.js index e39059df8..a8a1d61e4 100644 --- a/public/react/src/forge/Main/Detail.js +++ b/public/react/src/forge/Main/Detail.js @@ -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, diff --git a/public/react/src/forge/Settings/Branch.js b/public/react/src/forge/Settings/Branch.js index 4a88f4c46..74b89c27a 100644 --- a/public/react/src/forge/Settings/Branch.js +++ b/public/react/src/forge/Settings/Branch.js @@ -16,6 +16,14 @@ class Branch extends Component{ } render(){ + const { branchList } = this.props; + const branchListRender = ( + branchList && branchList.map((item,key)=>{ + return( + + ) + }) + ) return(
    @@ -24,7 +32,7 @@ class Branch extends Component{

    请选择一个默认的分支用于合并请求和提交:

    更新仓库设置
    diff --git a/public/react/src/forge/Settings/Collaborator.js b/public/react/src/forge/Settings/Collaborator.js index c33ca672b..c8602ea97 100644 --- a/public/react/src/forge/Settings/Collaborator.js +++ b/public/react/src/forge/Settings/Collaborator.js @@ -132,7 +132,7 @@ class Collaborator extends Component{ // 删除协作者 deleteUser=(id)=>{ this.props.confirm({ - content:"确认删除此成员?", + content:"确认将此成员从项目中移除?", onOk:()=>{ const { project_id } = this.props; const url = `/projects/${project_id}/members/remove.json`; @@ -153,8 +153,9 @@ class Collaborator extends Component{ }) } render(){ - const { user , userDataSource , listData , isSpin } = this.state; - + const { userDataSource , listData , isSpin } = this.state; + // 获取当前项目的拥有者 + const { author } = this.props; const menu =(id)=> ( { @@ -187,12 +188,21 @@ class Collaborator extends Component{
    {item.name} - - {operation && operation[0].name} - + { + author && author.login === item.login ? + + : + + {operation && operation[0].name} + + } + - this.deleteUser(item.id)}>删除 + { + author && author.login !== item.login && + this.deleteUser(item.id)}>删除 + }
    ) diff --git a/public/react/src/forge/Settings/Index.js b/public/react/src/forge/Settings/Index.js index 2e3a82e66..84674accd 100644 --- a/public/react/src/forge/Settings/Index.js +++ b/public/react/src/forge/Settings/Index.js @@ -31,16 +31,16 @@ class Index extends Component{
    • 仓库
    • -1?"active":""}>协作者
    • -
    • -1?"active":""}>分支列表
    • + {/*
    • -1?"active":""}>分支列表
    • */}
    {/* 分支列表 */} - () } - > + > */} {/* 协作者 */} { 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){ @@ -108,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(
    @@ -139,7 +151,7 @@ class Setting extends Component{ {getFieldDecorator('private', { rules: [], })( - 将仓库设为私有 + 将仓库设为私有 )}