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
da80286f
Commit
da80286f
authored
Feb 12, 2019
by
Hugo Häggmark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #15372 with number input and parseFloat
parent
1407691d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.test.tsx
+3
-3
packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.tsx
+8
-9
No files found.
packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.test.tsx
View file @
da80286f
import
React
from
'react'
;
import
React
,
{
ChangeEvent
}
from
'react'
;
import
{
shallow
}
from
'enzyme'
;
import
{
shallow
}
from
'enzyme'
;
import
{
ThresholdsEditor
,
Props
}
from
'./ThresholdsEditor'
;
import
{
ThresholdsEditor
,
Props
}
from
'./ThresholdsEditor'
;
...
@@ -118,7 +118,7 @@ describe('change threshold value', () => {
...
@@ -118,7 +118,7 @@ describe('change threshold value', () => {
];
];
const
instance
=
setup
({
thresholds
});
const
instance
=
setup
({
thresholds
});
const
mockEvent
=
{
target
:
{
value
:
12
}
}
;
const
mockEvent
=
({
target
:
{
value
:
'12'
}
}
as
any
)
as
ChangeEvent
<
HTMLInputElement
>
;
instance
.
onChangeThresholdValue
(
mockEvent
,
thresholds
[
0
]);
instance
.
onChangeThresholdValue
(
mockEvent
,
thresholds
[
0
]);
...
@@ -137,7 +137,7 @@ describe('change threshold value', () => {
...
@@ -137,7 +137,7 @@ describe('change threshold value', () => {
thresholds
,
thresholds
,
};
};
const
mockEvent
=
{
target
:
{
value
:
78
}
}
;
const
mockEvent
=
({
target
:
{
value
:
'78'
}
}
as
any
)
as
ChangeEvent
<
HTMLInputElement
>
;
instance
.
onChangeThresholdValue
(
mockEvent
,
thresholds
[
1
]);
instance
.
onChangeThresholdValue
(
mockEvent
,
thresholds
[
1
]);
...
...
packages/grafana-ui/src/components/ThresholdsEditor/ThresholdsEditor.tsx
View file @
da80286f
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
,
ChangeEvent
}
from
'react'
;
import
{
Threshold
}
from
'../../types'
;
import
{
Threshold
}
from
'../../types'
;
import
{
ColorPicker
}
from
'../ColorPicker/ColorPicker'
;
import
{
ColorPicker
}
from
'../ColorPicker/ColorPicker'
;
import
{
PanelOptionsGroup
}
from
'../PanelOptionsGroup/PanelOptionsGroup'
;
import
{
PanelOptionsGroup
}
from
'../PanelOptionsGroup/PanelOptionsGroup'
;
...
@@ -94,14 +94,15 @@ export class ThresholdsEditor extends PureComponent<Props, State> {
...
@@ -94,14 +94,15 @@ export class ThresholdsEditor extends PureComponent<Props, State> {
);
);
};
};
onChangeThresholdValue
=
(
event
:
any
,
threshold
:
Threshold
)
=>
{
onChangeThresholdValue
=
(
event
:
ChangeEvent
<
HTMLInputElement
>
,
threshold
:
Threshold
)
=>
{
if
(
threshold
.
index
===
0
)
{
if
(
threshold
.
index
===
0
)
{
return
;
return
;
}
}
const
{
thresholds
}
=
this
.
state
;
const
{
thresholds
}
=
this
.
state
;
const
parsedValue
=
parseInt
(
event
.
target
.
value
,
10
);
const
cleanValue
=
event
.
target
.
value
.
replace
(
/,/g
,
'.'
);
const
value
=
isNaN
(
parsedValue
)
?
null
:
parsedValue
;
const
parsedValue
=
parseFloat
(
cleanValue
);
const
value
=
isNaN
(
parsedValue
)
?
''
:
parsedValue
;
const
newThresholds
=
thresholds
.
map
(
t
=>
{
const
newThresholds
=
thresholds
.
map
(
t
=>
{
if
(
t
===
threshold
&&
t
.
index
!==
0
)
{
if
(
t
===
threshold
&&
t
.
index
!==
0
)
{
...
@@ -164,16 +165,14 @@ export class ThresholdsEditor extends PureComponent<Props, State> {
...
@@ -164,16 +165,14 @@ export class ThresholdsEditor extends PureComponent<Props, State> {
<
div
className=
"thresholds-row-input-inner-color"
>
<
div
className=
"thresholds-row-input-inner-color"
>
{
threshold
.
color
&&
(
{
threshold
.
color
&&
(
<
div
className=
"thresholds-row-input-inner-color-colorpicker"
>
<
div
className=
"thresholds-row-input-inner-color-colorpicker"
>
<
ColorPicker
<
ColorPicker
color=
{
threshold
.
color
}
onChange=
{
color
=>
this
.
onChangeThresholdColor
(
threshold
,
color
)
}
/>
color=
{
threshold
.
color
}
onChange=
{
color
=>
this
.
onChangeThresholdColor
(
threshold
,
color
)
}
/>
</
div
>
</
div
>
)
}
)
}
</
div
>
</
div
>
<
div
className=
"thresholds-row-input-inner-value"
>
<
div
className=
"thresholds-row-input-inner-value"
>
<
input
<
input
type=
"text"
type=
"number"
step=
"0.0001"
onChange=
{
event
=>
this
.
onChangeThresholdValue
(
event
,
threshold
)
}
onChange=
{
event
=>
this
.
onChangeThresholdValue
(
event
,
threshold
)
}
value=
{
value
}
value=
{
value
}
onBlur=
{
this
.
onBlur
}
onBlur=
{
this
.
onBlur
}
...
...
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