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
71837fe1
Unverified
Commit
71837fe1
authored
Dec 19, 2018
by
Torkel Ödegaard
Committed by
GitHub
Dec 19, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12681 from simPod/fix-variable-array-display
Fix array display from url
parents
52ccb491
e67d3df1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
public/app/features/templating/specs/variable_srv_init.test.ts
+31
-7
public/app/features/templating/variable_srv.ts
+3
-1
No files found.
public/app/features/templating/specs/variable_srv_init.test.ts
View file @
71837fe1
...
...
@@ -77,8 +77,8 @@ describe('VariableSrv init', function(this: any) {
{
name
:
'apps'
,
type
:
type
,
current
:
{
text
:
'
t
est'
,
value
:
'test'
},
options
:
[{
text
:
'
t
est'
,
value
:
'test'
}],
current
:
{
text
:
'
T
est'
,
value
:
'test'
},
options
:
[{
text
:
'
T
est'
,
value
:
'test'
}],
},
];
scenario
.
urlParams
[
'var-apps'
]
=
'new'
;
...
...
@@ -161,11 +161,11 @@ describe('VariableSrv init', function(this: any) {
name
:
'apps'
,
type
:
'query'
,
multi
:
true
,
current
:
{
text
:
'
v
al1'
,
value
:
'val1'
},
current
:
{
text
:
'
V
al1'
,
value
:
'val1'
},
options
:
[
{
text
:
'
v
al1'
,
value
:
'val1'
},
{
text
:
'
v
al2'
,
value
:
'val2'
},
{
text
:
'
v
al3'
,
value
:
'val3'
,
selected
:
true
},
{
text
:
'
V
al1'
,
value
:
'val1'
},
{
text
:
'
V
al2'
,
value
:
'val2'
},
{
text
:
'
V
al3'
,
value
:
'val3'
,
selected
:
true
},
],
},
];
...
...
@@ -177,7 +177,7 @@ describe('VariableSrv init', function(this: any) {
expect
(
variable
.
current
.
value
.
length
).
toBe
(
2
);
expect
(
variable
.
current
.
value
[
0
]).
toBe
(
'val2'
);
expect
(
variable
.
current
.
value
[
1
]).
toBe
(
'val1'
);
expect
(
variable
.
current
.
text
).
toBe
(
'
val2 + v
al1'
);
expect
(
variable
.
current
.
text
).
toBe
(
'
Val2 + V
al1'
);
expect
(
variable
.
options
[
0
].
selected
).
toBe
(
true
);
expect
(
variable
.
options
[
1
].
selected
).
toBe
(
true
);
});
...
...
@@ -188,6 +188,30 @@ describe('VariableSrv init', function(this: any) {
});
});
describeInitScenario
(
'when template variable is present in url multiple times and variables have no text'
,
scenario
=>
{
scenario
.
setup
(()
=>
{
scenario
.
variables
=
[
{
name
:
'apps'
,
type
:
'query'
,
multi
:
true
,
},
];
scenario
.
urlParams
[
'var-apps'
]
=
[
'val1'
,
'val2'
];
});
it
(
'should display concatenated values in text'
,
()
=>
{
const
variable
=
ctx
.
variableSrv
.
variables
[
0
];
expect
(
variable
.
current
.
value
.
length
).
toBe
(
2
);
expect
(
variable
.
current
.
value
[
0
]).
toBe
(
'val1'
);
expect
(
variable
.
current
.
value
[
1
]).
toBe
(
'val2'
);
expect
(
variable
.
current
.
text
).
toBe
(
'val1 + val2'
);
});
}
);
describeInitScenario
(
'when template variable is present in url multiple times using key/values'
,
scenario
=>
{
scenario
.
setup
(()
=>
{
scenario
.
variables
=
[
...
...
public/app/features/templating/variable_srv.ts
View file @
71837fe1
...
...
@@ -237,8 +237,10 @@ export class VariableSrv {
setOptionAsCurrent
(
variable
,
option
)
{
variable
.
current
=
_
.
cloneDeep
(
option
);
if
(
_
.
isArray
(
variable
.
current
.
text
))
{
if
(
_
.
isArray
(
variable
.
current
.
text
)
&&
variable
.
current
.
text
.
length
>
0
)
{
variable
.
current
.
text
=
variable
.
current
.
text
.
join
(
' + '
);
}
else
if
(
_
.
isArray
(
variable
.
current
.
value
)
&&
variable
.
current
.
value
[
0
]
!==
'$__all'
)
{
variable
.
current
.
text
=
variable
.
current
.
value
.
join
(
' + '
);
}
this
.
selectOptionsForCurrentValue
(
variable
);
...
...
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