Add check for submitPermissionEdit()

This commit is contained in:
Gucheng Wang
2022-08-19 00:09:26 +08:00
parent 8e9ed1205b
commit a4fe2a6485
2 changed files with 61 additions and 1 deletions

View File

@ -370,6 +370,27 @@ class PermissionEditPage extends React.Component {
} }
submitPermissionEdit(willExist) { submitPermissionEdit(willExist) {
if (this.state.permission.users.length === 0 && this.state.permission.roles.length === 0) {
Setting.showMessage("error", "The users and roles cannot be empty at the same time");
return;
}
if (this.state.permission.domains.length === 0) {
Setting.showMessage("error", "The domains cannot be empty");
return;
}
if (this.state.permission.resources.length === 0) {
Setting.showMessage("error", "The resources cannot be empty");
return;
}
if (this.state.permission.actions.length === 0) {
Setting.showMessage("error", "The actions cannot be empty");
return;
}
if (!Setting.isLocalAdminUser(this.props.account) && this.state.permission.submitter !== this.props.account.name) {
Setting.showMessage("error", "A normal user can only modify the permission submitted by itself");
return;
}
const permission = Setting.deepCopy(this.state.permission); const permission = Setting.deepCopy(this.state.permission);
PermissionBackend.updatePermission(this.state.organizationName, this.state.permissionName, permission) PermissionBackend.updatePermission(this.state.organizationName, this.state.permissionName, permission)
.then((res) => { .then((res) => {

View File

@ -215,6 +215,45 @@ class PermissionListPage extends BaseListPage {
); );
}, },
}, },
{
title: i18next.t("permission:Submitter"),
dataIndex: "submitter",
key: "submitter",
filterMultiple: false,
width: "120px",
sorter: true,
},
{
title: i18next.t("permission:Approver"),
dataIndex: "approver",
key: "approver",
filterMultiple: false,
width: "120px",
sorter: true,
},
{
title: i18next.t("permission:Approve time"),
dataIndex: "approveTime",
key: "approveTime",
filterMultiple: false,
width: "120px",
sorter: true,
render: (text, record, index) => {
return Setting.getFormattedDate(text);
},
},
{
title: i18next.t("permission:State"),
dataIndex: "state",
key: "state",
filterMultiple: false,
filters: [
{text: "Approved", value: "Approved"},
{text: "Pending", value: "Pending"},
],
width: "120px",
sorter: true,
},
{ {
title: i18next.t("general:Action"), title: i18next.t("general:Action"),
dataIndex: "", dataIndex: "",
@ -269,7 +308,7 @@ class PermissionListPage extends BaseListPage {
} }
this.setState({loading: true}); this.setState({loading: true});
const getPermissions = Setting.isAdminUser(this.props.account) ? PermissionBackend.getPermissions : PermissionBackend.getPermissionsBySubmitter; const getPermissions = Setting.isLocalAdminUser(this.props.account) ? PermissionBackend.getPermissions : PermissionBackend.getPermissionsBySubmitter;
getPermissions("", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder) getPermissions("", params.pagination.current, params.pagination.pageSize, field, value, sortField, sortOrder)
.then((res) => { .then((res) => {
if (res.status === "ok") { if (res.status === "ok") {