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
b7d26b12
Unverified
Commit
b7d26b12
authored
Jun 24, 2020
by
Torkel Ödegaard
Committed by
GitHub
Jun 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Templating: Fix searchFilter issue in templating system (#25770)
parent
f16bf361
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
2 deletions
+40
-2
public/app/features/variables/query/actions.test.ts
+26
-0
public/app/features/variables/query/actions.ts
+7
-1
public/test/core/redux/reduxTester.ts
+7
-1
No files found.
public/app/features/variables/query/actions.test.ts
View file @
b7d26b12
...
...
@@ -188,6 +188,32 @@ describe('query actions', () => {
});
});
describe
(
'when updateQueryVariableOptions is dispatched for variable with searchFilter'
,
()
=>
{
it
(
'then correct actions are dispatched'
,
async
()
=>
{
const
variable
=
createVariable
({
includeAll
:
true
,
useTags
:
false
});
const
optionsMetrics
=
[
createMetric
(
'A'
),
createMetric
(
'B'
)];
mockDatasourceMetrics
(
variable
,
optionsMetrics
,
[]);
const
tester
=
await
reduxTester
<
{
templating
:
TemplatingState
}
>
()
.
givenRootReducer
(
getRootReducer
())
.
whenActionIsDispatched
(
addVariable
(
toVariablePayload
(
variable
,
{
global
:
false
,
index
:
0
,
model
:
variable
})))
.
whenActionIsDispatched
(
setIdInEditor
({
id
:
variable
.
id
}))
.
whenAsyncActionIsDispatched
(
updateQueryVariableOptions
(
toVariablePayload
(
variable
),
'search'
),
true
);
const
update
=
{
results
:
optionsMetrics
,
templatedRegex
:
''
};
tester
.
thenDispatchedActionsPredicateShouldEqual
(
actions
=>
{
const
[
clearErrors
,
updateOptions
]
=
actions
;
const
expectedNumberOfActions
=
2
;
expect
(
clearErrors
).
toEqual
(
removeVariableEditorError
({
errorProp
:
'update'
}));
expect
(
updateOptions
).
toEqual
(
updateVariableOptions
(
toVariablePayload
(
variable
,
update
)));
return
actions
.
length
===
expectedNumberOfActions
;
});
});
});
describe
(
'when updateQueryVariableOptions is dispatched and fails for variable open in editor'
,
()
=>
{
it
(
'then correct actions are dispatched'
,
async
()
=>
{
const
variable
=
createVariable
({
includeAll
:
true
,
useTags
:
false
});
...
...
public/app/features/variables/query/actions.ts
View file @
b7d26b12
...
...
@@ -52,7 +52,13 @@ export const updateQueryVariableOptions = (
await
dispatch
(
updateVariableTags
(
toVariablePayload
(
variableInState
,
tagResults
)));
}
await
dispatch
(
validateVariableSelectionState
(
toVariableIdentifier
(
variableInState
)));
// If we are searching options there is no need to validate selection state
// This condition was added to as validateVariableSelectionState will update the current value of the variable
// So after search and selection the current value is already update so no setValue, refresh & url update is performed
// The if statement below fixes https://github.com/grafana/grafana/issues/25671
if
(
!
searchFilter
)
{
await
dispatch
(
validateVariableSelectionState
(
toVariableIdentifier
(
variableInState
)));
}
}
catch
(
err
)
{
console
.
error
(
err
);
if
(
err
.
data
&&
err
.
data
.
message
)
{
...
...
public/test/core/redux/reduxTester.ts
View file @
b7d26b12
...
...
@@ -50,10 +50,16 @@ export const reduxTester = <State>(args?: ReduxTesterArguments<State>): ReduxTes
const
debug
=
args
?.
debug
??
false
;
let
store
:
EnhancedStore
<
State
>
|
null
=
null
;
const
defaultMiddleware
=
getDefaultMiddleware
<
State
>
({
thunk
:
false
,
serializableCheck
:
false
,
immutableCheck
:
false
,
}
as
any
);
const
givenRootReducer
=
(
rootReducer
:
Reducer
<
State
>
):
ReduxTesterWhen
<
State
>
=>
{
store
=
configureStore
<
State
>
({
reducer
:
rootReducer
,
middleware
:
[...
getDefaultMiddleware
<
State
>
()
,
logActionsMiddleWare
,
thunk
]
as
[
ThunkMiddleware
<
State
>
],
middleware
:
[...
defaultMiddleware
,
logActionsMiddleWare
,
thunk
]
as
[
ThunkMiddleware
<
State
>
],
preloadedState
,
});
...
...
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