mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 11:55:52 +08:00
chore: new dashboard permission is added for editor and admin (#1077)
* chore: new dashboard permission is added for editor and admin
This commit is contained in:
parent
6223e89d4c
commit
9cf5c7ef74
@ -17,7 +17,7 @@ function AlertChannels({ allChannels }: AlertChannelsProps): JSX.Element {
|
|||||||
const [notifications, Element] = notification.useNotification();
|
const [notifications, Element] = notification.useNotification();
|
||||||
const [channels, setChannels] = useState<Channels[]>(allChannels);
|
const [channels, setChannels] = useState<Channels[]>(allChannels);
|
||||||
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
||||||
const [action] = useComponentPermission(['action'], role);
|
const [action] = useComponentPermission(['new_alert_action'], role);
|
||||||
|
|
||||||
const onClickEditHandler = useCallback((id: string) => {
|
const onClickEditHandler = useCallback((id: string) => {
|
||||||
history.replace(
|
history.replace(
|
||||||
|
@ -38,8 +38,8 @@ function ListOfAllDashboard(): JSX.Element {
|
|||||||
);
|
);
|
||||||
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
||||||
|
|
||||||
const [action, createNewDashboard] = useComponentPermission(
|
const [action, createNewDashboard, newDashboard] = useComponentPermission(
|
||||||
['action', 'create_new_dashboards'],
|
['action', 'create_new_dashboards', 'new_dashboard'],
|
||||||
role,
|
role,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -205,20 +205,28 @@ function ListOfAllDashboard(): JSX.Element {
|
|||||||
url: 'https://signoz.io/docs/userguide/dashboards',
|
url: 'https://signoz.io/docs/userguide/dashboards',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Dropdown trigger={['click']} overlay={menu}>
|
{newDashboard && (
|
||||||
<NewDashboardButton
|
<Dropdown trigger={['click']} overlay={menu}>
|
||||||
icon={<PlusOutlined />}
|
<NewDashboardButton
|
||||||
type="primary"
|
icon={<PlusOutlined />}
|
||||||
loading={newDashboardState.loading}
|
type="primary"
|
||||||
danger={newDashboardState.error}
|
loading={newDashboardState.loading}
|
||||||
>
|
danger={newDashboardState.error}
|
||||||
{getText()}
|
>
|
||||||
</NewDashboardButton>
|
{getText()}
|
||||||
</Dropdown>
|
</NewDashboardButton>
|
||||||
|
</Dropdown>
|
||||||
|
)}
|
||||||
</ButtonContainer>
|
</ButtonContainer>
|
||||||
</Row>
|
</Row>
|
||||||
),
|
),
|
||||||
[getText, menu, newDashboardState.error, newDashboardState.loading],
|
[
|
||||||
|
getText,
|
||||||
|
menu,
|
||||||
|
newDashboard,
|
||||||
|
newDashboardState.error,
|
||||||
|
newDashboardState.loading,
|
||||||
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -14,8 +14,11 @@ export type ComponentTypes =
|
|||||||
| 'save_layout'
|
| 'save_layout'
|
||||||
| 'edit_dashboard'
|
| 'edit_dashboard'
|
||||||
| 'delete_widget'
|
| 'delete_widget'
|
||||||
|
| 'new_dashboard'
|
||||||
|
| 'new_alert_action';
|
||||||
| 'edit_widget';
|
| 'edit_widget';
|
||||||
|
|
||||||
|
|
||||||
export const componentPermission: Record<ComponentTypes, ROLES[]> = {
|
export const componentPermission: Record<ComponentTypes, ROLES[]> = {
|
||||||
current_org_settings: ['ADMIN'],
|
current_org_settings: ['ADMIN'],
|
||||||
invite_members: ['ADMIN'],
|
invite_members: ['ADMIN'],
|
||||||
@ -29,7 +32,10 @@ export const componentPermission: Record<ComponentTypes, ROLES[]> = {
|
|||||||
save_layout: ['ADMIN', 'EDITOR'],
|
save_layout: ['ADMIN', 'EDITOR'],
|
||||||
edit_dashboard: ['ADMIN', 'EDITOR'],
|
edit_dashboard: ['ADMIN', 'EDITOR'],
|
||||||
delete_widget: ['ADMIN', 'EDITOR'],
|
delete_widget: ['ADMIN', 'EDITOR'],
|
||||||
|
new_dashboard: ['ADMIN', 'EDITOR'],
|
||||||
|
new_alert_action: ['ADMIN'],
|
||||||
edit_widget: ['ADMIN', 'EDITOR'],
|
edit_widget: ['ADMIN', 'EDITOR'],
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const routePermission: Record<keyof typeof ROUTES, ROLES[]> = {
|
export const routePermission: Record<keyof typeof ROUTES, ROLES[]> = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user