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
6a699af2
Unverified
Commit
6a699af2
authored
Sep 24, 2019
by
Andrej Ocenas
Committed by
GitHub
Sep 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explore: Refactor mode selection (#19356)
parent
ac3fb645
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
47 deletions
+10
-47
public/app/features/explore/ExploreToolbar.tsx
+10
-47
No files found.
public/app/features/explore/ExploreToolbar.tsx
View file @
6a699af2
...
...
@@ -16,7 +16,7 @@ import {
ButtonSelect
,
SetInterval
,
}
from
'@grafana/ui'
;
import
{
RawTimeRange
,
TimeZone
,
TimeRange
,
SelectableValue
}
from
'@grafana/data'
;
import
{
RawTimeRange
,
TimeZone
,
TimeRange
}
from
'@grafana/data'
;
import
{
DataSourcePicker
}
from
'app/core/components/Select/DataSourcePicker'
;
import
{
StoreState
}
from
'app/types/store'
;
import
{
...
...
@@ -61,8 +61,8 @@ interface StateProps {
selectedDatasource
:
DataSourceSelectItem
;
splitted
:
boolean
;
refreshInterval
:
string
;
supportedMode
Options
:
Array
<
SelectableValue
<
ExploreMode
>>
;
selectedMode
Option
:
SelectableValue
<
ExploreMode
>
;
supportedMode
s
:
ExploreMode
[]
;
selectedMode
:
ExploreMode
;
hasLiveOption
:
boolean
;
isLive
:
boolean
;
isPaused
:
boolean
;
...
...
@@ -150,8 +150,8 @@ export class UnConnectedExploreToolbar extends PureComponent<Props, {}> {
refreshInterval
,
onChangeTime
,
split
,
supportedMode
Option
s
,
selectedMode
Option
,
supportedModes
,
selectedMode
,
hasLiveOption
,
isLive
,
isPaused
,
...
...
@@ -195,14 +195,14 @@ export class UnConnectedExploreToolbar extends PureComponent<Props, {}> {
current=
{
selectedDatasource
}
/>
</
div
>
{
supportedMode
Option
s
.
length
>
1
?
(
{
supportedModes
.
length
>
1
?
(
<
div
className=
"query-type-toggle"
>
<
ToggleButtonGroup
label=
""
transparent=
{
true
}
>
<
ToggleButton
key=
{
ExploreMode
.
Metrics
}
value=
{
ExploreMode
.
Metrics
}
onChange=
{
this
.
onModeChange
}
selected=
{
selectedMode
Option
.
value
===
ExploreMode
.
Metrics
}
selected=
{
selectedMode
===
ExploreMode
.
Metrics
}
>
{
'Metrics'
}
</
ToggleButton
>
...
...
@@ -210,7 +210,7 @@ export class UnConnectedExploreToolbar extends PureComponent<Props, {}> {
key=
{
ExploreMode
.
Logs
}
value=
{
ExploreMode
.
Logs
}
onChange=
{
this
.
onModeChange
}
selected=
{
selectedMode
Option
.
value
===
ExploreMode
.
Logs
}
selected=
{
selectedMode
===
ExploreMode
.
Logs
}
>
{
'Logs'
}
</
ToggleButton
>
...
...
@@ -300,41 +300,6 @@ export class UnConnectedExploreToolbar extends PureComponent<Props, {}> {
}
}
const
getModeOptionsMemoized
=
memoizeOne
(
(
supportedModes
:
ExploreMode
[],
mode
:
ExploreMode
):
[
Array
<
SelectableValue
<
ExploreMode
>>
,
SelectableValue
<
ExploreMode
>
]
=>
{
const
supportedModeOptions
:
Array
<
SelectableValue
<
ExploreMode
>>
=
[];
let
selectedModeOption
=
null
;
for
(
const
supportedMode
of
supportedModes
)
{
switch
(
supportedMode
)
{
case
ExploreMode
.
Metrics
:
const
option1
=
{
value
:
ExploreMode
.
Metrics
,
label
:
ExploreMode
.
Metrics
,
};
supportedModeOptions
.
push
(
option1
);
if
(
mode
===
ExploreMode
.
Metrics
)
{
selectedModeOption
=
option1
;
}
break
;
case
ExploreMode
.
Logs
:
const
option2
=
{
value
:
ExploreMode
.
Logs
,
label
:
ExploreMode
.
Logs
,
};
supportedModeOptions
.
push
(
option2
);
if
(
mode
===
ExploreMode
.
Logs
)
{
selectedModeOption
=
option2
;
}
break
;
}
}
return
[
supportedModeOptions
,
selectedModeOption
];
}
);
const
mapStateToProps
=
(
state
:
StoreState
,
{
exploreId
}:
OwnProps
):
StateProps
=>
{
const
splitted
=
state
.
explore
.
split
;
const
exploreItem
:
ExploreItemState
=
state
.
explore
[
exploreId
];
...
...
@@ -358,8 +323,6 @@ const mapStateToProps = (state: StoreState, { exploreId }: OwnProps): StateProps
const
hasLiveOption
=
datasourceInstance
&&
datasourceInstance
.
meta
&&
datasourceInstance
.
meta
.
streaming
?
true
:
false
;
const
[
supportedModeOptions
,
selectedModeOption
]
=
getModeOptionsMemoized
(
supportedModes
,
mode
);
return
{
datasourceMissing
,
exploreDatasources
,
...
...
@@ -369,8 +332,8 @@ const mapStateToProps = (state: StoreState, { exploreId }: OwnProps): StateProps
selectedDatasource
,
splitted
,
refreshInterval
,
supportedMode
Option
s
,
selectedMode
Option
,
supportedModes
,
selectedMode
:
supportedModes
.
includes
(
mode
)
?
mode
:
supportedModes
[
0
]
,
hasLiveOption
,
isLive
,
isPaused
,
...
...
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