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
6b0400ee
Commit
6b0400ee
authored
Jan 28, 2019
by
Hugo Häggmark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Firing off an action instead of listening to location changes
parent
40f41056
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
10 deletions
+24
-10
public/app/features/explore/Wrapper.tsx
+7
-1
public/app/features/explore/state/actionTypes.ts
+7
-2
public/app/features/explore/state/actions.ts
+9
-1
public/app/features/explore/state/reducers.ts
+1
-6
No files found.
public/app/features/explore/Wrapper.tsx
View file @
6b0400ee
...
...
@@ -7,7 +7,7 @@ import { StoreState } from 'app/types';
import
{
ExploreId
,
ExploreUrlState
}
from
'app/types/explore'
;
import
{
parseUrlState
}
from
'app/core/utils/explore'
;
import
{
initializeExploreSplit
}
from
'./state/actions'
;
import
{
initializeExploreSplit
,
resetExplore
}
from
'./state/actions'
;
import
ErrorBoundary
from
'./ErrorBoundary'
;
import
Explore
from
'./Explore'
;
import
{
CustomScrollbar
}
from
'@grafana/ui'
;
...
...
@@ -16,6 +16,7 @@ interface WrapperProps {
initializeExploreSplit
:
typeof
initializeExploreSplit
;
split
:
boolean
;
updateLocation
:
typeof
updateLocation
;
resetExplore
:
typeof
resetExplore
;
urlStates
:
{
[
key
:
string
]:
string
};
}
...
...
@@ -42,6 +43,10 @@ export class Wrapper extends Component<WrapperProps> {
}
}
componentWillUnmount
()
{
this
.
props
.
resetExplore
();
}
render
()
{
const
{
split
}
=
this
.
props
;
const
{
leftState
,
rightState
}
=
this
.
urlStates
;
...
...
@@ -74,6 +79,7 @@ const mapStateToProps = (state: StoreState) => {
const
mapDispatchToProps
=
{
initializeExploreSplit
,
updateLocation
,
resetExplore
,
};
export
default
hot
(
module
)(
connect
(
mapStateToProps
,
mapDispatchToProps
)(
Wrapper
));
public/app/features/explore/state/actionTypes.ts
View file @
6b0400ee
...
...
@@ -9,7 +9,6 @@ import {
ResultType
,
QueryTransaction
,
}
from
'app/types/explore'
;
import
{
UpdateLocationAction
}
from
'app/core/actions/location'
;
export
enum
ActionTypes
{
AddQueryRow
=
'explore/ADD_QUERY_ROW'
,
...
...
@@ -42,6 +41,7 @@ export enum ActionTypes {
ToggleGraph
=
'explore/TOGGLE_GRAPH'
,
ToggleLogs
=
'explore/TOGGLE_LOGS'
,
ToggleTable
=
'explore/TOGGLE_TABLE'
,
ResetExplore
=
'explore/RESET_EXPLORE'
,
}
export
interface
AddQueryRowAction
{
...
...
@@ -271,6 +271,11 @@ export interface ToggleLogsAction {
};
}
export
interface
ResetExploreAction
{
type
:
ActionTypes
.
ResetExplore
;
payload
:
{};
}
export
type
Action
=
|
AddQueryRowAction
|
ChangeQueryAction
...
...
@@ -299,4 +304,4 @@ export type Action =
|
ToggleGraphAction
|
ToggleLogsAction
|
ToggleTableAction
|
UpdateLocation
Action
;
|
ResetExplore
Action
;
public/app/features/explore/state/actions.ts
View file @
6b0400ee
...
...
@@ -48,7 +48,6 @@ import {
ScanStopAction
,
}
from
'./actionTypes'
;
type
ThunkResult
<
R
>
=
ThunkAction
<
R
,
StoreState
,
undefined
,
ThunkableAction
>
;
/**
...
...
@@ -766,3 +765,12 @@ export function toggleTable(exploreId: ExploreId): ThunkResult<void> {
}
};
}
/**
* Resets state for explore.
*/
export
function
resetExplore
():
ThunkResult
<
void
>
{
return
dispatch
=>
{
dispatch
({
type
:
ActionTypes
.
ResetExplore
,
payload
:
{}
});
};
}
public/app/features/explore/state/reducers.ts
View file @
6b0400ee
...
...
@@ -8,7 +8,6 @@ import { ExploreItemState, ExploreState, QueryTransaction } from 'app/types/expl
import
{
DataQuery
}
from
'@grafana/ui/src/types'
;
import
{
Action
,
ActionTypes
}
from
'./actionTypes'
;
import
{
CoreActionTypes
}
from
'app/core/actions/location'
;
export
const
DEFAULT_RANGE
=
{
from
:
'now-6h'
,
...
...
@@ -440,13 +439,9 @@ export const exploreReducer = (state = initialExploreState, action: Action): Exp
return
{
...
state
,
split
:
true
};
}
case
CoreActionTypes
.
UpdateLocation
:
{
if
(
action
.
payload
.
path
&&
action
.
payload
.
path
!==
'/explore'
)
{
case
ActionTypes
.
ResetExplore
:
{
return
initialExploreState
;
}
return
state
;
}
}
if
(
action
.
payload
)
{
...
...
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