Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
4acc8f8a
Unverified
Commit
4acc8f8a
authored
Mar 07, 2018
by
Daniel Lee
Committed by
GitHub
Mar 07, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11119 from bergquist/no_row_setting_viewer
hide row actions for viewers
parents
310d7406
d3b23b01
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
public/app/features/dashboard/dashgrid/DashboardRow.tsx
+3
-0
public/app/features/dashboard/specs/DashboardRow.jest.tsx
+20
-3
No files found.
public/app/features/dashboard/dashgrid/DashboardRow.tsx
View file @
4acc8f8a
...
@@ -4,6 +4,7 @@ import { PanelModel } from '../panel_model';
...
@@ -4,6 +4,7 @@ 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
;
...
@@ -94,6 +95,7 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
...
@@ -94,6 +95,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'
&&
(
<
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"
/>
...
@@ -102,6 +104,7 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
...
@@ -102,6 +104,7 @@ export class DashboardRow extends React.Component<DashboardRowProps, any> {
<
i
className=
"fa fa-trash"
/>
<
i
className=
"fa fa-trash"
/>
</
a
>
</
a
>
</
div
>
</
div
>
)
}
<
div
className=
"dashboard-row__drag grid-drag-handle"
/>
<
div
className=
"dashboard-row__drag grid-drag-handle"
/>
</
div
>
</
div
>
);
);
...
...
public/app/features/dashboard/specs/DashboardRow.jest.tsx
View file @
4acc8f8a
...
@@ -2,19 +2,26 @@ import React from 'react';
...
@@ -2,19 +2,26 @@ 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
=
{
user
:
{
orgRole
:
'Admin'
,
},
};
getPanelContainer
=
jest
.
fn
().
mockReturnValue
({
getPanelContainer
=
jest
.
fn
().
mockReturnValue
({
getDashboard
:
jest
.
fn
().
mockReturnValue
(
dashboardMock
),
getDashboard
:
jest
.
fn
().
mockReturnValue
(
dashboardMock
),
getPanelLoader
:
jest
.
fn
()
getPanelLoader
:
jest
.
fn
()
,
});
});
panel
=
new
PanelModel
({
collapsed
:
false
});
panel
=
new
PanelModel
({
collapsed
:
false
});
wrapper
=
shallow
(<
DashboardRow
panel=
{
panel
}
getPanelContainer=
{
getPanelContainer
}
/>);
wrapper
=
shallow
(<
DashboardRow
panel=
{
panel
}
getPanelContainer=
{
getPanelContainer
}
/>);
});
});
...
@@ -30,4 +37,14 @@ describe('DashboardRow', () => {
...
@@ -30,4 +37,14 @@ describe('DashboardRow', () => {
expect
(
dashboardMock
.
toggleRow
.
mock
.
calls
).
toHaveLength
(
1
);
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
(<
DashboardRow
panel=
{
panel
}
getPanelContainer=
{
getPanelContainer
}
/>);
expect
(
wrapper
.
find
(
'.dashboard-row__actions .pointer'
)).
toHaveLength
(
0
);
});
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment