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
5617db36
Unverified
Commit
5617db36
authored
Mar 18, 2019
by
Torkel Ödegaard
Committed by
GitHub
Mar 18, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16014 from alexanderzobnin/fix-15993
Panels: fix loading panels with non-array targets
parents
8859d16a
c028d410
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
public/app/features/dashboard/state/PanelModel.test.ts
+13
-2
public/app/features/dashboard/state/PanelModel.ts
+1
-1
No files found.
public/app/features/dashboard/state/PanelModel.test.ts
View file @
5617db36
...
@@ -3,9 +3,10 @@ import { PanelModel } from './PanelModel';
...
@@ -3,9 +3,10 @@ import { PanelModel } from './PanelModel';
describe
(
'PanelModel'
,
()
=>
{
describe
(
'PanelModel'
,
()
=>
{
describe
(
'when creating new panel model'
,
()
=>
{
describe
(
'when creating new panel model'
,
()
=>
{
let
model
;
let
model
;
let
modelJson
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
model
=
new
PanelModel
(
{
model
Json
=
{
type
:
'table'
,
type
:
'table'
,
showColumns
:
true
,
showColumns
:
true
,
targets
:
[{
refId
:
'A'
},
{
noRefId
:
true
}],
targets
:
[{
refId
:
'A'
},
{
noRefId
:
true
}],
...
@@ -23,7 +24,8 @@ describe('PanelModel', () => {
...
@@ -23,7 +24,8 @@ describe('PanelModel', () => {
},
},
],
],
},
},
});
};
model
=
new
PanelModel
(
modelJson
);
});
});
it
(
'should apply defaults'
,
()
=>
{
it
(
'should apply defaults'
,
()
=>
{
...
@@ -38,6 +40,15 @@ describe('PanelModel', () => {
...
@@ -38,6 +40,15 @@ describe('PanelModel', () => {
expect
(
model
.
targets
[
1
].
refId
).
toBe
(
'B'
);
expect
(
model
.
targets
[
1
].
refId
).
toBe
(
'B'
);
});
});
it
(
"shouldn't break panel with non-array targets"
,
()
=>
{
modelJson
.
targets
=
{
0
:
{
refId
:
'A'
},
foo
:
{
bar
:
'baz'
},
};
model
=
new
PanelModel
(
modelJson
);
expect
(
model
.
targets
[
0
].
refId
).
toBe
(
'A'
);
});
it
(
'getSaveModel should remove defaults'
,
()
=>
{
it
(
'getSaveModel should remove defaults'
,
()
=>
{
const
saveModel
=
model
.
getSaveModel
();
const
saveModel
=
model
.
getSaveModel
();
expect
(
saveModel
.
gridPos
).
toBe
(
undefined
);
expect
(
saveModel
.
gridPos
).
toBe
(
undefined
);
...
...
public/app/features/dashboard/state/PanelModel.ts
View file @
5617db36
...
@@ -125,7 +125,7 @@ export class PanelModel {
...
@@ -125,7 +125,7 @@ export class PanelModel {
}
}
ensureQueryIds
()
{
ensureQueryIds
()
{
if
(
this
.
targets
)
{
if
(
this
.
targets
&&
_
.
isArray
(
this
.
targets
)
)
{
for
(
const
query
of
this
.
targets
)
{
for
(
const
query
of
this
.
targets
)
{
if
(
!
query
.
refId
)
{
if
(
!
query
.
refId
)
{
query
.
refId
=
this
.
getNextQueryLetter
();
query
.
refId
=
this
.
getNextQueryLetter
();
...
...
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