mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-22 18:25:47 +08:00
Add groups to permission
This commit is contained in:
parent
9820801634
commit
a9de7d3aef
@ -30,6 +30,7 @@ type Permission 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"`
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import {Button, Card, Col, Input, Row, Select, Switch} from "antd";
|
|||||||
import * as PermissionBackend from "./backend/PermissionBackend";
|
import * as PermissionBackend from "./backend/PermissionBackend";
|
||||||
import * as OrganizationBackend from "./backend/OrganizationBackend";
|
import * as OrganizationBackend from "./backend/OrganizationBackend";
|
||||||
import * as UserBackend from "./backend/UserBackend";
|
import * as UserBackend from "./backend/UserBackend";
|
||||||
|
import * as GroupBackend from "./backend/GroupBackend";
|
||||||
import * as Setting from "./Setting";
|
import * as Setting from "./Setting";
|
||||||
import i18next from "i18next";
|
import i18next from "i18next";
|
||||||
import * as RoleBackend from "./backend/RoleBackend";
|
import * as RoleBackend from "./backend/RoleBackend";
|
||||||
@ -35,6 +36,7 @@ class PermissionEditPage extends React.Component {
|
|||||||
organizations: [],
|
organizations: [],
|
||||||
model: null,
|
model: null,
|
||||||
users: [],
|
users: [],
|
||||||
|
groups: [],
|
||||||
roles: [],
|
roles: [],
|
||||||
models: [],
|
models: [],
|
||||||
resources: [],
|
resources: [],
|
||||||
@ -67,6 +69,7 @@ class PermissionEditPage extends React.Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.getUsers(permission.owner);
|
this.getUsers(permission.owner);
|
||||||
|
this.getGroups(permission.owner);
|
||||||
this.getRoles(permission.owner);
|
this.getRoles(permission.owner);
|
||||||
this.getModels(permission.owner);
|
this.getModels(permission.owner);
|
||||||
this.getResources(permission.owner);
|
this.getResources(permission.owner);
|
||||||
@ -97,6 +100,20 @@ class PermissionEditPage 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) => {
|
||||||
@ -192,6 +209,7 @@ class PermissionEditPage extends React.Component {
|
|||||||
<Select virtual={false} style={{width: "100%"}} disabled={!Setting.isAdminUser(this.props.account)} value={this.state.permission.owner} onChange={(owner => {
|
<Select virtual={false} style={{width: "100%"}} disabled={!Setting.isAdminUser(this.props.account)} value={this.state.permission.owner} onChange={(owner => {
|
||||||
this.updatePermissionField("owner", owner);
|
this.updatePermissionField("owner", owner);
|
||||||
this.getUsers(owner);
|
this.getUsers(owner);
|
||||||
|
this.getGroups(owner);
|
||||||
this.getRoles(owner);
|
this.getRoles(owner);
|
||||||
this.getModels(owner);
|
this.getModels(owner);
|
||||||
this.getResources(owner);
|
this.getResources(owner);
|
||||||
@ -263,6 +281,17 @@ class PermissionEditPage 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.permission.groups}
|
||||||
|
onChange={(value => {this.updatePermissionField("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 PermissionListPage extends BaseListPage {
|
|||||||
createdTime: moment().format(),
|
createdTime: moment().format(),
|
||||||
displayName: `New Permission - ${randomName}`,
|
displayName: `New Permission - ${randomName}`,
|
||||||
users: [`${this.props.account.owner}/${this.props.account.name}`],
|
users: [`${this.props.account.owner}/${this.props.account.name}`],
|
||||||
|
groups: [],
|
||||||
roles: [],
|
roles: [],
|
||||||
domains: [],
|
domains: [],
|
||||||
resourceType: "Application",
|
resourceType: "Application",
|
||||||
@ -179,6 +180,17 @@ class PermissionListPage 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