permission handling
parent
3e74b28f73
commit
bd8ef90148
|
@ -1,6 +1,5 @@
|
|||
import { Route, Routes } from "react-router-dom";
|
||||
import Dashboard from "../../Pages/Dashboard";
|
||||
import GroupTasks from "../../Pages/GroupTasks";
|
||||
import {
|
||||
Constants,
|
||||
WebSocketContext,
|
||||
|
@ -13,6 +12,8 @@ import AdminAreaRoles from "../../Pages/AdminArea/Roles";
|
|||
import AdminAreaLogs from "../../Pages/AdminArea/Logs";
|
||||
import AllUsers from "../../Pages/AllUsers";
|
||||
import { useContext } from "react";
|
||||
import GroupTasks from "../../Pages/GroupTasks/Overview";
|
||||
import GroupTasksHistory from "../../Pages/GroupTasks/History";
|
||||
|
||||
export default function AppRoutes() {
|
||||
const webSocketContext = useContext(WebSocketContext);
|
||||
|
@ -29,6 +30,16 @@ export default function AppRoutes() {
|
|||
element={<GroupTasks isGroupTasksViewModalOpen={true} />}
|
||||
/>
|
||||
|
||||
{hasPermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.GROUP_TASKS.HISTORY
|
||||
) && (
|
||||
<Route
|
||||
path={Constants.ROUTE_PATHS.GROUP_TASKS + "-history"}
|
||||
element={<GroupTasksHistory />}
|
||||
/>
|
||||
)}
|
||||
|
||||
{hasPermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.SCANNER.USE_SCANNERS
|
||||
|
@ -42,8 +53,7 @@ export default function AppRoutes() {
|
|||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.ADD_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.UPDATE_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.DELETE_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.ADD_USER_TO_ROLE
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.DELETE_ROLE
|
||||
) && <Route path="/admin-area/roles" element={<AdminAreaRoles />} />}
|
||||
|
||||
{hasPermission(
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
MyAvatar,
|
||||
WebSocketContext,
|
||||
getUserId,
|
||||
hasOnePermission,
|
||||
hasPermission,
|
||||
} from "../../utils";
|
||||
|
||||
|
@ -48,7 +49,9 @@ export default function SideMenu({ userSession, setUserSession }) {
|
|||
icon: <AppstoreOutlined />,
|
||||
key: "/",
|
||||
},
|
||||
{
|
||||
];
|
||||
|
||||
let groupTasks = {
|
||||
label: "Group Tasks",
|
||||
type: "group",
|
||||
children: [
|
||||
|
@ -57,43 +60,75 @@ export default function SideMenu({ userSession, setUserSession }) {
|
|||
icon: <SnippetsOutlined />,
|
||||
key: "/group-tasks",
|
||||
},
|
||||
{
|
||||
label: "History",
|
||||
icon: <HistoryOutlined />,
|
||||
key: "/group-tasks-history",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: "divider",
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
if (
|
||||
hasPermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.ADD_ROLE
|
||||
Constants.PERMISSIONS.GROUP_TASKS.HISTORY
|
||||
)
|
||||
) {
|
||||
groupTasks.children.push({
|
||||
label: "History",
|
||||
icon: <HistoryOutlined />,
|
||||
key: "/group-tasks-history",
|
||||
});
|
||||
}
|
||||
|
||||
items.push(groupTasks);
|
||||
|
||||
items.push({
|
||||
type: "divider",
|
||||
});
|
||||
|
||||
if (
|
||||
hasOnePermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.ADD_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.UPDATE_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.DELETE_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.LOGS
|
||||
)
|
||||
) {
|
||||
let adminArea = {
|
||||
label: "Admin Area",
|
||||
icon: <SettingOutlined />,
|
||||
key: "/admin-area",
|
||||
children: [
|
||||
{
|
||||
children: [],
|
||||
};
|
||||
|
||||
if (
|
||||
hasOnePermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.ADD_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.UPDATE_ROLE,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.ROLES.DELETE_ROLE
|
||||
)
|
||||
) {
|
||||
adminArea.children.push({
|
||||
label: "Roles",
|
||||
icon: <UsergroupAddOutlined />,
|
||||
key: "/admin-area/roles",
|
||||
},
|
||||
{
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
hasPermission(
|
||||
webSocketContext.User.Permissions,
|
||||
Constants.PERMISSIONS.ADMIN_AREA.LOGS
|
||||
)
|
||||
) {
|
||||
adminArea.children.push({
|
||||
label: "Logs",
|
||||
icon: <FileTextOutlined />,
|
||||
key: "/admin-area/logs",
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
items.push(adminArea);
|
||||
}
|
||||
|
||||
return items;
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export default function GroupTasksHistory() {
|
||||
return <p>GroupTasksHistory</p>;
|
||||
}
|
|
@ -16,7 +16,7 @@ import {
|
|||
MyAvatar,
|
||||
SentMessagesCommands,
|
||||
WebSocketContext,
|
||||
} from "../../utils";
|
||||
} from "../../../utils";
|
||||
import { useContext } from "react";
|
||||
|
||||
const columns = [
|
|
@ -25,7 +25,7 @@ import {
|
|||
MyAvatar,
|
||||
getUserId,
|
||||
GroupTasksStepsLockedAndUserUpdateInputValueRememberId,
|
||||
} from "../../utils";
|
||||
} from "../../../utils";
|
||||
import {
|
||||
FileImageOutlined,
|
||||
InfoCircleOutlined,
|
|
@ -10,7 +10,7 @@ import {
|
|||
Tag,
|
||||
notification,
|
||||
} from "antd";
|
||||
import { WebSocketContext, SentMessagesCommands } from "../../utils";
|
||||
import { WebSocketContext, SentMessagesCommands } from "../../../utils";
|
||||
import { useContext } from "react";
|
||||
import { InfoCircleOutlined } from "@ant-design/icons";
|
||||
import TextArea from "antd/es/input/TextArea";
|
|
@ -2,8 +2,8 @@ import { Result } from "antd";
|
|||
import { useContext, useState } from "react";
|
||||
import GroupTasksViewModal from "./GroupTasksViewModal";
|
||||
import GroupTypeSelectionModal from "./GroupTypeSelectionModal";
|
||||
import { WebSocketContext } from "../../utils";
|
||||
import GroupTaskTableList from "./GroupTasksTableList";
|
||||
import { WebSocketContext } from "../../../utils";
|
||||
|
||||
export default function GroupTasks({ isGroupTasksViewModalOpen }) {
|
||||
const [isGroupTypeSelectionModalOpen, setIsGroupTypeSelectionModalOpen] =
|
|
@ -41,6 +41,9 @@ export const Constants = {
|
|||
MAX_AVATAR_SIZE: 5 * 1024 * 1024,
|
||||
ACCEPTED_FILE_TYPES: ["image/png", "image/jpeg", "image/jpg"],
|
||||
PERMISSIONS: {
|
||||
GROUP_TASKS: {
|
||||
HISTORY: "group_tasks.history",
|
||||
},
|
||||
ALL_USERS: {
|
||||
ACTION: {
|
||||
CHANGE_ROLE: "all_users.action.change_role",
|
||||
|
@ -54,7 +57,6 @@ export const Constants = {
|
|||
ADD_ROLE: "admin_area.roles.add_role",
|
||||
UPDATE_ROLE: "admin_area.roles.update_role",
|
||||
DELETE_ROLE: "admin_area.roles.delete_role",
|
||||
ADD_USER_TO_ROLE: "admin_area.roles.add_user_to_role",
|
||||
},
|
||||
LOGS: "admin_area.logs",
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue