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
1633bacb
Unverified
Commit
1633bacb
authored
Mar 30, 2020
by
Torkel Ödegaard
Committed by
GitHub
Mar 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NewPanelEditor: Fixed so that test alert rule works in new edit mode (#23179)
parent
3cf82df8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
8 deletions
+17
-8
public/app/features/alerting/AlertTab.tsx
+2
-2
public/app/features/alerting/TestRuleResult.test.tsx
+2
-2
public/app/features/alerting/TestRuleResult.tsx
+13
-4
No files found.
public/app/features/alerting/AlertTab.tsx
View file @
1633bacb
...
@@ -145,8 +145,8 @@ class UnConnectedAlertTab extends PureComponent<Props, State> {
...
@@ -145,8 +145,8 @@ class UnConnectedAlertTab extends PureComponent<Props, State> {
};
};
renderTestRuleResult
=
()
=>
{
renderTestRuleResult
=
()
=>
{
const
{
panel
,
dashboard
}
=
this
.
props
;
const
{
dashboard
,
panel
}
=
this
.
props
;
return
<
TestRuleResult
panel
Id=
{
panel
.
id
}
dashboard=
{
dashboard
}
/>;
return
<
TestRuleResult
panel
=
{
panel
}
dashboard=
{
dashboard
}
/>;
};
};
testRule
=
():
EditorToolbarView
=>
({
testRule
=
():
EditorToolbarView
=>
({
...
...
public/app/features/alerting/TestRuleResult.test.tsx
View file @
1633bacb
import
React
from
'react'
;
import
React
from
'react'
;
import
{
TestRuleResult
,
Props
}
from
'./TestRuleResult'
;
import
{
TestRuleResult
,
Props
}
from
'./TestRuleResult'
;
import
{
DashboardModel
}
from
'../dashboard/state'
;
import
{
DashboardModel
,
PanelModel
}
from
'../dashboard/state'
;
import
{
shallow
}
from
'enzyme'
;
import
{
shallow
}
from
'enzyme'
;
jest
.
mock
(
'@grafana/runtime'
,
()
=>
{
jest
.
mock
(
'@grafana/runtime'
,
()
=>
{
...
@@ -16,7 +16,7 @@ jest.mock('@grafana/runtime', () => {
...
@@ -16,7 +16,7 @@ jest.mock('@grafana/runtime', () => {
const
setup
=
(
propOverrides
?:
object
)
=>
{
const
setup
=
(
propOverrides
?:
object
)
=>
{
const
props
:
Props
=
{
const
props
:
Props
=
{
panel
Id
:
1
,
panel
:
new
PanelModel
({
id
:
1
})
,
dashboard
:
new
DashboardModel
({
panels
:
[{
id
:
1
}]
}),
dashboard
:
new
DashboardModel
({
panels
:
[{
id
:
1
}]
}),
};
};
...
...
public/app/features/alerting/TestRuleResult.tsx
View file @
1633bacb
...
@@ -3,13 +3,13 @@ import { LoadingPlaceholder, JSONFormatter } from '@grafana/ui';
...
@@ -3,13 +3,13 @@ import { LoadingPlaceholder, JSONFormatter } from '@grafana/ui';
import
appEvents
from
'app/core/app_events'
;
import
appEvents
from
'app/core/app_events'
;
import
{
CopyToClipboard
}
from
'app/core/components/CopyToClipboard/CopyToClipboard'
;
import
{
CopyToClipboard
}
from
'app/core/components/CopyToClipboard/CopyToClipboard'
;
import
{
DashboardModel
}
from
'../dashboard/state/DashboardModel
'
;
import
{
DashboardModel
,
PanelModel
}
from
'../dashboard/state
'
;
import
{
getBackendSrv
}
from
'@grafana/runtime'
;
import
{
getBackendSrv
}
from
'@grafana/runtime'
;
import
{
AppEvents
}
from
'@grafana/data'
;
import
{
AppEvents
}
from
'@grafana/data'
;
export
interface
Props
{
export
interface
Props
{
panelId
:
number
;
dashboard
:
DashboardModel
;
dashboard
:
DashboardModel
;
panel
:
PanelModel
;
}
}
interface
State
{
interface
State
{
...
@@ -33,8 +33,17 @@ export class TestRuleResult extends PureComponent<Props, State> {
...
@@ -33,8 +33,17 @@ export class TestRuleResult extends PureComponent<Props, State> {
}
}
async
testRule
()
{
async
testRule
()
{
const
{
panelId
,
dashboard
}
=
this
.
props
;
const
{
dashboard
,
panel
}
=
this
.
props
;
const
payload
=
{
dashboard
:
dashboard
.
getSaveModelClone
(),
panelId
};
// dashboard save model
const
model
=
dashboard
.
getSaveModelClone
();
// now replace panel to get current edits
model
.
panels
=
model
.
panels
.
map
(
dashPanel
=>
{
return
dashPanel
.
id
===
panel
.
editSourceId
?
panel
.
getSaveModel
()
:
dashPanel
;
});
const
payload
=
{
dashboard
:
model
,
panelId
:
panel
.
id
};
this
.
setState
({
isLoading
:
true
});
this
.
setState
({
isLoading
:
true
});
const
testRuleResponse
=
await
getBackendSrv
().
post
(
`/api/alerts/test`
,
payload
);
const
testRuleResponse
=
await
getBackendSrv
().
post
(
`/api/alerts/test`
,
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