permission handling
parent
92bc08e511
commit
7300a0e107
|
@ -52,9 +52,10 @@ export default function AppRoutes() {
|
|||
|
||||
{hasOnePermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.ADD_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.CREATE_NEW_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.UPDATE_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.DELETE_ROLE
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.DELETE_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.MOVE_ROLE_UP_DOWN
|
||||
) && <Route path="/admin-area/roles" element={<AdminAreaRoles />} />}
|
||||
|
||||
{hasPermission(
|
||||
|
|
|
@ -85,9 +85,10 @@ export default function SideMenu({ userSession, setUserSession }) {
|
|||
if (
|
||||
hasOnePermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.ADD_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.CREATE_NEW_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.UPDATE_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.DELETE_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.MOVE_ROLE_UP_DOWN,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.LOGS
|
||||
)
|
||||
) {
|
||||
|
@ -101,9 +102,10 @@ export default function SideMenu({ userSession, setUserSession }) {
|
|||
if (
|
||||
hasOnePermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.ADD_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.CREATE_NEW_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.UPDATE_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.DELETE_ROLE
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.DELETE_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.MOVE_ROLE_UP_DOWN
|
||||
)
|
||||
) {
|
||||
adminArea.children.push({
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
MyAvatar,
|
||||
SentMessagesCommands,
|
||||
WebSocketContext,
|
||||
hasPermission,
|
||||
} from "../../../utils";
|
||||
import {
|
||||
ArrowDownOutlined,
|
||||
|
@ -120,6 +121,10 @@ export default function AdminAreaRoles() {
|
|||
/>
|
||||
))}
|
||||
|
||||
{hasPermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.CREATE_NEW_ROLE
|
||||
) && (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
|
@ -137,6 +142,7 @@ export default function AdminAreaRoles() {
|
|||
</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
)}
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
@ -361,7 +367,11 @@ function Role({ treeData, role, webSocketContext, notificationApi }) {
|
|||
key: "2",
|
||||
extra: editMode ? (
|
||||
<Space key="spaceedit" style={{ paddingLeft: 10 }} size="small">
|
||||
{role.Master || getUsersInRole().length > 0 ? (
|
||||
{hasPermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.DELETE_ROLE
|
||||
) ? (
|
||||
role.Master || getUsersInRole().length > 0 ? (
|
||||
<DeleteOutlined
|
||||
style={{
|
||||
color: "rgba(0, 0, 0, 0.25)",
|
||||
|
@ -379,8 +389,14 @@ function Role({ treeData, role, webSocketContext, notificationApi }) {
|
|||
<DeleteOutlined />
|
||||
</Tooltip>
|
||||
</Popconfirm>
|
||||
)}
|
||||
)
|
||||
) : null}
|
||||
|
||||
{hasPermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.MOVE_ROLE_UP_DOWN
|
||||
) ? (
|
||||
<>
|
||||
{role.SortingOrder === 0 ? (
|
||||
<ArrowUpOutlined
|
||||
style={{
|
||||
|
@ -405,10 +421,17 @@ function Role({ treeData, role, webSocketContext, notificationApi }) {
|
|||
<ArrowDownOutlined onClick={() => onMoveDownClick()} />
|
||||
</Tooltip>
|
||||
)}
|
||||
</>
|
||||
) : null}
|
||||
|
||||
{hasPermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.UPDATE_ROLE
|
||||
) && (
|
||||
<Tooltip title="Save">
|
||||
<SaveOutlined onClick={() => onSaveClick()} />
|
||||
</Tooltip>
|
||||
)}
|
||||
<Tooltip title="Close">
|
||||
<CloseOutlined onClick={() => onCloseClick()} />
|
||||
</Tooltip>
|
||||
|
|
|
@ -59,9 +59,10 @@ export const Constants = {
|
|||
},
|
||||
ADMIN_AREA: {
|
||||
ROLES: {
|
||||
ADD_ROLE: "admin_area.roles.add_role",
|
||||
CREATE_NEW_ROLE: "admin_area.roles.create_new_role",
|
||||
UPDATE_ROLE: "admin_area.roles.update_role",
|
||||
DELETE_ROLE: "admin_area.roles.delete_role",
|
||||
MOVE_ROLE_UP_DOWN: "admin_area.roles.move_role_up_down",
|
||||
},
|
||||
LOGS: "admin_area.logs",
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue