mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Variables: Support static keys in AdHocFiltersVariable (#83157)
* initial start * don't use getTagKeysProvider * some cleanup * undo kinds adjustment * simplify * remove async declaration * add description and a couple of unit tests * add transformSaveModelToScene test * add tests for AdHocVariableForm * add tests for AdHocFiltersVariableEditor * update to defaultKeys * fix snapshots * update to 3.13.3
This commit is contained in:
@@ -388,6 +388,91 @@ describe('sceneVariablesSetToVariables', () => {
|
||||
"type": "fake-std",
|
||||
"uid": "fake-std",
|
||||
},
|
||||
"defaultKeys": undefined,
|
||||
"description": "test-desc",
|
||||
"filters": [
|
||||
{
|
||||
"key": "filterTest",
|
||||
"operator": "=",
|
||||
"value": "test",
|
||||
},
|
||||
],
|
||||
"label": "test-label",
|
||||
"name": "test",
|
||||
"type": "adhoc",
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it('should handle AdHocFiltersVariable with defaultKeys', () => {
|
||||
const variable = new AdHocFiltersVariable({
|
||||
name: 'test',
|
||||
label: 'test-label',
|
||||
description: 'test-desc',
|
||||
datasource: { uid: 'fake-std', type: 'fake-std' },
|
||||
defaultKeys: [
|
||||
{
|
||||
text: 'some',
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
text: 'static',
|
||||
value: '2',
|
||||
},
|
||||
{
|
||||
text: 'keys',
|
||||
value: '3',
|
||||
},
|
||||
],
|
||||
filters: [
|
||||
{
|
||||
key: 'filterTest',
|
||||
operator: '=',
|
||||
value: 'test',
|
||||
},
|
||||
],
|
||||
baseFilters: [
|
||||
{
|
||||
key: 'baseFilterTest',
|
||||
operator: '=',
|
||||
value: 'test',
|
||||
},
|
||||
],
|
||||
});
|
||||
const set = new SceneVariableSet({
|
||||
variables: [variable],
|
||||
});
|
||||
|
||||
const result = sceneVariablesSetToVariables(set);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0]).toMatchInlineSnapshot(`
|
||||
{
|
||||
"baseFilters": [
|
||||
{
|
||||
"key": "baseFilterTest",
|
||||
"operator": "=",
|
||||
"value": "test",
|
||||
},
|
||||
],
|
||||
"datasource": {
|
||||
"type": "fake-std",
|
||||
"uid": "fake-std",
|
||||
},
|
||||
"defaultKeys": [
|
||||
{
|
||||
"text": "some",
|
||||
"value": "1",
|
||||
},
|
||||
{
|
||||
"text": "static",
|
||||
"value": "2",
|
||||
},
|
||||
{
|
||||
"text": "keys",
|
||||
"value": "3",
|
||||
},
|
||||
],
|
||||
"description": "test-desc",
|
||||
"filters": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user