权限问题测试版-第二版

This commit is contained in:
caishi 2021-08-26 17:29:28 +08:00
parent 269964cc70
commit 24e7e3c70f
9 changed files with 54 additions and 38 deletions

View File

@ -55,6 +55,7 @@ function AddGroup({organizeId,getGroupID}){
function addCollaborator(){
getGroupID && getGroupID(id);
setID(undefined);
}
return(

View File

@ -147,6 +147,7 @@ function CoderDepot(props){
setReadme(result.data.readme);
setEditReadme(false);
setHide(true);
console.log("dddd:",result.data.entries);
}
setTimeout(function(){setIsSpin(false);},500);
}).catch(error=>{setIsSpin(false);})
@ -388,7 +389,7 @@ function CoderDepot(props){
</AlignCenter>
</FlexAJ>
{
dirInfo || fileInfo ?
(dirInfo && dirInfo.length>0) || (fileInfo && fileInfo.length>0) ?
<div className="listtable">
{
lastCommit &&
@ -430,7 +431,7 @@ function CoderDepot(props){
})
}
{
fileInfo &&
fileInfo && fileInfo.length > 0 &&
<CoderRootFileDetail
{...props}
detail={fileInfo}
@ -446,7 +447,7 @@ function CoderDepot(props){
: ""
}
{
(dirInfo && dirInfo.length === 0) && (fileInfo && fileInfo.length === 0) ? <Nodata _html="暂未发现文件"/> :""
(dirInfo && dirInfo.length === 0) && !fileInfo ? <Nodata _html="暂未发现文件"/> :""
}
{/* readme文件显示(显示文件详情时不显示readme文件) */}
{ dirInfo && (readme && readme.content) ? <ReadMe ChangeFile={ChangeFile} readme={readme} operate={props && (props.isManager || props.isDeveloper) && projectDetail.type !==2 } history={props.history} /> :"" }
@ -516,11 +517,11 @@ function CoderDepot(props){
}
{/* 贡献者 */}
{
projectDetail && projectDetail.contributors &&
projectDetail && projectDetail.contributors && projectDetail.contributors.length >0 &&
<Contributors contributors={projectDetail && projectDetail.contributors} owner={owner} projectsId={projectsId} />
}
{/* 语言 */}
{ projectDetail && projectDetail.languages &&
{ projectDetail && projectDetail.languages && projectDetail.languages.length >0 &&
<React.Fragment>
<Divider />
<LanguagePower languages={projectDetail.languages}/>

View File

@ -255,7 +255,7 @@ class merge extends Component {
/>
</div>
{
data && data.user_admin_or_member &&
data && data.user_admin_or_developer &&
<a className="topWrapper_btn ml10" onClick={() => this.checkOperation()}>
+&nbsp;新建合并请求
</a>

View File

@ -75,6 +75,7 @@ class Index extends Component {
getOwner=()=>{
const { OIdentifier } = this.props.match.params;
const { user_id } = this.props && this.props.current_user;
const url = `/owners.json`;
axios.get(url).then(result=>{
if(result && result.data){
@ -83,16 +84,13 @@ class Index extends Component {
OwnerList: owner,
})
if(OIdentifier){
owner = owner.filter(item=>item.name === OIdentifier);
this.props.form.setFieldsValue({
user_id:OIdentifier
})
owner = owner.filter(item=>item.login === OIdentifier);
}else if(user_id){
owner = owner.filter(item=>item.id === user_id);
this.props.form.setFieldsValue({
user_id:owner && owner[0].name
})
}
this.props.form.setFieldsValue({
user_id:owner && owner[0].name
})
owner && this.setState({
owners_id:owner[0].id,
owners_name:owner[0].name

View File

@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState , useRef } from "react";
import {WhiteBack} from '../Component/layout';
import AddMember from '../Component/AddMember';
import AddGroup from '../Component/AddGroup';
@ -8,9 +8,11 @@ import Group from './CollaboratorGroup';
function Collaborator(props){
const [ nav , setNav] = useState("1");
const [ newId , setNewId] = useState(undefined);
const [ addOperation , setAddOperation] = useState(true);
const [ newGroupId , setNewGroupId] = useState(undefined);
const {projectsId ,owner} = props.match.params;
const author = props && props.projectDetail && props.projectDetail.author;
function getID(id){
@ -19,6 +21,7 @@ function Collaborator(props){
function getGroupID(id){
setNewGroupId(id);
}
return (
<WhiteBack>
@ -27,15 +30,17 @@ function Collaborator(props){
author && author.type === "Organization" ?
<span>
<span style={{cursor:"pointer"}} className={nav === "1" ? "font-18 text-black color-blue":"font-18 text-black"} onClick={()=>{setNav("1");setNewId(undefined)}}>协作者管理</span>
<span style={{cursor:"pointer"}} className={nav === "2" ? "font-18 text-black ml30 color-blue":"font-18 text-black ml30"} onClick={()=>{setNav("2");setNewId(undefined)}}>团队管理</span>
<span style={{cursor:"pointer"}} className={nav === "2" ? "font-18 text-black ml30 color-blue":"font-18 text-black ml30"} onClick={()=>{setNav("2");setNewId(undefined);setNewGroupId(undefined)}}>团队管理</span>
</span>
:
<span className="font-18 text-black">协作者管理</span>
}
{
nav === "1" ?
nav === "1" &&
<AddMember getID={getID} login showNotification={props.showNotification}/>
:
}
{
(nav !== "1" && addOperation) &&
<AddGroup getGroupID={getGroupID} organizeId={owner}/>
}
</div>
@ -44,7 +49,7 @@ function Collaborator(props){
nav === "1" ?
<Member newId={newId} projectsId={projectsId} owner={owner} project_id={props.project_id} author={props.projectDetail && props.projectDetail.author} showNotification={props.showNotification}/>
:
<Group owner={owner} projectsId={projectsId} newGroupId={newGroupId}/>
<Group setAddOperation={setAddOperation} owner={owner} projectsId={projectsId} newGroupId={newGroupId}/>
}
</div>
</WhiteBack>

View File

@ -10,7 +10,7 @@ const roles = {
read: "报告者",
};
const limit = 15;
function CollaboratorGroup({ newGroupId, owner, projectsId }) {
function CollaboratorGroup({ newGroupId, owner, projectsId , setAddOperation }) {
const [list, setList] = useState(undefined);
const [isSpin, setIsSpin] = useState(true);
const [page, setPage] = useState(1);
@ -34,6 +34,7 @@ function CollaboratorGroup({ newGroupId, owner, projectsId }) {
setList(result.data.teams);
setTotal(result.data.total_count);
setIsSpin(false);
setAddOperation(result.data.can_add);
}
})
.catch((error) => {});
@ -47,16 +48,15 @@ function CollaboratorGroup({ newGroupId, owner, projectsId }) {
//
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) => {});
}
//

View File

@ -34,6 +34,13 @@ export default Form.create()(
const { getFieldDecorator, validateFields, setFieldsValue } = form;
const { OIdentifier, groupId } = match.params;
useEffect(()=>{
setFieldsValue({
authorize:"read",
includes_all_project:0
})
},[])
useEffect(() => {
if (GroupDetail) {
setOnwers(GroupDetail.authorize === "owner");
@ -42,6 +49,7 @@ export default Form.create()(
setSwtichBox(GroupDetail.units)
setFieldsValue({
...GroupDetail,
includes_all_project:GroupDetail.includes_all_project ? 1 :0
})
setDescNum(GroupDetail.description ? GroupDetail.description.length : 0);
}
@ -72,11 +80,13 @@ export default Form.create()(
setIsSpin(true)
validateFields((error, values) => {
if (!error) {
values.unit_types = switch_box
// values.unit_types = switch_box
values.unit_types = ['code','pulls','issues','releases','wiki'];
if (groupId) { //
const url = `/organizations/${OIdentifier}/teams/${groupId}.json`;
axios.put(url, {
...values
...values,
includes_all_project:values.includes_all_project === 1?true:false
}).then(result => {
if (result && result.data) {
showNotification("基本设置更新成功!");
@ -86,7 +96,8 @@ export default Form.create()(
} else {
const url = `/organizations/${OIdentifier}/teams.json`;
axios.post(url, {
...values
...values,
includes_all_project:values.includes_all_project === 1?true:false
}).then(result => {
if (result && result.data) {
showNotification("团队创建成功!");
@ -204,8 +215,8 @@ export default Form.create()(
"includes_all_project",
[],
<Radio.Group>
<Radio value={false} style={addStyle}>指定项目<span className="color-grey-8 ml10">(团队成员将只能访问添加到团队的项目 选择此项 <span className="color-grey-3">将不会</span> 自动删除已经添加的项目)</span></Radio>
<Radio value={true} style={OptionStyle}>所有项目<span className="color-grey-8 ml10">(团队可以访问所有项目选择此选项将 <span className="color-grey-3">添加所有现有的</span> 项目到指定团队)</span></Radio>
<Radio value={0} style={addStyle}>指定项目<span className="color-grey-8 ml10">(团队成员将只能访问添加到团队的项目 选择此项 <span className="color-grey-3">将不会</span> 自动删除已经添加的项目)</span></Radio>
<Radio value={1} style={OptionStyle}>所有项目<span className="color-grey-8 ml10">(团队可以访问所有项目选择此选项将 <span className="color-grey-3">添加所有现有的</span> 项目到指定团队)</span></Radio>
</Radio.Group>, false, 0,onwers ? "hide":""
)}
{helper(
@ -225,7 +236,7 @@ export default Form.create()(
</Radio.Group>, false, 20,onwers ? "hide":""
)}
</Form>
<div className={(auth!=="owner" && auth !=="admin") ? "" :"hide"}>
{/* <div className={(auth!=="owner" && auth !=="admin") ? "" :"hide"}>
<p className="required">允许访问项目单元</p>
<AlignCenter className="mb10">
<Switch checked={switch_box_code} onClick={switch_code_types} />
@ -247,7 +258,7 @@ export default Form.create()(
<Switch checked={switch_box_wiki} onClick={switch_wiki_types} />
<span className="ml30 color-grey-3">wiki<span className="color-grey-8 ml15">(编辑此仓库的相关文档说明)</span></span>
</AlignCenter>
</div>
</div> */}
<Button type={"primary"} onClick={saveGroupFrom}>{groupId ? "更新团队设置" : "新建团队"}</Button>
<Cancel className="ml30" onClick={() => cancelEdit()}><span>取消</span></Cancel>
</Div>

View File

@ -75,7 +75,7 @@ function List(props){
<Search placeholder="输入仓库名称进行搜索" onSearch={onSearch}/>
</div>
<p>
{ organizeDetail && organizeDetail.is_admin ?
{ organizeDetail && organizeDetail.can_create_project ?
<Sort menu={menu_new}>
<a className="addBtn mr30">+&nbsp;新建项目</a>
</Sort>

View File

@ -168,7 +168,7 @@ export default Form.create()(
'权限:',
"repo_admin_change_team_access",
[],
<Checkbox style={radioStyle}>仓库管理员可以添加或移除团队的访问权限</Checkbox>,false,true
<Checkbox style={radioStyle}>项目管理员可以添加或移除团队的访问权限</Checkbox>,false,true
)}
<Divider/>
{helper(