From 373700edf2cc3203360a15366d80c28ca2a8588f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Thu, 8 Sep 2022 17:23:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=A2=E9=98=9F=E9=A1=B9=E7=9B=AE=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=93=8D=E4=BD=9C+webhook=E6=80=BB=E6=95=B0=E9=99=90?= =?UTF-8?q?=E5=88=B6=E8=B0=83=E6=95=B4+=E8=B7=A8=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=90=8C=E6=AD=A5=E6=96=B0=E5=BB=BA=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=88=86=E6=94=AF=E6=A0=B7=E5=BC=8F=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AppConfig.js | 2 +- src/forge/Component/layout.jsx | 2 +- .../reposyncer/component/createJobModal.jsx | 1 + src/forge/Settings/Webhooks/Index.jsx | 8 +- .../Group/Setting/GroupProjectSetting.jsx | 153 ++++++++++-------- src/forge/Team/Sub/SubDetail.jsx | 2 +- 6 files changed, 98 insertions(+), 70 deletions(-) diff --git a/src/AppConfig.js b/src/AppConfig.js index a55649ce0..f771b9eab 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -25,7 +25,7 @@ if (isDev) { } debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' : window.location.search.indexOf('debug=s') !== -1 ? 'student' : - window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'student' + window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin' } window._debugType = debugType; export function initAxiosInterceptors(props) { diff --git a/src/forge/Component/layout.jsx b/src/forge/Component/layout.jsx index ca188866c..6413a4408 100644 --- a/src/forge/Component/layout.jsx +++ b/src/forge/Component/layout.jsx @@ -130,7 +130,7 @@ export const Redback = styled.a`{ line-height:30px; border-radius:2px; background-color:#F73030; - color:#fff; + color:#fff!important; padding:0px 12px; display:inline-block; min-width:80px; diff --git a/src/forge/Server/reposyncer/component/createJobModal.jsx b/src/forge/Server/reposyncer/component/createJobModal.jsx index 1c0eb1e27..b8418a877 100644 --- a/src/forge/Server/reposyncer/component/createJobModal.jsx +++ b/src/forge/Server/reposyncer/component/createJobModal.jsx @@ -59,6 +59,7 @@ function DeleteBox({owner, projectsId, visible, setVisible, createJobBy, branchO dropdownMatchSelectWidth={false} dropdownClassName="overlihide" placeholder="请选择仓库分支" + getPopupContainer={trigger => trigger.parentNode} > {branchOptions && branchOptions.map((item, key) => { return ( diff --git a/src/forge/Settings/Webhooks/Index.jsx b/src/forge/Settings/Webhooks/Index.jsx index 1ce5dd617..645185813 100644 --- a/src/forge/Settings/Webhooks/Index.jsx +++ b/src/forge/Settings/Webhooks/Index.jsx @@ -16,6 +16,7 @@ function Index(props) { const [ editId , setEditId ] = useState(undefined); const [ deleteWebHookModTitle, setDeleteWebHookModTitle] = useState(undefined); const [ deleteWebHookModSubTitle, setDeleteWebHookModSubTitle] = useState(undefined); + const [ totalByUserCreate, setTotalByUserCreate] = useState(undefined); const { owner , projectsId } = props.match.params; @@ -33,9 +34,12 @@ function Index(props) { if(result && result.data){ const reg1 = new RegExp("https://(.*?)jianmuhub.com(.*?)"); const reg2 = new RegExp("https://jianmu.gitlink.org.cn(.*?)"); + let totalByUserCreate = 0; result.data.webhooks.map(item=>{ item.isJianMu = reg1.test(item.url) || reg2.test(item.url); + !(reg1.test(item.url) || reg2.test(item.url)) && totalByUserCreate++; }) + setTotalByUserCreate(totalByUserCreate); setData(result.data.webhooks); setTotal(result.data.total_count); } @@ -67,8 +71,8 @@ function Index(props) { } function addFunc() { - if(total >= 20){ - return props.showNotification("webhooks数量已到上限!请删除暂不使用的webhooks以进行添加操作"); + if(totalByUserCreate >= 20){ + return props.showNotification("您创建的Webhook数量已达到上线!请删除部分Webhook以进行添加操作"); } props.history.push(`/${owner}/${projectsId}/settings/webhooks/new`) } diff --git a/src/forge/Team/Group/Setting/GroupProjectSetting.jsx b/src/forge/Team/Group/Setting/GroupProjectSetting.jsx index 9a4f39582..1da2af0fe 100644 --- a/src/forge/Team/Group/Setting/GroupProjectSetting.jsx +++ b/src/forge/Team/Group/Setting/GroupProjectSetting.jsx @@ -1,7 +1,7 @@ import React, { useState, useEffect } from 'react'; import axios from 'axios'; -import { AutoComplete, Pagination, List, Popconfirm, Dropdown, Spin } from 'antd'; -import { WhiteBack, Blueline, FlexAJ, GroupProjectBackgroup, Greenline, Redline } from '../../../Component/layout'; +import { AutoComplete, Pagination, Popconfirm, Spin, Table, message, Tooltip } from 'antd'; +import { WhiteBack, Blueline, FlexAJ, Redback, Blueback } from '../../../Component/layout'; import Title from '../../../Component/Title'; const { Option } = AutoComplete; const limit = 15; @@ -17,6 +17,7 @@ function GroupProjectSetting(props) { const [ optionsSource , setOptionsSource ] = useState(undefined); const { OIdentifier, groupId } = props.match.params; + const { includesAllProject} = props; useEffect(() => { get_project() @@ -55,12 +56,29 @@ function GroupProjectSetting(props) { setIsSpin(false) } + // 移除所有项目 function removeALLProject() { -// 移除所有项目 + setIsSpin(true); + axios.delete(`/organizations/${OIdentifier}/teams/${groupId}/team_projects/destroy_all.json`).then((result) => { + if (result && !result.data.status) { + message.success('移除成功'); + get_project(); + } + setIsSpin(false); + }).catch((error) => {setIsSpin(false)}); } + // 添加所有项目 function addALLProject() { -// 添加所有项目 + setIsSpin(true); + axios.post(`/organizations/${OIdentifier}/teams/${groupId}/team_projects/create_all.json`).then((result) => { + console.log('result', result); + if (result && !result.data.status) { + message.success('添加成功'); + get_project(); + } + setIsSpin(false); + }).catch((error) => {setIsSpin(false)}); } // 添加单个项目 @@ -117,74 +135,79 @@ function GroupProjectSetting(props) { setSearch(value); } + const columns = [ + { + title: '项目名称', + dataIndex: 'project', + width: "85%", + render: (value, item) => { + return ( + {value.owner_name}/{value.name} + ) + } + }, + { + title: '操作', + dataIndex: 'operation', + render: (value, item) => { + return includesAllProject ? 移除 : removeProject(item.project.identifier)} + okText="确认" + cancelText="取消" + > + 移除 + + } + } + ] + return ( - <FlexAJ style={{width:"100%"}}> - <span>团队项目管理</span> - <div> - <AutoComplete - style={{ width: 300 }} - placeholder="搜索项目..." - onChange={changeInput} - onSelect={selectInput} - allowClear - > - {optionsSource} - </AutoComplete> - <Blueline className="ml30" onClick={()=>addSingleProject()}>+ 添加项目</Blueline> - </div> - </FlexAJ> + <span>团队项目管理</span> - {/* - - -
- addALLProject()} - okText="确认" - cancelText="取消" - > - 添加所有 - - - removeALLProject()} - okText="确认" - cancelText="取消" - > - 移除所有 - -
-
-
-
*/} + +
+ + {optionsSource} + + addSingleProject()}>+ 添加项目 +
+ {!includesAllProject &&
+ addALLProject()} + okText="确认" + cancelText="取消" + > + 添加所有 + + removeALLProject()} + okText="确认" + cancelText="取消" + > + 移除所有 + +
} +
- ( - removeProject(item.project.identifier)} - okText="确认" - cancelText="取消" - > - 移除 - - } - > - {item.project.owner_name}/{item.project.name}} - /> - - )} - /> + pagination={false} + className="teamMemberTable" + >
{ total > limit ? diff --git a/src/forge/Team/Sub/SubDetail.jsx b/src/forge/Team/Sub/SubDetail.jsx index 278fef07e..6bf79b962 100644 --- a/src/forge/Team/Sub/SubDetail.jsx +++ b/src/forge/Team/Sub/SubDetail.jsx @@ -71,7 +71,7 @@ export default ((props)=>{ { - return + return }} >