From 0290822ebfa1f5ae4e3e91f0c2e16b15abe38323 Mon Sep 17 00:00:00 2001
From: caishi <1149225589@qq.com>
Date: Mon, 22 Mar 2021 11:24:07 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=BA=93-=E9=BB=98=E8=AE=A4?=
=?UTF-8?q?=E6=98=BE=E7=A4=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/forge/Settings/CollaboratorGroup.jsx | 184 +++++++++++++----------
src/forge/Settings/Setting.js | 6 +-
2 files changed, 111 insertions(+), 79 deletions(-)
diff --git a/src/forge/Settings/CollaboratorGroup.jsx b/src/forge/Settings/CollaboratorGroup.jsx
index e3850e24..c6ab6ffb 100644
--- a/src/forge/Settings/CollaboratorGroup.jsx
+++ b/src/forge/Settings/CollaboratorGroup.jsx
@@ -1,107 +1,139 @@
-import React, { useEffect, useState } from 'react';
-import { Table , Button , Popconfirm , Pagination } from 'antd';
-import { Link } from 'react-router-dom';
-import axios from 'axios';
+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:"报告者"
-}
+ 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({ newGroupId, owner, projectsId }) {
+ const [list, setList] = useState(undefined);
+ const [isSpin, setIsSpin] = useState(true);
+ const [page, setPage] = useState(1);
+ const [total, setTotal] = useState(0);
- useEffect(()=>{
+ useEffect(() => {
getData();
- },[])
+ }, []);
- function 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=>{})
+ axios
+ .get(url, {
+ params: {
+ page,
+ limit,
+ },
+ })
+ .then((result) => {
+ if (result && result.data) {
+ setList(result.data.teams);
+ setTotal(result.data.total_count);
+ setIsSpin(false);
+ }
+ })
+ .catch((error) => {});
}
- useEffect(()=>{
- if(newGroupId){
+ useEffect(() => {
+ if (newGroupId) {
addGroup(newGroupId);
}
- },[newGroupId])
+ }, [newGroupId]);
// 添加团队
- function addGroup(id){
+ function addGroup(id) {
const url = `/${owner}/${projectsId}/teams.json`;
- axios.post(url,{
- team_id:id
- }).then(result=>{
- if(result && result.data){
- getData();
- }
- }).catch(error=>{})
+ axios
+ .post(url, {
+ team_id: id,
+ })
+ .then((result) => {
+ if (result && result.data) {
+ getData();
+ }
+ })
+ .catch((error) => {});
}
// 删除团队
- function deleteGroup(id){
+ function deleteGroup(id) {
const url = `/${owner}/${projectsId}/teams/${id}.json`;
- axios.delete(url).then(result=>{
- if(result && result.data){
- getData();
- }
- }).catch(error=>{})
+ 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 &&