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
e69ec6ca
Unverified
Commit
e69ec6ca
authored
Dec 12, 2019
by
Hugo Häggmark
Committed by
GitHub
Dec 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prometheus: Fixes so user can change HTTP Method in config (#21055)
Fixes #21004
parent
4e1e0b90
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
3 deletions
+43
-3
public/app/plugins/datasource/prometheus/configuration/PromSettings.test.tsx
+28
-0
public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx
+15
-3
No files found.
public/app/plugins/datasource/prometheus/configuration/PromSettings.test.tsx
0 → 100644
View file @
e69ec6ca
import
{
getValueFromEventItem
}
from
'./PromSettings'
;
describe
(
'PromSettings'
,
()
=>
{
describe
(
'getValueFromEventItem'
,
()
=>
{
describe
(
'when called with undefined'
,
()
=>
{
it
(
'then it should return empty string'
,
()
=>
{
const
result
=
getValueFromEventItem
(
undefined
);
expect
(
result
).
toEqual
(
''
);
});
});
describe
(
'when called with an input event'
,
()
=>
{
it
(
'then it should return value from currentTarget'
,
()
=>
{
const
value
=
'An input value'
;
const
result
=
getValueFromEventItem
({
currentTarget
:
{
value
}
});
expect
(
result
).
toEqual
(
value
);
});
});
describe
(
'when called with a select event'
,
()
=>
{
it
(
'then it should return value'
,
()
=>
{
const
value
=
'A select value'
;
const
result
=
getValueFromEventItem
({
value
});
expect
(
result
).
toEqual
(
value
);
});
});
});
});
public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx
View file @
e69ec6ca
import
React
,
{
SyntheticEvent
}
from
'react'
;
import
{
EventsWithValidation
,
FormField
,
FormLabel
,
Input
,
regexValidation
,
Select
}
from
'@grafana/ui'
;
import
{
DataSourceSettings
}
from
'@grafana/data'
;
import
{
DataSourceSettings
,
SelectableValue
}
from
'@grafana/data'
;
import
{
PromOptions
}
from
'../types'
;
const
httpOptions
=
[
...
...
@@ -112,14 +112,26 @@ export const PromSettings = (props: Props) => {
);
};
export
const
getValueFromEventItem
=
(
eventItem
:
SyntheticEvent
<
HTMLInputElement
>
|
SelectableValue
<
string
>
)
=>
{
if
(
!
eventItem
)
{
return
''
;
}
if
(
eventItem
.
hasOwnProperty
(
'currentTarget'
))
{
return
eventItem
.
currentTarget
.
value
;
}
return
(
eventItem
as
SelectableValue
<
string
>
).
value
;
};
const
onChangeHandler
=
(
key
:
keyof
PromOptions
,
value
:
Props
[
'value'
],
onChange
:
Props
[
'onChange'
])
=>
(
event
:
SyntheticEvent
<
HTMLInputElement
|
HTMLSelectElement
>
event
Item
:
SyntheticEvent
<
HTMLInputElement
>
|
SelectableValue
<
string
>
)
=>
{
onChange
({
...
value
,
jsonData
:
{
...
value
.
jsonData
,
[
key
]:
event
.
currentTarget
.
value
,
[
key
]:
getValueFromEventItem
(
eventItem
)
,
},
});
};
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