Skip to content

Commit

Permalink
Add check for submitPermissionEdit()
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeguy committed Aug 18, 2022
1 parent 8e9ed12 commit d4802c0
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
17 changes: 17 additions & 0 deletions web/src/PermissionEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,23 @@ class PermissionEditPage extends React.Component {
}

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;
}

const permission = Setting.deepCopy(this.state.permission);
PermissionBackend.updatePermission(this.state.organizationName, this.state.permissionName, permission)
.then((res) => {
Expand Down
41 changes: 40 additions & 1 deletion web/src/PermissionListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
dataIndex: "",
Expand Down Expand Up @@ -269,7 +308,7 @@ class PermissionListPage extends BaseListPage {
}
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)
.then((res) => {
if (res.status === "ok") {
Expand Down

0 comments on commit d4802c0

Please sign in to comment.