Skip to content

Commit

Permalink
Checks for permissions on monitor page for delete/edit button
Browse files Browse the repository at this point in the history
  • Loading branch information
KSJaay committed Nov 21, 2024
1 parent ec6f5b3 commit 4021409
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions app/components/monitor/menu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ const MonitorMenu = ({ name = 'Unknown', monitorId }) => {
const {
modalStore: { openModal, closeModal },
globalStore: { getMonitor, editMonitor, removeMonitor },
userStore: { user },
} = useContextStore();
const navigate = useNavigate();

const isEditor = user.permission <= 3;

const handleConfirm = async () => {
await createGetRequest('/api/monitor/delete', {
monitorId,
Expand Down Expand Up @@ -65,20 +68,24 @@ const MonitorMenu = ({ name = 'Unknown', monitorId }) => {
</div>
{/* <Button iconLeft={<FaTrashCan style={{ width: '20px', height: '20px' }} />}>Pause</Button> */}
{/* <Button iconLeft={<FaTrashCan style={{ width: '20px', height: '20px' }} />}>Duplicate</Button> */}
<Button
id="monitor-edit-button"
iconLeft={<MdEdit style={{ width: '20px', height: '20px' }} />}
onClick={handleEdit}
>
Edit
</Button>
<Button
id="monitor-delete-button"
iconLeft={<FaTrashCan style={{ width: '20px', height: '20px' }} />}
onClick={handleDelete}
>
Delete
</Button>
{isEditor && (
<>
<Button
id="monitor-edit-button"
iconLeft={<MdEdit style={{ width: '20px', height: '20px' }} />}
onClick={handleEdit}
>
Edit
</Button>
<Button
id="monitor-delete-button"
iconLeft={<FaTrashCan style={{ width: '20px', height: '20px' }} />}
onClick={handleDelete}
>
Delete
</Button>
</>
)}
</div>
);
};
Expand Down

0 comments on commit 4021409

Please sign in to comment.