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:
palash-signoz 2022-05-04 20:40:49 +05:30 committed by GitHub
parent 6223e89d4c
commit 9cf5c7ef74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 14 deletions

View File

@ -17,7 +17,7 @@ function AlertChannels({ allChannels }: AlertChannelsProps): JSX.Element {
const [notifications, Element] = notification.useNotification();
const [channels, setChannels] = useState<Channels[]>(allChannels);
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) => {
history.replace(

View File

@ -38,8 +38,8 @@ function ListOfAllDashboard(): JSX.Element {
);
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
const [action, createNewDashboard] = useComponentPermission(
['action', 'create_new_dashboards'],
const [action, createNewDashboard, newDashboard] = useComponentPermission(
['action', 'create_new_dashboards', 'new_dashboard'],
role,
);
@ -205,6 +205,7 @@ function ListOfAllDashboard(): JSX.Element {
url: 'https://signoz.io/docs/userguide/dashboards',
}}
/>
{newDashboard && (
<Dropdown trigger={['click']} overlay={menu}>
<NewDashboardButton
icon={<PlusOutlined />}
@ -215,10 +216,17 @@ function ListOfAllDashboard(): JSX.Element {
{getText()}
</NewDashboardButton>
</Dropdown>
)}
</ButtonContainer>
</Row>
),
[getText, menu, newDashboardState.error, newDashboardState.loading],
[
getText,
menu,
newDashboard,
newDashboardState.error,
newDashboardState.loading,
],
);
return (

View File

@ -14,8 +14,11 @@ export type ComponentTypes =
| 'save_layout'
| 'edit_dashboard'
| 'delete_widget'
| 'new_dashboard'
| 'new_alert_action';
| 'edit_widget';
export const componentPermission: Record<ComponentTypes, ROLES[]> = {
current_org_settings: ['ADMIN'],
invite_members: ['ADMIN'],
@ -29,7 +32,10 @@ export const componentPermission: Record<ComponentTypes, ROLES[]> = {
save_layout: ['ADMIN', 'EDITOR'],
edit_dashboard: ['ADMIN', 'EDITOR'],
delete_widget: ['ADMIN', 'EDITOR'],
new_dashboard: ['ADMIN', 'EDITOR'],
new_alert_action: ['ADMIN'],
edit_widget: ['ADMIN', 'EDITOR'],
};
export const routePermission: Record<keyof typeof ROUTES, ROLES[]> = {