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
460d642b
Commit
460d642b
authored
Nov 28, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sorting tests
parent
e74db94a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
18 deletions
+19
-18
public/app/plugins/panel/gauge/Threshold.test.tsx
+18
-16
public/app/plugins/panel/gauge/Thresholds.tsx
+1
-2
No files found.
public/app/plugins/panel/gauge/Threshold.test.tsx
View file @
460d642b
...
...
@@ -15,6 +15,12 @@ const setup = (propOverrides?: object) => {
return
shallow
(<
Thresholds
{
...
props
}
/>).
instance
()
as
Thresholds
;
};
const
thresholds
=
[
{
index
:
0
,
label
:
'Min'
,
value
:
0
,
canRemove
:
false
,
color
:
'#3aa655'
},
{
index
:
1
,
label
:
''
,
value
:
50
,
canRemove
:
true
,
color
:
'#ff851b'
},
{
index
:
2
,
label
:
'Max'
,
value
:
100
,
canRemove
:
false
},
];
describe
(
'Add threshold'
,
()
=>
{
it
(
'should add threshold between min and max'
,
()
=>
{
const
instance
=
setup
();
...
...
@@ -22,8 +28,8 @@ describe('Add threshold', () => {
instance
.
onAddThreshold
(
1
);
expect
(
instance
.
state
.
thresholds
).
toEqual
([
{
index
:
0
,
label
:
'Min'
,
value
:
0
,
canRemove
:
false
},
{
index
:
1
,
label
:
''
,
value
:
50
,
canRemove
:
true
},
{
index
:
0
,
label
:
'Min'
,
value
:
0
,
canRemove
:
false
,
color
:
'#3aa655'
},
{
index
:
1
,
label
:
''
,
value
:
50
,
canRemove
:
true
,
color
:
'#ff851b'
},
{
index
:
2
,
label
:
'Max'
,
value
:
100
,
canRemove
:
false
},
]);
});
...
...
@@ -32,20 +38,16 @@ describe('Add threshold', () => {
const
instance
=
setup
();
instance
.
state
=
{
thresholds
:
[
{
index
:
0
,
label
:
'Min'
,
value
:
0
,
canRemove
:
false
},
{
index
:
1
,
label
:
''
,
value
:
50
,
canRemove
:
true
},
{
index
:
2
,
label
:
'Max'
,
value
:
100
,
canRemove
:
false
},
],
thresholds
:
thresholds
,
userAddedThresholds
:
1
,
};
instance
.
onAddThreshold
(
1
);
expect
(
instance
.
state
.
thresholds
).
toEqual
([
{
index
:
0
,
label
:
'Min'
,
value
:
0
,
canRemove
:
false
},
{
index
:
1
,
label
:
''
,
value
:
25
,
canRemove
:
true
},
{
index
:
2
,
label
:
''
,
value
:
50
,
canRemove
:
true
},
{
index
:
0
,
label
:
'Min'
,
value
:
0
,
canRemove
:
false
,
color
:
'#3aa655'
},
{
index
:
1
,
label
:
''
,
value
:
25
,
canRemove
:
true
,
color
:
'#ff851b'
},
{
index
:
2
,
label
:
''
,
value
:
50
,
canRemove
:
true
,
color
:
'#ff851b'
},
{
index
:
3
,
label
:
'Max'
,
value
:
100
,
canRemove
:
false
},
]);
});
...
...
@@ -114,9 +116,9 @@ describe('change threshold value', () => {
it
(
'should update value and resort rows'
,
()
=>
{
const
instance
=
setup
();
const
mockThresholds
=
[
{
index
:
0
,
label
:
'Min'
,
value
:
0
,
canRemove
:
false
},
{
index
:
1
,
label
:
''
,
value
:
50
,
canRemove
:
true
},
{
index
:
2
,
label
:
''
,
value
:
75
,
canRemove
:
true
},
{
index
:
0
,
label
:
'Min'
,
value
:
0
,
canRemove
:
false
,
color
:
'#3aa655'
},
{
index
:
1
,
label
:
''
,
value
:
50
,
canRemove
:
true
,
color
:
'#ff851b'
},
{
index
:
2
,
label
:
''
,
value
:
75
,
canRemove
:
true
,
color
:
'#ff851b'
},
{
index
:
3
,
label
:
'Max'
,
value
:
100
,
canRemove
:
false
},
];
...
...
@@ -130,9 +132,9 @@ describe('change threshold value', () => {
instance
.
onChangeThresholdValue
(
mockEvent
,
mockThresholds
[
1
]);
expect
(
instance
.
state
.
thresholds
).
toEqual
([
{
index
:
0
,
label
:
'Min'
,
value
:
0
,
canRemove
:
false
},
{
index
:
1
,
label
:
''
,
value
:
7
5
,
canRemove
:
true
},
{
index
:
2
,
label
:
''
,
value
:
7
8
,
canRemove
:
true
},
{
index
:
0
,
label
:
'Min'
,
value
:
0
,
canRemove
:
false
,
color
:
'#3aa655'
},
{
index
:
1
,
label
:
''
,
value
:
7
8
,
canRemove
:
true
,
color
:
'#ff851b'
},
{
index
:
2
,
label
:
''
,
value
:
7
5
,
canRemove
:
true
,
color
:
'#ff851b'
},
{
index
:
3
,
label
:
'Max'
,
value
:
100
,
canRemove
:
false
},
]);
});
...
...
public/app/plugins/panel/gauge/Thresholds.tsx
View file @
460d642b
...
...
@@ -23,10 +23,9 @@ export default class Thresholds extends PureComponent<PanelOptionsProps<OptionsP
}
onAddThreshold
=
index
=>
{
console
.
log
(
'add at index'
,
index
);
const
{
thresholds
}
=
this
.
state
;
const
newThresholds
=
thresholds
.
map
(
(
threshold
,
index
)
=>
{
const
newThresholds
=
thresholds
.
map
(
threshold
=>
{
if
(
threshold
.
index
>=
index
)
{
threshold
=
{
...
threshold
,
index
:
threshold
.
index
+
1
};
}
...
...
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