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
bc3d5ee0
Unverified
Commit
bc3d5ee0
authored
May 07, 2020
by
Andrej Ocenas
Committed by
GitHub
May 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CloudWatch/Metrics: Fix error with expression only query (#24362)
parent
01b46d17
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
public/app/plugins/datasource/cloudwatch/components/MetricsQueryEditor.test.tsx
+31
-0
public/app/plugins/datasource/cloudwatch/components/MetricsQueryEditor.tsx
+6
-0
No files found.
public/app/plugins/datasource/cloudwatch/components/MetricsQueryEditor.test.tsx
View file @
bc3d5ee0
...
@@ -70,6 +70,37 @@ describe('QueryEditor', () => {
...
@@ -70,6 +70,37 @@ describe('QueryEditor', () => {
});
});
});
});
it
(
'normalizes query on mount'
,
async
()
=>
{
const
{
act
}
=
renderer
;
const
props
=
setup
();
// This does not actually even conform to the prop type but this happens on initialisation somehow
props
.
query
=
{
queryMode
:
'Metrics'
,
apiMode
:
'Metrics'
,
refId
:
''
,
expression
:
''
,
matchExact
:
true
,
}
as
any
;
await
act
(
async
()
=>
{
renderer
.
create
(<
MetricsQueryEditor
{
...
props
}
/>);
});
expect
((
props
.
onChange
as
jest
.
Mock
).
mock
.
calls
[
0
][
0
]).
toEqual
({
namespace
:
''
,
metricName
:
''
,
expression
:
''
,
dimensions
:
{},
region
:
'default'
,
id
:
''
,
alias
:
''
,
statistics
:
[
'Average'
],
period
:
''
,
queryMode
:
'Metrics'
,
apiMode
:
'Metrics'
,
refId
:
''
,
matchExact
:
true
,
});
});
describe
(
'should use correct default values'
,
()
=>
{
describe
(
'should use correct default values'
,
()
=>
{
it
(
'when region is null is display default in the label'
,
async
()
=>
{
it
(
'when region is null is display default in the label'
,
async
()
=>
{
// @ts-ignore strict null error TS2345: Argument of type '() => Promise<void>' is not assignable to parameter of type '() => void | undefined'.
// @ts-ignore strict null error TS2345: Argument of type '() => Promise<void>' is not assignable to parameter of type '() => void | undefined'.
...
...
public/app/plugins/datasource/cloudwatch/components/MetricsQueryEditor.tsx
View file @
bc3d5ee0
...
@@ -53,6 +53,12 @@ export const normalizeQuery = ({
...
@@ -53,6 +53,12 @@ export const normalizeQuery = ({
export
class
MetricsQueryEditor
extends
PureComponent
<
Props
,
State
>
{
export
class
MetricsQueryEditor
extends
PureComponent
<
Props
,
State
>
{
state
:
State
=
{
showMeta
:
false
};
state
:
State
=
{
showMeta
:
false
};
componentDidMount
():
void
{
const
metricsQuery
=
this
.
props
.
query
as
CloudWatchMetricsQuery
;
const
query
=
normalizeQuery
(
metricsQuery
);
this
.
props
.
onChange
(
query
);
}
onChange
(
query
:
CloudWatchMetricsQuery
)
{
onChange
(
query
:
CloudWatchMetricsQuery
)
{
const
{
onChange
,
onRunQuery
}
=
this
.
props
;
const
{
onChange
,
onRunQuery
}
=
this
.
props
;
onChange
(
query
);
onChange
(
query
);
...
...
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