forked from Gitlink/forgeplus-react
bug
This commit is contained in:
parent
cae10cec2a
commit
34ba476011
|
@ -13,54 +13,55 @@ export default ((props) => {
|
|||
const { current_user } = props;
|
||||
|
||||
useEffect(() => {
|
||||
getMember()
|
||||
}, [page])
|
||||
if(groupId && OIdentifier){
|
||||
getMember();
|
||||
}
|
||||
}, [OIdentifier,groupId,page])
|
||||
|
||||
function getMember() {
|
||||
setIsSpin(true)
|
||||
const url = `/organizations/${OIdentifier}/teams/${groupId}/team_users.json`;
|
||||
axios
|
||||
.get(url, {
|
||||
params: {
|
||||
page,
|
||||
limit
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
if (result && result.data) {
|
||||
setMembers(result.data.team_users)
|
||||
setTotal(result.data.total_count)
|
||||
}
|
||||
}).catch((error) => { });
|
||||
axios.get(url, {
|
||||
params: {
|
||||
page,
|
||||
limit
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
if (result && result.data) {
|
||||
setMembers(result.data.team_users)
|
||||
setTotal(result.data.total_count)
|
||||
}
|
||||
}).catch((error) => { });
|
||||
setIsSpin(false)
|
||||
};
|
||||
|
||||
return (
|
||||
<Spin spinning={isSpin}>
|
||||
<div className="MemberBoxThree">
|
||||
{
|
||||
data && data.length > 0 ? data.map((item, key) => {
|
||||
return (
|
||||
<Cards
|
||||
img={item.user.image_url}
|
||||
name={item.user.name}
|
||||
time={item.created_at}
|
||||
focusStatus={item.user.watched}
|
||||
is_current_user={current_user && item.user.login === current_user.login}
|
||||
login={item.user.login}
|
||||
/>
|
||||
)
|
||||
})
|
||||
:
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
||||
}
|
||||
</div>
|
||||
{ data && data.length > 0 ?
|
||||
<div className="MemberBoxThree">
|
||||
{
|
||||
data.map((item, key) => {
|
||||
return (
|
||||
<Cards
|
||||
img={item.user.image_url}
|
||||
name={item.user.name}
|
||||
time={item.created_at}
|
||||
focusStatus={item.user.watched}
|
||||
is_current_user={current_user && item.user.login === current_user.login}
|
||||
login={item.user.login}
|
||||
/>
|
||||
)
|
||||
})
|
||||
}
|
||||
</div>:""
|
||||
}
|
||||
{
|
||||
total > limit ?
|
||||
<div className="edu-txt-center mt30 mb20">
|
||||
<Pagination simple defaultCurrent={page} total={total} pageSize={limit} onChange={ChangePage}></Pagination>
|
||||
</div>
|
||||
: ""
|
||||
<div className="edu-txt-center mt30 mb20">
|
||||
<Pagination simple defaultCurrent={page} total={total} pageSize={limit} onChange={ChangePage}></Pagination>
|
||||
</div>
|
||||
: ""
|
||||
}
|
||||
</Spin>
|
||||
|
||||
|
|
|
@ -18,84 +18,58 @@ const Leave = styled.a`{
|
|||
}`
|
||||
export default ((props) => {
|
||||
const [nav, setNav] = useState('0');
|
||||
const [isSpin, setIsSpin] = useState(false);
|
||||
const [userSpin, setUserSpin] = useState(false);
|
||||
const [page, setPage] = useState(1);
|
||||
const [limit, setLimit] = useState(15);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [group, setGroup] = useState(undefined);
|
||||
const { OIdentifier, groupId } = props.match.params;
|
||||
const { current_user } = props;
|
||||
|
||||
useEffect(() => {
|
||||
setIsSpin(true)
|
||||
const url = `/organizations/${OIdentifier}/teams/${groupId}.json`;
|
||||
axios.get(url)
|
||||
.then((result) => {
|
||||
if (result && result.data) {
|
||||
setGroup(result.data)
|
||||
}
|
||||
}).catch((error) => { });
|
||||
setIsSpin(false)
|
||||
}, [])
|
||||
const { current_user , group } = props;
|
||||
|
||||
// 移除成员
|
||||
function removeUser(username) {
|
||||
setIsSpin(true)
|
||||
const url = `/organizations/${OIdentifier}/teams/${groupId}/team_users/${username}.json`;
|
||||
if (username) {
|
||||
axios.delete(url)
|
||||
.then((result) => {
|
||||
if (result && result.data) {
|
||||
setPage(1)
|
||||
this.getMember();
|
||||
}
|
||||
})
|
||||
.catch((error) => { });
|
||||
axios.delete(url).then((result) => {
|
||||
if (result && result.data) {
|
||||
|
||||
}
|
||||
}).catch((error) => { });
|
||||
}
|
||||
setIsSpin(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<Box className="GroupSubLevel">
|
||||
<Short className="g-sub-left">
|
||||
<Spin spinning={isSpin}>
|
||||
{
|
||||
group ?
|
||||
<div>
|
||||
<AlignCenterBetween>
|
||||
<span className="color-grey-3">{group.name}</span>
|
||||
{group.is_member ?
|
||||
<Popconfirm
|
||||
title="确认离开团队吗?"
|
||||
onConfirm={() => removeUser(current_user.login)}
|
||||
okText="确认"
|
||||
cancelText="取消"
|
||||
>
|
||||
<Leave>离开团队</Leave>
|
||||
</Popconfirm>
|
||||
: ""
|
||||
}
|
||||
</AlignCenterBetween>
|
||||
<div className="g-desc">{group.description ? group.description : "暂无描述"}</div>
|
||||
<div className="g-tip">
|
||||
<p>管理员团队对 <span>所有仓库</span> 具有操作权限,且对组织具有 <span>管理员权限</span>。 </p>
|
||||
<p>此外,该团队拥有了 <span>创建仓库</span> 的权限:成员可以在组织中创建新的仓库。 </p>
|
||||
{group.is_admin ? <Button type="primary" onClick={()=>props.history.push(`/organize/${OIdentifier}/group/${groupId}/setting`)}><span className="color-white">团队设置</span></Button> : ""}
|
||||
</div>
|
||||
{
|
||||
group ?
|
||||
<div>
|
||||
<AlignCenterBetween>
|
||||
<span className="color-grey-3">{group.name}</span>
|
||||
{group.is_member ?
|
||||
<Popconfirm
|
||||
title="确认离开团队吗?"
|
||||
onConfirm={() => removeUser(current_user.login)}
|
||||
okText="确认"
|
||||
cancelText="取消"
|
||||
>
|
||||
<Leave>离开团队</Leave>
|
||||
</Popconfirm>
|
||||
: ""
|
||||
}
|
||||
</AlignCenterBetween>
|
||||
<div className="g-desc">{group.description ? group.description : "暂无描述"}</div>
|
||||
<div className="g-tip">
|
||||
<p>管理员团队对 <span>所有仓库</span> 具有操作权限,且对组织具有 <span>管理员权限</span>。 </p>
|
||||
<p>此外,该团队拥有了 <span>创建仓库</span> 的权限:成员可以在组织中创建新的仓库。 </p>
|
||||
{group.is_admin ? <Button type="primary" onClick={()=>props.history.push(`/organize/${OIdentifier}/group/${groupId}/setting`)}><span className="color-white">团队设置</span></Button> : ""}
|
||||
</div>
|
||||
:
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
||||
}
|
||||
</Spin>
|
||||
</div>
|
||||
:
|
||||
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
||||
}
|
||||
</Short>
|
||||
<Long>
|
||||
<Gap>
|
||||
<WhiteBack>
|
||||
<Tabs nav={['团队成员', '团队项目']} index={nav} onChange={setNav}>
|
||||
{
|
||||
nav === "0" ?
|
||||
<Memberlist {...props} /> : <Grouplist {...props}/>
|
||||
nav === "0" ? <Memberlist {...props} /> : <Grouplist {...props}/>
|
||||
}
|
||||
</Tabs>
|
||||
</WhiteBack>
|
||||
|
|
|
@ -95,7 +95,7 @@ export default ((props)=>{
|
|||
<Route
|
||||
path="/organize/:OIdentifier/group/:groupId"
|
||||
render={(p) => {
|
||||
return <GroupDetails {...props} {...p}/>
|
||||
return <GroupDetails {...props} {...p} group={detail}/>
|
||||
}}
|
||||
></Route>
|
||||
</Switch>
|
||||
|
|
Loading…
Reference in New Issue