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:
Ashley Harrison
2024-03-18 16:12:00 +00:00
committed by GitHub
parent 677b765dab
commit b1b65faf02
13 changed files with 337 additions and 34 deletions

View File

@@ -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": [
{