mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
feat: fix bug that group.HaveChildren is never set to false bug Something isn't working (#3609)
This commit is contained in:
parent
24ab8880cc
commit
2df3878c15
@ -83,19 +83,23 @@ func GetPaginationGroups(owner string, offset, limit int, field, value, sortFiel
|
|||||||
func GetGroupsHaveChildrenMap(groups []*Group) (map[string]*Group, error) {
|
func GetGroupsHaveChildrenMap(groups []*Group) (map[string]*Group, error) {
|
||||||
groupsHaveChildren := []*Group{}
|
groupsHaveChildren := []*Group{}
|
||||||
resultMap := make(map[string]*Group)
|
resultMap := make(map[string]*Group)
|
||||||
|
groupMap := map[string]*Group{}
|
||||||
|
|
||||||
groupIds := []string{}
|
groupIds := []string{}
|
||||||
for _, group := range groups {
|
for _, group := range groups {
|
||||||
|
groupMap[group.Name] = group
|
||||||
groupIds = append(groupIds, group.Name)
|
groupIds = append(groupIds, group.Name)
|
||||||
groupIds = append(groupIds, group.ParentId)
|
if !group.IsTopGroup {
|
||||||
|
groupIds = append(groupIds, group.ParentId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := ormer.Engine.Cols("owner", "name", "parent_id", "display_name").Distinct("parent_id").In("parent_id", groupIds).Find(&groupsHaveChildren)
|
err := ormer.Engine.Cols("owner", "name", "parent_id", "display_name").Distinct("parent_id").In("parent_id", groupIds).Find(&groupsHaveChildren)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, group := range groups {
|
for _, group := range groupsHaveChildren {
|
||||||
resultMap[group.Name] = group
|
resultMap[group.ParentId] = groupMap[group.ParentId]
|
||||||
}
|
}
|
||||||
return resultMap, nil
|
return resultMap, nil
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {Link} from "react-router-dom";
|
import {Link} from "react-router-dom";
|
||||||
import {Button, Table} from "antd";
|
import {Button, Table, Tooltip} from "antd";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import * as Setting from "./Setting";
|
import * as Setting from "./Setting";
|
||||||
import * as GroupBackend from "./backend/GroupBackend";
|
import * as GroupBackend from "./backend/GroupBackend";
|
||||||
@ -202,12 +202,16 @@ class GroupListPage extends BaseListPage {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<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>
|
<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={record.haveChildren}
|
record.haveChildren ? <Tooltip placement="topLeft" title={i18next.t("group:You need to delete all subgroups first. You can view the subgroups in the left group tree of the [Organizations] -> [Groups] page")}>
|
||||||
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
|
<Button disabled type="primary" danger>{i18next.t("general:Delete")}</Button>
|
||||||
onConfirm={() => this.deleteGroup(index)}
|
</Tooltip> :
|
||||||
>
|
<PopconfirmModal
|
||||||
</PopconfirmModal>
|
title={i18next.t("general:Sure to delete") + `: ${record.name} ?`}
|
||||||
|
onConfirm={() => this.deleteGroup(index)}
|
||||||
|
>
|
||||||
|
</PopconfirmModal>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user