From eaa46dbcee87ce6c9641d417ded17b1a0e8291fa Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Thu, 4 Feb 2021 17:47:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE-=E5=9B=A2=E9=98=9F=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Component/AddGroup.jsx | 7 +- src/forge/Component/AddMember.jsx | 1 - src/forge/Settings/Collaborator.js | 18 +++-- src/forge/Settings/CollaboratorGroup.jsx | 95 ++++++++++++++++++++++- src/forge/Settings/CollaboratorMember.jsx | 9 ++- 5 files changed, 113 insertions(+), 17 deletions(-) diff --git a/src/forge/Component/AddGroup.jsx b/src/forge/Component/AddGroup.jsx index 5bef2565..656175d5 100644 --- a/src/forge/Component/AddGroup.jsx +++ b/src/forge/Component/AddGroup.jsx @@ -6,14 +6,14 @@ const { Option } = AutoComplete; function AddGroup({organizeId,getGroupID}){ const [ id , setID ] = useState(undefined); const [ source , setSource ] = useState(undefined); - const [ searchKey , setSearchKey ] = useState(undefined); + const [ searchKey , setSearchKey ] = useState(""); useEffect(()=>{ getUserList(); },[searchKey]) function getUserList(e){ - const url = `/organizations/${organizeId}/teams.json`; + const url = `/organizations/${organizeId}/teams/search.json`; axios.get(url, { params: { search: searchKey, @@ -44,7 +44,7 @@ function AddGroup({organizeId,getGroupID}){ } function changeInputUser(e){ - setSearchKey(e); + setSearchKey(e || ""); }; // 选择用户 @@ -55,7 +55,6 @@ function AddGroup({organizeId,getGroupID}){ function addCollaborator(){ getGroupID && getGroupID(id); - setSearchKey(undefined); } return( diff --git a/src/forge/Component/AddMember.jsx b/src/forge/Component/AddMember.jsx index 7af75d1d..a4188229 100644 --- a/src/forge/Component/AddMember.jsx +++ b/src/forge/Component/AddMember.jsx @@ -67,7 +67,6 @@ function AddMember({getID,login}){ function addCollaborator(){ getID && getID(id); - setSearchKey(undefined); } return( diff --git a/src/forge/Settings/Collaborator.js b/src/forge/Settings/Collaborator.js index 34e43139..fdffad36 100644 --- a/src/forge/Settings/Collaborator.js +++ b/src/forge/Settings/Collaborator.js @@ -11,6 +11,8 @@ function Collaborator(props){ const [ newGroupId , setNewGroupId] = useState(undefined); const {projectsId ,owner} = props.match.params; + const author = props.projectDetail && props.projectDetail.author; + function getID(id){ setNewId(id); } @@ -21,24 +23,28 @@ function Collaborator(props){ return (
- - setNav("1")}>协作者管理 - setNav("2")}>团队管理 - + { + author && author.type === "Organization" ? + + setNav("1")}>协作者管理 + setNav("2")}>团队管理 + + : + 协作者管理 + } { nav === "1" ? : } -
{ nav === "1" ? : - + }
diff --git a/src/forge/Settings/CollaboratorGroup.jsx b/src/forge/Settings/CollaboratorGroup.jsx index b314b67e..e3850e24 100644 --- a/src/forge/Settings/CollaboratorGroup.jsx +++ b/src/forge/Settings/CollaboratorGroup.jsx @@ -1,18 +1,107 @@ import React, { useEffect, useState } from 'react'; +import { Table , Button , Popconfirm , Pagination } from 'antd'; +import { Link } from 'react-router-dom'; +import axios from 'axios'; +const roles = { + owner:"所有者", + admin:"管理者", + write:"开发者", + read:"报告者" +} +const limit = 15; +function CollaboratorGroup({newGroupId,owner , projectsId}){ + const [ list , setList ] = useState(undefined); + const [ isSpin , setIsSpin ] = useState(false); + const [ page , setPage ] = useState(1); + const [ total , setTotal ] = useState(0); -function CollaboratorGroup(props,{newGroupId}){ + useEffect(()=>{ + getData(); + },[]) + + function getData(){ + const url = `/${owner}/${projectsId}/teams.json`; + axios.get(url,{ + params:{ + page,limit + } + }).then(result=>{ + if(result && result.data){ + setList(result.data.teams); + setTotal(result.data.total_count); + } + }).catch(error=>{}) + } useEffect(()=>{ if(newGroupId){ addGroup(newGroupId); } },[newGroupId]) + // 添加团队 function addGroup(id){ - + const url = `/${owner}/${projectsId}/teams.json`; + axios.post(url,{ + team_id:id + }).then(result=>{ + if(result && result.data){ + getData(); + } + }).catch(error=>{}) } + + // 删除团队 + function deleteGroup(id){ + const url = `/${owner}/${projectsId}/teams/${id}.json`; + axios.delete(url).then(result=>{ + if(result && result.data){ + getData(); + } + }).catch(error=>{}) + } + + const columns = [ + { + title:"团队名", + dataIndex:"name", + render:(value,item)=>{ + return {value} + } + },{ + title:"权限", + dataIndex:"authorize", + width:"20%", + render:(value,item)=>{ + return roles[value] + } + },{ + title:"操作", + dataIndex:"operation", + width:"25%", + render:(value,item)=>{ + return( + item.can_remove && {deleteGroup(item.id)}}> + ) + } + } + ] return( -
团队管理
+
+
+ { + total > limit ? +
+ {setPage(page)}}/> +
+ :"" + } +
) } export default CollaboratorGroup; \ No newline at end of file diff --git a/src/forge/Settings/CollaboratorMember.jsx b/src/forge/Settings/CollaboratorMember.jsx index 097fe5d5..d3161835 100644 --- a/src/forge/Settings/CollaboratorMember.jsx +++ b/src/forge/Settings/CollaboratorMember.jsx @@ -232,6 +232,7 @@ function CollaboratorMember({projectsId,owner,project_id,author,showNotification }, ]; return( + listData && listData.length>0 ?
@@ -249,16 +250,16 @@ function CollaboratorMember({projectsId,owner,project_id,author,showNotification
- {listData && listData.length>0 ? ( + { listData && listData.length>0 ? record.id} >
- ) : ( + : - )} + }
{total > LIMIT ? @@ -273,6 +274,8 @@ function CollaboratorMember({projectsId,owner,project_id,author,showNotification :""}
+ : + ) } export default CollaboratorMember; \ No newline at end of file