mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
Add groups to role
This commit is contained in:
parent
4cc9137637
commit
f9cc6ed064
@ -32,6 +32,7 @@ type Role struct {
|
|||||||
Description string `xorm:"varchar(100)" json:"description"`
|
Description string `xorm:"varchar(100)" json:"description"`
|
||||||
|
|
||||||
Users []string `xorm:"mediumtext" json:"users"`
|
Users []string `xorm:"mediumtext" json:"users"`
|
||||||
|
Groups []string `xorm:"mediumtext" json:"groups"`
|
||||||
Roles []string `xorm:"mediumtext" json:"roles"`
|
Roles []string `xorm:"mediumtext" json:"roles"`
|
||||||
Domains []string `xorm:"mediumtext" json:"domains"`
|
Domains []string `xorm:"mediumtext" json:"domains"`
|
||||||
IsEnabled bool `json:"isEnabled"`
|
IsEnabled bool `json:"isEnabled"`
|
||||||
|
@ -14,11 +14,12 @@
|
|||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {Button, Card, Col, Input, Row, Select, Switch} from "antd";
|
import {Button, Card, Col, Input, Row, Select, Switch} from "antd";
|
||||||
import * as RoleBackend from "./backend/RoleBackend";
|
|
||||||
import * as OrganizationBackend from "./backend/OrganizationBackend";
|
import * as OrganizationBackend from "./backend/OrganizationBackend";
|
||||||
|
import * as UserBackend from "./backend/UserBackend";
|
||||||
|
import * as GroupBackend from "./backend/GroupBackend";
|
||||||
|
import * as RoleBackend from "./backend/RoleBackend";
|
||||||
import * as Setting from "./Setting";
|
import * as Setting from "./Setting";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import * as UserBackend from "./backend/UserBackend";
|
|
||||||
|
|
||||||
class RoleEditPage extends React.Component {
|
class RoleEditPage extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -30,6 +31,7 @@ class RoleEditPage extends React.Component {
|
|||||||
role: null,
|
role: null,
|
||||||
organizations: [],
|
organizations: [],
|
||||||
users: [],
|
users: [],
|
||||||
|
groups: [],
|
||||||
roles: [],
|
roles: [],
|
||||||
mode: props.location.mode !== undefined ? props.location.mode : "edit",
|
mode: props.location.mode !== undefined ? props.location.mode : "edit",
|
||||||
};
|
};
|
||||||
@ -57,6 +59,7 @@ class RoleEditPage extends React.Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.getUsers(this.state.organizationName);
|
this.getUsers(this.state.organizationName);
|
||||||
|
this.getGroups(this.state.organizationName);
|
||||||
this.getRoles(this.state.organizationName);
|
this.getRoles(this.state.organizationName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -84,6 +87,20 @@ class RoleEditPage extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getGroups(organizationName) {
|
||||||
|
GroupBackend.getGroups(organizationName)
|
||||||
|
.then((res) => {
|
||||||
|
if (res.status === "error") {
|
||||||
|
Setting.showMessage("error", res.msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
groups: res.data,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getRoles(organizationName) {
|
getRoles(organizationName) {
|
||||||
RoleBackend.getRoles(organizationName)
|
RoleBackend.getRoles(organizationName)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -176,6 +193,17 @@ class RoleEditPage extends React.Component {
|
|||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
<Row style={{marginTop: "20px"}} >
|
||||||
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||||
|
{Setting.getLabel(i18next.t("role:Sub groups"), i18next.t("role:Sub groups - Tooltip"))} :
|
||||||
|
</Col>
|
||||||
|
<Col span={22} >
|
||||||
|
<Select virtual={false} mode="multiple" style={{width: "100%"}} value={this.state.role.groups}
|
||||||
|
onChange={(value => {this.updateRoleField("groups", value);})}
|
||||||
|
options={this.state.groups.map((group) => Setting.getOption(`${group.owner}/${group.name}`, `${group.owner}/${group.name}`))}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
<Row style={{marginTop: "20px"}} >
|
<Row style={{marginTop: "20px"}} >
|
||||||
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
<Col style={{marginTop: "5px"}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||||
{Setting.getLabel(i18next.t("role:Sub roles"), i18next.t("role:Sub roles - Tooltip"))} :
|
{Setting.getLabel(i18next.t("role:Sub roles"), i18next.t("role:Sub roles - Tooltip"))} :
|
||||||
|
@ -33,6 +33,7 @@ class RoleListPage extends BaseListPage {
|
|||||||
createdTime: moment().format(),
|
createdTime: moment().format(),
|
||||||
displayName: `New Role - ${randomName}`,
|
displayName: `New Role - ${randomName}`,
|
||||||
users: [],
|
users: [],
|
||||||
|
groups: [],
|
||||||
roles: [],
|
roles: [],
|
||||||
domains: [],
|
domains: [],
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
@ -171,6 +172,17 @@ class RoleListPage extends BaseListPage {
|
|||||||
return Setting.getTags(text, "users");
|
return Setting.getTags(text, "users");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: i18next.t("role:Sub groups"),
|
||||||
|
dataIndex: "groups",
|
||||||
|
key: "groups",
|
||||||
|
// width: '100px',
|
||||||
|
sorter: true,
|
||||||
|
...this.getColumnSearchProps("groups"),
|
||||||
|
render: (text, record, index) => {
|
||||||
|
return Setting.getTags(text, "groups");
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: i18next.t("role:Sub roles"),
|
title: i18next.t("role:Sub roles"),
|
||||||
dataIndex: "roles",
|
dataIndex: "roles",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user