diff --git a/public/app/features/dashboard/dashgrid/DashboardRow.tsx b/public/app/features/dashboard/dashgrid/DashboardRow.tsx index 7a4d6cf8070..c2a84cb7da9 100644 --- a/public/app/features/dashboard/dashgrid/DashboardRow.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardRow.tsx @@ -4,6 +4,7 @@ import { PanelModel } from '../panel_model'; import { PanelContainer } from './PanelContainer'; import templateSrv from 'app/features/templating/template_srv'; import appEvents from 'app/core/app_events'; +import config from 'app/core/config'; export interface DashboardRowProps { panel: PanelModel; @@ -94,14 +95,16 @@ export class DashboardRow extends React.Component { {title} ({hiddenPanels} hidden panels) -
- - - - - - -
+ {config.bootData.user.orgRole !== 'Viewer' && ( +
+ + + + + + +
+ )}
); diff --git a/public/app/features/dashboard/specs/DashboardRow.jest.tsx b/public/app/features/dashboard/specs/DashboardRow.jest.tsx index 2d44f2e0e74..c0ac172aa26 100644 --- a/public/app/features/dashboard/specs/DashboardRow.jest.tsx +++ b/public/app/features/dashboard/specs/DashboardRow.jest.tsx @@ -2,19 +2,26 @@ import React from 'react'; import { shallow } from 'enzyme'; import { DashboardRow } from '../dashgrid/DashboardRow'; import { PanelModel } from '../panel_model'; +import config from '../../../core/config'; describe('DashboardRow', () => { let wrapper, panel, getPanelContainer, dashboardMock; beforeEach(() => { - dashboardMock = {toggleRow: jest.fn()}; + dashboardMock = { toggleRow: jest.fn() }; + + config.bootData = { + user: { + orgRole: 'Admin', + }, + }; getPanelContainer = jest.fn().mockReturnValue({ getDashboard: jest.fn().mockReturnValue(dashboardMock), - getPanelLoader: jest.fn() + getPanelLoader: jest.fn(), }); - panel = new PanelModel({collapsed: false}); + panel = new PanelModel({ collapsed: false }); wrapper = shallow(); }); @@ -30,4 +37,14 @@ describe('DashboardRow', () => { expect(dashboardMock.toggleRow.mock.calls).toHaveLength(1); }); + it('should have two actions as admin', () => { + expect(wrapper.find('.dashboard-row__actions .pointer')).toHaveLength(2); + }); + + it('should have zero actions as viewer', () => { + config.bootData.user.orgRole = 'Viewer'; + panel = new PanelModel({ collapsed: false }); + wrapper = shallow(); + expect(wrapper.find('.dashboard-row__actions .pointer')).toHaveLength(0); + }); });