Hide infra manage buttons if not allowed
This commit is contained in:
parent
028f717ae2
commit
2e2a5438d8
@ -3,7 +3,7 @@ import AssignRoleModel from "../AssignRole";
|
||||
import { useParams } from "react-router-dom";
|
||||
//import EditActivityModal from "./EditActivityModal";
|
||||
import { useHasUserPermission } from "../../../hooks/useHasUserPermission";
|
||||
import { MANAGE_TASK } from "../../../utils/constants";
|
||||
import { MANAGE_PROJECT_INFRA, MANAGE_TASK } from "../../../utils/constants";
|
||||
|
||||
const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => {
|
||||
const { projectId } = useParams();
|
||||
@ -12,6 +12,8 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => {
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
const ManageTasks = useHasUserPermission(MANAGE_TASK);
|
||||
const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA);
|
||||
|
||||
const openModal = () => setIsModalOpen(true);
|
||||
const closeModal = () => setIsModalOpen(false);
|
||||
const getProgress = (planned, completed) => {
|
||||
@ -138,67 +140,75 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => {
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
aria-label="Modify"
|
||||
type="button"
|
||||
className="btn p-0 dropdown-toggle hide-arrow"
|
||||
onClick={showModal1}
|
||||
>
|
||||
<i
|
||||
className="bx bxs-edit me-2 text-primary"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="Edit Activity"
|
||||
data-bs-original-title="Edit Activity"
|
||||
></i>
|
||||
</button>
|
||||
<button
|
||||
aria-label="Delete"
|
||||
type="button"
|
||||
className="btn p-0 dropdown-toggle hide-arrow"
|
||||
onClick={showModal1}
|
||||
>
|
||||
<i
|
||||
className="bx bx-trash me-1 text-danger"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="Delete Activity"
|
||||
data-bs-original-title="Delete Activity"
|
||||
></i>
|
||||
</button>
|
||||
{!projectId && ManageInfra && (
|
||||
<>
|
||||
<button
|
||||
aria-label="Modify"
|
||||
type="button"
|
||||
className="btn p-0 dropdown-toggle hide-arrow"
|
||||
onClick={showModal1}
|
||||
>
|
||||
<i
|
||||
className="bx bxs-edit me-2 text-primary"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="Edit Activity"
|
||||
data-bs-original-title="Edit Activity"
|
||||
></i>
|
||||
</button>
|
||||
<button
|
||||
aria-label="Delete"
|
||||
type="button"
|
||||
className="btn p-0 dropdown-toggle hide-arrow"
|
||||
onClick={showModal1}
|
||||
>
|
||||
<i
|
||||
className="bx bx-trash me-1 text-danger"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="Delete Activity"
|
||||
data-bs-original-title="Delete Activity"
|
||||
></i>
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
<td className="text-end d-sm-none d-sm-table-cell">
|
||||
<div className="d-flex align-items-center justify-content-center ">
|
||||
<a
|
||||
className={`btn btn-icon dropdown-toggle hide-arrow`}
|
||||
data-bs-toggle="dropdown"
|
||||
>
|
||||
<i className="bx bx-dots-vertical-rounded bx-md"></i>
|
||||
</a>
|
||||
|
||||
<div className="dropdown-menu dropdown-menu-end m-0">
|
||||
{" "}
|
||||
<a className="dropdown-item " onClick={showModal1}>
|
||||
{" "}
|
||||
<i className="bx bxs-edit me-2 text-primary"></i>Edit
|
||||
</a>
|
||||
<a className="dropdown-item" onClick={showModal1}>
|
||||
{" "}
|
||||
<i className="bx bx-trash me-1 text-danger"></i>Delete
|
||||
</a>
|
||||
{!projectId && (
|
||||
{ManageInfra && (
|
||||
<>
|
||||
<a
|
||||
className="dropdown-item"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#project-modal"
|
||||
onClick={openModal}
|
||||
className={`btn btn-icon dropdown-toggle hide-arrow`}
|
||||
data-bs-toggle="dropdown"
|
||||
>
|
||||
{" "}
|
||||
<i className="bx bx-task me-1 text-info"></i>Assign
|
||||
<i className="bx bx-dots-vertical-rounded bx-md"></i>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="dropdown-menu dropdown-menu-end m-0">
|
||||
{" "}
|
||||
<a className="dropdown-item " onClick={showModal1}>
|
||||
{" "}
|
||||
<i className="bx bxs-edit me-2 text-primary"></i>Edit
|
||||
</a>
|
||||
<a className="dropdown-item" onClick={showModal1}>
|
||||
{" "}
|
||||
<i className="bx bx-trash me-1 text-danger"></i>Delete
|
||||
</a>
|
||||
{!projectId && (
|
||||
<a
|
||||
className="dropdown-item"
|
||||
data-bs-toggle="modal"
|
||||
data-bs-target="#project-modal"
|
||||
onClick={openModal}
|
||||
>
|
||||
{" "}
|
||||
<i className="bx bx-task me-1 text-info"></i>Assign
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user