@perses-dev/dashboards 0.0.0-snapshot-time-chart-rewrite-4667058 → 0.0.0-snapshot-panel-extra-content-3-17f9c42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Dashboard/Dashboard.js +3 -2
- package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +12 -52
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +2 -1
- package/dist/cjs/components/GridLayout/GridItemContent.js +3 -1
- package/dist/cjs/components/GridLayout/GridLayout.js +1 -0
- package/dist/cjs/components/GridLayout/index.js +3 -1
- package/dist/cjs/components/Panel/Panel.js +8 -3
- package/dist/cjs/components/Panel/PanelHeader.js +7 -3
- package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +3 -1
- package/dist/cjs/components/Variables/EditVariablesButton.js +2 -0
- package/dist/cjs/components/Variables/TemplateVariable.js +22 -18
- package/dist/cjs/components/Variables/VariableEditor.js +271 -99
- package/dist/cjs/components/Variables/VariableList.js +38 -18
- package/dist/cjs/components/Variables/index.js +0 -2
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +3 -2
- package/dist/cjs/context/DatasourceStoreProvider.js +22 -18
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +71 -24
- package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +55 -5
- package/dist/cjs/context/TemplateVariableProvider/utils.js +39 -7
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +1 -1
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +6 -4
- package/dist/components/Dashboard/Dashboard.d.ts +3 -1
- package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
- package/dist/components/Dashboard/Dashboard.js +3 -2
- package/dist/components/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +11 -46
- package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js +2 -1
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/GridLayout/GridItemContent.d.ts +2 -0
- package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
- package/dist/components/GridLayout/GridItemContent.js +3 -1
- package/dist/components/GridLayout/GridItemContent.js.map +1 -1
- package/dist/components/GridLayout/GridLayout.d.ts +2 -0
- package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
- package/dist/components/GridLayout/GridLayout.js +1 -0
- package/dist/components/GridLayout/GridLayout.js.map +1 -1
- package/dist/components/GridLayout/index.d.ts +3 -1
- package/dist/components/GridLayout/index.d.ts.map +1 -1
- package/dist/components/GridLayout/index.js +3 -1
- package/dist/components/GridLayout/index.js.map +1 -1
- package/dist/components/Panel/Panel.d.ts +20 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +8 -3
- package/dist/components/Panel/Panel.js.map +1 -1
- package/dist/components/Panel/PanelHeader.d.ts +2 -1
- package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
- package/dist/components/Panel/PanelHeader.js +7 -3
- package/dist/components/Panel/PanelHeader.js.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js +3 -1
- package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
- package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
- package/dist/components/Variables/EditVariablesButton.js +3 -1
- package/dist/components/Variables/EditVariablesButton.js.map +1 -1
- package/dist/components/Variables/TemplateVariable.d.ts +2 -1
- package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
- package/dist/components/Variables/TemplateVariable.js +21 -17
- package/dist/components/Variables/TemplateVariable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts +7 -0
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js +261 -95
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.d.ts +5 -0
- package/dist/components/Variables/VariableList.d.ts.map +1 -1
- package/dist/components/Variables/VariableList.js +31 -17
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/Variables/index.d.ts +0 -2
- package/dist/components/Variables/index.d.ts.map +1 -1
- package/dist/components/Variables/index.js +0 -2
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +3 -2
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +4 -3
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +22 -18
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +39 -10
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +76 -27
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts +9 -2
- package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/hydrationUtils.js +60 -5
- package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.d.ts +27 -2
- package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/utils.js +46 -4
- package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +2 -2
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +6 -4
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +6 -6
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -399
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +0 -178
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +0 -29
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -91
- package/dist/cjs/components/Variables/variable-model.js +0 -117
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +0 -10
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -354
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +0 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +0 -16
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +0 -122
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +0 -1
- package/dist/components/Variables/VariableEditorForm/index.d.ts +0 -3
- package/dist/components/Variables/VariableEditorForm/index.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/index.js +0 -16
- package/dist/components/Variables/VariableEditorForm/index.js.map +0 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +0 -23
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +0 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -79
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +0 -1
- package/dist/components/Variables/variable-model.d.ts +0 -16
- package/dist/components/Variables/variable-model.d.ts.map +0 -1
- package/dist/components/Variables/variable-model.js +0 -105
- package/dist/components/Variables/variable-model.js.map +0 -1
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
export function getInitialState(initialVariableDefinition) {
|
|
14
|
-
var ref;
|
|
15
|
-
var _value;
|
|
16
|
-
const textVariableFields = {
|
|
17
|
-
value: (_value = initialVariableDefinition.spec.value) !== null && _value !== void 0 ? _value : ''
|
|
18
|
-
};
|
|
19
|
-
const listVariableFields = {
|
|
20
|
-
allowMultiple: false,
|
|
21
|
-
allowAll: false,
|
|
22
|
-
capturing_regexp: undefined,
|
|
23
|
-
plugin: {
|
|
24
|
-
kind: '',
|
|
25
|
-
spec: {}
|
|
26
|
-
},
|
|
27
|
-
customAllValue: undefined
|
|
28
|
-
};
|
|
29
|
-
if (initialVariableDefinition.kind === 'ListVariable') {
|
|
30
|
-
var _allow_all_value;
|
|
31
|
-
listVariableFields.allowMultiple = (_allow_all_value = initialVariableDefinition.spec.allow_all_value) !== null && _allow_all_value !== void 0 ? _allow_all_value : false;
|
|
32
|
-
var _allow_all_value1;
|
|
33
|
-
listVariableFields.allowAll = (_allow_all_value1 = initialVariableDefinition.spec.allow_all_value) !== null && _allow_all_value1 !== void 0 ? _allow_all_value1 : false;
|
|
34
|
-
listVariableFields.capturing_regexp = initialVariableDefinition.spec.capturing_regexp;
|
|
35
|
-
listVariableFields.plugin = initialVariableDefinition.spec.plugin;
|
|
36
|
-
listVariableFields.customAllValue = initialVariableDefinition.spec.custom_all_value;
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
name: initialVariableDefinition.spec.name,
|
|
40
|
-
title: (ref = initialVariableDefinition.spec.display) === null || ref === void 0 ? void 0 : ref.name,
|
|
41
|
-
kind: initialVariableDefinition.kind,
|
|
42
|
-
description: '',
|
|
43
|
-
listVariableFields,
|
|
44
|
-
textVariableFields
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export function getVariableDefinitionFromState(state) {
|
|
48
|
-
const { name , title , kind } = state;
|
|
49
|
-
const display = title ? {
|
|
50
|
-
name: title
|
|
51
|
-
} : undefined;
|
|
52
|
-
if (kind === 'TextVariable') {
|
|
53
|
-
return {
|
|
54
|
-
kind,
|
|
55
|
-
spec: {
|
|
56
|
-
name,
|
|
57
|
-
display,
|
|
58
|
-
...state.textVariableFields
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
if (kind === 'ListVariable') {
|
|
63
|
-
return {
|
|
64
|
-
kind,
|
|
65
|
-
spec: {
|
|
66
|
-
name,
|
|
67
|
-
display,
|
|
68
|
-
allow_multiple: state.listVariableFields.allowMultiple,
|
|
69
|
-
allow_all_value: state.listVariableFields.allowAll,
|
|
70
|
-
capturing_regexp: state.listVariableFields.capturing_regexp,
|
|
71
|
-
plugin: state.listVariableFields.plugin,
|
|
72
|
-
custom_all_value: state.listVariableFields.customAllValue
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
throw new Error(`Unknown variable kind: ${kind}`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
//# sourceMappingURL=variable-editor-form-model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { VariableDefinition, TextVariableDefinition, Display } from '@perses-dev/core';\n\nexport function getInitialState(initialVariableDefinition: VariableDefinition) {\n const textVariableFields = {\n value: (initialVariableDefinition as TextVariableDefinition).spec.value ?? '',\n };\n\n const listVariableFields = {\n allowMultiple: false,\n allowAll: false,\n capturing_regexp: undefined as string | undefined,\n plugin: {\n kind: '',\n spec: {},\n },\n customAllValue: undefined as string | undefined,\n };\n if (initialVariableDefinition.kind === 'ListVariable') {\n listVariableFields.allowMultiple = initialVariableDefinition.spec.allow_all_value ?? false;\n listVariableFields.allowAll = initialVariableDefinition.spec.allow_all_value ?? false;\n listVariableFields.capturing_regexp = initialVariableDefinition.spec.capturing_regexp;\n listVariableFields.plugin = initialVariableDefinition.spec.plugin;\n listVariableFields.customAllValue = initialVariableDefinition.spec.custom_all_value;\n }\n\n return {\n name: initialVariableDefinition.spec.name,\n title: initialVariableDefinition.spec.display?.name,\n kind: initialVariableDefinition.kind,\n description: '',\n listVariableFields,\n textVariableFields,\n };\n}\n\nexport type VariableEditorState = ReturnType<typeof getInitialState>;\n\nexport function getVariableDefinitionFromState(state: VariableEditorState): VariableDefinition {\n const { name, title, kind } = state;\n\n const display: Display | undefined = title ? { name: title } : undefined;\n\n if (kind === 'TextVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n ...state.textVariableFields,\n },\n };\n }\n\n if (kind === 'ListVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n allow_multiple: state.listVariableFields.allowMultiple,\n allow_all_value: state.listVariableFields.allowAll,\n capturing_regexp: state.listVariableFields.capturing_regexp,\n plugin: state.listVariableFields.plugin,\n custom_all_value: state.listVariableFields.customAllValue,\n },\n };\n }\n throw new Error(`Unknown variable kind: ${kind}`);\n}\n"],"names":["getInitialState","initialVariableDefinition","textVariableFields","value","spec","listVariableFields","allowMultiple","allowAll","capturing_regexp","undefined","plugin","kind","customAllValue","allow_all_value","custom_all_value","name","title","display","description","getVariableDefinitionFromState","state","allow_multiple","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAO,SAASA,eAAe,CAACC,yBAA6C,EAAE;QAyBpEA,GAAsC;QAvBtC,MAAgE;IADzE,MAAMC,kBAAkB,GAAG;QACzBC,KAAK,EAAE,CAAA,MAAgE,GAAhE,AAACF,yBAAyB,CAA4BG,IAAI,CAACD,KAAK,cAAhE,MAAgE,cAAhE,MAAgE,GAAI,EAAE;KAC9E,AAAC;IAEF,MAAME,kBAAkB,GAAG;QACzBC,aAAa,EAAE,KAAK;QACpBC,QAAQ,EAAE,KAAK;QACfC,gBAAgB,EAAEC,SAAS;QAC3BC,MAAM,EAAE;YACNC,IAAI,EAAE,EAAE;YACRP,IAAI,EAAE,EAAE;SACT;QACDQ,cAAc,EAAEH,SAAS;KAC1B,AAAC;IACF,IAAIR,yBAAyB,CAACU,IAAI,KAAK,cAAc,EAAE;YAClBV,gBAA8C;QAAjFI,kBAAkB,CAACC,aAAa,GAAGL,CAAAA,gBAA8C,GAA9CA,yBAAyB,CAACG,IAAI,CAACS,eAAe,cAA9CZ,gBAA8C,cAA9CA,gBAA8C,GAAI,KAAK,CAAC;YAC7DA,iBAA8C;QAA5EI,kBAAkB,CAACE,QAAQ,GAAGN,CAAAA,iBAA8C,GAA9CA,yBAAyB,CAACG,IAAI,CAACS,eAAe,cAA9CZ,iBAA8C,cAA9CA,iBAA8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AAEY,KAAK,CAACf,kBAAkB,CAACG,gBAAgB;gBAC3DE,MAAM,EAAEU,KAAK,CAACf,kBAAkB,CAACK,MAAM;gBACvCI,gBAAgB,EAAEM,KAAK,CAACf,kBAAkB,CAACO,cAAc;aAC1D;SACF,CAAC;IACJ,CAAC;IACD,MAAM,IAAIU,KAAK,CAAC,CAAC,uBAAuB,EAAEX,IAAI,CAAC,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ListVariableDefinition } from '@perses-dev/core';
|
|
2
|
-
import { VariableOption, VariableStateMap } from '@perses-dev/plugin-system';
|
|
3
|
-
export declare function filterVariableList(data: VariableOption[], capturedRegexp: RegExp): VariableOption[];
|
|
4
|
-
export declare function useListVariablePluginValues(definition: ListVariableDefinition): import("@tanstack/react-query").UseQueryResult<VariableOption[], unknown>;
|
|
5
|
-
/**
|
|
6
|
-
* Returns a serialized string of the current state of variable values.
|
|
7
|
-
*/
|
|
8
|
-
export declare function getVariableValuesKey(v: VariableStateMap): string;
|
|
9
|
-
export declare const VARIABLE_TYPES: readonly [{
|
|
10
|
-
readonly label: "List";
|
|
11
|
-
readonly kind: "ListVariable";
|
|
12
|
-
}, {
|
|
13
|
-
readonly label: "Text";
|
|
14
|
-
readonly kind: "TextVariable";
|
|
15
|
-
}];
|
|
16
|
-
//# sourceMappingURL=variable-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variable-model.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/variable-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAKL,cAAc,EACd,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAGnC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,cAAc,EAAE,MAAM,GAAG,cAAc,EAAE,CAqBnG;AAED,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,sBAAsB,6EAyC7E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,gBAAgB,UAIvD;AAED,eAAO,MAAM,cAAc;;;;;;EAGjB,CAAC"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
// Copyright 2023 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import { useDatasourceStore, usePlugin, useTemplateVariableValues, useTimeRange } from '@perses-dev/plugin-system';
|
|
14
|
-
import { useQuery } from '@tanstack/react-query';
|
|
15
|
-
export function filterVariableList(data, capturedRegexp) {
|
|
16
|
-
const result = [];
|
|
17
|
-
const filteredSet = new Set();
|
|
18
|
-
for (const variableValue of data){
|
|
19
|
-
const matches = variableValue.value.matchAll(capturedRegexp);
|
|
20
|
-
let concat = '';
|
|
21
|
-
for (const match of matches){
|
|
22
|
-
for(let i = 1; i < match.length; i++){
|
|
23
|
-
const m = match[i];
|
|
24
|
-
if (m !== undefined) {
|
|
25
|
-
concat = `${concat}${m}`;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (concat !== '' && !filteredSet.has(concat)) {
|
|
30
|
-
// like that we are avoiding to have duplicating variable value
|
|
31
|
-
filteredSet.add(concat);
|
|
32
|
-
result.push({
|
|
33
|
-
label: variableValue.label,
|
|
34
|
-
value: concat
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
export function useListVariablePluginValues(definition) {
|
|
41
|
-
const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);
|
|
42
|
-
const datasourceStore = useDatasourceStore();
|
|
43
|
-
const allVariables = useTemplateVariableValues();
|
|
44
|
-
const { absoluteTimeRange: timeRange , refreshKey } = useTimeRange();
|
|
45
|
-
const variablePluginCtx = {
|
|
46
|
-
timeRange,
|
|
47
|
-
datasourceStore,
|
|
48
|
-
variables: allVariables
|
|
49
|
-
};
|
|
50
|
-
const spec = definition.spec.plugin.spec;
|
|
51
|
-
const capturingRegexp = definition.spec.capturing_regexp !== undefined ? new RegExp(definition.spec.capturing_regexp, 'g') : undefined;
|
|
52
|
-
let dependsOnVariables;
|
|
53
|
-
if (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.dependsOn) {
|
|
54
|
-
const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);
|
|
55
|
-
dependsOnVariables = dependencies.variables;
|
|
56
|
-
}
|
|
57
|
-
const variables = useTemplateVariableValues(dependsOnVariables);
|
|
58
|
-
let waitToLoad = false;
|
|
59
|
-
if (dependsOnVariables) {
|
|
60
|
-
waitToLoad = dependsOnVariables.some((v)=>{
|
|
61
|
-
var ref;
|
|
62
|
-
return (ref = variables[v]) === null || ref === void 0 ? void 0 : ref.loading;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
const variablesValueKey = getVariableValuesKey(variables);
|
|
66
|
-
return useQuery([
|
|
67
|
-
name,
|
|
68
|
-
definition,
|
|
69
|
-
variablesValueKey,
|
|
70
|
-
timeRange,
|
|
71
|
-
refreshKey
|
|
72
|
-
], async ()=>{
|
|
73
|
-
const resp = await (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.getVariableOptions(spec, {
|
|
74
|
-
datasourceStore,
|
|
75
|
-
variables,
|
|
76
|
-
timeRange
|
|
77
|
-
}));
|
|
78
|
-
if (resp === undefined) {
|
|
79
|
-
return [];
|
|
80
|
-
}
|
|
81
|
-
if (capturingRegexp === undefined) {
|
|
82
|
-
return resp.data;
|
|
83
|
-
}
|
|
84
|
-
return filterVariableList(resp.data, capturingRegexp);
|
|
85
|
-
}, {
|
|
86
|
-
enabled: !!variablePlugin || waitToLoad
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Returns a serialized string of the current state of variable values.
|
|
91
|
-
*/ export function getVariableValuesKey(v) {
|
|
92
|
-
return Object.values(v).map((v)=>JSON.stringify(v.value)).join(',');
|
|
93
|
-
}
|
|
94
|
-
export const VARIABLE_TYPES = [
|
|
95
|
-
{
|
|
96
|
-
label: 'List',
|
|
97
|
-
kind: 'ListVariable'
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
label: 'Text',
|
|
101
|
-
kind: 'TextVariable'
|
|
102
|
-
}
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
//# sourceMappingURL=variable-model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Variables/variable-model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ListVariableDefinition } from '@perses-dev/core';\nimport {\n useDatasourceStore,\n usePlugin,\n useTemplateVariableValues,\n useTimeRange,\n VariableOption,\n VariableStateMap,\n} from '@perses-dev/plugin-system';\nimport { useQuery } from '@tanstack/react-query';\n\nexport function filterVariableList(data: VariableOption[], capturedRegexp: RegExp): VariableOption[] {\n const result: VariableOption[] = [];\n const filteredSet = new Set<string>();\n for (const variableValue of data) {\n const matches = variableValue.value.matchAll(capturedRegexp);\n let concat = '';\n for (const match of matches) {\n for (let i = 1; i < match.length; i++) {\n const m = match[i];\n if (m !== undefined) {\n concat = `${concat}${m}`;\n }\n }\n }\n if (concat !== '' && !filteredSet.has(concat)) {\n // like that we are avoiding to have duplicating variable value\n filteredSet.add(concat);\n result.push({ label: variableValue.label, value: concat });\n }\n }\n return result;\n}\n\nexport function useListVariablePluginValues(definition: ListVariableDefinition) {\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const datasourceStore = useDatasourceStore();\n const allVariables = useTemplateVariableValues();\n const { absoluteTimeRange: timeRange, refreshKey } = useTimeRange();\n\n const variablePluginCtx = { timeRange, datasourceStore, variables: allVariables };\n\n const spec = definition.spec.plugin.spec;\n const capturingRegexp =\n definition.spec.capturing_regexp !== undefined ? new RegExp(definition.spec.capturing_regexp, 'g') : undefined;\n\n let dependsOnVariables: string[] | undefined;\n if (variablePlugin?.dependsOn) {\n const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);\n dependsOnVariables = dependencies.variables;\n }\n\n const variables = useTemplateVariableValues(dependsOnVariables);\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n\n return useQuery(\n [name, definition, variablesValueKey, timeRange, refreshKey],\n async () => {\n const resp = await variablePlugin?.getVariableOptions(spec, { datasourceStore, variables, timeRange });\n if (resp === undefined) {\n return [];\n }\n if (capturingRegexp === undefined) {\n return resp.data;\n }\n return filterVariableList(resp.data, capturingRegexp);\n },\n { enabled: !!variablePlugin || waitToLoad }\n );\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nexport function getVariableValuesKey(v: VariableStateMap) {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nexport const VARIABLE_TYPES = [\n { label: 'List', kind: 'ListVariable' },\n { label: 'Text', kind: 'TextVariable' },\n] as const;\n"],"names":["useDatasourceStore","usePlugin","useTemplateVariableValues","useTimeRange","useQuery","filterVariableList","data","capturedRegexp","result","filteredSet","Set","variableValue","matches","value","matchAll","concat","match","i","length","m","undefined","has","add","push","label","useListVariablePluginValues","definition","variablePlugin","spec","plugin","kind","datasourceStore","allVariables","absoluteTimeRange","timeRange","refreshKey","variablePluginCtx","variables","capturingRegexp","capturing_regexp","RegExp","dependsOnVariables","dependsOn","dependencies","waitToLoad","some","v","loading","variablesValueKey","getVariableValuesKey","name","resp","getVariableOptions","enabled","Object","values","map","JSON","stringify","join","VARIABLE_TYPES"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SACEA,kBAAkB,EAClBC,SAAS,EACTC,yBAAyB,EACzBC,YAAY,QAGP,2BAA2B,CAAC;AACnC,SAASC,QAAQ,QAAQ,uBAAuB,CAAC;AAEjD,OAAO,SAASC,kBAAkB,CAACC,IAAsB,EAAEC,cAAsB,EAAoB;IACnG,MAAMC,MAAM,GAAqB,EAAE,AAAC;IACpC,MAAMC,WAAW,GAAG,IAAIC,GAAG,EAAU,AAAC;IACtC,KAAK,MAAMC,aAAa,IAAIL,IAAI,CAAE;QAChC,MAAMM,OAAO,GAAGD,aAAa,CAACE,KAAK,CAACC,QAAQ,CAACP,cAAc,CAAC,AAAC;QAC7D,IAAIQ,MAAM,GAAG,EAAE,AAAC;QAChB,KAAK,MAAMC,KAAK,IAAIJ,OAAO,CAAE;YAC3B,IAAK,IAAIK,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGD,KAAK,CAACE,MAAM,EAAED,CAAC,EAAE,CAAE;gBACrC,MAAME,CAAC,GAAGH,KAAK,CAACC,CAAC,CAAC,AAAC;gBACnB,IAAIE,CAAC,KAAKC,SAAS,E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