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
1e5ad4da
Commit
1e5ad4da
authored
Sep 04, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
redux: minor changes to redux thunk actions and use of typings
parent
41dcd764
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
26 deletions
+14
-26
public/app/features/alerting/AlertRuleList.test.tsx
+1
-1
public/app/features/alerting/AlertRuleList.tsx
+1
-1
public/app/features/alerting/state/actions.ts
+12
-24
No files found.
public/app/features/alerting/AlertRuleList.test.tsx
View file @
1e5ad4da
import
React
from
'react'
;
import
{
shallow
}
from
'enzyme'
;
import
AlertRuleList
,
{
Props
}
from
'./AlertRuleList'
;
import
{
AlertRuleList
,
Props
}
from
'./AlertRuleList'
;
import
{
AlertRule
,
NavModel
}
from
'../../types'
;
import
appEvents
from
'../../core/app_events'
;
...
...
public/app/features/alerting/AlertRuleList.tsx
View file @
1e5ad4da
...
...
@@ -20,7 +20,7 @@ export interface Props {
search
:
string
;
}
class
AlertRuleList
extends
PureComponent
<
Props
,
any
>
{
export
class
AlertRuleList
extends
PureComponent
<
Props
,
any
>
{
stateFilters
=
[
{
text
:
'All'
,
value
:
'all'
},
{
text
:
'OK'
,
value
:
'ok'
},
...
...
public/app/features/alerting/state/actions.ts
View file @
1e5ad4da
import
{
Dispatch
}
from
'redux'
;
import
{
getBackendSrv
}
from
'app/core/services/backend_srv'
;
import
{
AlertRuleApi
,
StoreState
}
from
'app/types'
;
import
{
ThunkAction
}
from
'redux-thunk'
;
export
enum
ActionTypes
{
LoadAlertRules
=
'LOAD_ALERT_RULES'
,
...
...
@@ -29,31 +29,19 @@ export const setSearchQuery = (query: string): SetSearchQueryAction => ({
export
type
Action
=
LoadAlertRulesAction
|
SetSearchQueryAction
;
export
const
getAlertRulesAsync
=
(
options
:
{
state
:
string
})
=>
async
(
dispatch
:
Dispatch
<
Action
>
):
Promise
<
AlertRuleApi
[]
>
=
>
{
try
{
type
ThunkResult
<
R
>
=
ThunkAction
<
R
,
StoreState
,
undefined
,
Action
>
;
export
function
getAlertRulesAsync
(
options
:
{
state
:
string
}):
ThunkResult
<
void
>
{
return
async
dispatch
=>
{
const
rules
=
await
getBackendSrv
().
get
(
'/api/alerts'
,
options
);
dispatch
(
loadAlertRules
(
rules
));
return
rules
;
}
catch
(
error
)
{
console
.
error
(
error
);
throw
error
;
}
};
export
const
togglePauseAlertRule
=
(
id
:
number
,
options
:
{
paused
:
boolean
})
=>
async
(
// Maybe fix dispatch type?
dispatch
:
Dispatch
<
any
>
,
getState
:
()
=>
StoreState
):
Promise
<
boolean
>
=>
{
try
{
};
}
export
function
togglePauseAlertRule
(
id
:
number
,
options
:
{
paused
:
boolean
}):
ThunkResult
<
void
>
{
return
async
(
dispatch
,
getState
)
=>
{
await
getBackendSrv
().
post
(
`/api/alerts/
${
id
}
/pause`
,
options
);
const
stateFilter
=
getState
().
location
.
query
.
state
||
'all'
;
dispatch
(
getAlertRulesAsync
({
state
:
stateFilter
.
toString
()
}));
return
true
;
}
catch
(
error
)
{
console
.
log
(
error
);
throw
error
;
}
};
};
}
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