@perses-dev/plugin-system 0.54.0-beta.7 → 0.54.0-beta.9

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 (68) hide show
  1. package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +3 -3
  2. package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +8 -22
  3. package/dist/cjs/components/Annotations/constants.js +23 -0
  4. package/dist/cjs/components/Annotations/index.js +1 -0
  5. package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +97 -12
  6. package/dist/cjs/components/MultiQueryEditor/index.js +1 -0
  7. package/dist/cjs/components/MultiQueryEditor/utils.js +36 -0
  8. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +3 -6
  9. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +21 -28
  10. package/dist/cjs/runtime/DataQueriesProvider/model.js +3 -119
  11. package/dist/cjs/runtime/index.js +0 -1
  12. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -1
  13. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +1 -1
  14. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -1
  15. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -1
  16. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +8 -22
  17. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -1
  18. package/dist/components/Annotations/constants.d.ts +2 -0
  19. package/dist/components/Annotations/constants.d.ts.map +1 -0
  20. package/dist/{runtime/QueryCountProvider.js → components/Annotations/constants.js} +2 -13
  21. package/dist/components/Annotations/constants.js.map +1 -0
  22. package/dist/components/Annotations/index.d.ts +1 -0
  23. package/dist/components/Annotations/index.d.ts.map +1 -1
  24. package/dist/components/Annotations/index.js +1 -0
  25. package/dist/components/Annotations/index.js.map +1 -1
  26. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +1 -1
  27. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
  28. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +1 -1
  29. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
  30. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
  31. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +99 -14
  32. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  33. package/dist/components/MultiQueryEditor/index.d.ts +1 -0
  34. package/dist/components/MultiQueryEditor/index.d.ts.map +1 -1
  35. package/dist/components/MultiQueryEditor/index.js +1 -0
  36. package/dist/components/MultiQueryEditor/index.js.map +1 -1
  37. package/dist/components/MultiQueryEditor/utils.d.ts +8 -0
  38. package/dist/components/MultiQueryEditor/utils.d.ts.map +1 -0
  39. package/dist/components/MultiQueryEditor/utils.js +23 -0
  40. package/dist/components/MultiQueryEditor/utils.js.map +1 -0
  41. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  42. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +4 -7
  43. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  44. package/dist/model/annotations.d.ts +1 -1
  45. package/dist/model/annotations.d.ts.map +1 -1
  46. package/dist/model/annotations.js.map +1 -1
  47. package/dist/model/log-queries.d.ts +2 -1
  48. package/dist/model/log-queries.d.ts.map +1 -1
  49. package/dist/model/log-queries.js.map +1 -1
  50. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  51. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +22 -29
  52. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  53. package/dist/runtime/DataQueriesProvider/model.d.ts +4 -4
  54. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  55. package/dist/runtime/DataQueriesProvider/model.js +0 -108
  56. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  57. package/dist/runtime/index.d.ts +0 -1
  58. package/dist/runtime/index.d.ts.map +1 -1
  59. package/dist/runtime/index.js +0 -1
  60. package/dist/runtime/index.js.map +1 -1
  61. package/dist/runtime/plugin-registry.d.ts +1 -2
  62. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  63. package/dist/runtime/plugin-registry.js.map +1 -1
  64. package/package.json +5 -5
  65. package/dist/cjs/runtime/QueryCountProvider.js +0 -83
  66. package/dist/runtime/QueryCountProvider.d.ts +0 -9
  67. package/dist/runtime/QueryCountProvider.d.ts.map +0 -1
  68. package/dist/runtime/QueryCountProvider.js.map +0 -1
@@ -30,13 +30,13 @@ const _reactquery = require("@tanstack/react-query");
30
30
  const _InvertColors = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/InvertColors"));
31
31
  const _PluginEditor = require("../../PluginEditor");
32
32
  const _context = require("../../../context");
33
+ const _constants = require("../constants");
33
34
  const _AnnotationPreview = require("./AnnotationPreview");
34
35
  function _interop_require_default(obj) {
35
36
  return obj && obj.__esModule ? obj : {
36
37
  default: obj
37
38
  };
38
39
  }
39
- const DEFAULT_ANNOTATION_COLOR = '#FF6B6B';
40
40
  function FallbackPreview() {
41
41
  return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
42
42
  children: "Error previewing annotations"
@@ -207,12 +207,12 @@ function AnnotationEditorForm({ initialAnnotationSpec, action, isDraft, isReadon
207
207
  children: isEnabled ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsColorPicker, {
208
208
  size: "medium",
209
209
  label: "annotation",
210
- color: field.value ?? DEFAULT_ANNOTATION_COLOR,
210
+ color: field.value ?? _constants.DEFAULT_ANNOTATION_COLOR,
211
211
  onColorChange: (color)=>field.onChange(color),
212
212
  onClear: ()=>field.onChange(undefined)
213
213
  }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
214
214
  size: "medium",
215
- onClick: ()=>field.onChange(DEFAULT_ANNOTATION_COLOR),
215
+ onClick: ()=>field.onChange(_constants.DEFAULT_ANNOTATION_COLOR),
216
216
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_InvertColors.default, {})
217
217
  })
218
218
  });
@@ -23,31 +23,17 @@ Object.defineProperty(exports, "AnnotationPreview", {
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _react = require("react");
25
25
  const _material = require("@mui/material");
26
- const _pluginsystem = require("@perses-dev/plugin-system");
27
26
  const _components = require("@perses-dev/components");
28
27
  const _Alert = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Alert"));
28
+ const _runtime = require("../../../runtime");
29
29
  function _interop_require_default(obj) {
30
30
  return obj && obj.__esModule ? obj : {
31
31
  default: obj
32
32
  };
33
33
  }
34
- const formatDate = (timeMs, format)=>{
35
- // Disallows NaN, Infinity, and -Infinity
36
- if (!Number.isFinite(timeMs)) {
37
- return {
38
- date: 'N/A',
39
- time: 'N/A'
40
- };
41
- }
42
- const d = new Date(timeMs);
43
- return {
44
- date: format(d, 'MMM dd, yyyy'),
45
- time: format(d, 'HH:mm:ss')
46
- };
47
- };
48
34
  function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
49
- const start = formatDate(value.start, formatWithUserTimeZone);
50
- const end = value.end !== undefined ? formatDate(value.start, formatWithUserTimeZone) : null;
35
+ const start = (0, _components.getDateAndTime)(value.start, formatWithUserTimeZone);
36
+ const end = value.end !== undefined ? (0, _components.getDateAndTime)(value.start, formatWithUserTimeZone) : null;
51
37
  const tags = (0, _react.useMemo)(()=>{
52
38
  return Object.entries(value.tags ?? []).map(([key, value])=>{
53
39
  return {
@@ -95,10 +81,10 @@ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
95
81
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
96
82
  variant: "caption",
97
83
  children: [
98
- start.date,
84
+ start.formattedDate,
99
85
  " - ",
100
86
  /*#__PURE__*/ (0, _jsxruntime.jsx)("strong", {
101
- children: start.time
87
+ children: start.formattedTime
102
88
  })
103
89
  ]
104
90
  }),
@@ -111,10 +97,10 @@ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
111
97
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
112
98
  variant: "caption",
113
99
  children: [
114
- end.date,
100
+ end.formattedDate,
115
101
  " - ",
116
102
  /*#__PURE__*/ (0, _jsxruntime.jsx)("strong", {
117
- children: end.time
103
+ children: end.formattedTime
118
104
  })
119
105
  ]
120
106
  })
@@ -127,7 +113,7 @@ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
127
113
  });
128
114
  }
129
115
  function AnnotationPreview({ spec, ...props }) {
130
- const { data, isFetching, error } = (0, _pluginsystem.useAnnotationData)(spec);
116
+ const { data, isFetching, error } = (0, _runtime.useAnnotationData)(spec);
131
117
  const { formatWithUserTimeZone } = (0, _components.useTimeZone)();
132
118
  const [showAll, setShowAll] = (0, _react.useState)(false);
133
119
  const annotationsToShow = showAll ? data : data?.slice(0, 1);
@@ -0,0 +1,23 @@
1
+ // Copyright 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, "DEFAULT_ANNOTATION_COLOR", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return DEFAULT_ANNOTATION_COLOR;
21
+ }
22
+ });
23
+ const DEFAULT_ANNOTATION_COLOR = '#FF6B6B';
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _export_star(require("./AnnotationEditorForm"), exports);
18
+ _export_star(require("./constants"), exports);
18
19
  function _export_star(from, to) {
19
20
  Object.keys(from).forEach(function(k) {
20
21
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -29,7 +29,11 @@ const _ChevronRight = /*#__PURE__*/ _interop_require_default(require("mdi-materi
29
29
  const _react = require("react");
30
30
  const _Alert = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Alert"));
31
31
  const _components = require("@perses-dev/components");
32
+ const _Pencil = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Pencil"));
33
+ const _Check = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Check"));
34
+ const _Close = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Close"));
32
35
  const _PluginEditor = require("../PluginEditor");
36
+ const _utils = require("./utils");
33
37
  function _interop_require_default(obj) {
34
38
  return obj && obj.__esModule ? obj : {
35
39
  default: obj
@@ -37,6 +41,16 @@ function _interop_require_default(obj) {
37
41
  }
38
42
  const QueryEditorContainer = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
39
43
  const { queryTypes, index, query, queryResult, filteredQueryPlugins, isCollapsed, onDelete, onChange, onQueryRun, onCollapseExpand } = props;
44
+ // The displayed name is always derived from props so it stays in sync with the
45
+ // current query/index, even when queries are added, removed or reordered.
46
+ const displayedName = query.spec.name ?? (0, _utils.defaultQueryName)(index);
47
+ const [isEditingName, setIsEditingName] = (0, _react.useState)(false);
48
+ function handleNameSave(name) {
49
+ setIsEditingName(false);
50
+ onChange(index, (0, _immer.produce)(query, (draft)=>{
51
+ draft.spec.name = name;
52
+ }));
53
+ }
40
54
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
41
55
  spacing: 1,
42
56
  children: [
@@ -49,19 +63,40 @@ const QueryEditorContainer = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>
49
63
  children: [
50
64
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
51
65
  direction: "row",
66
+ gap: 1,
67
+ sx: {
68
+ width: '100%'
69
+ },
52
70
  children: [
53
71
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
54
72
  size: "small",
73
+ sx: {
74
+ width: 'fit-content',
75
+ height: 'fit-content'
76
+ },
55
77
  onClick: ()=>onCollapseExpand(index),
56
78
  children: isCollapsed ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChevronRight.default, {}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_ChevronDown.default, {})
57
79
  }),
58
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
59
- variant: "overline",
60
- component: "h4",
61
- children: [
62
- "Query #",
63
- index + 1
64
- ]
80
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
81
+ direction: "row",
82
+ gap: 1,
83
+ alignItems: "center",
84
+ alignContent: "center",
85
+ sx: {
86
+ width: '100%',
87
+ '&:hover button': {
88
+ visibility: 'visible'
89
+ }
90
+ },
91
+ children: isEditingName ? /*#__PURE__*/ (0, _jsxruntime.jsx)(QueryNameInput, {
92
+ initialName: displayedName,
93
+ onSave: handleNameSave,
94
+ onCancel: ()=>setIsEditingName(false)
95
+ }, displayedName) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
96
+ variant: "overline",
97
+ component: "h4",
98
+ children: displayedName
99
+ })
65
100
  })
66
101
  ]
67
102
  }),
@@ -105,11 +140,24 @@ const QueryEditorContainer = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>
105
140
  ]
106
141
  })
107
142
  }),
108
- onDelete && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
109
- "aria-label": "delete query",
110
- size: "small",
111
- onClick: ()=>onDelete && onDelete(index),
112
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DeleteOutline.default, {})
143
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
144
+ direction: "row",
145
+ children: [
146
+ !isEditingName && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
147
+ "aria-label": "edit query name",
148
+ size: "small",
149
+ onClick: ()=>setIsEditingName(true),
150
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Pencil.default, {
151
+ fontSize: "small"
152
+ })
153
+ }),
154
+ onDelete && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
155
+ "aria-label": "delete query",
156
+ size: "small",
157
+ onClick: ()=>onDelete && onDelete(index),
158
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DeleteOutline.default, {})
159
+ })
160
+ ]
113
161
  })
114
162
  ]
115
163
  })
@@ -127,6 +175,43 @@ const QueryEditorContainer = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>
127
175
  }, index);
128
176
  });
129
177
  QueryEditorContainer.displayName = 'QueryEditorContainer';
178
+ /**
179
+ * Self-contained input to edit a query name. The draft value is local state seeded from
180
+ * `initialName`; callers reset it by changing the `key` (remounting) rather than syncing
181
+ * with an useEffect.
182
+ */ function QueryNameInput({ initialName, onSave, onCancel }) {
183
+ const [draftName, setDraftName] = (0, _react.useState)(initialName);
184
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
185
+ size: "small",
186
+ variant: "outlined",
187
+ label: "Query name",
188
+ "aria-label": "query name",
189
+ value: draftName,
190
+ onChange: (e)=>setDraftName(e.target.value),
191
+ fullWidth: true,
192
+ InputProps: {
193
+ endAdornment: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.InputAdornment, {
194
+ position: "end",
195
+ children: [
196
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
197
+ size: "small",
198
+ "aria-label": "cancel edit",
199
+ onClick: onCancel,
200
+ edge: "end",
201
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Close.default, {})
202
+ }),
203
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
204
+ size: "small",
205
+ "aria-label": "save query name",
206
+ onClick: ()=>onSave(draftName),
207
+ edge: "end",
208
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Check.default, {})
209
+ })
210
+ ]
211
+ })
212
+ }
213
+ });
214
+ }
130
215
  /**
131
216
  * Editor for a query definition. This component is responsible for rendering the plugin editor for the given query.
132
217
  * This will allow user to select a plugin extending from the given supported query types, and then edit the plugin
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _export_star(require("./MultiQueryEditor"), exports);
18
+ _export_star(require("./utils"), exports);
18
19
  function _export_star(from, to) {
19
20
  Object.keys(from).forEach(function(k) {
20
21
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -0,0 +1,36 @@
1
+ // Copyright 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: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get defaultQueryName () {
25
+ return defaultQueryName;
26
+ },
27
+ get generateQueryNames () {
28
+ return generateQueryNames;
29
+ }
30
+ });
31
+ function defaultQueryName(index) {
32
+ return `Query #${index + 1}`;
33
+ }
34
+ function generateQueryNames(definitions) {
35
+ return definitions.map((queryDef, index)=>queryDef.spec.name ?? defaultQueryName(index));
36
+ }
@@ -109,11 +109,8 @@ const PanelSpecEditor = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
109
109
  })
110
110
  })
111
111
  });
112
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.QueryCountProvider, {
113
- queryCount: (panelDefinition.spec.queries ?? []).length,
114
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorTabs.OptionsEditorTabs, {
115
- tabs: tabs
116
- }, tabs.length)
117
- });
112
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorTabs.OptionsEditorTabs, {
113
+ tabs: tabs
114
+ }, tabs.length);
118
115
  });
119
116
  PanelSpecEditor.displayName = 'PanelSpecEditor';
@@ -54,46 +54,37 @@ function useDataQueriesContext() {
54
54
  }
55
55
  function useDataQueries(queryType) {
56
56
  const ctx = useDataQueriesContext();
57
+ // Filter query definitions based on the specified query type
58
+ const filteredQueryDefinitions = ctx.queryDefinitions.filter((definition)=>definition.kind === queryType);
57
59
  // Filter the query results based on the specified query type
58
60
  const filteredQueryResults = ctx.queryResults.filter((queryResult)=>queryResult?.definition?.kind === queryType);
59
61
  // Filter the errors based on the specified query type
60
62
  const filteredErrors = ctx.errors.filter((errors, index)=>ctx.queryResults[index]?.definition?.kind === queryType);
61
63
  // Create a new context object with the filtered results and errors
62
- const filteredCtx = {
64
+ return {
65
+ queryDefinitions: filteredQueryDefinitions,
63
66
  queryResults: filteredQueryResults,
64
67
  isFetching: filteredQueryResults.some((result)=>result.isFetching),
65
68
  isLoading: filteredQueryResults.some((result)=>result.isLoading),
66
69
  refetchAll: ctx.refetchAll,
67
70
  errors: filteredErrors
68
71
  };
69
- return filteredCtx;
70
72
  }
71
73
  function DataQueriesProvider(props) {
72
74
  const { definitions, options, children, queryOptions } = props;
73
- // Returns a query kind, for example "TimeSeriesQuery" = getQueryType("PrometheusTimeSeriesQuery")
74
- const getQueryType = (0, _model.useQueryType)();
75
- const queryDefinitions = definitions.map((definition)=>{
76
- const type = getQueryType(definition.kind);
77
- return {
78
- kind: type,
79
- spec: {
80
- plugin: definition
81
- }
82
- };
83
- });
84
75
  const usageMetrics = (0, _UsageMetricsProvider.useUsageMetrics)();
85
76
  // Filter definitions for time series query and other future query plugins
86
- const timeSeriesQueries = queryDefinitions.filter((definition)=>definition.kind === 'TimeSeriesQuery');
77
+ const timeSeriesQueries = definitions.filter((definition)=>definition.kind === 'TimeSeriesQuery');
87
78
  const timeSeriesResults = (0, _timeseriesqueries.useTimeSeriesQueries)(timeSeriesQueries, options, queryOptions);
88
- const traceQueries = queryDefinitions.filter((definition)=>definition.kind === 'TraceQuery');
79
+ const traceQueries = definitions.filter((definition)=>definition.kind === 'TraceQuery');
89
80
  const traceResults = (0, _tracequeries.useTraceQueries)(traceQueries);
90
- const profileQueries = queryDefinitions.filter((definition)=>definition.kind === 'ProfileQuery');
81
+ const profileQueries = definitions.filter((definition)=>definition.kind === 'ProfileQuery');
91
82
  const profileResults = (0, _profilequeries.useProfileQueries)(profileQueries);
92
- const logQueries = queryDefinitions.filter((definition)=>definition.kind === 'LogQuery');
83
+ const logQueries = definitions.filter((definition)=>definition.kind === 'LogQuery');
93
84
  const logResults = (0, _logqueries.useLogQueries)(logQueries);
94
- const alertsQueries = queryDefinitions.filter((definition)=>definition.kind === 'AlertsQuery');
85
+ const alertsQueries = definitions.filter((definition)=>definition.kind === 'AlertsQuery');
95
86
  const alertsResults = (0, _alertsqueries.useAlertsQueries)(alertsQueries);
96
- const silencesQueries = queryDefinitions.filter((definition)=>definition.kind === 'SilencesQuery');
87
+ const silencesQueries = definitions.filter((definition)=>definition.kind === 'SilencesQuery');
97
88
  const silencesResults = (0, _silencesqueries.useSilencesQueries)(silencesQueries);
98
89
  const refetchAll = (0, _react.useCallback)(()=>{
99
90
  timeSeriesResults.forEach((result)=>result.refetch());
@@ -131,6 +122,7 @@ function DataQueriesProvider(props) {
131
122
  }
132
123
  }
133
124
  return {
125
+ queryDefinitions: definitions,
134
126
  queryResults: mergedQueryResults,
135
127
  isFetching: mergedQueryResults.some((result)=>result.isFetching),
136
128
  isLoading: mergedQueryResults.some((result)=>result.isLoading),
@@ -138,20 +130,21 @@ function DataQueriesProvider(props) {
138
130
  errors: mergedQueryResults.map((result)=>result.error)
139
131
  };
140
132
  }, [
141
- timeSeriesQueries,
142
- timeSeriesResults,
143
- traceQueries,
144
- traceResults,
145
- profileQueries,
146
- profileResults,
147
- logQueries,
148
- logResults,
149
133
  alertsQueries,
150
134
  alertsResults,
135
+ logQueries,
136
+ logResults,
137
+ profileQueries,
138
+ profileResults,
151
139
  silencesQueries,
152
140
  silencesResults,
153
- refetchAll,
141
+ timeSeriesQueries,
142
+ timeSeriesResults,
143
+ traceQueries,
144
+ traceResults,
145
+ definitions,
154
146
  queryOptions?.enabled,
147
+ refetchAll,
155
148
  usageMetrics
156
149
  ]);
157
150
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(DataQueriesContext.Provider, {
@@ -14,22 +14,12 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get transformQueryResults () {
17
+ Object.defineProperty(exports, "transformQueryResults", {
18
+ enumerable: true,
19
+ get: function() {
25
20
  return transformQueryResults;
26
- },
27
- get useQueryType () {
28
- return useQueryType;
29
21
  }
30
22
  });
31
- const _react = require("react");
32
- const _pluginregistry = require("../plugin-registry");
33
23
  function transformQueryResults(results, definitions) {
34
24
  return results.map(({ data, isFetching, isLoading, refetch, error }, i)=>{
35
25
  return {
@@ -42,109 +32,3 @@ function transformQueryResults(results, definitions) {
42
32
  };
43
33
  });
44
34
  }
45
- function useQueryType() {
46
- const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = (0, _pluginregistry.useListPluginMetadata)([
47
- 'TimeSeriesQuery'
48
- ]);
49
- const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
50
- 'TraceQuery'
51
- ]);
52
- const { data: profileQueryPlugins, isLoading: isProfileQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
53
- 'ProfileQuery'
54
- ]);
55
- const { data: logQueries, isLoading: isLogQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
56
- 'LogQuery'
57
- ]);
58
- const { data: alertsQueryPlugins, isLoading: isAlertsQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
59
- 'AlertsQuery'
60
- ]);
61
- const { data: silencesQueryPlugins, isLoading: isSilencesQueryPluginLoading } = (0, _pluginregistry.useListPluginMetadata)([
62
- 'SilencesQuery'
63
- ]);
64
- // For example, `map: {"TimeSeriesQuery":["PrometheusTimeSeriesQuery"],"TraceQuery":["TempoTraceQuery"]}`
65
- const queryTypeMap = (0, _react.useMemo)(()=>{
66
- const map = {
67
- TimeSeriesQuery: [],
68
- TraceQuery: [],
69
- ProfileQuery: [],
70
- LogQuery: [],
71
- AlertsQuery: [],
72
- SilencesQuery: []
73
- };
74
- if (timeSeriesQueryPlugins) {
75
- timeSeriesQueryPlugins.forEach((plugin)=>{
76
- map[plugin.kind]?.push(plugin.spec.name);
77
- });
78
- }
79
- if (traceQueryPlugins) {
80
- traceQueryPlugins.forEach((plugin)=>{
81
- map[plugin.kind]?.push(plugin.spec.name);
82
- });
83
- }
84
- if (profileQueryPlugins) {
85
- profileQueryPlugins.forEach((plugin)=>{
86
- map[plugin.kind]?.push(plugin.spec.name);
87
- });
88
- }
89
- if (logQueries) {
90
- logQueries.forEach((plugin)=>{
91
- map[plugin.kind]?.push(plugin.spec.name);
92
- });
93
- }
94
- if (alertsQueryPlugins) {
95
- alertsQueryPlugins.forEach((plugin)=>{
96
- map[plugin.kind]?.push(plugin.spec.name);
97
- });
98
- }
99
- if (silencesQueryPlugins) {
100
- silencesQueryPlugins.forEach((plugin)=>{
101
- map[plugin.kind]?.push(plugin.spec.name);
102
- });
103
- }
104
- return map;
105
- }, [
106
- timeSeriesQueryPlugins,
107
- traceQueryPlugins,
108
- profileQueryPlugins,
109
- logQueries,
110
- alertsQueryPlugins,
111
- silencesQueryPlugins
112
- ]);
113
- const getQueryType = (0, _react.useCallback)((pluginKind)=>{
114
- const isLoading = (pluginKind)=>{
115
- switch(pluginKind){
116
- case 'PrometheusTimeSeriesQuery':
117
- return isTimeSeriesQueryLoading;
118
- case 'TempoTraceQuery':
119
- return isTraceQueryPluginLoading;
120
- case 'PyroscopeProfileQuery':
121
- return isProfileQueryPluginLoading;
122
- case 'LokiLogQuery':
123
- return isLogQueryPluginLoading;
124
- case 'AlertmanagerAlertsQuery':
125
- return isAlertsQueryPluginLoading;
126
- case 'AlertmanagerSilencesQuery':
127
- return isSilencesQueryPluginLoading;
128
- }
129
- return isTraceQueryPluginLoading || isTimeSeriesQueryLoading || isProfileQueryPluginLoading || isLogQueryPluginLoading || isAlertsQueryPluginLoading || isSilencesQueryPluginLoading;
130
- };
131
- if (isLoading(pluginKind)) {
132
- return undefined;
133
- }
134
- for(const queryType in queryTypeMap){
135
- if (queryTypeMap[queryType]?.includes(pluginKind)) {
136
- return queryType;
137
- }
138
- }
139
- throw new Error(`Unable to determine the query type: ${pluginKind}`);
140
- }, [
141
- queryTypeMap,
142
- isTimeSeriesQueryLoading,
143
- isTraceQueryPluginLoading,
144
- isProfileQueryPluginLoading,
145
- isLogQueryPluginLoading,
146
- isAlertsQueryPluginLoading,
147
- isSilencesQueryPluginLoading
148
- ]);
149
- return getQueryType;
150
- }
@@ -27,7 +27,6 @@ _export_star(require("./alerts-queries"), exports);
27
27
  _export_star(require("./silences-queries"), exports);
28
28
  _export_star(require("./item-actions"), exports);
29
29
  _export_star(require("./DataQueriesProvider"), exports);
30
- _export_star(require("./QueryCountProvider"), exports);
31
30
  _export_star(require("./RouterProvider"), exports);
32
31
  _export_star(require("./UsageMetricsProvider"), exports);
33
32
  function _export_star(from, to) {
@@ -1 +1 @@
1
- {"version":3,"file":"AnnotationEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAclD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAoD5C,UAAU,yBAAyB;IACjC,qBAAqB,EAAE,cAAc,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;IACtC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,EACnC,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,UAAU,EACV,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,yBAAyB,GAAG,YAAY,CAuK1C"}
1
+ {"version":3,"file":"AnnotationEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAclD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmD5C,UAAU,yBAAyB;IACjC,qBAAqB,EAAE,cAAc,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;IACtC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,EACnC,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,UAAU,EACV,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,yBAAyB,GAAG,YAAY,CAuK1C"}
@@ -20,8 +20,8 @@ import { useQueryClient } from '@tanstack/react-query';
20
20
  import InvertColorsIcon from 'mdi-material-ui/InvertColors';
21
21
  import { PluginEditor } from '../../PluginEditor';
22
22
  import { useValidationSchemas } from '../../../context';
23
+ import { DEFAULT_ANNOTATION_COLOR } from '../constants';
23
24
  import { AnnotationPreview } from './AnnotationPreview';
24
- const DEFAULT_ANNOTATION_COLOR = '#FF6B6B';
25
25
  function FallbackPreview() {
26
26
  return /*#__PURE__*/ _jsx("div", {
27
27
  children: "Error previewing annotations"