@perses-dev/plugin-system 0.0.0-snapshot-explorer-plugin-c4a7621 → 0.0.0-snapshot-histogram-types-78c5104

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 (87) hide show
  1. package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +8 -2
  2. package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +13 -10
  3. package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +2 -2
  4. package/dist/cjs/remote/PluginRuntime.js +168 -162
  5. package/dist/cjs/runtime/DataQueriesProvider/model.js +1 -1
  6. package/dist/cjs/runtime/plugin-registry.js +13 -4
  7. package/dist/cjs/runtime/trace-queries.js +1 -5
  8. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  9. package/dist/components/DatasourceSelect.d.ts +2 -2
  10. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  11. package/dist/components/DatasourceSelect.js.map +1 -1
  12. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
  13. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +8 -2
  14. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
  15. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
  16. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +13 -10
  17. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  18. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
  19. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  20. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  21. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  22. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  23. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  24. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  25. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  26. package/dist/components/Variables/variable-model.js.map +1 -1
  27. package/dist/model/panels.d.ts +13 -3
  28. package/dist/model/panels.d.ts.map +1 -1
  29. package/dist/model/panels.js.map +1 -1
  30. package/dist/remote/PluginLoaderComponent.js.map +1 -1
  31. package/dist/remote/PluginRuntime.d.ts +0 -1
  32. package/dist/remote/PluginRuntime.d.ts.map +1 -1
  33. package/dist/remote/PluginRuntime.js +169 -160
  34. package/dist/remote/PluginRuntime.js.map +1 -1
  35. package/dist/remote/remotePluginLoader.js.map +1 -1
  36. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  37. package/dist/runtime/DataQueriesProvider/model.js +1 -1
  38. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  39. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  40. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  41. package/dist/runtime/plugin-registry.js +13 -4
  42. package/dist/runtime/plugin-registry.js.map +1 -1
  43. package/dist/runtime/trace-queries.d.ts.map +1 -1
  44. package/dist/runtime/trace-queries.js +1 -5
  45. package/dist/runtime/trace-queries.js.map +1 -1
  46. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  47. package/package.json +7 -9
  48. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +0 -41
  49. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +0 -34
  50. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -42
  51. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -101
  52. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemVariables.js +0 -42
  53. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +0 -41
  54. package/dist/cjs/stories/shared-utils/decorators/index.js +0 -35
  55. package/dist/cjs/stories/shared-utils/index.js +0 -30
  56. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +0 -13
  57. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +0 -1
  58. package/dist/stories/shared-utils/decorators/WithDataQueries.js +0 -33
  59. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +0 -1
  60. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +0 -4
  61. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +0 -1
  62. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +0 -26
  63. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +0 -1
  64. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +0 -13
  65. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +0 -1
  66. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -39
  67. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +0 -1
  68. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +0 -13
  69. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +0 -1
  70. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -95
  71. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +0 -1
  72. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +0 -13
  73. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +0 -1
  74. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js +0 -39
  75. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +0 -1
  76. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +0 -13
  77. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +0 -1
  78. package/dist/stories/shared-utils/decorators/WithTimeRange.js +0 -33
  79. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +0 -1
  80. package/dist/stories/shared-utils/decorators/index.d.ts +0 -7
  81. package/dist/stories/shared-utils/decorators/index.d.ts.map +0 -1
  82. package/dist/stories/shared-utils/decorators/index.js +0 -20
  83. package/dist/stories/shared-utils/decorators/index.js.map +0 -1
  84. package/dist/stories/shared-utils/index.d.ts +0 -2
  85. package/dist/stories/shared-utils/index.d.ts.map +0 -1
  86. package/dist/stories/shared-utils/index.js +0 -15
  87. package/dist/stories/shared-utils/index.js.map +0 -1
@@ -498,14 +498,20 @@ function HTTPSettingsEditor(props) {
498
498
  const handleModeChange = (v)=>{
499
499
  if (tabs[v]?.label === strDirect) {
500
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;
501
504
  onChange({
502
- ...value,
505
+ ...newValue,
503
506
  directUrl: previousSpecDirect.directUrl
504
507
  });
505
508
  } else if (tabs[v]?.label === strProxy) {
506
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;
507
513
  onChange({
508
- ...value,
514
+ ...newValue,
509
515
  proxy: previousSpecProxy.proxy
510
516
  });
511
517
  }
@@ -39,7 +39,7 @@ function useDefaultQueryDefinition(queryTypes) {
39
39
  const defaultQueryType = queryTypes[0];
40
40
  // Then the default plugin kind
41
41
  // Use as default the plugin kind explicitly set as default or the first in the list
42
- const { data: queryPlugins } = (0, _runtime.useListPluginMetadata)(queryTypes);
42
+ const { data: queryPlugins, isLoading } = (0, _runtime.useListPluginMetadata)(queryTypes);
43
43
  const { defaultPluginKinds } = (0, _runtime.usePluginRegistry)();
44
44
  const defaultQueryKind = defaultPluginKinds?.[defaultQueryType] ?? queryPlugins?.[0]?.spec.name ?? '';
45
45
  const { data: defaultQueryPlugin } = (0, _runtime.usePlugin)(defaultQueryType, defaultQueryKind, {
@@ -48,17 +48,20 @@ function useDefaultQueryDefinition(queryTypes) {
48
48
  });
49
49
  // This default query definition is used if no query is provided initially or when we add a new query
50
50
  return {
51
- kind: defaultQueryType,
52
- spec: {
53
- plugin: {
54
- kind: defaultQueryKind,
55
- spec: defaultQueryPlugin?.createInitialOptions() || {}
51
+ defaultInitialQueryDefinition: {
52
+ kind: defaultQueryType,
53
+ spec: {
54
+ plugin: {
55
+ kind: defaultQueryKind,
56
+ spec: defaultQueryPlugin?.createInitialOptions() || {}
57
+ }
56
58
  }
57
- }
59
+ },
60
+ isLoading
58
61
  };
59
62
  }
60
63
  function MultiQueryEditor({ queryTypes, queries = [], onChange }) {
61
- const defaultInitialQueryDefinition = useDefaultQueryDefinition(queryTypes);
64
+ const { defaultInitialQueryDefinition, isLoading } = useDefaultQueryDefinition(queryTypes);
62
65
  // State for which queries are collapsed
63
66
  const [queriesCollapsed, setQueriesCollapsed] = (0, _react.useState)(queries.map(()=>false));
64
67
  // Query handlers
@@ -111,9 +114,9 @@ function MultiQueryEditor({ queryTypes, queries = [], onChange }) {
111
114
  });
112
115
  };
113
116
  // show one query input if queries is empty
114
- const queryDefinitions = queries.length ? queries : [
117
+ const queryDefinitions = queries.length ? queries : !isLoading ? [
115
118
  defaultInitialQueryDefinition
116
- ];
119
+ ] : [];
117
120
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
118
121
  children: [
119
122
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
@@ -21,7 +21,7 @@ Object.defineProperty(exports, "QueryEditorContainer", {
21
21
  }
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
- const _immer = /*#__PURE__*/ _interop_require_default(require("immer"));
24
+ const _immer = require("immer");
25
25
  const _material = require("@mui/material");
26
26
  const _DeleteOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/DeleteOutline"));
27
27
  const _ChevronDown = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/ChevronDown"));
@@ -84,7 +84,7 @@ const QueryEditorContainer = ({ queryTypes, index, query, isCollapsed, onDelete,
84
84
  */ function QueryEditor(props) {
85
85
  const { value, onChange, queryTypes, ...others } = props;
86
86
  const handlePluginChange = (next)=>{
87
- onChange((0, _immer.default)(value, (draft)=>{
87
+ onChange((0, _immer.produce)(value, (draft)=>{
88
88
  draft.kind = next.selection.type;
89
89
  draft.spec.plugin.kind = next.selection.kind;
90
90
  draft.spec.plugin.spec = next.spec;
@@ -24,9 +24,6 @@ _export(exports, {
24
24
  loadPlugin: function() {
25
25
  return loadPlugin;
26
26
  },
27
- pluginRuntime: function() {
28
- return pluginRuntime;
29
- },
30
27
  usePluginRuntime: function() {
31
28
  return usePluginRuntime;
32
29
  }
@@ -35,8 +32,8 @@ const _runtime = require("@module-federation/enhanced/runtime");
35
32
  const _reactquery = /*#__PURE__*/ _interop_require_wildcard(require("@tanstack/react-query"));
36
33
  const _react = /*#__PURE__*/ _interop_require_default(require("react"));
37
34
  const _reactdom = /*#__PURE__*/ _interop_require_default(require("react-dom"));
38
- const _reactrouterdom = /*#__PURE__*/ _interop_require_wildcard(require("react-router-dom"));
39
35
  const _reacthookform = /*#__PURE__*/ _interop_require_wildcard(require("react-hook-form"));
36
+ const _reactrouterdom = /*#__PURE__*/ _interop_require_wildcard(require("react-router-dom"));
40
37
  function _interop_require_default(obj) {
41
38
  return obj && obj.__esModule ? obj : {
42
39
  default: obj
@@ -83,166 +80,175 @@ function _interop_require_wildcard(obj, nodeInterop) {
83
80
  }
84
81
  return newObj;
85
82
  }
86
- const pluginRuntime = (0, _runtime.init)({
87
- name: '@perses/perses-ui-host',
88
- remotes: [],
89
- shared: {
90
- react: {
91
- version: _react.default.version,
92
- lib: ()=>_react.default,
93
- shareConfig: {
94
- singleton: true,
95
- requiredVersion: `^${_react.default.version}`
96
- }
97
- },
98
- 'react-dom': {
99
- version: '18.3.1',
100
- lib: ()=>_reactdom.default,
101
- shareConfig: {
102
- singleton: true,
103
- requiredVersion: `^18.3.1`
104
- }
105
- },
106
- 'react-router-dom': {
107
- version: '6.26.0',
108
- lib: ()=>_reactrouterdom,
109
- shareConfig: {
110
- singleton: true,
111
- requiredVersion: '^6.26.0'
112
- }
113
- },
114
- '@tanstack/react-query': {
115
- version: '4.36.1',
116
- lib: ()=>_reactquery,
117
- shareConfig: {
118
- singleton: true,
119
- requiredVersion: '^4.36.1'
120
- }
121
- },
122
- 'react-hook-form': {
123
- version: '7.52.2',
124
- lib: ()=>_reacthookform,
125
- shareConfig: {
126
- singleton: true,
127
- requiredVersion: '^7.52.2'
128
- }
129
- },
130
- echarts: {
131
- version: '5.5.0',
132
- lib: ()=>require('echarts'),
133
- shareConfig: {
134
- singleton: true,
135
- requiredVersion: '^5.5.0'
136
- }
137
- },
138
- '@perses-dev/components': {
139
- version: '0.50.0',
140
- lib: ()=>require('@perses-dev/components'),
141
- shareConfig: {
142
- singleton: true,
143
- requiredVersion: '^0.50.0'
144
- }
145
- },
146
- '@perses-dev/plugin-system': {
147
- version: '0.50.0',
148
- lib: ()=>require('@perses-dev/plugin-system'),
149
- shareConfig: {
150
- singleton: true,
151
- requiredVersion: '^0.50.0'
152
- }
153
- },
154
- '@perses-dev/explore': {
155
- version: '0.50.0',
156
- lib: ()=>require('@perses-dev/explore'),
157
- shareConfig: {
158
- singleton: true,
159
- requiredVersion: '^0.50.0'
160
- }
161
- },
162
- '@perses-dev/dashboards': {
163
- version: '0.50.0',
164
- lib: ()=>require('@perses-dev/dashboards'),
165
- shareConfig: {
166
- singleton: true,
167
- requiredVersion: '^0.50.0'
83
+ let instance = null;
84
+ const getPluginRuntime = ()=>{
85
+ if (instance === null) {
86
+ const pluginRuntime = (0, _runtime.init)({
87
+ name: '@perses/perses-ui-host',
88
+ remotes: [],
89
+ shared: {
90
+ react: {
91
+ version: _react.default.version,
92
+ lib: ()=>_react.default,
93
+ shareConfig: {
94
+ singleton: true,
95
+ requiredVersion: `^${_react.default.version}`
96
+ }
97
+ },
98
+ 'react-dom': {
99
+ version: '18.3.1',
100
+ lib: ()=>_reactdom.default,
101
+ shareConfig: {
102
+ singleton: true,
103
+ requiredVersion: `^18.3.1`
104
+ }
105
+ },
106
+ 'react-router-dom': {
107
+ version: '6.26.0',
108
+ lib: ()=>_reactrouterdom,
109
+ shareConfig: {
110
+ singleton: true,
111
+ requiredVersion: '^6.26.0'
112
+ }
113
+ },
114
+ '@tanstack/react-query': {
115
+ version: '5.64.2',
116
+ lib: ()=>_reactquery,
117
+ shareConfig: {
118
+ singleton: true,
119
+ requiredVersion: '^5.64.2'
120
+ }
121
+ },
122
+ 'react-hook-form': {
123
+ version: '7.52.2',
124
+ lib: ()=>_reacthookform,
125
+ shareConfig: {
126
+ singleton: true,
127
+ requiredVersion: '^7.52.2'
128
+ }
129
+ },
130
+ echarts: {
131
+ version: '5.5.0',
132
+ lib: ()=>require('echarts'),
133
+ shareConfig: {
134
+ singleton: true,
135
+ requiredVersion: '^5.5.0'
136
+ }
137
+ },
138
+ '@perses-dev/components': {
139
+ version: '0.51.0-beta.0',
140
+ lib: ()=>require('@perses-dev/components'),
141
+ shareConfig: {
142
+ singleton: true,
143
+ requiredVersion: '^0.51.0-beta.0'
144
+ }
145
+ },
146
+ '@perses-dev/plugin-system': {
147
+ version: '0.51.0-beta.0',
148
+ lib: ()=>require('@perses-dev/plugin-system'),
149
+ shareConfig: {
150
+ singleton: true,
151
+ requiredVersion: '^0.51.0-beta.0'
152
+ }
153
+ },
154
+ '@perses-dev/explore': {
155
+ version: '0.51.0-beta.0',
156
+ lib: ()=>require('@perses-dev/explore'),
157
+ shareConfig: {
158
+ singleton: true,
159
+ requiredVersion: '^0.51.0-beta.0'
160
+ }
161
+ },
162
+ '@perses-dev/dashboards': {
163
+ version: '0.51.0-beta.0',
164
+ lib: ()=>require('@perses-dev/dashboards'),
165
+ shareConfig: {
166
+ singleton: true,
167
+ requiredVersion: '^0.51.0-beta.0'
168
+ }
169
+ },
170
+ // Below are the shared modules that are used by the plugins, this can be part of the SDK
171
+ 'date-fns': {
172
+ version: '4.1.0',
173
+ lib: ()=>require('date-fns'),
174
+ shareConfig: {
175
+ singleton: true,
176
+ requiredVersion: '^4.1.0'
177
+ }
178
+ },
179
+ 'date-fns-tz': {
180
+ version: '3.2.0',
181
+ lib: ()=>require('date-fns-tz'),
182
+ shareConfig: {
183
+ singleton: true,
184
+ requiredVersion: '^3.2.0'
185
+ }
186
+ },
187
+ lodash: {
188
+ version: '4.17.21',
189
+ lib: ()=>require('lodash'),
190
+ shareConfig: {
191
+ singleton: true,
192
+ requiredVersion: '^4.17.21'
193
+ }
194
+ },
195
+ '@emotion/react': {
196
+ version: '11.11.3',
197
+ lib: ()=>require('@emotion/react'),
198
+ shareConfig: {
199
+ singleton: true,
200
+ requiredVersion: '^11.11.3'
201
+ }
202
+ },
203
+ '@emotion/styled': {
204
+ version: '11.11.0',
205
+ lib: ()=>require('@emotion/styled'),
206
+ shareConfig: {
207
+ singleton: true,
208
+ requiredVersion: '^11.11.0'
209
+ }
210
+ },
211
+ '@hookform/resolvers/zod': {
212
+ version: '3.3.4',
213
+ lib: ()=>require('@hookform/resolvers/zod'),
214
+ shareConfig: {
215
+ singleton: true,
216
+ requiredVersion: '^3.3.4'
217
+ }
218
+ },
219
+ 'use-resize-observer': {
220
+ version: '9.1.0',
221
+ lib: ()=>require('use-resize-observer'),
222
+ shareConfig: {
223
+ singleton: true,
224
+ requiredVersion: '^9.1.0'
225
+ }
226
+ },
227
+ 'mdi-material-ui': {
228
+ version: '7.4.0',
229
+ lib: ()=>require('mdi-material-ui'),
230
+ shareConfig: {
231
+ singleton: true,
232
+ requiredVersion: '^7.4.0'
233
+ }
234
+ },
235
+ immer: {
236
+ version: '10.1.1',
237
+ lib: ()=>require('immer'),
238
+ shareConfig: {
239
+ singleton: true,
240
+ requiredVersion: '^10.1.1'
241
+ }
242
+ }
168
243
  }
169
- },
170
- // Below are the shared modules that are used by the plugins, this can be part of the SDK
171
- 'date-fns': {
172
- version: '2.29.3',
173
- lib: ()=>require('date-fns'),
174
- shareConfig: {
175
- singleton: true,
176
- requiredVersion: '^2.29.3'
177
- }
178
- },
179
- 'date-fns-tz': {
180
- version: '1.3.8',
181
- lib: ()=>require('date-fns-tz'),
182
- shareConfig: {
183
- singleton: true,
184
- requiredVersion: '^1.3.8'
185
- }
186
- },
187
- lodash: {
188
- version: '4.17.21',
189
- lib: ()=>require('lodash'),
190
- shareConfig: {
191
- singleton: true,
192
- requiredVersion: '^4.17.21'
193
- }
194
- },
195
- '@emotion/react': {
196
- version: '11.11.3',
197
- lib: ()=>require('@emotion/react'),
198
- shareConfig: {
199
- singleton: true,
200
- requiredVersion: '^11.11.3'
201
- }
202
- },
203
- '@emotion/styled': {
204
- version: '11.11.0',
205
- lib: ()=>require('@emotion/styled'),
206
- shareConfig: {
207
- singleton: true,
208
- requiredVersion: '^11.11.0'
209
- }
210
- },
211
- '@hookform/resolvers/zod': {
212
- version: '3.3.4',
213
- lib: ()=>require('@hookform/resolvers/zod'),
214
- shareConfig: {
215
- singleton: true,
216
- requiredVersion: '^3.3.4'
217
- }
218
- },
219
- 'use-resize-observer': {
220
- version: '9.1.0',
221
- lib: ()=>require('use-resize-observer'),
222
- shareConfig: {
223
- singleton: true,
224
- requiredVersion: '^9.1.0'
225
- }
226
- },
227
- 'mdi-material-ui': {
228
- version: '7.4.0',
229
- lib: ()=>require('mdi-material-ui'),
230
- shareConfig: {
231
- singleton: true,
232
- requiredVersion: '^7.4.0'
233
- }
234
- },
235
- immer: {
236
- version: '9.0.15',
237
- lib: ()=>require('immer'),
238
- shareConfig: {
239
- singleton: true,
240
- requiredVersion: '^9.0.15'
241
- }
242
- }
244
+ });
245
+ instance = pluginRuntime;
246
+ return instance;
243
247
  }
244
- });
248
+ return instance;
249
+ };
245
250
  const registerRemote = (name, baseURL)=>{
251
+ const pluginRuntime = getPluginRuntime();
246
252
  const existingRemote = pluginRuntime.options.remotes.find((remote)=>remote.name === name);
247
253
  if (!existingRemote) {
248
254
  const remoteEntryURL = baseURL ? `${baseURL}/${name}/mf-manifest.json` : `/plugins/${name}/mf-manifest.json`;
@@ -261,7 +267,7 @@ const loadPlugin = async (moduleName, pluginName, baseURL)=>{
261
267
  };
262
268
  function usePluginRuntime({ plugin }) {
263
269
  return {
264
- pluginRuntime,
270
+ pluginRuntime: getPluginRuntime(),
265
271
  loadPlugin: ()=>loadPlugin(plugin.moduleName, plugin.name, plugin.baseURL)
266
272
  };
267
273
  }
@@ -78,7 +78,7 @@ function useQueryType() {
78
78
  case 'TempoTraceQuery':
79
79
  return isTraceQueryPluginLoading;
80
80
  }
81
- throw new Error(`Unable to determine the query type: ${pluginKind}`);
81
+ return isTraceQueryPluginLoading || isTimeSeriesQueryLoading;
82
82
  };
83
83
  if (isLoading(pluginKind)) {
84
84
  return undefined;
@@ -69,18 +69,27 @@ function usePlugin(pluginType, kind, options) {
69
69
  }
70
70
  function usePlugins(pluginType, plugins) {
71
71
  const { getPlugin } = usePluginRegistry();
72
- return (0, _reactquery.useQueries)({
73
- queries: plugins.map((p)=>{
72
+ // useQueries() does not support queries with duplicate keys, therefore we de-duplicate the plugin kinds before running useQueries()
73
+ // This resolves the following warning in the JS console: "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
74
+ // https://github.com/TanStack/query/issues/8224#issuecomment-2523554831
75
+ // https://github.com/TanStack/query/issues/4187#issuecomment-1256336901
76
+ const kinds = [
77
+ ...new Set(plugins.map((p)=>p.kind))
78
+ ];
79
+ const result = (0, _reactquery.useQueries)({
80
+ queries: kinds.map((kind)=>{
74
81
  return {
75
82
  queryKey: [
76
83
  'getPlugin',
77
84
  pluginType,
78
- p.kind
85
+ kind
79
86
  ],
80
- queryFn: ()=>getPlugin(pluginType, p.kind)
87
+ queryFn: ()=>getPlugin(pluginType, kind)
81
88
  };
82
89
  })
83
90
  });
91
+ // Re-assemble array in original order
92
+ return plugins.map((p)=>result[kinds.indexOf(p.kind)]);
84
93
  }
85
94
  function useListPluginMetadata(pluginTypes, options) {
86
95
  const { listPluginMetadata } = usePluginRegistry();
@@ -68,11 +68,7 @@ function useTraceQueries(definitions) {
68
68
  const plugin = await getPlugin(TRACE_QUERY_KEY, traceQueryKind);
69
69
  const data = await plugin.getTraceData(definition.spec.plugin.spec, context);
70
70
  return data;
71
- },
72
- // The data returned by getTraceData() contains circular dependencies (a span has a reference to the parent span, and the parent span has an array of child spans)
73
- // Therefore structuralSharing must be turned off, otherwise the query is stuck in the 'fetching' state on re-fetch.
74
- // Ref: https://github.com/TanStack/query/issues/6954#issuecomment-1962321426
75
- structuralSharing: false
71
+ }
76
72
  };
77
73
  })
78
74
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { Box, Divider, FormControlLabel, Grid, Stack, Switch, TextField, Typography } from '@mui/material';\nimport { DiscardChangesConfirmationDialog, FormActions } from '@perses-dev/components';\nimport { Action, DatasourceDefinition } from '@perses-dev/core';\nimport { DispatchWithoutAction, ReactElement, useState } from 'react';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { useValidationSchemas } from '../../context';\nimport { getSubmitText, getTitleAction } from '../../utils';\nimport { PluginEditor } from '../PluginEditor';\n\ninterface DatasourceEditorFormProps {\n initialDatasourceDefinition: DatasourceDefinition;\n action: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onActionChange?: (action: Action) => void;\n onSave: (def: DatasourceDefinition) => void;\n onClose: DispatchWithoutAction;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function DatasourceEditorForm(props: DatasourceEditorFormProps): ReactElement {\n const { initialDatasourceDefinition, action, isDraft, isReadonly, onActionChange, onSave, onClose, onDelete } = props;\n\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const { datasourceEditorSchema } = useValidationSchemas();\n const form = useForm<DatasourceDefinition>({\n resolver: zodResolver(datasourceEditorSchema),\n mode: 'onBlur',\n defaultValues: initialDatasourceDefinition,\n });\n\n /*\n * Remove empty fields that are optional\n */\n function clearFormData(data: DatasourceDefinition): DatasourceDefinition {\n const result = { ...data };\n if (result.spec.display?.name === undefined && result.spec.display?.description === undefined) {\n delete result.spec.display;\n }\n return result;\n }\n\n const processForm: SubmitHandler<DatasourceDefinition> = (data: DatasourceDefinition) => {\n onSave(clearFormData(data));\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel(): void {\n if (JSON.stringify(initialDatasourceDefinition) !== JSON.stringify(clearFormData(form.getValues()))) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Datasource</Typography>\n <FormActions\n action={action}\n submitText={submitText}\n isReadonly={isReadonly}\n isValid={form.formState.isValid}\n onActionChange={onActionChange}\n onSubmit={form.handleSubmit(processForm)}\n onDelete={onDelete}\n onCancel={handleCancel}\n />\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n name=\"name\"\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"spec.display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"title\"\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Controller\n control={form.control}\n name=\"spec.display.description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"description\"\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={6} sx={{ paddingTop: '5px !important' }}>\n <Stack>\n <Controller\n control={form.control}\n name=\"spec.default\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Set as default\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n <Typography variant=\"caption\">\n Whether this datasource should be the default {form.getValues().spec.plugin.kind} to be used\n </Typography>\n </Stack>\n </Grid>\n </Grid>\n <Divider />\n <Typography py={1} variant=\"h3\">\n Plugin Options\n </Typography>\n <Controller\n control={form.control}\n name=\"spec.plugin\"\n render={({ field }) => (\n <PluginEditor\n width=\"100%\"\n pluginTypes={['Datasource']}\n pluginKindLabel=\"Source\"\n value={{\n selection: {\n type: 'Datasource',\n kind: field.value.kind,\n },\n spec: field.value.spec,\n }}\n isReadonly={action === 'read'}\n onChange={(v) => {\n field.onChange({ kind: v.selection.kind, spec: v.spec });\n }}\n />\n )}\n />\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard your changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => setDiscardDialogOpened(false)}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["zodResolver","Box","Divider","FormControlLabel","Grid","Stack","Switch","TextField","Typography","DiscardChangesConfirmationDialog","FormActions","useState","Controller","FormProvider","useForm","useValidationSchemas","getSubmitText","getTitleAction","PluginEditor","DatasourceEditorForm","props","initialDatasourceDefinition","action","isDraft","isReadonly","onActionChange","onSave","onClose","onDelete","isDiscardDialogOpened","setDiscardDialogOpened","titleAction","submitText","datasourceEditorSchema","form","resolver","mode","defaultValues","clearFormData","data","result","spec","display","name","undefined","description","processForm","handleCancel","JSON","stringify","getValues","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","isValid","formState","onSubmit","handleSubmit","onCancel","overflowY","container","mb","item","xs","control","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","InputProps","disabled","readOnly","error","helperText","message","value","onChange","event","paddingTop","checked","plugin","kind","py","width","pluginTypes","pluginKindLabel","selection","type","v","isOpen","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,WAAW,QAAQ,0BAA0B;AACtD,SAASC,GAAG,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,KAAK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ChB,KAACrE;oDACCyE,OAAM;oDACNN,uBACE,KAAChE;wDACE,GAAGkE,KAAK;wDACTiB,SAAS,CAAC,CAACjB,MAAMa,KAAK;wDACtBJ,UAAU3D,WAAW;wDACrBgE,UAAU,CAACC;4DACT,IAAIjE,WAAW,QAAQ,QAAQ,oDAAoD;4DACnFkD,MAAMc,QAAQ,CAACC;wDACjB;;;;sDAMV,MAAC/E;4CAAWmD,SAAQ;;gDAAU;gDACmBzB,KAAKgB,SAAS,GAAGT,IAAI,CAACiD,MAAM,CAACC,IAAI;gDAAC;;;;;;;;kCAKzF,KAACzF;kCACD,KAACM;wBAAWoF,IAAI;wBAAGjC,SAAQ;kCAAK;;kCAGhC,KAAC/C;wBACC0D,SAASpC,KAAKoC,OAAO;wBACrB3B,MAAK;wBACL4B,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,KAACtD;gCACC2E,OAAM;gCACNC,aAAa;oCAAC;iCAAa;gCAC3BC,iBAAgB;gCAChBV,OAAO;oCACLW,WAAW;wCACTC,MAAM;wCACNN,MAAMnB,MAAMa,KAAK,CAACM,IAAI;oCACxB;oCACAlD,MAAM+B,MAAMa,KAAK,CAAC5C,IAAI;gCACxB;gCACAjB,YAAYF,WAAW;gCACvBgE,UAAU,CAACY;oCACT1B,MAAMc,QAAQ,CAAC;wCAAEK,MAAMO,EAAEF,SAAS,CAACL,IAAI;wCAAElD,MAAMyD,EAAEzD,IAAI;oCAAC;gCACxD;;;;;0BAKR,KAAChC;gBACCoC,aAAY;gBACZsD,QAAQtE;gBACRmC,UAAU,IAAMlC,uBAAuB;gBACvCsE,kBAAkB;oBAChBtE,uBAAuB;oBACvBH;gBACF;;;;AAIR"}
1
+ {"version":3,"sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { Box, Divider, FormControlLabel, Grid, Stack, Switch, TextField, Typography } from '@mui/material';\nimport { DiscardChangesConfirmationDialog, FormActions } from '@perses-dev/components';\nimport { Action, DatasourceDefinition } from '@perses-dev/core';\nimport { DispatchWithoutAction, ReactElement, useState } from 'react';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { useValidationSchemas } from '../../context';\nimport { getSubmitText, getTitleAction } from '../../utils';\nimport { PluginEditor } from '../PluginEditor';\n\ninterface DatasourceEditorFormProps {\n initialDatasourceDefinition: DatasourceDefinition;\n action: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onActionChange?: (action: Action) => void;\n onSave: (def: DatasourceDefinition) => void;\n onClose: DispatchWithoutAction;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function DatasourceEditorForm(props: DatasourceEditorFormProps): ReactElement {\n const { initialDatasourceDefinition, action, isDraft, isReadonly, onActionChange, onSave, onClose, onDelete } = props;\n\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const { datasourceEditorSchema } = useValidationSchemas();\n const form = useForm<DatasourceDefinition>({\n resolver: zodResolver(datasourceEditorSchema),\n mode: 'onBlur',\n defaultValues: initialDatasourceDefinition,\n });\n\n /*\n * Remove empty fields that are optional\n */\n function clearFormData(data: DatasourceDefinition): DatasourceDefinition {\n const result = { ...data };\n if (result.spec.display?.name === undefined && result.spec.display?.description === undefined) {\n delete result.spec.display;\n }\n return result;\n }\n\n const processForm: SubmitHandler<DatasourceDefinition> = (data: DatasourceDefinition) => {\n onSave(clearFormData(data));\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel(): void {\n if (JSON.stringify(initialDatasourceDefinition) !== JSON.stringify(clearFormData(form.getValues()))) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Datasource</Typography>\n <FormActions\n action={action}\n submitText={submitText}\n isReadonly={isReadonly}\n isValid={form.formState.isValid}\n onActionChange={onActionChange}\n onSubmit={form.handleSubmit(processForm)}\n onDelete={onDelete}\n onCancel={handleCancel}\n />\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n name=\"name\"\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"spec.display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"title\"\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Controller\n control={form.control}\n name=\"spec.display.description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"description\"\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={6} sx={{ paddingTop: '5px !important' }}>\n <Stack>\n <Controller\n control={form.control}\n name=\"spec.default\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Set as default\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n <Typography variant=\"caption\">\n Whether this datasource should be the default {form.getValues().spec.plugin.kind} to be used\n </Typography>\n </Stack>\n </Grid>\n </Grid>\n <Divider />\n <Typography py={1} variant=\"h3\">\n Plugin Options\n </Typography>\n <Controller\n control={form.control}\n name=\"spec.plugin\"\n render={({ field }) => (\n <PluginEditor\n width=\"100%\"\n pluginTypes={['Datasource']}\n pluginKindLabel=\"Source\"\n value={{\n selection: {\n type: 'Datasource',\n kind: field.value.kind,\n },\n spec: field.value.spec,\n }}\n isReadonly={action === 'read'}\n onChange={(v) => {\n field.onChange({ kind: v.selection.kind, spec: v.spec });\n }}\n />\n )}\n />\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard your changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => setDiscardDialogOpened(false)}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["zodResolver","Box","Divider","FormControlLabel","Grid","Stack","Switch","TextField","Typography","DiscardChangesConfirmationDialog","FormActions","useState","Controller","FormProvider","useForm","useValidationSchemas","getSubmitText","getTitleAction","PluginEditor","DatasourceEditorForm","props","initialDatasourceDefinition","action","isDraft","isReadonly","onActionChange","onSave","onClose","onDelete","isDiscardDialogOpened","setDiscardDialogOpened","titleAction","submitText","datasourceEditorSchema","form","resolver","mode","defaultValues","clearFormData","data","result","spec","display","name","undefined","description","processForm","handleCancel","JSON","stringify","getValues","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","isValid","formState","onSubmit","handleSubmit","onCancel","overflowY","container","mb","item","xs","control","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","InputProps","disabled","readOnly","error","helperText","message","value","onChange","event","paddingTop","checked","plugin","kind","py","width","pluginTypes","pluginKindLabel","selection","type","v","isOpen","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,WAAW,QAAQ,0BAA0B;AACtD,SAASC,GAAG,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAC3G,SAASC,gCAAgC,EAAEC,WAAW,QAAQ,yBAAyB;AAEvF,SAA8CC,QAAQ,QAAQ,QAAQ;AACtE,SAASC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,QAAQ,kBAAkB;AACnF,SAASC,oBAAoB,QAAQ,gBAAgB;AACrD,SAASC,aAAa,EAAEC,cAAc,QAAQ,cAAc;AAC5D,SAASC,YAAY,QAAQ,kBAAkB;AAa/C,OAAO,SAASC,qBAAqBC,KAAgC;IACnE,MAAM,EAAEC,2BAA2B,EAAEC,MAAM,EAAEC,OAAO,EAAEC,UAAU,EAAEC,cAAc,EAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGR;IAEhH,MAAM,CAACS,uBAAuBC,uBAAuB,GAAGnB,SAAkB;IAC1E,MAAMoB,cAAcd,eAAe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CAAa;gCAC3BC,iBAAgB;gCAChBV,OAAO;oCACLW,WAAW;wCACTC,MAAM;wCACNN,MAAMnB,MAAMa,KAAK,CAACM,IAAI;oCACxB;oCACAlD,MAAM+B,MAAMa,KAAK,CAAC5C,IAAI;gCACxB;gCACAjB,YAAYF,WAAW;gCACvBgE,UAAU,CAACY;oCACT1B,MAAMc,QAAQ,CAAC;wCAAEK,MAAMO,EAAEF,SAAS,CAACL,IAAI;wCAAElD,MAAMyD,EAAEzD,IAAI;oCAAC;gCACxD;;;;;0BAKR,KAAChC;gBACCoC,aAAY;gBACZsD,QAAQtE;gBACRmC,UAAU,IAAMlC,uBAAuB;gBACvCsE,kBAAkB;oBAChBtE,uBAAuB;oBACvBH;gBACF;;;;AAIR"}
@@ -1,8 +1,8 @@
1
- import { SelectProps } from '@mui/material';
1
+ import { OutlinedSelectProps, BaseSelectProps } from '@mui/material';
2
2
  import { DatasourceSelector } from '@perses-dev/core';
3
3
  import { ReactElement } from 'react';
4
4
  type OmittedMuiProps = 'children' | 'value' | 'onChange';
5
- export interface DatasourceSelectProps extends Omit<SelectProps<string>, OmittedMuiProps> {
5
+ export interface DatasourceSelectProps extends Omit<OutlinedSelectProps & BaseSelectProps<string>, OmittedMuiProps> {
6
6
  value: DatasourceSelector;
7
7
  onChange: (next: DatasourceSelector) => void;
8
8
  datasourcePluginKind: string;
@@ -1 +1 @@
1
- {"version":3,"file":"DatasourceSelect.d.ts","sourceRoot":"","sources":["../../src/components/DatasourceSelect.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAU,WAAW,EAAiE,MAAM,eAAe,CAAC;AACnH,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAK9C,KAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,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