@perses-dev/plugin-system 0.50.0 → 0.51.0-beta.0

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 (180) hide show
  1. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +17 -71
  2. package/dist/cjs/components/DatasourceSelect.js +8 -13
  3. package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +534 -0
  4. package/dist/cjs/components/HTTPSettingsEditor/index.js +30 -0
  5. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -4
  6. package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +41 -0
  7. package/dist/cjs/components/MetricLabelInput/index.js +30 -0
  8. package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +15 -14
  9. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +7 -11
  10. package/dist/cjs/components/PluginEditor/PluginEditor.js +10 -6
  11. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +4 -5
  12. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +7 -8
  13. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +7 -10
  14. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +17 -14
  15. package/dist/cjs/components/ProjectSelect.js +2 -3
  16. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +46 -92
  17. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +6 -6
  18. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
  19. package/dist/cjs/components/Variables/variable-model.js +4 -7
  20. package/dist/cjs/components/index.js +2 -0
  21. package/dist/cjs/index.js +1 -0
  22. package/dist/cjs/model/explore.js +16 -0
  23. package/dist/cjs/remote/PersesPlugin.types.js +16 -0
  24. package/dist/cjs/remote/PluginLoaderComponent.js +75 -0
  25. package/dist/cjs/remote/PluginRuntime.js +267 -0
  26. package/dist/cjs/remote/index.js +31 -0
  27. package/dist/cjs/remote/remotePluginLoader.js +61 -0
  28. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +4 -10
  29. package/dist/cjs/runtime/DataQueriesProvider/model.js +4 -7
  30. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +2 -2
  31. package/dist/cjs/runtime/builtin-variables.js +1 -1
  32. package/dist/cjs/runtime/datasources.js +3 -3
  33. package/dist/cjs/runtime/plugin-registry.js +5 -6
  34. package/dist/cjs/runtime/time-series-queries.js +11 -18
  35. package/dist/cjs/runtime/trace-queries.js +1 -2
  36. package/dist/cjs/runtime/variables.js +10 -28
  37. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  38. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +1 -67
  39. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  40. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
  41. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemVariables.js +1 -1
  42. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  43. package/dist/cjs/test/render.js +1 -2
  44. package/dist/cjs/test-utils/mock-plugin-registry.js +10 -10
  45. package/dist/cjs/utils/variables.js +1 -1
  46. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  47. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +17 -30
  48. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  49. package/dist/components/DatasourceSelect.d.ts +2 -2
  50. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  51. package/dist/components/DatasourceSelect.js +8 -13
  52. package/dist/components/DatasourceSelect.js.map +1 -1
  53. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +11 -0
  54. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -0
  55. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +480 -0
  56. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -0
  57. package/dist/components/HTTPSettingsEditor/index.d.ts +2 -0
  58. package/dist/components/HTTPSettingsEditor/index.d.ts.map +1 -0
  59. package/dist/components/HTTPSettingsEditor/index.js +15 -0
  60. package/dist/components/HTTPSettingsEditor/index.js.map +1 -0
  61. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -4
  62. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  63. package/dist/components/MetricLabelInput/MetricLabelInput.d.ts +7 -0
  64. package/dist/components/MetricLabelInput/MetricLabelInput.d.ts.map +1 -0
  65. package/dist/components/MetricLabelInput/MetricLabelInput.js +33 -0
  66. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -0
  67. package/dist/components/MetricLabelInput/index.d.ts +2 -0
  68. package/dist/components/MetricLabelInput/index.d.ts.map +1 -0
  69. package/dist/components/MetricLabelInput/index.js +15 -0
  70. package/dist/components/MetricLabelInput/index.js.map +1 -0
  71. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
  72. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +15 -14
  73. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  74. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +7 -11
  75. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  76. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  77. package/dist/components/PluginEditor/PluginEditor.js +10 -6
  78. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  79. package/dist/components/PluginEditor/plugin-editor-api.js +4 -5
  80. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  81. package/dist/components/PluginKindSelect/PluginKindSelect.js +7 -8
  82. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  83. package/dist/components/PluginRegistry/PluginRegistry.js +7 -10
  84. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  85. package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -4
  86. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  87. package/dist/components/PluginRegistry/plugin-indexes.js +17 -14
  88. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  89. package/dist/components/ProjectSelect.js +2 -3
  90. package/dist/components/ProjectSelect.js.map +1 -1
  91. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +46 -92
  92. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  93. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +6 -6
  94. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  95. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
  96. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  97. package/dist/components/Variables/variable-model.js +4 -7
  98. package/dist/components/Variables/variable-model.js.map +1 -1
  99. package/dist/components/index.d.ts +2 -0
  100. package/dist/components/index.d.ts.map +1 -1
  101. package/dist/components/index.js +2 -0
  102. package/dist/components/index.js.map +1 -1
  103. package/dist/index.d.ts +1 -0
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +1 -0
  106. package/dist/index.js.map +1 -1
  107. package/dist/model/explore.d.ts +13 -0
  108. package/dist/model/explore.d.ts.map +1 -0
  109. package/dist/model/explore.js +17 -0
  110. package/dist/model/explore.js.map +1 -0
  111. package/dist/model/panels.d.ts +13 -3
  112. package/dist/model/panels.d.ts.map +1 -1
  113. package/dist/model/panels.js.map +1 -1
  114. package/dist/model/plugins.d.ts +31 -17
  115. package/dist/model/plugins.d.ts.map +1 -1
  116. package/dist/model/plugins.js.map +1 -1
  117. package/dist/remote/PersesPlugin.types.d.ts +7 -0
  118. package/dist/remote/PersesPlugin.types.d.ts.map +1 -0
  119. package/dist/remote/PersesPlugin.types.js +15 -0
  120. package/dist/remote/PersesPlugin.types.js.map +1 -0
  121. package/dist/remote/PluginLoaderComponent.d.ts +10 -0
  122. package/dist/remote/PluginLoaderComponent.d.ts.map +1 -0
  123. package/dist/remote/PluginLoaderComponent.js +67 -0
  124. package/dist/remote/PluginLoaderComponent.js.map +1 -0
  125. package/dist/remote/PluginRuntime.d.ts +11 -0
  126. package/dist/remote/PluginRuntime.d.ts.map +1 -0
  127. package/dist/remote/PluginRuntime.js +202 -0
  128. package/dist/remote/PluginRuntime.js.map +1 -0
  129. package/dist/remote/index.d.ts +3 -0
  130. package/dist/remote/index.d.ts.map +1 -0
  131. package/dist/remote/index.js +16 -0
  132. package/dist/remote/index.js.map +1 -0
  133. package/dist/remote/remotePluginLoader.d.ts +3 -0
  134. package/dist/remote/remotePluginLoader.d.ts.map +1 -0
  135. package/dist/remote/remotePluginLoader.js +53 -0
  136. package/dist/remote/remotePluginLoader.js.map +1 -0
  137. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +4 -10
  138. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  139. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  140. package/dist/runtime/DataQueriesProvider/model.js +4 -7
  141. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  142. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +2 -2
  143. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  144. package/dist/runtime/builtin-variables.js +1 -1
  145. package/dist/runtime/builtin-variables.js.map +1 -1
  146. package/dist/runtime/datasources.d.ts +2 -2
  147. package/dist/runtime/datasources.js +3 -3
  148. package/dist/runtime/datasources.js.map +1 -1
  149. package/dist/runtime/plugin-registry.d.ts +6 -6
  150. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  151. package/dist/runtime/plugin-registry.js +5 -6
  152. package/dist/runtime/plugin-registry.js.map +1 -1
  153. package/dist/runtime/time-series-queries.js +11 -18
  154. package/dist/runtime/time-series-queries.js.map +1 -1
  155. package/dist/runtime/trace-queries.js +1 -2
  156. package/dist/runtime/trace-queries.js.map +1 -1
  157. package/dist/runtime/variables.js +10 -28
  158. package/dist/runtime/variables.js.map +1 -1
  159. package/dist/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  160. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  161. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  162. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -22
  163. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
  164. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  165. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -1
  166. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
  167. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  168. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js +1 -1
  169. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +1 -1
  170. package/dist/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  171. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  172. package/dist/test/render.js +1 -2
  173. package/dist/test/render.js.map +1 -1
  174. package/dist/test-utils/mock-plugin-registry.d.ts +5 -3
  175. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  176. package/dist/test-utils/mock-plugin-registry.js +10 -10
  177. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  178. package/dist/utils/variables.js +1 -1
  179. package/dist/utils/variables.js.map +1 -1
  180. package/package.json +6 -5
@@ -0,0 +1,534 @@
1
+ // Copyright 2024 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
+ Object.defineProperty(exports, "HTTPSettingsEditor", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return HTTPSettingsEditor;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
26
+ const _immer = require("immer");
27
+ const _reacthookform = require("react-hook-form");
28
+ const _Minus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Minus"));
29
+ const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
30
+ const _OptionsEditorRadios = require("../OptionsEditorRadios");
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ function _getRequireWildcardCache(nodeInterop) {
37
+ if (typeof WeakMap !== "function") return null;
38
+ var cacheBabelInterop = new WeakMap();
39
+ var cacheNodeInterop = new WeakMap();
40
+ return (_getRequireWildcardCache = function(nodeInterop) {
41
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
+ })(nodeInterop);
43
+ }
44
+ function _interop_require_wildcard(obj, nodeInterop) {
45
+ if (!nodeInterop && obj && obj.__esModule) {
46
+ return obj;
47
+ }
48
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
+ return {
50
+ default: obj
51
+ };
52
+ }
53
+ var cache = _getRequireWildcardCache(nodeInterop);
54
+ if (cache && cache.has(obj)) {
55
+ return cache.get(obj);
56
+ }
57
+ var newObj = {
58
+ __proto__: null
59
+ };
60
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
+ for(var key in obj){
62
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
+ if (desc && (desc.get || desc.set)) {
65
+ Object.defineProperty(newObj, key, desc);
66
+ } else {
67
+ newObj[key] = obj[key];
68
+ }
69
+ }
70
+ }
71
+ newObj.default = obj;
72
+ if (cache) {
73
+ cache.set(obj, newObj);
74
+ }
75
+ return newObj;
76
+ }
77
+ function HTTPSettingsEditor(props) {
78
+ const { value, onChange, isReadonly, initialSpecDirect, initialSpecProxy } = props;
79
+ const strDirect = 'Direct access';
80
+ const strProxy = 'Proxy';
81
+ // utilitary function used for headers when renaming a property
82
+ // -> TODO it would be cleaner to manipulate headers as an intermediary list instead, to avoid doing this.
83
+ const buildNewHeaders = (oldHeaders, oldName, newName)=>{
84
+ if (oldHeaders === undefined) return oldHeaders;
85
+ const keys = Object.keys(oldHeaders);
86
+ const newHeaders = keys.reduce((acc, val)=>{
87
+ if (val === oldName) {
88
+ acc[newName] = oldHeaders[oldName] || '';
89
+ } else {
90
+ acc[val] = oldHeaders[val] || '';
91
+ }
92
+ return acc;
93
+ }, {});
94
+ return {
95
+ ...newHeaders
96
+ };
97
+ };
98
+ const tabs = [
99
+ {
100
+ label: strDirect,
101
+ content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
102
+ name: "URL",
103
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
104
+ ...field,
105
+ fullWidth: true,
106
+ label: "URL",
107
+ value: value.directUrl || '',
108
+ error: !!fieldState.error,
109
+ helperText: fieldState.error?.message,
110
+ InputProps: {
111
+ readOnly: isReadonly
112
+ },
113
+ InputLabelProps: {
114
+ shrink: isReadonly ? true : undefined
115
+ },
116
+ onChange: (e)=>{
117
+ field.onChange(e);
118
+ onChange((0, _immer.produce)(value, (draft)=>{
119
+ draft.directUrl = e.target.value;
120
+ }));
121
+ }
122
+ })
123
+ })
124
+ },
125
+ {
126
+ label: strProxy,
127
+ content: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
128
+ children: [
129
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
130
+ name: "URL",
131
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
132
+ ...field,
133
+ fullWidth: true,
134
+ label: "URL",
135
+ value: value.proxy?.spec.url || '',
136
+ error: !!fieldState.error,
137
+ helperText: fieldState.error?.message,
138
+ InputProps: {
139
+ readOnly: isReadonly
140
+ },
141
+ InputLabelProps: {
142
+ shrink: isReadonly ? true : undefined
143
+ },
144
+ onChange: (e)=>{
145
+ field.onChange(e);
146
+ onChange((0, _immer.produce)(value, (draft)=>{
147
+ if (draft.proxy !== undefined) {
148
+ draft.proxy.spec.url = e.target.value;
149
+ }
150
+ }));
151
+ },
152
+ sx: {
153
+ mb: 2
154
+ }
155
+ })
156
+ }),
157
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
158
+ variant: "h4",
159
+ mb: 2,
160
+ children: "Allowed endpoints"
161
+ }),
162
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
163
+ container: true,
164
+ spacing: 2,
165
+ mb: 2,
166
+ children: [
167
+ value.proxy?.spec.allowedEndpoints && value.proxy?.spec.allowedEndpoints.length !== 0 ? value.proxy.spec.allowedEndpoints.map(({ endpointPattern, method }, i)=>{
168
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
169
+ children: [
170
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
171
+ item: true,
172
+ xs: 8,
173
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
174
+ name: `Endpoint pattern ${i}`,
175
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
176
+ ...field,
177
+ fullWidth: true,
178
+ label: "Endpoint pattern",
179
+ value: endpointPattern,
180
+ error: !!fieldState.error,
181
+ helperText: fieldState.error?.message,
182
+ InputProps: {
183
+ readOnly: isReadonly
184
+ },
185
+ InputLabelProps: {
186
+ shrink: isReadonly ? true : undefined
187
+ },
188
+ onChange: (e)=>{
189
+ field.onChange(e);
190
+ onChange((0, _immer.produce)(value, (draft)=>{
191
+ if (draft.proxy !== undefined) {
192
+ draft.proxy.spec.allowedEndpoints = draft.proxy.spec.allowedEndpoints?.map((item, itemIndex)=>{
193
+ if (i === itemIndex) {
194
+ return {
195
+ endpointPattern: e.target.value,
196
+ method: item.method
197
+ };
198
+ } else {
199
+ return item;
200
+ }
201
+ });
202
+ }
203
+ }));
204
+ }
205
+ })
206
+ })
207
+ }),
208
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
209
+ item: true,
210
+ xs: 3,
211
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
212
+ name: `Method ${i}`,
213
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
214
+ ...field,
215
+ select: true,
216
+ fullWidth: true,
217
+ label: "Method",
218
+ value: method,
219
+ error: !!fieldState.error,
220
+ helperText: fieldState.error?.message,
221
+ InputProps: {
222
+ readOnly: isReadonly
223
+ },
224
+ InputLabelProps: {
225
+ shrink: isReadonly ? true : undefined
226
+ },
227
+ onChange: (e)=>{
228
+ field.onChange(e);
229
+ onChange((0, _immer.produce)(value, (draft)=>{
230
+ if (draft.proxy !== undefined) {
231
+ draft.proxy.spec.allowedEndpoints = draft.proxy.spec.allowedEndpoints?.map((item, itemIndex)=>{
232
+ if (i === itemIndex) {
233
+ return {
234
+ endpointPattern: item.endpointPattern,
235
+ method: e.target.value
236
+ };
237
+ } else {
238
+ return item;
239
+ }
240
+ });
241
+ }
242
+ }));
243
+ },
244
+ children: [
245
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
246
+ value: "GET",
247
+ children: "GET"
248
+ }),
249
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
250
+ value: "POST",
251
+ children: "POST"
252
+ }),
253
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
254
+ value: "PUT",
255
+ children: "PUT"
256
+ }),
257
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
258
+ value: "PATCH",
259
+ children: "PATCH"
260
+ }),
261
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
262
+ value: "DELETE",
263
+ children: "DELETE"
264
+ })
265
+ ]
266
+ })
267
+ })
268
+ }),
269
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
270
+ item: true,
271
+ xs: 1,
272
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
273
+ name: `Remove Endpoint ${i}`,
274
+ render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
275
+ ...field,
276
+ disabled: isReadonly,
277
+ // Remove the given allowed endpoint from the list
278
+ onClick: (e)=>{
279
+ field.onChange(e);
280
+ onChange((0, _immer.produce)(value, (draft)=>{
281
+ if (draft.proxy !== undefined) {
282
+ draft.proxy.spec.allowedEndpoints = [
283
+ ...draft.proxy.spec.allowedEndpoints?.filter((item, itemIndex)=>{
284
+ return itemIndex !== i;
285
+ }) || []
286
+ ];
287
+ }
288
+ }));
289
+ },
290
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
291
+ })
292
+ })
293
+ })
294
+ ]
295
+ }, i);
296
+ }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
297
+ item: true,
298
+ xs: 4,
299
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
300
+ sx: {
301
+ fontStyle: 'italic'
302
+ },
303
+ children: "None"
304
+ })
305
+ }),
306
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
307
+ item: true,
308
+ xs: 12,
309
+ sx: {
310
+ paddingTop: '0px !important',
311
+ paddingLeft: '5px !important'
312
+ },
313
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
314
+ disabled: isReadonly,
315
+ // Add a new (empty) allowed endpoint to the list
316
+ onClick: ()=>onChange((0, _immer.produce)(value, (draft)=>{
317
+ if (draft.proxy !== undefined) {
318
+ draft.proxy.spec.allowedEndpoints = [
319
+ ...draft.proxy.spec.allowedEndpoints ?? [],
320
+ {
321
+ endpointPattern: '',
322
+ method: ''
323
+ }
324
+ ];
325
+ }
326
+ })),
327
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
328
+ })
329
+ })
330
+ ]
331
+ }),
332
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
333
+ variant: "h4",
334
+ mb: 2,
335
+ children: "Request Headers"
336
+ }),
337
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
338
+ container: true,
339
+ spacing: 2,
340
+ mb: 2,
341
+ children: [
342
+ value.proxy?.spec.headers && Object.keys(value.proxy.spec.headers).map((headerName, i)=>{
343
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
344
+ children: [
345
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
346
+ item: true,
347
+ xs: 4,
348
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
349
+ name: `Header name ${i}`,
350
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
351
+ ...field,
352
+ fullWidth: true,
353
+ label: "Header name",
354
+ value: headerName,
355
+ error: !!fieldState.error,
356
+ helperText: fieldState.error?.message,
357
+ InputProps: {
358
+ readOnly: isReadonly
359
+ },
360
+ InputLabelProps: {
361
+ shrink: isReadonly ? true : undefined
362
+ },
363
+ onChange: (e)=>{
364
+ field.onChange(e);
365
+ onChange((0, _immer.produce)(value, (draft)=>{
366
+ if (draft.proxy !== undefined) {
367
+ draft.proxy.spec.headers = buildNewHeaders(draft.proxy.spec.headers, headerName, e.target.value);
368
+ }
369
+ }));
370
+ }
371
+ })
372
+ })
373
+ }),
374
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
375
+ item: true,
376
+ xs: 7,
377
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
378
+ name: `Header value ${i}`,
379
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
380
+ ...field,
381
+ fullWidth: true,
382
+ label: "Header value",
383
+ value: value.proxy?.spec.headers?.[headerName],
384
+ error: !!fieldState.error,
385
+ helperText: fieldState.error?.message,
386
+ InputProps: {
387
+ readOnly: isReadonly
388
+ },
389
+ InputLabelProps: {
390
+ shrink: isReadonly ? true : undefined
391
+ },
392
+ onChange: (e)=>{
393
+ field.onChange(e);
394
+ onChange((0, _immer.produce)(value, (draft)=>{
395
+ if (draft.proxy !== undefined) {
396
+ draft.proxy.spec.headers = {
397
+ ...draft.proxy.spec.headers,
398
+ [headerName]: e.target.value
399
+ };
400
+ }
401
+ }));
402
+ }
403
+ })
404
+ })
405
+ }),
406
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
407
+ item: true,
408
+ xs: 1,
409
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
410
+ name: `Remove Header ${i}`,
411
+ render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
412
+ ...field,
413
+ disabled: isReadonly,
414
+ // Remove the given header from the list
415
+ onClick: (e)=>{
416
+ field.onChange(e);
417
+ const newHeaders = {
418
+ ...value.proxy?.spec.headers
419
+ };
420
+ delete newHeaders[headerName];
421
+ onChange((0, _immer.produce)(value, (draft)=>{
422
+ if (draft.proxy !== undefined) {
423
+ draft.proxy.spec.headers = newHeaders;
424
+ }
425
+ }));
426
+ },
427
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
428
+ })
429
+ })
430
+ })
431
+ ]
432
+ }, i);
433
+ }),
434
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
435
+ item: true,
436
+ xs: 12,
437
+ sx: {
438
+ paddingTop: '0px !important',
439
+ paddingLeft: '5px !important'
440
+ },
441
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
442
+ disabled: isReadonly,
443
+ // Add a new (empty) header to the list
444
+ onClick: ()=>onChange((0, _immer.produce)(value, (draft)=>{
445
+ if (draft.proxy !== undefined) {
446
+ draft.proxy.spec.headers = {
447
+ ...draft.proxy.spec.headers,
448
+ '': ''
449
+ };
450
+ }
451
+ })),
452
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
453
+ })
454
+ })
455
+ ]
456
+ }),
457
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
458
+ name: "Secret",
459
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
460
+ ...field,
461
+ fullWidth: true,
462
+ label: "Secret",
463
+ value: value.proxy?.spec.secret || '',
464
+ error: !!fieldState.error,
465
+ helperText: fieldState.error?.message,
466
+ InputProps: {
467
+ readOnly: isReadonly
468
+ },
469
+ InputLabelProps: {
470
+ shrink: isReadonly ? true : undefined
471
+ },
472
+ onChange: (e)=>{
473
+ field.onChange(e);
474
+ onChange((0, _immer.produce)(value, (draft)=>{
475
+ if (draft.proxy !== undefined) {
476
+ draft.proxy.spec.secret = e.target.value;
477
+ }
478
+ }));
479
+ }
480
+ })
481
+ })
482
+ ]
483
+ })
484
+ }
485
+ ];
486
+ // Use of findIndex instead of providing hardcoded values to avoid desynchronisatio or
487
+ // bug in case the tabs get eventually swapped in the future.
488
+ const directModeId = tabs.findIndex((tab)=>tab.label === strDirect);
489
+ const proxyModeId = tabs.findIndex((tab)=>tab.label === strProxy);
490
+ // In "update datasource" case, set defaultTab to the mode that this datasource is currently relying on.
491
+ // Otherwise (create datasource), set defaultTab to Direct access.
492
+ const defaultTab = value.proxy ? proxyModeId : directModeId;
493
+ // For better user experience, save previous states in mind for both mode.
494
+ // This avoids losing everything when the user changes their mind back.
495
+ const [previousSpecDirect, setPreviousSpecDirect] = (0, _react.useState)(initialSpecDirect);
496
+ const [previousSpecProxy, setPreviousSpecProxy] = (0, _react.useState)(initialSpecProxy);
497
+ // When changing mode, remove previous mode's config + append default values for the new mode.
498
+ const handleModeChange = (v)=>{
499
+ if (tabs[v]?.label === strDirect) {
500
+ setPreviousSpecProxy(value);
501
+ // Copy all settings (for example, scrapeInterval), except 'proxy'
502
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
503
+ const { proxy, ...newValue } = value;
504
+ onChange({
505
+ ...newValue,
506
+ directUrl: previousSpecDirect.directUrl
507
+ });
508
+ } else if (tabs[v]?.label === strProxy) {
509
+ setPreviousSpecDirect(value);
510
+ // Copy all settings (for example, scrapeInterval), except 'directUrl'
511
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
512
+ const { directUrl, ...newValue } = value;
513
+ onChange({
514
+ ...newValue,
515
+ proxy: previousSpecProxy.proxy
516
+ });
517
+ }
518
+ };
519
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
520
+ children: [
521
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
522
+ variant: "h4",
523
+ mt: 2,
524
+ children: "HTTP Settings"
525
+ }),
526
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorRadios.OptionsEditorRadios, {
527
+ isReadonly: isReadonly,
528
+ tabs: tabs,
529
+ defaultTab: defaultTab,
530
+ onModeChange: handleModeChange
531
+ })
532
+ ]
533
+ });
534
+ }
@@ -0,0 +1,30 @@
1
+ // Copyright 2024 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
+ _export_star(require("./HTTPSettingsEditor"), exports);
18
+ function _export_star(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
+ Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ }
28
+ });
29
+ return from;
30
+ }
@@ -87,13 +87,13 @@ function LegendOptionsEditor({ value, onChange, showValuesEditor = true }) {
87
87
  });
88
88
  };
89
89
  const isValidLegend = (0, _model.validateLegendSpec)(value);
90
- const currentPosition = (0, _core.getLegendPosition)(value === null || value === void 0 ? void 0 : value.position);
90
+ const currentPosition = (0, _core.getLegendPosition)(value?.position);
91
91
  const legendPositionConfig = _model.LEGEND_POSITIONS_CONFIG[currentPosition];
92
- const currentMode = (0, _core.getLegendMode)(value === null || value === void 0 ? void 0 : value.mode);
92
+ const currentMode = (0, _core.getLegendMode)(value?.mode);
93
93
  const legendModeConfig = _model.LEGEND_MODE_CONFIG[currentMode];
94
- const currentSize = (0, _core.getLegendSize)(value === null || value === void 0 ? void 0 : value.size);
94
+ const currentSize = (0, _core.getLegendSize)(value?.size);
95
95
  const legendSizeConfig = _model.LEGEND_SIZE_CONFIG[currentSize];
96
- const currentValues = (value === null || value === void 0 ? void 0 : value.values) || [];
96
+ const currentValues = value?.values || [];
97
97
  const legendValuesConfig = currentValues.reduce((result, item)=>{
98
98
  const config = _model.LEGEND_VALUE_CONFIG[item];
99
99
  if (config) {
@@ -0,0 +1,41 @@
1
+ // Copyright 2025 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
+ Object.defineProperty(exports, "MetricLabelInput", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return MetricLabelInput;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _components = require("@perses-dev/components");
26
+ const MetricLabelInput = ({ value, onChange })=>{
27
+ const handleChange = (event)=>{
28
+ const newValue = event.target.value;
29
+ onChange(newValue || undefined);
30
+ };
31
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
32
+ label: "Metric label",
33
+ description: "Specify label to display",
34
+ control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
35
+ fullWidth: true,
36
+ name: "Metric label",
37
+ value: value || '',
38
+ onChange: handleChange
39
+ })
40
+ });
41
+ };
@@ -0,0 +1,30 @@
1
+ // Copyright 2025 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
+ _export_star(require("./MetricLabelInput"), exports);
18
+ function _export_star(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
+ Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ }
28
+ });
29
+ return from;
30
+ }