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
1b29d346
Unverified
Commit
1b29d346
authored
May 14, 2020
by
kay delaney
Committed by
GitHub
May 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Datasource/CloudWatch: Handle invalidation of log groups when switching datasources (#24703)
parent
d3a8f6d0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
13 deletions
+27
-13
public/app/features/dashboard/panel_editor/QueryEditorRow.tsx
+7
-6
public/app/plugins/datasource/cloudwatch/components/LogsQueryField.test.tsx
+1
-1
public/app/plugins/datasource/cloudwatch/components/LogsQueryField.tsx
+19
-6
No files found.
public/app/features/dashboard/panel_editor/QueryEditorRow.tsx
View file @
1b29d346
...
...
@@ -56,7 +56,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
datasource
:
null
,
loadedDataSourceValue
:
undefined
,
hasTextEditMode
:
false
,
data
:
null
,
data
:
undefined
,
isOpen
:
true
,
};
...
...
@@ -163,15 +163,16 @@ export class QueryEditorRow extends PureComponent<Props, State> {
const
{
query
,
onChange
}
=
this
.
props
;
const
{
datasource
,
data
}
=
this
.
state
;
if
(
datasource
.
components
.
QueryCtrl
)
{
if
(
datasource
?.
components
?
.
QueryCtrl
)
{
return
<
div
ref=
{
element
=>
(
this
.
element
=
element
)
}
/>;
}
if
(
datasource
.
components
.
QueryEditor
)
{
if
(
datasource
?.
components
?
.
QueryEditor
)
{
const
QueryEditor
=
datasource
.
components
.
QueryEditor
;
return
(
<
QueryEditor
key=
{
datasource
?.
name
}
query=
{
query
}
datasource=
{
datasource
}
onChange=
{
onChange
}
...
...
@@ -188,7 +189,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
e
.
stopPropagation
();
if
(
this
.
angularScope
&&
this
.
angularScope
.
toggleEditorMode
)
{
this
.
angularScope
.
toggleEditorMode
();
this
.
angularQueryEditor
.
digest
();
this
.
angularQueryEditor
?
.
digest
();
if
(
!
isOpen
)
{
openRow
();
}
...
...
@@ -212,7 +213,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
renderCollapsedText
():
string
|
null
{
const
{
datasource
}
=
this
.
state
;
if
(
datasource
.
getQueryDisplayText
)
{
if
(
datasource
?
.
getQueryDisplayText
)
{
return
datasource
.
getQueryDisplayText
(
this
.
props
.
query
);
}
...
...
@@ -302,7 +303,7 @@ export class QueryEditorRow extends PureComponent<Props, State> {
// To avoid sending duplicate events for each row we have this global cached object here
// So we can check if we already emitted this legacy data event
let
globalLastPanelDataCache
:
PanelData
=
null
;
let
globalLastPanelDataCache
:
PanelData
|
null
=
null
;
function
notifyAngularQueryEditorsOfData
(
panel
:
PanelModel
,
data
:
PanelData
,
editor
:
AngularComponent
)
{
if
(
data
===
globalLastPanelDataCache
)
{
...
...
public/app/plugins/datasource/cloudwatch/components/LogsQueryField.test.tsx
View file @
1b29d346
...
...
@@ -56,6 +56,6 @@ describe('CloudWatchLogsQueryField', () => {
// We clear the select
expect
(
getLogGroupSelect
().
props
.
value
.
length
).
toBe
(
0
);
// Make sure we correctly updated the upstream state
expect
(
onChange
.
mock
.
calls
[
1
][
0
]).
toEqual
({
region
:
'region2'
,
logGroupNames
:
[]
});
expect
(
onChange
.
mock
.
calls
[
onChange
.
mock
.
calls
.
length
-
1
][
0
]).
toEqual
({
region
:
'region2'
,
logGroupNames
:
[]
});
});
});
public/app/plugins/datasource/cloudwatch/components/LogsQueryField.tsx
View file @
1b29d346
// Libraries
import
React
,
{
ReactNode
}
from
'react'
;
import
intersection
from
'lodash/intersection
'
;
import
intersection
By
from
'lodash/intersectionBy
'
;
import
debounce
from
'lodash/debounce'
;
import
{
...
...
@@ -122,16 +122,29 @@ export class CloudWatchLogsQueryField extends React.PureComponent<CloudWatchLogs
};
componentWillMount
=
()
=>
{
const
{
datasource
,
query
}
=
this
.
props
;
const
{
datasource
,
query
,
onChange
}
=
this
.
props
;
this
.
setState
({
loadingLogGroups
:
true
,
});
this
.
fetchLogGroupOptions
(
query
.
region
).
then
(
logGroups
=>
{
this
.
setState
({
loadingLogGroups
:
false
,
availableLogGroups
:
logGroups
,
this
.
setState
(
state
=>
{
const
selectedLogGroups
=
intersectionBy
(
state
.
selectedLogGroups
,
logGroups
,
'value'
);
if
(
onChange
)
{
const
nextQuery
=
{
...
query
,
logGroupNames
:
selectedLogGroups
.
map
(
group
=>
group
.
value
!
),
};
onChange
(
nextQuery
);
}
return
{
loadingLogGroups
:
false
,
availableLogGroups
:
logGroups
,
selectedLogGroups
,
};
});
});
...
...
@@ -184,7 +197,7 @@ export class CloudWatchLogsQueryField extends React.PureComponent<CloudWatchLogs
const
logGroups
=
await
this
.
fetchLogGroupOptions
(
v
.
value
!
);
this
.
setState
(
state
=>
{
const
selectedLogGroups
=
intersection
(
state
.
selectedLogGroups
,
logGroups
);
const
selectedLogGroups
=
intersection
By
(
state
.
selectedLogGroups
,
logGroups
,
'value'
);
const
{
onChange
,
query
}
=
this
.
props
;
if
(
onChange
)
{
...
...
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