mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 07:35:57 +08:00
feat: added user role restriction on crud for planned downtime feat (#7896)
This commit is contained in:
parent
9383b6576d
commit
9c298e83a5
@ -15,8 +15,10 @@ import cx from 'classnames';
|
|||||||
import { useNotifications } from 'hooks/useNotifications';
|
import { useNotifications } from 'hooks/useNotifications';
|
||||||
import { defaultTo } from 'lodash-es';
|
import { defaultTo } from 'lodash-es';
|
||||||
import { CalendarClock, PenLine, Trash2 } from 'lucide-react';
|
import { CalendarClock, PenLine, Trash2 } from 'lucide-react';
|
||||||
|
import { useAppContext } from 'providers/App/App';
|
||||||
import { ReactNode, useEffect } from 'react';
|
import { ReactNode, useEffect } from 'react';
|
||||||
import { UseQueryResult } from 'react-query';
|
import { UseQueryResult } from 'react-query';
|
||||||
|
import { USER_ROLES } from 'types/roles';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
formatDateTime,
|
formatDateTime,
|
||||||
@ -84,6 +86,8 @@ function HeaderComponent({
|
|||||||
handleEdit: () => void;
|
handleEdit: () => void;
|
||||||
handleDelete: () => void;
|
handleDelete: () => void;
|
||||||
}): JSX.Element {
|
}): JSX.Element {
|
||||||
|
const { user } = useAppContext();
|
||||||
|
const isCrudEnabled = user?.role !== USER_ROLES.VIEWER;
|
||||||
return (
|
return (
|
||||||
<Flex className="header-content" justify="space-between">
|
<Flex className="header-content" justify="space-between">
|
||||||
<Flex gap={8}>
|
<Flex gap={8}>
|
||||||
@ -91,25 +95,27 @@ function HeaderComponent({
|
|||||||
<Tag>{duration}</Tag>
|
<Tag>{duration}</Tag>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<div className="action-btn">
|
{isCrudEnabled && (
|
||||||
<PenLine
|
<div className="action-btn">
|
||||||
size={14}
|
<PenLine
|
||||||
onClick={(e): void => {
|
size={14}
|
||||||
e.preventDefault();
|
onClick={(e): void => {
|
||||||
e.stopPropagation();
|
e.preventDefault();
|
||||||
handleEdit();
|
e.stopPropagation();
|
||||||
}}
|
handleEdit();
|
||||||
/>
|
}}
|
||||||
<Trash2
|
/>
|
||||||
size={14}
|
<Trash2
|
||||||
color={Color.BG_CHERRY_500}
|
size={14}
|
||||||
onClick={(e): void => {
|
color={Color.BG_CHERRY_500}
|
||||||
e.preventDefault();
|
onClick={(e): void => {
|
||||||
e.stopPropagation();
|
e.preventDefault();
|
||||||
handleDelete();
|
e.stopPropagation();
|
||||||
}}
|
handleDelete();
|
||||||
/>
|
}}
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user