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
2f00087a
Commit
2f00087a
authored
Jun 15, 2019
by
Tobias Skarhed
Committed by
Torkel Ödegaard
Jun 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RefreshPicker: Handle empty intervals (#17585)
* Refresh picker empty * RefreshPicker: refactoring
parent
f9b691bd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
16 deletions
+7
-16
packages/grafana-ui/src/components/RefreshPicker/RefreshPicker.tsx
+7
-16
No files found.
packages/grafana-ui/src/components/RefreshPicker/RefreshPicker.tsx
View file @
2f00087a
...
...
@@ -19,29 +19,20 @@ export interface Props {
}
export
class
RefreshPicker
extends
PureComponent
<
Props
>
{
static
defaultProps
=
{
intervals
:
defaultIntervals
,
};
constructor
(
props
:
Props
)
{
super
(
props
);
}
hasNoIntervals
=
()
=>
{
const
{
intervals
}
=
this
.
props
;
// Current implementaion returns an array with length of 1 consisting of
// an empty string when auto-refresh is empty in dashboard settings
if
(
!
intervals
||
intervals
.
length
<
1
||
(
intervals
.
length
===
1
&&
intervals
[
0
]
===
''
))
{
return
true
;
}
return
false
;
};
intervalsToOptions
=
(
intervals
:
string
[]
|
undefined
):
Array
<
SelectOptionItem
<
string
>>
=>
{
const
intervalsOrDefault
=
intervals
||
defaultIntervals
;
const
options
=
intervalsOrDefault
.
filter
(
str
=>
str
!==
''
)
.
map
(
interval
=>
({
label
:
interval
,
value
:
interval
}));
intervalsToOptions
=
(
intervals
:
string
[]
=
defaultIntervals
):
Array
<
SelectOptionItem
<
string
>>
=>
{
const
options
=
intervals
.
map
(
interval
=>
({
label
:
interval
,
value
:
interval
}));
if
(
this
.
props
.
hasLiveOption
)
{
options
.
unshift
(
liveOption
);
}
options
.
unshift
(
offOption
);
return
options
;
};
...
...
@@ -56,7 +47,7 @@ export class RefreshPicker extends PureComponent<Props> {
render
()
{
const
{
onRefresh
,
intervals
,
tooltip
,
value
}
=
this
.
props
;
const
options
=
this
.
intervalsToOptions
(
this
.
hasNoIntervals
()
?
defaultIntervals
:
intervals
);
const
options
=
this
.
intervalsToOptions
(
intervals
);
const
currentValue
=
value
||
''
;
const
selectedValue
=
options
.
find
(
item
=>
item
.
value
===
currentValue
)
||
offOption
;
...
...
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