@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.
Files changed (124) hide show
  1. package/dist/cjs/components/Dashboard/Dashboard.js +3 -2
  2. package/dist/cjs/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +12 -52
  3. package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +2 -1
  4. package/dist/cjs/components/GridLayout/GridItemContent.js +3 -1
  5. package/dist/cjs/components/GridLayout/GridLayout.js +1 -0
  6. package/dist/cjs/components/GridLayout/index.js +3 -1
  7. package/dist/cjs/components/Panel/Panel.js +8 -3
  8. package/dist/cjs/components/Panel/PanelHeader.js +7 -3
  9. package/dist/cjs/components/SaveDashboardButton/SaveDashboardButton.js +3 -1
  10. package/dist/cjs/components/Variables/EditVariablesButton.js +2 -0
  11. package/dist/cjs/components/Variables/TemplateVariable.js +22 -18
  12. package/dist/cjs/components/Variables/VariableEditor.js +271 -99
  13. package/dist/cjs/components/Variables/VariableList.js +38 -18
  14. package/dist/cjs/components/Variables/index.js +0 -2
  15. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +3 -2
  16. package/dist/cjs/context/DatasourceStoreProvider.js +22 -18
  17. package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +71 -24
  18. package/dist/cjs/context/TemplateVariableProvider/hydrationUtils.js +55 -5
  19. package/dist/cjs/context/TemplateVariableProvider/utils.js +39 -7
  20. package/dist/cjs/views/ViewDashboard/DashboardApp.js +1 -1
  21. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +6 -4
  22. package/dist/components/Dashboard/Dashboard.d.ts +3 -1
  23. package/dist/components/Dashboard/Dashboard.d.ts.map +1 -1
  24. package/dist/components/Dashboard/Dashboard.js +3 -2
  25. package/dist/components/Dashboard/Dashboard.js.map +1 -1
  26. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts +1 -1
  27. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.d.ts.map +1 -1
  28. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js +11 -46
  29. package/dist/components/DiscardChangesConfirmationDialog/DiscardChangesConfirmationDialog.js.map +1 -1
  30. package/dist/components/EditJsonDialog/EditJsonDialog.js +2 -1
  31. package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
  32. package/dist/components/GridLayout/GridItemContent.d.ts +2 -0
  33. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  34. package/dist/components/GridLayout/GridItemContent.js +3 -1
  35. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  36. package/dist/components/GridLayout/GridLayout.d.ts +2 -0
  37. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  38. package/dist/components/GridLayout/GridLayout.js +1 -0
  39. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  40. package/dist/components/GridLayout/index.d.ts +3 -1
  41. package/dist/components/GridLayout/index.d.ts.map +1 -1
  42. package/dist/components/GridLayout/index.js +3 -1
  43. package/dist/components/GridLayout/index.js.map +1 -1
  44. package/dist/components/Panel/Panel.d.ts +20 -0
  45. package/dist/components/Panel/Panel.d.ts.map +1 -1
  46. package/dist/components/Panel/Panel.js +8 -3
  47. package/dist/components/Panel/Panel.js.map +1 -1
  48. package/dist/components/Panel/PanelHeader.d.ts +2 -1
  49. package/dist/components/Panel/PanelHeader.d.ts.map +1 -1
  50. package/dist/components/Panel/PanelHeader.js +7 -3
  51. package/dist/components/Panel/PanelHeader.js.map +1 -1
  52. package/dist/components/SaveDashboardButton/SaveDashboardButton.d.ts.map +1 -1
  53. package/dist/components/SaveDashboardButton/SaveDashboardButton.js +3 -1
  54. package/dist/components/SaveDashboardButton/SaveDashboardButton.js.map +1 -1
  55. package/dist/components/Variables/EditVariablesButton.d.ts.map +1 -1
  56. package/dist/components/Variables/EditVariablesButton.js +3 -1
  57. package/dist/components/Variables/EditVariablesButton.js.map +1 -1
  58. package/dist/components/Variables/TemplateVariable.d.ts +2 -1
  59. package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
  60. package/dist/components/Variables/TemplateVariable.js +21 -17
  61. package/dist/components/Variables/TemplateVariable.js.map +1 -1
  62. package/dist/components/Variables/VariableEditor.d.ts +7 -0
  63. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  64. package/dist/components/Variables/VariableEditor.js +261 -95
  65. package/dist/components/Variables/VariableEditor.js.map +1 -1
  66. package/dist/components/Variables/VariableList.d.ts +5 -0
  67. package/dist/components/Variables/VariableList.d.ts.map +1 -1
  68. package/dist/components/Variables/VariableList.js +31 -17
  69. package/dist/components/Variables/VariableList.js.map +1 -1
  70. package/dist/components/Variables/index.d.ts +0 -2
  71. package/dist/components/Variables/index.d.ts.map +1 -1
  72. package/dist/components/Variables/index.js +0 -2
  73. package/dist/components/Variables/index.js.map +1 -1
  74. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  75. package/dist/context/DashboardProvider/DashboardProvider.js +3 -2
  76. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  77. package/dist/context/DatasourceStoreProvider.d.ts +4 -3
  78. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
  79. package/dist/context/DatasourceStoreProvider.js +22 -18
  80. package/dist/context/DatasourceStoreProvider.js.map +1 -1
  81. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +39 -10
  82. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
  83. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +76 -27
  84. package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
  85. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts +9 -2
  86. package/dist/context/TemplateVariableProvider/hydrationUtils.d.ts.map +1 -1
  87. package/dist/context/TemplateVariableProvider/hydrationUtils.js +60 -5
  88. package/dist/context/TemplateVariableProvider/hydrationUtils.js.map +1 -1
  89. package/dist/context/TemplateVariableProvider/utils.d.ts +27 -2
  90. package/dist/context/TemplateVariableProvider/utils.d.ts.map +1 -1
  91. package/dist/context/TemplateVariableProvider/utils.js +46 -4
  92. package/dist/context/TemplateVariableProvider/utils.js.map +1 -1
  93. package/dist/views/ViewDashboard/DashboardApp.js +2 -2
  94. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  95. package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -1
  96. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  97. package/dist/views/ViewDashboard/ViewDashboard.js +6 -4
  98. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  99. package/package.json +6 -6
  100. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -399
  101. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +0 -178
  102. package/dist/cjs/components/Variables/VariableEditorForm/index.js +0 -29
  103. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -91
  104. package/dist/cjs/components/Variables/variable-model.js +0 -117
  105. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +0 -10
  106. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +0 -1
  107. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +0 -354
  108. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +0 -1
  109. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +0 -16
  110. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +0 -1
  111. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +0 -122
  112. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +0 -1
  113. package/dist/components/Variables/VariableEditorForm/index.d.ts +0 -3
  114. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +0 -1
  115. package/dist/components/Variables/VariableEditorForm/index.js +0 -16
  116. package/dist/components/Variables/VariableEditorForm/index.js.map +0 -1
  117. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +0 -23
  118. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +0 -1
  119. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +0 -79
  120. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +0 -1
  121. package/dist/components/Variables/variable-model.d.ts +0 -16
  122. package/dist/components/Variables/variable-model.d.ts.map +0 -1
  123. package/dist/components/Variables/variable-model.js +0 -105
  124. package/dist/components/Variables/variable-model.js.map +0 -1
@@ -1,178 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- VariablePreview: ()=>VariablePreview,
25
- VariableListPreview: ()=>VariableListPreview
26
- });
27
- const _jsxRuntime = require("react/jsx-runtime");
28
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
29
- const _material = require("@mui/material");
30
- const _components = require("@perses-dev/components");
31
- const _refresh = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Refresh"));
32
- const _clipboardOutline = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/ClipboardOutline"));
33
- const _constants = require("../../../constants");
34
- const _variableModel = require("../variable-model");
35
- function _interopRequireDefault(obj) {
36
- return obj && obj.__esModule ? obj : {
37
- default: obj
38
- };
39
- }
40
- function _getRequireWildcardCache(nodeInterop) {
41
- if (typeof WeakMap !== "function") return null;
42
- var cacheBabelInterop = new WeakMap();
43
- var cacheNodeInterop = new WeakMap();
44
- return (_getRequireWildcardCache = function(nodeInterop) {
45
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
46
- })(nodeInterop);
47
- }
48
- function _interopRequireWildcard(obj, nodeInterop) {
49
- if (!nodeInterop && obj && obj.__esModule) {
50
- return obj;
51
- }
52
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
53
- return {
54
- default: obj
55
- };
56
- }
57
- var cache = _getRequireWildcardCache(nodeInterop);
58
- if (cache && cache.has(obj)) {
59
- return cache.get(obj);
60
- }
61
- var newObj = {};
62
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
63
- for(var key in obj){
64
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
65
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
66
- if (desc && (desc.get || desc.set)) {
67
- Object.defineProperty(newObj, key, desc);
68
- } else {
69
- newObj[key] = obj[key];
70
- }
71
- }
72
- }
73
- newObj.default = obj;
74
- if (cache) {
75
- cache.set(obj, newObj);
76
- }
77
- return newObj;
78
- }
79
- const DEFAULT_MAX_PREVIEW_VALUES = 50;
80
- function VariablePreview(props) {
81
- const { values , onRefresh , isLoading , error } = props;
82
- const [maxValues, setMaxValues] = (0, _react.useState)(DEFAULT_MAX_PREVIEW_VALUES);
83
- const { infoSnackbar } = (0, _components.useSnackbar)();
84
- const showAll = ()=>{
85
- setMaxValues(undefined);
86
- };
87
- let notShown = 0;
88
- if (values && (values === null || values === void 0 ? void 0 : values.length) > 0 && maxValues) {
89
- notShown = values.length - maxValues;
90
- }
91
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
92
- children: [
93
- /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
94
- direction: "row",
95
- spacing: 1,
96
- alignItems: "center",
97
- mb: 1,
98
- children: [
99
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
100
- variant: "h4",
101
- children: "Preview Values"
102
- }),
103
- onRefresh && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
104
- description: _constants.TOOLTIP_TEXT.refreshVariableValues,
105
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
106
- onClick: onRefresh,
107
- size: "small",
108
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_refresh.default, {})
109
- })
110
- }),
111
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_components.InfoTooltip, {
112
- description: _constants.TOOLTIP_TEXT.copyVariableValues,
113
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
114
- onClick: async ()=>{
115
- if (values === null || values === void 0 ? void 0 : values.length) {
116
- await navigator.clipboard.writeText(values.map((value)=>value).join(', '));
117
- infoSnackbar('Preview values copied to clipboard!');
118
- }
119
- },
120
- size: "small",
121
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_clipboardOutline.default, {})
122
- })
123
- })
124
- ]
125
- }),
126
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Card, {
127
- variant: "outlined",
128
- children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
129
- sx: {
130
- display: 'flex',
131
- flexWrap: 'wrap',
132
- gap: 1,
133
- m: 2
134
- },
135
- children: [
136
- error && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Alert, {
137
- severity: "error",
138
- children: error
139
- }),
140
- (values === null || values === void 0 ? void 0 : values.length) === 0 && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Alert, {
141
- severity: "info",
142
- children: "No results"
143
- }),
144
- isLoading && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
145
- width: "100%",
146
- sx: {
147
- alignItems: 'center',
148
- justifyContent: 'center'
149
- },
150
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.CircularProgress, {})
151
- }),
152
- values === null || values === void 0 ? void 0 : values.slice(0, maxValues).map((val)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Chip, {
153
- size: "small",
154
- label: val
155
- }, val)),
156
- notShown > 0 && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Chip, {
157
- onClick: showAll,
158
- variant: "outlined",
159
- size: "small",
160
- label: `+${notShown} more`
161
- })
162
- ]
163
- })
164
- })
165
- ]
166
- });
167
- }
168
- function VariableListPreview(props) {
169
- const { definition , onRefresh } = props;
170
- const { data , isFetching , error } = (0, _variableModel.useListVariablePluginValues)(definition);
171
- const errorMessage = error === null || error === void 0 ? void 0 : error.message;
172
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(VariablePreview, {
173
- values: (data === null || data === void 0 ? void 0 : data.map((val)=>val.value)) || [],
174
- onRefresh: onRefresh,
175
- isLoading: isFetching,
176
- error: errorMessage
177
- });
178
- }
@@ -1,29 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- _exportStar(require("./VariableEditorForm"), exports);
18
- _exportStar(require("./VariablePreview"), exports);
19
- function _exportStar(from, to) {
20
- Object.keys(from).forEach(function(k) {
21
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
22
- enumerable: true,
23
- get: function() {
24
- return from[k];
25
- }
26
- });
27
- });
28
- return from;
29
- }
@@ -1,91 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: all[name]
21
- });
22
- }
23
- _export(exports, {
24
- getInitialState: ()=>getInitialState,
25
- getVariableDefinitionFromState: ()=>getVariableDefinitionFromState
26
- });
27
- function getInitialState(initialVariableDefinition) {
28
- var ref;
29
- var _value;
30
- const textVariableFields = {
31
- value: (_value = initialVariableDefinition.spec.value) !== null && _value !== void 0 ? _value : ''
32
- };
33
- const listVariableFields = {
34
- allowMultiple: false,
35
- allowAll: false,
36
- capturing_regexp: undefined,
37
- plugin: {
38
- kind: '',
39
- spec: {}
40
- },
41
- customAllValue: undefined
42
- };
43
- if (initialVariableDefinition.kind === 'ListVariable') {
44
- var _allow_all_value;
45
- listVariableFields.allowMultiple = (_allow_all_value = initialVariableDefinition.spec.allow_all_value) !== null && _allow_all_value !== void 0 ? _allow_all_value : false;
46
- var _allow_all_value1;
47
- listVariableFields.allowAll = (_allow_all_value1 = initialVariableDefinition.spec.allow_all_value) !== null && _allow_all_value1 !== void 0 ? _allow_all_value1 : false;
48
- listVariableFields.capturing_regexp = initialVariableDefinition.spec.capturing_regexp;
49
- listVariableFields.plugin = initialVariableDefinition.spec.plugin;
50
- listVariableFields.customAllValue = initialVariableDefinition.spec.custom_all_value;
51
- }
52
- return {
53
- name: initialVariableDefinition.spec.name,
54
- title: (ref = initialVariableDefinition.spec.display) === null || ref === void 0 ? void 0 : ref.name,
55
- kind: initialVariableDefinition.kind,
56
- description: '',
57
- listVariableFields,
58
- textVariableFields
59
- };
60
- }
61
- function getVariableDefinitionFromState(state) {
62
- const { name , title , kind } = state;
63
- const display = title ? {
64
- name: title
65
- } : undefined;
66
- if (kind === 'TextVariable') {
67
- return {
68
- kind,
69
- spec: {
70
- name,
71
- display,
72
- ...state.textVariableFields
73
- }
74
- };
75
- }
76
- if (kind === 'ListVariable') {
77
- return {
78
- kind,
79
- spec: {
80
- name,
81
- display,
82
- allow_multiple: state.listVariableFields.allowMultiple,
83
- allow_all_value: state.listVariableFields.allowAll,
84
- capturing_regexp: state.listVariableFields.capturing_regexp,
85
- plugin: state.listVariableFields.plugin,
86
- custom_all_value: state.listVariableFields.customAllValue
87
- }
88
- };
89
- }
90
- throw new Error(`Unknown variable kind: ${kind}`);
91
- }
@@ -1,117 +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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- function _export(target, all) {
18
- for(var name1 in all)Object.defineProperty(target, name1, {
19
- enumerable: true,
20
- get: all[name1]
21
- });
22
- }
23
- _export(exports, {
24
- filterVariableList: ()=>filterVariableList,
25
- useListVariablePluginValues: ()=>useListVariablePluginValues,
26
- getVariableValuesKey: ()=>getVariableValuesKey,
27
- VARIABLE_TYPES: ()=>VARIABLE_TYPES
28
- });
29
- const _pluginSystem = require("@perses-dev/plugin-system");
30
- const _reactQuery = require("@tanstack/react-query");
31
- function filterVariableList(data, capturedRegexp) {
32
- const result = [];
33
- const filteredSet = new Set();
34
- for (const variableValue of data){
35
- const matches = variableValue.value.matchAll(capturedRegexp);
36
- let concat = '';
37
- for (const match of matches){
38
- for(let i = 1; i < match.length; i++){
39
- const m = match[i];
40
- if (m !== undefined) {
41
- concat = `${concat}${m}`;
42
- }
43
- }
44
- }
45
- if (concat !== '' && !filteredSet.has(concat)) {
46
- // like that we are avoiding to have duplicating variable value
47
- filteredSet.add(concat);
48
- result.push({
49
- label: variableValue.label,
50
- value: concat
51
- });
52
- }
53
- }
54
- return result;
55
- }
56
- function useListVariablePluginValues(definition) {
57
- const { data: variablePlugin } = (0, _pluginSystem.usePlugin)('Variable', definition.spec.plugin.kind);
58
- const datasourceStore = (0, _pluginSystem.useDatasourceStore)();
59
- const allVariables = (0, _pluginSystem.useTemplateVariableValues)();
60
- const { absoluteTimeRange: timeRange , refreshKey } = (0, _pluginSystem.useTimeRange)();
61
- const variablePluginCtx = {
62
- timeRange,
63
- datasourceStore,
64
- variables: allVariables
65
- };
66
- const spec = definition.spec.plugin.spec;
67
- const capturingRegexp = definition.spec.capturing_regexp !== undefined ? new RegExp(definition.spec.capturing_regexp, 'g') : undefined;
68
- let dependsOnVariables;
69
- if (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.dependsOn) {
70
- const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);
71
- dependsOnVariables = dependencies.variables;
72
- }
73
- const variables = (0, _pluginSystem.useTemplateVariableValues)(dependsOnVariables);
74
- let waitToLoad = false;
75
- if (dependsOnVariables) {
76
- waitToLoad = dependsOnVariables.some((v)=>{
77
- var ref;
78
- return (ref = variables[v]) === null || ref === void 0 ? void 0 : ref.loading;
79
- });
80
- }
81
- const variablesValueKey = getVariableValuesKey(variables);
82
- return (0, _reactQuery.useQuery)([
83
- name,
84
- definition,
85
- variablesValueKey,
86
- timeRange,
87
- refreshKey
88
- ], async ()=>{
89
- const resp = await (variablePlugin === null || variablePlugin === void 0 ? void 0 : variablePlugin.getVariableOptions(spec, {
90
- datasourceStore,
91
- variables,
92
- timeRange
93
- }));
94
- if (resp === undefined) {
95
- return [];
96
- }
97
- if (capturingRegexp === undefined) {
98
- return resp.data;
99
- }
100
- return filterVariableList(resp.data, capturingRegexp);
101
- }, {
102
- enabled: !!variablePlugin || waitToLoad
103
- });
104
- }
105
- function getVariableValuesKey(v) {
106
- return Object.values(v).map((v)=>JSON.stringify(v.value)).join(',');
107
- }
108
- const VARIABLE_TYPES = [
109
- {
110
- label: 'List',
111
- kind: 'ListVariable'
112
- },
113
- {
114
- label: 'Text',
115
- kind: 'TextVariable'
116
- }
117
- ];
@@ -1,10 +0,0 @@
1
- /// <reference types="react" />
2
- import { VariableDefinition } from '@perses-dev/core';
3
- interface VariableEditFormProps {
4
- initialVariableDefinition: VariableDefinition;
5
- onChange: (def: VariableDefinition) => void;
6
- onCancel: () => void;
7
- }
8
- export declare function VariableEditForm(props: VariableEditFormProps): JSX.Element;
9
- export {};
10
- //# sourceMappingURL=VariableEditorForm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VariableEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"names":[],"mappings":";AAgCA,OAAO,EAAE,kBAAkB,EAA0B,MAAM,kBAAkB,CAAC;AA6B9E,UAAU,qBAAqB;IAC7B,yBAAyB,EAAE,kBAAkB,CAAC;IAC9C,QAAQ,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC5C,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,eAiQ5D"}