Commit d36efddc by Marcus Efraimsson Committed by GitHub

Merge pull request #11699 from grafana/11466-edit-row

fixed so user who can edit dashboard can edit row
parents 00555663 38a4a2dc
...@@ -4,7 +4,6 @@ import { PanelModel } from '../panel_model'; ...@@ -4,7 +4,6 @@ import { PanelModel } from '../panel_model';
import { PanelContainer } from './PanelContainer'; import { PanelContainer } from './PanelContainer';
import templateSrv from 'app/features/templating/template_srv'; import templateSrv from 'app/features/templating/template_srv';
import appEvents from 'app/core/app_events'; import appEvents from 'app/core/app_events';
import config from 'app/core/config';
export interface DashboardRowProps { export interface DashboardRowProps {
panel: PanelModel; panel: PanelModel;
...@@ -95,7 +94,7 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> { ...@@ -95,7 +94,7 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
{title} {title}
<span className="dashboard-row__panel_count">({hiddenPanels} hidden panels)</span> <span className="dashboard-row__panel_count">({hiddenPanels} hidden panels)</span>
</a> </a>
{config.bootData.user.orgRole !== 'Viewer' && ( {this.dashboard.meta.canEdit === true && (
<div className="dashboard-row__actions"> <div className="dashboard-row__actions">
<a className="pointer" onClick={this.openSettings}> <a className="pointer" onClick={this.openSettings}>
<i className="fa fa-cog" /> <i className="fa fa-cog" />
......
...@@ -2,17 +2,15 @@ import React from 'react'; ...@@ -2,17 +2,15 @@ import React from 'react';
import { shallow } from 'enzyme'; import { shallow } from 'enzyme';
import { DashboardRow } from '../dashgrid/DashboardRow'; import { DashboardRow } from '../dashgrid/DashboardRow';
import { PanelModel } from '../panel_model'; import { PanelModel } from '../panel_model';
import config from '../../../core/config';
describe('DashboardRow', () => { describe('DashboardRow', () => {
let wrapper, panel, getPanelContainer, dashboardMock; let wrapper, panel, getPanelContainer, dashboardMock;
beforeEach(() => { beforeEach(() => {
dashboardMock = { toggleRow: jest.fn() }; dashboardMock = {
toggleRow: jest.fn(),
config.bootData = { meta: {
user: { canEdit: true,
orgRole: 'Admin',
}, },
}; };
...@@ -41,8 +39,8 @@ describe('DashboardRow', () => { ...@@ -41,8 +39,8 @@ describe('DashboardRow', () => {
expect(wrapper.find('.dashboard-row__actions .pointer')).toHaveLength(2); expect(wrapper.find('.dashboard-row__actions .pointer')).toHaveLength(2);
}); });
it('should have zero actions as viewer', () => { it('should have zero actions when cannot edit', () => {
config.bootData.user.orgRole = 'Viewer'; dashboardMock.meta.canEdit = false;
panel = new PanelModel({ collapsed: false }); panel = new PanelModel({ collapsed: false });
wrapper = shallow(<DashboardRow panel={panel} getPanelContainer={getPanelContainer} />); wrapper = shallow(<DashboardRow panel={panel} getPanelContainer={getPanelContainer} />);
expect(wrapper.find('.dashboard-row__actions .pointer')).toHaveLength(0); expect(wrapper.find('.dashboard-row__actions .pointer')).toHaveLength(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment