Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

feat(FE): dashboard edit permission based on RBAC

Pranshu Chittorace14638a6345
diff --git a/frontend/src/container/GridGraphLayout/GraphLayout.tsx b/frontend/src/container/GridGraphLayout/GraphLayout.tsx
index 32b87ee09d..97fee8ec9d 100644
--- a/frontend/src/container/GridGraphLayout/GraphLayout.tsx
+++ b/frontend/src/container/GridGraphLayout/GraphLayout.tsx
@@ -29,12 +29,15 @@ function GraphLayout({
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
const { isDarkMode } = useSelector<AppState, AppReducer>((state) => state.app);
- const [saveLayout] = useComponentPermission(['save_layout'], role);
+ const [saveLayoutPermission, addPanelPermission] = useComponentPermission(
+ ['save_layout', 'add_panel'],
+ role,
+ );
return (
<>
<ButtonContainer>
- {saveLayout && (
+ {saveLayoutPermission && (
<Button
loading={saveLayoutState.loading}
onClick={(): Promise<void> => onLayoutSaveHandler(layouts)}
@@ -45,24 +48,26 @@ function GraphLayout({
</Button>
)}
- <Button
- loading={addPanelLoading}
- disabled={addPanelLoading}
- onClick={onAddPanelHandler}
- icon={<PlusOutlined />}
- >
- Add Panel
- </Button>
+ {addPanelPermission && (
+ <Button
+ loading={addPanelLoading}
+ disabled={addPanelLoading}
+ onClick={onAddPanelHandler}
+ icon={<PlusOutlined />}
+ >
+ Add Panel
+ </Button>
+ )}
</ButtonContainer>
<ReactGridLayout
- isResizable
cols={12}
rowHeight={100}
autoSize
width={100}
- isDraggable
- isDroppable
+ isDraggable={addPanelPermission}
+ isDroppable={addPanelPermission}
+ isResizable={addPanelPermission}
useCSSTransforms
allowOverlap={false}
onLayoutChange={onLayoutChangeHandler}
diff --git a/frontend/src/utils/permission/index.ts b/frontend/src/utils/permission/index.ts
index a4fe82b395..27fa273703 100644
--- a/frontend/src/utils/permission/index.ts
+++ b/frontend/src/utils/permission/index.ts
@@ -16,7 +16,8 @@ export type ComponentTypes =
| 'delete_widget'
| 'new_dashboard'
| 'new_alert_action'
- | 'edit_widget';
+ | 'edit_widget'
+ | 'add_panel';
export const componentPermission: Record<ComponentTypes, ROLES[]> = {
current_org_settings: ['ADMIN'],
@@ -34,6 +35,7 @@ export const componentPermission: Record<ComponentTypes, ROLES[]> = {
new_dashboard: ['ADMIN', 'EDITOR'],
new_alert_action: ['ADMIN'],
edit_widget: ['ADMIN', 'EDITOR'],
+ add_panel: ['ADMIN', 'EDITOR'],
};
export const routePermission: Record<keyof typeof ROUTES, ROLES[]> = {