@perses-dev/plugin-system 0.0.0-snapshot-ts-panel-actions-90e9ef0 → 0.0.0-snapshot-reverse-proxy-75afbd7

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 (193) hide show
  1. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +1 -0
  2. package/dist/cjs/components/{DatasourceSelect.js → DatasourceSelect/DatasourceSelect.js} +4 -3
  3. package/dist/cjs/components/DatasourceSelect/index.js +30 -0
  4. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +117 -90
  5. package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +5 -2
  6. package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +14 -4
  7. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +7 -5
  8. package/dist/cjs/components/PluginEditor/PluginEditor.js +57 -17
  9. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +6 -3
  10. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +13 -9
  11. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +62 -120
  12. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +42 -33
  13. package/dist/cjs/components/Variables/VariableEditorForm/index.js +1 -0
  14. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +47 -0
  15. package/dist/cjs/components/Variables/variable-model.js +3 -3
  16. package/dist/cjs/components/index.js +0 -1
  17. package/dist/cjs/context/index.js +0 -1
  18. package/dist/cjs/model/legend.js +13 -0
  19. package/dist/cjs/model/log-queries.js +16 -0
  20. package/dist/cjs/remote/PluginRuntime.js +3 -2
  21. package/dist/cjs/remote/remotePluginLoader.js +19 -4
  22. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +10 -2
  23. package/dist/cjs/runtime/DataQueriesProvider/model.js +17 -4
  24. package/dist/cjs/runtime/RouterProvider.js +114 -0
  25. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +6 -1
  26. package/dist/cjs/runtime/UsageMetricsProvider.js +4 -3
  27. package/dist/cjs/runtime/index.js +1 -0
  28. package/dist/cjs/runtime/log-queries.js +68 -0
  29. package/dist/cjs/runtime/time-series-queries.js +4 -4
  30. package/dist/cjs/runtime/variables.js +15 -0
  31. package/dist/cjs/test/mock-data.js +182 -0
  32. package/dist/cjs/test/utils.js +17 -8
  33. package/dist/cjs/utils/variables.js +109 -14
  34. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  35. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +1 -0
  36. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  37. package/dist/components/{DatasourceSelect.d.ts → DatasourceSelect/DatasourceSelect.d.ts} +1 -1
  38. package/dist/components/DatasourceSelect/DatasourceSelect.d.ts.map +1 -0
  39. package/dist/components/{DatasourceSelect.js → DatasourceSelect/DatasourceSelect.js} +4 -3
  40. package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -0
  41. package/dist/components/DatasourceSelect/index.d.ts +2 -0
  42. package/dist/components/DatasourceSelect/index.d.ts.map +1 -0
  43. package/dist/components/DatasourceSelect/index.js +15 -0
  44. package/dist/components/DatasourceSelect/index.js.map +1 -0
  45. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +2 -1
  46. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  47. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +120 -93
  48. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  49. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +3 -2
  50. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
  51. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +6 -3
  52. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  53. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +3 -2
  54. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
  55. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +14 -4
  56. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  57. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +3 -2
  58. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  59. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +7 -5
  60. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  61. package/dist/components/PluginEditor/PluginEditor.d.ts +3 -3
  62. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  63. package/dist/components/PluginEditor/PluginEditor.js +57 -17
  64. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  65. package/dist/components/PluginEditor/plugin-editor-api.d.ts +5 -0
  66. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  67. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  68. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  69. package/dist/components/PluginKindSelect/PluginKindSelect.js +7 -4
  70. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  71. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  72. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +13 -9
  73. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  74. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  75. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  76. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +63 -80
  77. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  78. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +2 -2
  79. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  80. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +43 -34
  81. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  82. package/dist/components/Variables/VariableEditorForm/index.d.ts +1 -0
  83. package/dist/components/Variables/VariableEditorForm/index.d.ts.map +1 -1
  84. package/dist/components/Variables/VariableEditorForm/index.js +1 -0
  85. package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
  86. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +6 -0
  87. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  88. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +44 -0
  89. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  90. package/dist/components/Variables/variable-model.js +3 -3
  91. package/dist/components/Variables/variable-model.js.map +1 -1
  92. package/dist/components/index.d.ts +0 -1
  93. package/dist/components/index.d.ts.map +1 -1
  94. package/dist/components/index.js +0 -1
  95. package/dist/components/index.js.map +1 -1
  96. package/dist/context/index.d.ts +0 -1
  97. package/dist/context/index.d.ts.map +1 -1
  98. package/dist/context/index.js +0 -1
  99. package/dist/context/index.js.map +1 -1
  100. package/dist/model/legend.d.ts +3 -1
  101. package/dist/model/legend.d.ts.map +1 -1
  102. package/dist/model/legend.js +10 -0
  103. package/dist/model/legend.js.map +1 -1
  104. package/dist/model/log-queries.d.ts +24 -0
  105. package/dist/model/log-queries.d.ts.map +1 -0
  106. package/dist/model/log-queries.js +15 -0
  107. package/dist/model/log-queries.js.map +1 -0
  108. package/dist/model/panels.d.ts +8 -0
  109. package/dist/model/panels.d.ts.map +1 -1
  110. package/dist/model/panels.js.map +1 -1
  111. package/dist/model/plugin-base.d.ts +6 -1
  112. package/dist/model/plugin-base.d.ts.map +1 -1
  113. package/dist/model/plugin-base.js.map +1 -1
  114. package/dist/model/plugins.d.ts +2 -0
  115. package/dist/model/plugins.d.ts.map +1 -1
  116. package/dist/model/plugins.js.map +1 -1
  117. package/dist/model/time-series-queries.d.ts +1 -1
  118. package/dist/model/time-series-queries.d.ts.map +1 -1
  119. package/dist/model/time-series-queries.js.map +1 -1
  120. package/dist/model/variables.d.ts +1 -1
  121. package/dist/model/variables.d.ts.map +1 -1
  122. package/dist/model/variables.js.map +1 -1
  123. package/dist/remote/PluginRuntime.d.ts +2 -2
  124. package/dist/remote/PluginRuntime.d.ts.map +1 -1
  125. package/dist/remote/PluginRuntime.js +4 -3
  126. package/dist/remote/PluginRuntime.js.map +1 -1
  127. package/dist/remote/remotePluginLoader.d.ts +18 -1
  128. package/dist/remote/remotePluginLoader.d.ts.map +1 -1
  129. package/dist/remote/remotePluginLoader.js +22 -4
  130. package/dist/remote/remotePluginLoader.js.map +1 -1
  131. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  132. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +10 -2
  133. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  134. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  135. package/dist/runtime/DataQueriesProvider/model.js +17 -4
  136. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  137. package/dist/runtime/RouterProvider.d.ts +32 -0
  138. package/dist/runtime/RouterProvider.d.ts.map +1 -0
  139. package/dist/runtime/RouterProvider.js +59 -0
  140. package/dist/runtime/RouterProvider.js.map +1 -0
  141. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  142. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +6 -1
  143. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  144. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  145. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  146. package/dist/runtime/UsageMetricsProvider.d.ts +3 -1
  147. package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -1
  148. package/dist/runtime/UsageMetricsProvider.js +4 -3
  149. package/dist/runtime/UsageMetricsProvider.js.map +1 -1
  150. package/dist/runtime/index.d.ts +1 -0
  151. package/dist/runtime/index.d.ts.map +1 -1
  152. package/dist/runtime/index.js +1 -0
  153. package/dist/runtime/index.js.map +1 -1
  154. package/dist/runtime/log-queries.d.ts +7 -0
  155. package/dist/runtime/log-queries.d.ts.map +1 -0
  156. package/dist/runtime/log-queries.js +52 -0
  157. package/dist/runtime/log-queries.js.map +1 -0
  158. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  159. package/dist/runtime/time-series-queries.js +4 -4
  160. package/dist/runtime/time-series-queries.js.map +1 -1
  161. package/dist/runtime/variables.d.ts +1 -0
  162. package/dist/runtime/variables.d.ts.map +1 -1
  163. package/dist/runtime/variables.js +13 -0
  164. package/dist/runtime/variables.js.map +1 -1
  165. package/dist/test/mock-data.d.ts +136 -1
  166. package/dist/test/mock-data.d.ts.map +1 -1
  167. package/dist/test/mock-data.js +156 -0
  168. package/dist/test/mock-data.js.map +1 -1
  169. package/dist/test/utils.d.ts.map +1 -1
  170. package/dist/test/utils.js +17 -8
  171. package/dist/test/utils.js.map +1 -1
  172. package/dist/utils/variables.d.ts +24 -2
  173. package/dist/utils/variables.d.ts.map +1 -1
  174. package/dist/utils/variables.js +102 -14
  175. package/dist/utils/variables.js.map +1 -1
  176. package/package.json +7 -7
  177. package/dist/cjs/components/ProjectSelect.js +0 -96
  178. package/dist/cjs/context/ProjectStoreProvider.js +0 -81
  179. package/dist/cjs/context/query-params.js +0 -49
  180. package/dist/components/DatasourceSelect.d.ts.map +0 -1
  181. package/dist/components/DatasourceSelect.js.map +0 -1
  182. package/dist/components/ProjectSelect.d.ts +0 -15
  183. package/dist/components/ProjectSelect.d.ts.map +0 -1
  184. package/dist/components/ProjectSelect.js +0 -91
  185. package/dist/components/ProjectSelect.js.map +0 -1
  186. package/dist/context/ProjectStoreProvider.d.ts +0 -16
  187. package/dist/context/ProjectStoreProvider.d.ts.map +0 -1
  188. package/dist/context/ProjectStoreProvider.js +0 -59
  189. package/dist/context/ProjectStoreProvider.js.map +0 -1
  190. package/dist/context/query-params.d.ts +0 -5
  191. package/dist/context/query-params.d.ts.map +0 -1
  192. package/dist/context/query-params.js +0 -41
  193. package/dist/context/query-params.js.map +0 -1
@@ -21,57 +21,18 @@ Object.defineProperty(exports, "VariableEditorForm", {
21
21
  }
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
- const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
24
+ const _react = require("react");
25
25
  const _material = require("@mui/material");
26
26
  const _components = require("@perses-dev/components");
27
27
  const _reacthookform = require("react-hook-form");
28
28
  const _zod = require("@hookform/resolvers/zod");
29
29
  const _utils = require("../../../utils");
30
- const _variablemodel = require("../variable-model");
31
30
  const _PluginEditor = require("../../PluginEditor");
32
31
  const _context = require("../../../context");
32
+ const _variablemodel = require("../variable-model");
33
+ const _runtime = require("../../../runtime");
33
34
  const _VariablePreview = require("./VariablePreview");
34
- function _getRequireWildcardCache(nodeInterop) {
35
- if (typeof WeakMap !== "function") return null;
36
- var cacheBabelInterop = new WeakMap();
37
- var cacheNodeInterop = new WeakMap();
38
- return (_getRequireWildcardCache = function(nodeInterop) {
39
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
40
- })(nodeInterop);
41
- }
42
- function _interop_require_wildcard(obj, nodeInterop) {
43
- if (!nodeInterop && obj && obj.__esModule) {
44
- return obj;
45
- }
46
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
47
- return {
48
- default: obj
49
- };
50
- }
51
- var cache = _getRequireWildcardCache(nodeInterop);
52
- if (cache && cache.has(obj)) {
53
- return cache.get(obj);
54
- }
55
- var newObj = {
56
- __proto__: null
57
- };
58
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
59
- for(var key in obj){
60
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
61
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
62
- if (desc && (desc.get || desc.set)) {
63
- Object.defineProperty(newObj, key, desc);
64
- } else {
65
- newObj[key] = obj[key];
66
- }
67
- }
68
- }
69
- newObj.default = obj;
70
- if (cache) {
71
- cache.set(obj, newObj);
72
- }
73
- return newObj;
74
- }
35
+ const _variableeditorformmodel = require("./variable-editor-form-model");
75
36
  function FallbackPreview() {
76
37
  return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
77
38
  children: "Error previewing values"
@@ -146,10 +107,7 @@ function ListVariableEditorForm({ action, control }) {
146
107
  /** We use `previewSpec` to know when to explicitly update the
147
108
  * spec that will be used for preview. The reason why we do this is to avoid
148
109
  * having to re-fetch the values when the user is still editing the spec.
149
- */ const [previewSpec, setPreviewSpec] = (0, _react.useState)(form.getValues());
150
- const refreshPreview = ()=>{
151
- setPreviewSpec(form.getValues());
152
- };
110
+ */ const previewSpec = form.getValues();
153
111
  const plugin = (0, _reacthookform.useWatch)({
154
112
  control,
155
113
  name: 'spec.plugin'
@@ -160,6 +118,10 @@ function ListVariableEditorForm({ action, control }) {
160
118
  control: control,
161
119
  name: 'spec.allowAllValue'
162
120
  });
121
+ const sortMethod = (0, _reacthookform.useWatch)({
122
+ control: control,
123
+ name: 'spec.sort'
124
+ });
163
125
  // When variable kind is selected we need to provide default values
164
126
  // TODO: check if react-hook-form has a better way to do this
165
127
  const values = form.getValues();
@@ -169,6 +131,16 @@ function ListVariableEditorForm({ action, control }) {
169
131
  if (values.spec.allowMultiple === undefined) {
170
132
  form.setValue('spec.allowMultiple', false);
171
133
  }
134
+ if (!values.spec.plugin) {
135
+ form.setValue('spec.plugin', {
136
+ kind: 'StaticListVariable',
137
+ spec: {}
138
+ });
139
+ }
140
+ if (!values.spec.sort) {
141
+ form.setValue('spec.sort', 'none');
142
+ }
143
+ const { refresh } = (0, _runtime.useTimeRange)();
172
144
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
173
145
  children: [
174
146
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
@@ -180,59 +152,51 @@ function ListVariableEditorForm({ action, control }) {
180
152
  spacing: 2,
181
153
  mb: 2,
182
154
  children: [
183
- kind ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
155
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
184
156
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
185
157
  FallbackComponent: FallbackPreview,
186
158
  resetKeys: [
187
159
  previewSpec
188
160
  ],
189
161
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_VariablePreview.VariableListPreview, {
190
- definition: previewSpec,
191
- onRefresh: refreshPreview
162
+ sortMethod: sortMethod,
163
+ definition: previewSpec
192
164
  })
193
165
  })
194
- }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_VariablePreview.VariablePreview, {
195
- isLoading: true
196
166
  }),
197
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
198
- children: [
199
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ClickAwayListener, {
200
- onClickAway: ()=>refreshPreview(),
201
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {})
202
- }),
203
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
204
- FallbackComponent: _components.ErrorAlert,
205
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
206
- control: control,
207
- name: "spec.plugin",
208
- render: ({ field })=>{
209
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginEditor.PluginEditor, {
210
- width: "100%",
211
- pluginTypes: [
212
- 'Variable'
213
- ],
214
- pluginKindLabel: "Source",
215
- value: {
216
- selection: {
217
- type: 'Variable',
218
- kind: kind ?? 'StaticListVariable'
219
- },
220
- spec: pluginSpec ?? {
221
- values: []
222
- }
167
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
168
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
169
+ FallbackComponent: _components.ErrorAlert,
170
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
171
+ control: control,
172
+ name: "spec.plugin",
173
+ render: ({ field })=>{
174
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginEditor.PluginEditor, {
175
+ postExecuteRunQuery: refresh,
176
+ withRunQueryButton: true,
177
+ width: "100%",
178
+ pluginTypes: [
179
+ 'Variable'
180
+ ],
181
+ pluginKindLabel: "Source",
182
+ value: {
183
+ selection: {
184
+ type: 'Variable',
185
+ kind: kind ?? 'StaticListVariable'
223
186
  },
224
- isReadonly: action === 'read',
225
- onChange: (v)=>{
226
- field.onChange({
227
- kind: v.selection.kind,
228
- spec: v.spec
229
- });
230
- }
231
- });
232
- }
233
- })
187
+ spec: pluginSpec ?? {}
188
+ },
189
+ isReadonly: action === 'read',
190
+ onChange: (v)=>{
191
+ field.onChange({
192
+ kind: v.selection.kind,
193
+ spec: v.spec
194
+ });
195
+ }
196
+ });
197
+ }
234
198
  })
235
- ]
199
+ })
236
200
  }),
237
201
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
238
202
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
@@ -264,7 +228,7 @@ function ListVariableEditorForm({ action, control }) {
264
228
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
265
229
  control: control,
266
230
  name: "spec.sort",
267
- render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
231
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
268
232
  select: true,
269
233
  ...field,
270
234
  fullWidth: true,
@@ -281,36 +245,14 @@ function ListVariableEditorForm({ action, control }) {
281
245
  onChange: (event)=>{
282
246
  field.onChange(event);
283
247
  },
284
- children: [
285
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
286
- value: "none",
287
- children: "None"
288
- }),
289
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
290
- value: "alphabetical-asc",
291
- children: "Alphabetical, asc"
292
- }),
293
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
294
- value: "alphabetical-desc",
295
- children: "Alphabetical, desc"
296
- }),
297
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
298
- value: "numerical-asc",
299
- children: "Numerical, asc"
300
- }),
301
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
302
- value: "numerical-desc",
303
- children: "Numerical, desc"
304
- }),
305
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
306
- value: "alphabetical-ci-asc",
307
- children: "Alphabetical, case-insensitive, asc"
308
- }),
309
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
310
- value: "alphabetical-ci-desc",
311
- children: "Alphabetical, case-insensitive, desc"
312
- })
313
- ]
248
+ children: Object.keys(_variableeditorformmodel.SORT_METHODS).map((key)=>{
249
+ if (!_variableeditorformmodel.SORT_METHODS[key]) return null;
250
+ const { label } = _variableeditorformmodel.SORT_METHODS[key];
251
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
252
+ value: key,
253
+ children: label
254
+ }, key);
255
+ })
314
256
  })
315
257
  })
316
258
  })
@@ -32,10 +32,10 @@ const _jsxruntime = require("react/jsx-runtime");
32
32
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
33
33
  const _material = require("@mui/material");
34
34
  const _components = require("@perses-dev/components");
35
- const _Refresh = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Refresh"));
36
35
  const _ClipboardOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ClipboardOutline"));
37
36
  const _constants = require("../../../constants");
38
37
  const _variablemodel = require("../variable-model");
38
+ const _variableeditorformmodel = require("./variable-editor-form-model");
39
39
  function _interop_require_default(obj) {
40
40
  return obj && obj.__esModule ? obj : {
41
41
  default: obj
@@ -84,7 +84,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
84
84
  }
85
85
  const DEFAULT_MAX_PREVIEW_VALUES = 50;
86
86
  function VariablePreview(props) {
87
- const { values, onRefresh, isLoading, error } = props;
87
+ const { values, isLoading, error } = props;
88
88
  const [maxValues, setMaxValues] = (0, _react.useState)(DEFAULT_MAX_PREVIEW_VALUES);
89
89
  const { infoSnackbar } = (0, _components.useSnackbar)();
90
90
  const showAll = ()=>{
@@ -94,6 +94,33 @@ function VariablePreview(props) {
94
94
  if (values && values?.length > 0 && maxValues) {
95
95
  notShown = values.length - maxValues;
96
96
  }
97
+ const variablePreviewState = (0, _react.useMemo)(()=>{
98
+ if (isLoading) {
99
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
100
+ width: "100%",
101
+ sx: {
102
+ alignItems: 'center',
103
+ justifyContent: 'center'
104
+ },
105
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {})
106
+ });
107
+ } else if (error) {
108
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Alert, {
109
+ severity: "error",
110
+ children: error
111
+ });
112
+ } else if (!values?.length) {
113
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Alert, {
114
+ severity: "info",
115
+ children: "No results"
116
+ });
117
+ }
118
+ return null;
119
+ }, [
120
+ error,
121
+ isLoading,
122
+ values
123
+ ]);
97
124
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
98
125
  children: [
99
126
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
@@ -106,14 +133,6 @@ function VariablePreview(props) {
106
133
  variant: "h4",
107
134
  children: "Preview Values"
108
135
  }),
109
- onRefresh && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
110
- description: _constants.TOOLTIP_TEXT.refreshVariableValues,
111
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
112
- onClick: onRefresh,
113
- size: "small",
114
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Refresh.default, {})
115
- })
116
- }),
117
136
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
118
137
  description: _constants.TOOLTIP_TEXT.copyVariableValues,
119
138
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
@@ -139,22 +158,7 @@ function VariablePreview(props) {
139
158
  m: 2
140
159
  },
141
160
  children: [
142
- error && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Alert, {
143
- severity: "error",
144
- children: error
145
- }),
146
- values?.length === 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Alert, {
147
- severity: "info",
148
- children: "No results"
149
- }),
150
- isLoading && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
151
- width: "100%",
152
- sx: {
153
- alignItems: 'center',
154
- justifyContent: 'center'
155
- },
156
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {})
157
- }),
161
+ variablePreviewState,
158
162
  values?.slice(0, maxValues).map((val, index)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
159
163
  size: "small",
160
164
  label: val
@@ -172,13 +176,18 @@ function VariablePreview(props) {
172
176
  });
173
177
  }
174
178
  function VariableListPreview(props) {
175
- const { definition, onRefresh } = props;
179
+ const { definition, sortMethod } = props;
176
180
  const { data, isFetching, error } = (0, _variablemodel.useListVariablePluginValues)(definition);
177
181
  const errorMessage = error?.message;
178
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(VariablePreview, {
179
- values: data?.map((val)=>val.value) || [],
180
- onRefresh: onRefresh,
181
- isLoading: isFetching,
182
- error: errorMessage
183
- });
182
+ const result = !sortMethod || sortMethod === 'none' || !data ? data : _variableeditorformmodel.SORT_METHODS[sortMethod].sort(data);
183
+ const variablePreview = (0, _react.useMemo)(()=>/*#__PURE__*/ (0, _jsxruntime.jsx)(VariablePreview, {
184
+ values: result?.map((val)=>val.value),
185
+ isLoading: isFetching,
186
+ error: errorMessage
187
+ }), [
188
+ errorMessage,
189
+ isFetching,
190
+ result
191
+ ]);
192
+ return variablePreview;
184
193
  }
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "__esModule", {
16
16
  });
17
17
  _export_star(require("./VariableEditorForm"), exports);
18
18
  _export_star(require("./VariablePreview"), exports);
19
+ _export_star(require("./variable-editor-form-model"), exports);
19
20
  function _export_star(from, to) {
20
21
  Object.keys(from).forEach(function(k) {
21
22
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -21,6 +21,9 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
+ SORT_METHODS: function() {
25
+ return SORT_METHODS;
26
+ },
24
27
  getInitialState: function() {
25
28
  return getInitialState;
26
29
  },
@@ -28,6 +31,50 @@ _export(exports, {
28
31
  return getVariableDefinitionFromState;
29
32
  }
30
33
  });
34
+ const SORT_METHODS = {
35
+ none: {
36
+ label: 'None',
37
+ sort: (input)=>{
38
+ return input.slice();
39
+ }
40
+ },
41
+ 'alphabetical-asc': {
42
+ label: 'Alphabetical, asc',
43
+ sort: (input)=>{
44
+ return input.slice().sort((a, b)=>a.label > b.label ? 1 : -1);
45
+ }
46
+ },
47
+ 'alphabetical-desc': {
48
+ label: 'Alphabetical, desc',
49
+ sort: (input)=>{
50
+ return input.slice().sort((a, b)=>a.label > b.label ? -1 : 1);
51
+ }
52
+ },
53
+ 'numerical-asc': {
54
+ label: 'Numerical, asc',
55
+ sort: (input)=>{
56
+ return input.slice().sort((a, b)=>parseInt(a.label) > parseInt(b.label) ? 1 : -1);
57
+ }
58
+ },
59
+ 'numerical-desc': {
60
+ label: 'Numerical, desc',
61
+ sort: (input)=>{
62
+ return input.slice().sort((a, b)=>parseInt(a.label) < parseInt(b.label) ? 1 : -1);
63
+ }
64
+ },
65
+ 'alphabetical-ci-asc': {
66
+ label: 'Alphabetical, case-insensitive, asc',
67
+ sort: (input)=>{
68
+ return input.slice().sort((a, b)=>a.label.toLowerCase() > b.label.toLowerCase() ? 1 : -1);
69
+ }
70
+ },
71
+ 'alphabetical-ci-desc': {
72
+ label: 'Alphabetical, case-insensitive, desc',
73
+ sort: (input)=>{
74
+ return input.slice().sort((a, b)=>a.label.toLowerCase() > b.label.toLowerCase() ? -1 : 1);
75
+ }
76
+ }
77
+ };
31
78
  function getInitialState(initialVariableDefinition) {
32
79
  const textVariableFields = {
33
80
  value: initialVariableDefinition.spec.value ?? '',
@@ -93,13 +93,13 @@ function useListVariablePluginValues(definition) {
93
93
  timeRange,
94
94
  refreshKey
95
95
  ],
96
- queryFn: async ()=>{
96
+ queryFn: async ({ signal })=>{
97
97
  const resp = await variablePlugin?.getVariableOptions(spec, {
98
98
  datasourceStore,
99
99
  variables,
100
100
  timeRange
101
- });
102
- if (resp === undefined) {
101
+ }, signal);
102
+ if (!resp?.data?.length) {
103
103
  return [];
104
104
  }
105
105
  if (!capturingRegexp) {
@@ -29,7 +29,6 @@ _export_star(require("./PluginRegistry"), exports);
29
29
  _export_star(require("./PluginSpecEditor"), exports);
30
30
  _export_star(require("./TimeRangeControls"), exports);
31
31
  _export_star(require("./Variables"), exports);
32
- _export_star(require("./ProjectSelect"), exports);
33
32
  _export_star(require("./MetricLabelInput"), exports);
34
33
  function _export_star(from, to) {
35
34
  Object.keys(from).forEach(function(k) {
@@ -14,7 +14,6 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- _export_star(require("./ProjectStoreProvider"), exports);
18
17
  _export_star(require("./ValidationProvider"), exports);
19
18
  function _export_star(from, to) {
20
19
  Object.keys(from).forEach(function(k) {
@@ -33,6 +33,9 @@ _export(exports, {
33
33
  LEGEND_VALUE_CONFIG: function() {
34
34
  return LEGEND_VALUE_CONFIG;
35
35
  },
36
+ comparisonLegends: function() {
37
+ return comparisonLegends;
38
+ },
36
39
  legendValues: function() {
37
40
  return legendValues;
38
41
  },
@@ -51,6 +54,16 @@ const legendValues = [
51
54
  'max',
52
55
  'sum'
53
56
  ];
57
+ const comparisonLegends = {
58
+ abs: {
59
+ label: 'Absolute',
60
+ description: 'Absolute value'
61
+ },
62
+ relative: {
63
+ label: 'Relative',
64
+ description: 'Relative value'
65
+ }
66
+ };
54
67
  const LEGEND_POSITIONS_CONFIG = {
55
68
  bottom: {
56
69
  label: 'Bottom'
@@ -0,0 +1,16 @@
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
+ });
@@ -83,7 +83,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
83
83
  let instance = null;
84
84
  const getPluginRuntime = ()=>{
85
85
  if (instance === null) {
86
- const pluginRuntime = (0, _runtime.init)({
86
+ const pluginRuntime = (0, _runtime.createInstance)({
87
87
  name: '@perses/perses-ui-host',
88
88
  remotes: [],
89
89
  shared: {
@@ -271,7 +271,8 @@ const registerRemote = (name, baseURL)=>{
271
271
  };
272
272
  const loadPlugin = async (moduleName, pluginName, baseURL)=>{
273
273
  registerRemote(moduleName, baseURL);
274
- return (0, _runtime.loadRemote)(`${moduleName}/${pluginName}`);
274
+ const pluginRuntime = getPluginRuntime();
275
+ return pluginRuntime.loadRemote(`${moduleName}/${pluginName}`);
275
276
  };
276
277
  function usePluginRuntime({ plugin }) {
277
278
  return {
@@ -27,10 +27,25 @@ const isPluginMetadata = (plugin)=>{
27
27
  const isPluginModuleResource = (pluginModule)=>{
28
28
  return typeof pluginModule === 'object' && pluginModule !== null && 'metadata' in pluginModule && 'spec' in pluginModule && typeof pluginModule.spec === 'object' && pluginModule.spec !== null && 'plugins' in pluginModule.spec && Array.isArray(pluginModule.spec.plugins) && pluginModule.spec.plugins.every(isPluginMetadata);
29
29
  };
30
- const remotePluginLoader = (baseURL)=>{
30
+ const DEFAULT_PLUGINS_API_PATH = '/api/v1/plugins';
31
+ const DEFAULT_PLUGINS_ASSETS_PATH = '/plugins';
32
+ const paramToOptions = (options)=>{
33
+ if (options === undefined) {
34
+ return {
35
+ pluginsApiPath: DEFAULT_PLUGINS_API_PATH,
36
+ pluginsAssetsPath: DEFAULT_PLUGINS_ASSETS_PATH
37
+ };
38
+ }
39
+ return {
40
+ pluginsApiPath: `${options?.apiPrefix ?? ''}${DEFAULT_PLUGINS_API_PATH}`,
41
+ pluginsAssetsPath: `${options?.baseURL ?? ''}${DEFAULT_PLUGINS_ASSETS_PATH}`
42
+ };
43
+ };
44
+ function remotePluginLoader(options) {
45
+ const { pluginsApiPath, pluginsAssetsPath } = paramToOptions(options);
31
46
  return {
32
47
  getInstalledPlugins: async ()=>{
33
- const pluginsResponse = await fetch(`${baseURL ? baseURL : ''}/api/v1/plugins`);
48
+ const pluginsResponse = await fetch(pluginsApiPath);
34
49
  const plugins = await pluginsResponse.json();
35
50
  let pluginModules = [];
36
51
  if (Array.isArray(plugins)) {
@@ -47,7 +62,7 @@ const remotePluginLoader = (baseURL)=>{
47
62
  const pluginModuleName = resource.metadata.name;
48
63
  const pluginModule = {};
49
64
  for (const plugin of resource.spec.plugins){
50
- const remotePluginModule = await (0, _PluginRuntime.loadPlugin)(pluginModuleName, plugin.spec.name);
65
+ const remotePluginModule = await (0, _PluginRuntime.loadPlugin)(pluginModuleName, plugin.spec.name, pluginsAssetsPath);
51
66
  const remotePlugin = remotePluginModule?.[plugin.spec.name];
52
67
  if (remotePlugin) {
53
68
  pluginModule[plugin.spec.name] = remotePlugin;
@@ -58,4 +73,4 @@ const remotePluginLoader = (baseURL)=>{
58
73
  return pluginModule;
59
74
  }
60
75
  };
61
- };
76
+ }
@@ -40,6 +40,7 @@ const _timeseriesqueries = require("../time-series-queries");
40
40
  const _tracequeries = require("../trace-queries");
41
41
  const _profilequeries = require("../profile-queries");
42
42
  const _UsageMetricsProvider = require("../UsageMetricsProvider");
43
+ const _logqueries = require("../log-queries");
43
44
  const _model = require("./model");
44
45
  const DataQueriesContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
45
46
  function useDataQueriesContext() {
@@ -86,20 +87,25 @@ function DataQueriesProvider(props) {
86
87
  const traceResults = (0, _tracequeries.useTraceQueries)(traceQueries);
87
88
  const profileQueries = queryDefinitions.filter((definition)=>definition.kind === 'ProfileQuery');
88
89
  const profileResults = (0, _profilequeries.useProfileQueries)(profileQueries);
90
+ const logQueries = queryDefinitions.filter((definition)=>definition.kind === 'LogQuery');
91
+ const logResults = (0, _logqueries.useLogQueries)(logQueries);
89
92
  const refetchAll = (0, _react.useCallback)(()=>{
90
93
  timeSeriesResults.forEach((result)=>result.refetch());
91
94
  traceResults.forEach((result)=>result.refetch());
92
95
  profileResults.forEach((result)=>result.refetch());
96
+ logResults.forEach((result)=>result.refetch());
93
97
  }, [
94
98
  timeSeriesResults,
95
99
  traceResults,
96
- profileResults
100
+ profileResults,
101
+ logResults
97
102
  ]);
98
103
  const ctx = (0, _react.useMemo)(()=>{
99
104
  const mergedQueryResults = [
100
105
  ...(0, _model.transformQueryResults)(timeSeriesResults, timeSeriesQueries),
101
106
  ...(0, _model.transformQueryResults)(traceResults, traceQueries),
102
- ...(0, _model.transformQueryResults)(profileResults, profileQueries)
107
+ ...(0, _model.transformQueryResults)(profileResults, profileQueries),
108
+ ...(0, _model.transformQueryResults)(logResults, logQueries)
103
109
  ];
104
110
  if (queryOptions?.enabled) {
105
111
  for (const result of mergedQueryResults){
@@ -126,6 +132,8 @@ function DataQueriesProvider(props) {
126
132
  traceResults,
127
133
  profileQueries,
128
134
  profileResults,
135
+ logQueries,
136
+ logResults,
129
137
  refetchAll,
130
138
  queryOptions?.enabled,
131
139
  usageMetrics