Add user soft deletion.

This commit is contained in:
Gucheng Wang
2021-11-06 15:52:03 +08:00
parent db892333fe
commit 9e920181d2
11 changed files with 72 additions and 19 deletions

View File

@ -13,7 +13,7 @@
// limitations under the License.
import React from "react";
import {Button, Card, Col, Input, Row, Select} from 'antd';
import {Button, Card, Col, Input, Row, Select, Switch} from 'antd';
import * as OrganizationBackend from "./backend/OrganizationBackend";
import * as LdapBackend from "./backend/LdapBackend";
import * as Setting from "./Setting";
@ -205,6 +205,16 @@ class OrganizationEditPage extends React.Component {
</Row>
</Col>
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 19 : 2}>
{Setting.getLabel(i18next.t("organization:Soft deletion"), i18next.t("organization:Soft deletion - Tooltip"))} :
</Col>
<Col span={1} >
<Switch checked={this.state.organization.enableSoftDeletion} onChange={checked => {
this.updateOrganizationField('enableSoftDeletion', checked);
}} />
</Col>
</Row>
<Row style={{marginTop: '20px'}}>
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("general:LDAPs"), i18next.t("general:LDAPs - Tooltip"))} :

View File

@ -14,7 +14,7 @@
import React from "react";
import {Link} from "react-router-dom";
import {Button, Popconfirm, Table} from 'antd';
import {Button, Popconfirm, Switch, Table} from 'antd';
import moment from "moment";
import * as Setting from "./Setting";
import * as OrganizationBackend from "./backend/OrganizationBackend";
@ -59,6 +59,7 @@ class OrganizationListPage extends React.Component {
PasswordSalt: "",
phonePrefix: "86",
defaultAvatar: "https://casbin.org/img/casbin.svg",
enableSoftDeletion: false,
}
}
@ -158,7 +159,7 @@ class OrganizationListPage extends React.Component {
title: i18next.t("general:Password type"),
dataIndex: 'passwordType',
key: 'passwordType',
width: '100px',
width: '150px',
sorter: (a, b) => a.passwordType.localeCompare(b.passwordType),
},
{
@ -172,7 +173,7 @@ class OrganizationListPage extends React.Component {
title: i18next.t("organization:Default avatar"),
dataIndex: 'defaultAvatar',
key: 'defaultAvatar',
width: '50px',
width: '120px',
render: (text, record, index) => {
return (
<a target="_blank" rel="noreferrer" href={text}>
@ -181,6 +182,18 @@ class OrganizationListPage extends React.Component {
)
}
},
{
title: i18next.t("organization:Soft deletion"),
dataIndex: 'enableSoftDeletion',
key: 'enableSoftDeletion',
width: '140px',
sorter: (a, b) => a.enableSoftDeletion - b.enableSoftDeletion,
render: (text, record, index) => {
return (
<Switch disabled checkedChildren="ON" unCheckedChildren="OFF" checked={text} />
)
}
},
{
title: i18next.t("general:Action"),
dataIndex: '',

View File

@ -353,6 +353,16 @@ class UserEditPage extends React.Component {
}} />
</Col>
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}>
{Setting.getLabel(i18next.t("user:Is deleted"), i18next.t("user:Is deleted - Tooltip"))} :
</Col>
<Col span={(Setting.isMobile()) ? 22 : 2} >
<Switch checked={this.state.user.isDeleted} onChange={checked => {
this.updateUserField('isDeleted', checked);
}} />
</Col>
</Row>
</React.Fragment>
)
}

View File

@ -67,6 +67,7 @@ class UserListPage extends React.Component {
createdTime: moment().format(),
type: "normal-user",
password: "123",
passwordSalt: "",
displayName: `New User - ${randomName}`,
avatar: "https://casbin.org/img/casbin.svg",
email: "user@example.com",
@ -78,6 +79,7 @@ class UserListPage extends React.Component {
isAdmin: false,
isGlobalAdmin: false,
IsForbidden: false,
isDeleted: false,
properties: {},
}
}
@ -164,7 +166,7 @@ class UserListPage extends React.Component {
title: i18next.t("general:Created time"),
dataIndex: 'createdTime',
key: 'createdTime',
width: '180px',
width: '160px',
sorter: (a, b) => a.createdTime.localeCompare(b.createdTime),
render: (text, record, index) => {
return Setting.getFormattedDate(text);
@ -243,7 +245,7 @@ class UserListPage extends React.Component {
title: i18next.t("user:Is admin"),
dataIndex: 'isAdmin',
key: 'isAdmin',
width: '100px',
width: '110px',
sorter: (a, b) => a.isAdmin - b.isAdmin,
render: (text, record, index) => {
return (
@ -255,7 +257,7 @@ class UserListPage extends React.Component {
title: i18next.t("user:Is global admin"),
dataIndex: 'isGlobalAdmin',
key: 'isGlobalAdmin',
width: '100px',
width: '110px',
sorter: (a, b) => a.isGlobalAdmin - b.isGlobalAdmin,
render: (text, record, index) => {
return (
@ -267,7 +269,7 @@ class UserListPage extends React.Component {
title: i18next.t("user:Is forbidden"),
dataIndex: 'isForbidden',
key: 'isForbidden',
width: '100px',
width: '110px',
sorter: (a, b) => a.isForbidden - b.isForbidden,
render: (text, record, index) => {
return (
@ -275,6 +277,18 @@ class UserListPage extends React.Component {
)
}
},
{
title: i18next.t("user:Is deleted"),
dataIndex: 'isDeleted',
key: 'isDeleted',
width: '110px',
sorter: (a, b) => a.isDeleted - b.isDeleted,
render: (text, record, index) => {
return (
<Switch disabled checkedChildren="ON" unCheckedChildren="OFF" checked={text} />
)
}
},
{
title: i18next.t("general:Action"),
dataIndex: '',