feat: optimize get-groups API and GroupListPage (#3518)

* fix: optimize get-groups api and GroupListPage

* fix: fix linter issue
This commit is contained in:
DacongDA
2025-01-23 09:47:39 +08:00
committed by GitHub
parent 9701818a6e
commit a5a627f92e
3 changed files with 58 additions and 57 deletions

View File

@ -33,18 +33,6 @@ class GroupListPage extends BaseListPage {
}
UNSAFE_componentWillMount() {
super.UNSAFE_componentWillMount();
this.getGroups(this.state.owner);
}
getGroups(organizationName) {
GroupBackend.getGroups(organizationName)
.then((res) => {
if (res.status === "ok") {
this.setState({
groups: res.data,
});
}
});
}
newGroup() {
@ -188,12 +176,8 @@ class GroupListPage extends BaseListPage {
{record.parentId}
</Link>;
}
const parentGroup = this.state.groups.find((group) => group.name === text);
if (parentGroup === undefined) {
return "";
}
return <Link to={`/groups/${parentGroup.owner}/${parentGroup.name}`}>
{parentGroup?.displayName}
return <Link to={`/groups/${record.owner}/${record.parentId}`}>
{record?.parentName}
</Link>;
},
},
@ -215,12 +199,11 @@ class GroupListPage extends BaseListPage {
width: "180px",
fixed: (Setting.isMobile()) ? "false" : "right",
render: (text, record, index) => {
const haveChildren = this.state.groups.find((group) => group.parentId === record.id) !== undefined;
return (
<div>
<Button style={{marginTop: "10px", marginBottom: "10px", marginRight: "10px"}} type="primary" onClick={() => this.props.history.push(`/groups/${record.owner}/${record.name}`)}>{i18next.t("general:Edit")}</Button>
<PopconfirmModal
disabled={haveChildren}
disabled={record.haveChildren}
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
onConfirm={() => this.deleteGroup(index)}
>