@perses-dev/plugin-system 0.50.0 → 0.51.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +17 -71
- package/dist/cjs/components/DatasourceSelect.js +8 -13
- package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +534 -0
- package/dist/cjs/components/HTTPSettingsEditor/index.js +30 -0
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -4
- package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +41 -0
- package/dist/cjs/components/MetricLabelInput/index.js +30 -0
- package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +15 -14
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +7 -11
- package/dist/cjs/components/PluginEditor/PluginEditor.js +10 -6
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +4 -5
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +7 -8
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +7 -10
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +17 -14
- package/dist/cjs/components/ProjectSelect.js +2 -3
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +46 -92
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +6 -6
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
- package/dist/cjs/components/Variables/variable-model.js +4 -7
- package/dist/cjs/components/index.js +2 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/model/explore.js +16 -0
- package/dist/cjs/remote/PersesPlugin.types.js +16 -0
- package/dist/cjs/remote/PluginLoaderComponent.js +75 -0
- package/dist/cjs/remote/PluginRuntime.js +267 -0
- package/dist/cjs/remote/index.js +31 -0
- package/dist/cjs/remote/remotePluginLoader.js +61 -0
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +4 -10
- package/dist/cjs/runtime/DataQueriesProvider/model.js +4 -7
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +2 -2
- package/dist/cjs/runtime/builtin-variables.js +1 -1
- package/dist/cjs/runtime/datasources.js +3 -3
- package/dist/cjs/runtime/plugin-registry.js +5 -6
- package/dist/cjs/runtime/time-series-queries.js +11 -18
- package/dist/cjs/runtime/trace-queries.js +1 -2
- package/dist/cjs/runtime/variables.js +10 -28
- package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +1 -1
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +1 -67
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemVariables.js +1 -1
- package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +1 -1
- package/dist/cjs/test/render.js +1 -2
- package/dist/cjs/test-utils/mock-plugin-registry.js +10 -10
- package/dist/cjs/utils/variables.js +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +17 -30
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect.d.ts +2 -2
- package/dist/components/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect.js +8 -13
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +11 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +480 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -0
- package/dist/components/HTTPSettingsEditor/index.d.ts +2 -0
- package/dist/components/HTTPSettingsEditor/index.d.ts.map +1 -0
- package/dist/components/HTTPSettingsEditor/index.js +15 -0
- package/dist/components/HTTPSettingsEditor/index.js.map +1 -0
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -4
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.d.ts +7 -0
- package/dist/components/MetricLabelInput/MetricLabelInput.d.ts.map +1 -0
- package/dist/components/MetricLabelInput/MetricLabelInput.js +33 -0
- package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -0
- package/dist/components/MetricLabelInput/index.d.ts +2 -0
- package/dist/components/MetricLabelInput/index.d.ts.map +1 -0
- package/dist/components/MetricLabelInput/index.js +15 -0
- package/dist/components/MetricLabelInput/index.js.map +1 -0
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +15 -14
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +7 -11
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +10 -6
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +4 -5
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +7 -8
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +7 -10
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -4
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +17 -14
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/ProjectSelect.js +2 -3
- package/dist/components/ProjectSelect.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +46 -92
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +6 -6
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.js +4 -7
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/explore.d.ts +13 -0
- package/dist/model/explore.d.ts.map +1 -0
- package/dist/model/explore.js +17 -0
- package/dist/model/explore.js.map +1 -0
- package/dist/model/panels.d.ts +13 -3
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugins.d.ts +31 -17
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/remote/PersesPlugin.types.d.ts +7 -0
- package/dist/remote/PersesPlugin.types.d.ts.map +1 -0
- package/dist/remote/PersesPlugin.types.js +15 -0
- package/dist/remote/PersesPlugin.types.js.map +1 -0
- package/dist/remote/PluginLoaderComponent.d.ts +10 -0
- package/dist/remote/PluginLoaderComponent.d.ts.map +1 -0
- package/dist/remote/PluginLoaderComponent.js +67 -0
- package/dist/remote/PluginLoaderComponent.js.map +1 -0
- package/dist/remote/PluginRuntime.d.ts +11 -0
- package/dist/remote/PluginRuntime.d.ts.map +1 -0
- package/dist/remote/PluginRuntime.js +202 -0
- package/dist/remote/PluginRuntime.js.map +1 -0
- package/dist/remote/index.d.ts +3 -0
- package/dist/remote/index.d.ts.map +1 -0
- package/dist/remote/index.js +16 -0
- package/dist/remote/index.js.map +1 -0
- package/dist/remote/remotePluginLoader.d.ts +3 -0
- package/dist/remote/remotePluginLoader.d.ts.map +1 -0
- package/dist/remote/remotePluginLoader.js +53 -0
- package/dist/remote/remotePluginLoader.js.map +1 -0
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +4 -10
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +4 -7
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +2 -2
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/builtin-variables.js +1 -1
- package/dist/runtime/builtin-variables.js.map +1 -1
- package/dist/runtime/datasources.d.ts +2 -2
- package/dist/runtime/datasources.js +3 -3
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +6 -6
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +5 -6
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/time-series-queries.js +11 -18
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.js +1 -2
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/variables.js +10 -28
- package/dist/runtime/variables.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.js +1 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -22
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +4 -4
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.js +1 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
- package/dist/test/render.js +1 -2
- package/dist/test/render.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts +5 -3
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +10 -10
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/dist/utils/variables.js +1 -1
- package/dist/utils/variables.js.map +1 -1
- package/package.json +6 -5
|
@@ -91,10 +91,7 @@ function TextVariableEditorForm({ action, control }) {
|
|
|
91
91
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
92
92
|
control: control,
|
|
93
93
|
name: "spec.value",
|
|
94
|
-
render: ({ field, fieldState })
|
|
95
|
-
var _fieldState_error;
|
|
96
|
-
var _field_value;
|
|
97
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
94
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
98
95
|
children: [
|
|
99
96
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
100
97
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_VariablePreview.VariablePreview, {
|
|
@@ -113,35 +110,31 @@ function TextVariableEditorForm({ action, control }) {
|
|
|
113
110
|
readOnly: action === 'read'
|
|
114
111
|
},
|
|
115
112
|
error: !!fieldState.error,
|
|
116
|
-
helperText:
|
|
117
|
-
value:
|
|
113
|
+
helperText: fieldState.error?.message,
|
|
114
|
+
value: field.value ?? '',
|
|
118
115
|
onChange: (event)=>{
|
|
119
116
|
field.onChange(event);
|
|
120
117
|
}
|
|
121
118
|
})
|
|
122
119
|
]
|
|
123
|
-
})
|
|
124
|
-
}
|
|
120
|
+
})
|
|
125
121
|
}),
|
|
126
122
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
127
123
|
control: control,
|
|
128
124
|
name: "spec.constant",
|
|
129
|
-
render: ({ field })
|
|
130
|
-
var _field_value;
|
|
131
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
125
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
132
126
|
label: "Constant",
|
|
133
127
|
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
134
128
|
...field,
|
|
135
129
|
checked: !!field.value,
|
|
136
130
|
readOnly: action === 'read',
|
|
137
|
-
value:
|
|
131
|
+
value: field.value ?? false,
|
|
138
132
|
onChange: (event)=>{
|
|
139
133
|
if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
|
|
140
134
|
field.onChange(event);
|
|
141
135
|
}
|
|
142
136
|
})
|
|
143
|
-
})
|
|
144
|
-
}
|
|
137
|
+
})
|
|
145
138
|
})
|
|
146
139
|
]
|
|
147
140
|
})
|
|
@@ -210,10 +203,7 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
210
203
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
211
204
|
control: control,
|
|
212
205
|
name: "spec.plugin",
|
|
213
|
-
render: ({ field })
|
|
214
|
-
var _field_value, _field_value1;
|
|
215
|
-
var _field_value_kind, _field_value_spec;
|
|
216
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginEditor.PluginEditor, {
|
|
206
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginEditor.PluginEditor, {
|
|
217
207
|
width: "100%",
|
|
218
208
|
pluginTypes: [
|
|
219
209
|
'Variable'
|
|
@@ -222,9 +212,9 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
222
212
|
value: {
|
|
223
213
|
selection: {
|
|
224
214
|
type: 'Variable',
|
|
225
|
-
kind:
|
|
215
|
+
kind: field.value?.kind ?? 'StaticListVariable'
|
|
226
216
|
},
|
|
227
|
-
spec:
|
|
217
|
+
spec: field.value?.spec ?? {
|
|
228
218
|
values: []
|
|
229
219
|
}
|
|
230
220
|
},
|
|
@@ -235,8 +225,7 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
235
225
|
spec: v.spec
|
|
236
226
|
});
|
|
237
227
|
}
|
|
238
|
-
})
|
|
239
|
-
}
|
|
228
|
+
})
|
|
240
229
|
})
|
|
241
230
|
})
|
|
242
231
|
]
|
|
@@ -245,10 +234,7 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
245
234
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
246
235
|
control: control,
|
|
247
236
|
name: "spec.capturingRegexp",
|
|
248
|
-
render: ({ field, fieldState })
|
|
249
|
-
var _fieldState_error;
|
|
250
|
-
var _field_value;
|
|
251
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
237
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
252
238
|
...field,
|
|
253
239
|
label: "Capturing Regexp Filter",
|
|
254
240
|
InputLabelProps: {
|
|
@@ -258,7 +244,7 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
258
244
|
readOnly: action === 'read'
|
|
259
245
|
},
|
|
260
246
|
error: !!fieldState.error,
|
|
261
|
-
value:
|
|
247
|
+
value: field.value ?? '',
|
|
262
248
|
onChange: (event)=>{
|
|
263
249
|
if (event.target.value === '') {
|
|
264
250
|
field.onChange(undefined);
|
|
@@ -266,19 +252,15 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
266
252
|
field.onChange(event);
|
|
267
253
|
}
|
|
268
254
|
},
|
|
269
|
-
helperText:
|
|
270
|
-
})
|
|
271
|
-
}
|
|
255
|
+
helperText: fieldState.error?.message ? fieldState.error.message : 'Optional, if you want to filter on captured result.'
|
|
256
|
+
})
|
|
272
257
|
})
|
|
273
258
|
}),
|
|
274
259
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
275
260
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
276
261
|
control: control,
|
|
277
262
|
name: "spec.sort",
|
|
278
|
-
render: ({ field, fieldState })
|
|
279
|
-
var _fieldState_error;
|
|
280
|
-
var _field_value;
|
|
281
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
263
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
282
264
|
select: true,
|
|
283
265
|
...field,
|
|
284
266
|
fullWidth: true,
|
|
@@ -290,8 +272,8 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
290
272
|
readOnly: action === 'read'
|
|
291
273
|
},
|
|
292
274
|
error: !!fieldState.error,
|
|
293
|
-
helperText:
|
|
294
|
-
value:
|
|
275
|
+
helperText: fieldState.error?.message,
|
|
276
|
+
value: field.value ?? 'none',
|
|
295
277
|
onChange: (event)=>{
|
|
296
278
|
field.onChange(event);
|
|
297
279
|
},
|
|
@@ -325,8 +307,7 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
325
307
|
children: "Alphabetical, case-insensitive, desc"
|
|
326
308
|
})
|
|
327
309
|
]
|
|
328
|
-
})
|
|
329
|
-
}
|
|
310
|
+
})
|
|
330
311
|
})
|
|
331
312
|
})
|
|
332
313
|
]
|
|
@@ -345,22 +326,19 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
345
326
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
346
327
|
control: control,
|
|
347
328
|
name: "spec.allowMultiple",
|
|
348
|
-
render: ({ field })
|
|
349
|
-
var _field_value;
|
|
350
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
329
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
351
330
|
label: "Allow Multiple Values",
|
|
352
331
|
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
353
332
|
...field,
|
|
354
333
|
checked: !!field.value,
|
|
355
334
|
readOnly: action === 'read',
|
|
356
|
-
value:
|
|
335
|
+
value: field.value ?? false,
|
|
357
336
|
onChange: (event)=>{
|
|
358
337
|
if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
|
|
359
338
|
field.onChange(event);
|
|
360
339
|
}
|
|
361
340
|
})
|
|
362
|
-
})
|
|
363
|
-
}
|
|
341
|
+
})
|
|
364
342
|
}),
|
|
365
343
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
366
344
|
variant: "caption",
|
|
@@ -373,22 +351,19 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
373
351
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
374
352
|
control: control,
|
|
375
353
|
name: "spec.allowAllValue",
|
|
376
|
-
render: ({ field })
|
|
377
|
-
var _field_value;
|
|
378
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
354
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
379
355
|
label: "Allow All option",
|
|
380
356
|
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
381
357
|
...field,
|
|
382
358
|
checked: !!field.value,
|
|
383
359
|
readOnly: action === 'read',
|
|
384
|
-
value:
|
|
360
|
+
value: field.value ?? false,
|
|
385
361
|
onChange: (event)=>{
|
|
386
362
|
if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
|
|
387
363
|
field.onChange(event);
|
|
388
364
|
}
|
|
389
365
|
})
|
|
390
|
-
})
|
|
391
|
-
}
|
|
366
|
+
})
|
|
392
367
|
}),
|
|
393
368
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
394
369
|
mb: 1,
|
|
@@ -398,10 +373,7 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
398
373
|
_allowAllValue && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
399
374
|
control: control,
|
|
400
375
|
name: "spec.customAllValue",
|
|
401
|
-
render: ({ field, fieldState })
|
|
402
|
-
var _fieldState_error;
|
|
403
|
-
var _field_value;
|
|
404
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
376
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
405
377
|
...field,
|
|
406
378
|
fullWidth: true,
|
|
407
379
|
label: "Custom All Value",
|
|
@@ -412,8 +384,8 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
412
384
|
readOnly: action === 'read'
|
|
413
385
|
},
|
|
414
386
|
error: !!fieldState.error,
|
|
415
|
-
helperText:
|
|
416
|
-
value:
|
|
387
|
+
helperText: fieldState.error?.message ? fieldState.error.message : 'When All is selected, this value will be used',
|
|
388
|
+
value: field.value ?? '',
|
|
417
389
|
onChange: (event)=>{
|
|
418
390
|
if (event.target.value === '') {
|
|
419
391
|
field.onChange(undefined);
|
|
@@ -421,8 +393,7 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
421
393
|
field.onChange(event);
|
|
422
394
|
}
|
|
423
395
|
}
|
|
424
|
-
})
|
|
425
|
-
}
|
|
396
|
+
})
|
|
426
397
|
})
|
|
427
398
|
]
|
|
428
399
|
})
|
|
@@ -446,11 +417,10 @@ function VariableEditorForm({ initialVariableDefinition, action, isDraft, isRead
|
|
|
446
417
|
name: 'kind'
|
|
447
418
|
});
|
|
448
419
|
function clearFormData(data) {
|
|
449
|
-
var _result_spec_display, _result_spec_display1, _result_spec_display2;
|
|
450
420
|
const result = {
|
|
451
421
|
...data
|
|
452
422
|
};
|
|
453
|
-
if (
|
|
423
|
+
if (result.spec.display?.name === undefined && result.spec.display?.description === undefined && result.spec.display?.hidden === undefined) {
|
|
454
424
|
delete result.spec.display;
|
|
455
425
|
}
|
|
456
426
|
return result;
|
|
@@ -517,10 +487,7 @@ function VariableEditorForm({ initialVariableDefinition, action, isDraft, isRead
|
|
|
517
487
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
518
488
|
control: form.control,
|
|
519
489
|
name: "spec.name",
|
|
520
|
-
render: ({ field, fieldState })
|
|
521
|
-
var _fieldState_error;
|
|
522
|
-
var _field_value;
|
|
523
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
490
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
524
491
|
...field,
|
|
525
492
|
required: true,
|
|
526
493
|
fullWidth: true,
|
|
@@ -533,13 +500,12 @@ function VariableEditorForm({ initialVariableDefinition, action, isDraft, isRead
|
|
|
533
500
|
readOnly: action === 'read'
|
|
534
501
|
},
|
|
535
502
|
error: !!fieldState.error,
|
|
536
|
-
helperText:
|
|
537
|
-
value:
|
|
503
|
+
helperText: fieldState.error?.message,
|
|
504
|
+
value: field.value ?? '',
|
|
538
505
|
onChange: (event)=>{
|
|
539
506
|
field.onChange(event);
|
|
540
507
|
}
|
|
541
|
-
})
|
|
542
|
-
}
|
|
508
|
+
})
|
|
543
509
|
})
|
|
544
510
|
}),
|
|
545
511
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
@@ -548,10 +514,7 @@ function VariableEditorForm({ initialVariableDefinition, action, isDraft, isRead
|
|
|
548
514
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
549
515
|
control: form.control,
|
|
550
516
|
name: "spec.display.name",
|
|
551
|
-
render: ({ field, fieldState })
|
|
552
|
-
var _fieldState_error;
|
|
553
|
-
var _field_value;
|
|
554
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
517
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
555
518
|
...field,
|
|
556
519
|
fullWidth: true,
|
|
557
520
|
label: "Display Label",
|
|
@@ -562,13 +525,12 @@ function VariableEditorForm({ initialVariableDefinition, action, isDraft, isRead
|
|
|
562
525
|
readOnly: action === 'read'
|
|
563
526
|
},
|
|
564
527
|
error: !!fieldState.error,
|
|
565
|
-
helperText:
|
|
566
|
-
value:
|
|
528
|
+
helperText: fieldState.error?.message,
|
|
529
|
+
value: field.value ?? '',
|
|
567
530
|
onChange: (event)=>{
|
|
568
531
|
field.onChange(event);
|
|
569
532
|
}
|
|
570
|
-
})
|
|
571
|
-
}
|
|
533
|
+
})
|
|
572
534
|
})
|
|
573
535
|
}),
|
|
574
536
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
@@ -577,10 +539,7 @@ function VariableEditorForm({ initialVariableDefinition, action, isDraft, isRead
|
|
|
577
539
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
578
540
|
control: form.control,
|
|
579
541
|
name: "spec.display.description",
|
|
580
|
-
render: ({ field, fieldState })
|
|
581
|
-
var _fieldState_error;
|
|
582
|
-
var _field_value;
|
|
583
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
542
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
584
543
|
...field,
|
|
585
544
|
fullWidth: true,
|
|
586
545
|
label: "Description",
|
|
@@ -591,13 +550,12 @@ function VariableEditorForm({ initialVariableDefinition, action, isDraft, isRead
|
|
|
591
550
|
readOnly: action === 'read'
|
|
592
551
|
},
|
|
593
552
|
error: !!fieldState.error,
|
|
594
|
-
helperText:
|
|
595
|
-
value:
|
|
553
|
+
helperText: fieldState.error?.message,
|
|
554
|
+
value: field.value ?? '',
|
|
596
555
|
onChange: (event)=>{
|
|
597
556
|
field.onChange(event);
|
|
598
557
|
}
|
|
599
|
-
})
|
|
600
|
-
}
|
|
558
|
+
})
|
|
601
559
|
})
|
|
602
560
|
}),
|
|
603
561
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
@@ -606,10 +564,7 @@ function VariableEditorForm({ initialVariableDefinition, action, isDraft, isRead
|
|
|
606
564
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
607
565
|
control: form.control,
|
|
608
566
|
name: "kind",
|
|
609
|
-
render: ({ field, fieldState })
|
|
610
|
-
var _fieldState_error;
|
|
611
|
-
var _field_value;
|
|
612
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
567
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
613
568
|
select: true,
|
|
614
569
|
...field,
|
|
615
570
|
fullWidth: true,
|
|
@@ -621,8 +576,8 @@ function VariableEditorForm({ initialVariableDefinition, action, isDraft, isRead
|
|
|
621
576
|
readOnly: action === 'read'
|
|
622
577
|
},
|
|
623
578
|
error: !!fieldState.error,
|
|
624
|
-
helperText:
|
|
625
|
-
value:
|
|
579
|
+
helperText: fieldState.error?.message,
|
|
580
|
+
value: field.value ?? 'TextVariable',
|
|
626
581
|
onChange: (event)=>{
|
|
627
582
|
field.onChange(event);
|
|
628
583
|
},
|
|
@@ -630,8 +585,7 @@ function VariableEditorForm({ initialVariableDefinition, action, isDraft, isRead
|
|
|
630
585
|
value: v.kind,
|
|
631
586
|
children: v.label
|
|
632
587
|
}, v.kind))
|
|
633
|
-
})
|
|
634
|
-
}
|
|
588
|
+
})
|
|
635
589
|
})
|
|
636
590
|
})
|
|
637
591
|
]
|
|
@@ -91,7 +91,7 @@ function VariablePreview(props) {
|
|
|
91
91
|
setMaxValues(undefined);
|
|
92
92
|
};
|
|
93
93
|
let notShown = 0;
|
|
94
|
-
if (values &&
|
|
94
|
+
if (values && values?.length > 0 && maxValues) {
|
|
95
95
|
notShown = values.length - maxValues;
|
|
96
96
|
}
|
|
97
97
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
@@ -118,7 +118,7 @@ function VariablePreview(props) {
|
|
|
118
118
|
description: _constants.TOOLTIP_TEXT.copyVariableValues,
|
|
119
119
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
120
120
|
onClick: async ()=>{
|
|
121
|
-
if (values
|
|
121
|
+
if (values?.length) {
|
|
122
122
|
await navigator.clipboard.writeText(values.map((value)=>value).join(', '));
|
|
123
123
|
infoSnackbar('Preview values copied to clipboard!');
|
|
124
124
|
}
|
|
@@ -143,7 +143,7 @@ function VariablePreview(props) {
|
|
|
143
143
|
severity: "error",
|
|
144
144
|
children: error
|
|
145
145
|
}),
|
|
146
|
-
|
|
146
|
+
values?.length === 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Alert, {
|
|
147
147
|
severity: "info",
|
|
148
148
|
children: "No results"
|
|
149
149
|
}),
|
|
@@ -155,7 +155,7 @@ function VariablePreview(props) {
|
|
|
155
155
|
},
|
|
156
156
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {})
|
|
157
157
|
}),
|
|
158
|
-
values
|
|
158
|
+
values?.slice(0, maxValues).map((val, index)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
|
|
159
159
|
size: "small",
|
|
160
160
|
label: val
|
|
161
161
|
}, index)),
|
|
@@ -174,9 +174,9 @@ function VariablePreview(props) {
|
|
|
174
174
|
function VariableListPreview(props) {
|
|
175
175
|
const { definition, onRefresh } = props;
|
|
176
176
|
const { data, isFetching, error } = (0, _variablemodel.useListVariablePluginValues)(definition);
|
|
177
|
-
const errorMessage = error
|
|
177
|
+
const errorMessage = error?.message;
|
|
178
178
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(VariablePreview, {
|
|
179
|
-
values:
|
|
179
|
+
values: data?.map((val)=>val.value) || [],
|
|
180
180
|
onRefresh: onRefresh,
|
|
181
181
|
isLoading: isFetching,
|
|
182
182
|
error: errorMessage
|
|
@@ -29,11 +29,9 @@ _export(exports, {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
function getInitialState(initialVariableDefinition) {
|
|
32
|
-
var _initialVariableDefinition_spec_display, _initialVariableDefinition_spec_display1;
|
|
33
|
-
var _initialVariableDefinition_spec_value, _initialVariableDefinition_spec_constant;
|
|
34
32
|
const textVariableFields = {
|
|
35
|
-
value:
|
|
36
|
-
constant:
|
|
33
|
+
value: initialVariableDefinition.spec.value ?? '',
|
|
34
|
+
constant: initialVariableDefinition.spec.constant ?? false
|
|
37
35
|
};
|
|
38
36
|
const listVariableFields = {
|
|
39
37
|
allowMultiple: false,
|
|
@@ -47,21 +45,18 @@ function getInitialState(initialVariableDefinition) {
|
|
|
47
45
|
}
|
|
48
46
|
};
|
|
49
47
|
if (initialVariableDefinition.kind === 'ListVariable') {
|
|
50
|
-
|
|
51
|
-
listVariableFields.
|
|
52
|
-
var _initialVariableDefinition_spec_allowAllValue;
|
|
53
|
-
listVariableFields.allowAllValue = (_initialVariableDefinition_spec_allowAllValue = initialVariableDefinition.spec.allowAllValue) !== null && _initialVariableDefinition_spec_allowAllValue !== void 0 ? _initialVariableDefinition_spec_allowAllValue : false;
|
|
48
|
+
listVariableFields.allowMultiple = initialVariableDefinition.spec.allowMultiple ?? false;
|
|
49
|
+
listVariableFields.allowAllValue = initialVariableDefinition.spec.allowAllValue ?? false;
|
|
54
50
|
listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;
|
|
55
51
|
listVariableFields.capturingRegexp = initialVariableDefinition.spec.capturingRegexp;
|
|
56
52
|
listVariableFields.sort = initialVariableDefinition.spec.sort;
|
|
57
53
|
listVariableFields.plugin = initialVariableDefinition.spec.plugin;
|
|
58
54
|
}
|
|
59
|
-
var _initialVariableDefinition_spec_display_name, _initialVariableDefinition_spec_display_description;
|
|
60
55
|
return {
|
|
61
56
|
name: initialVariableDefinition.spec.name,
|
|
62
|
-
title:
|
|
57
|
+
title: initialVariableDefinition.spec.display?.name ?? '',
|
|
63
58
|
kind: initialVariableDefinition.kind,
|
|
64
|
-
description:
|
|
59
|
+
description: initialVariableDefinition.spec.display?.description ?? '',
|
|
65
60
|
listVariableFields,
|
|
66
61
|
textVariableFields
|
|
67
62
|
};
|
|
@@ -74,17 +74,14 @@ function useListVariablePluginValues(definition) {
|
|
|
74
74
|
const spec = definition.spec.plugin.spec;
|
|
75
75
|
const capturingRegexp = definition.spec.capturingRegexp !== undefined ? new RegExp(definition.spec.capturingRegexp, 'g') : undefined;
|
|
76
76
|
let dependsOnVariables;
|
|
77
|
-
if (variablePlugin
|
|
77
|
+
if (variablePlugin?.dependsOn) {
|
|
78
78
|
const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);
|
|
79
79
|
dependsOnVariables = dependencies.variables;
|
|
80
80
|
}
|
|
81
81
|
const variables = (0, _runtime.useAllVariableValues)(dependsOnVariables);
|
|
82
82
|
let waitToLoad = false;
|
|
83
83
|
if (dependsOnVariables) {
|
|
84
|
-
waitToLoad = dependsOnVariables.some((v)=>
|
|
85
|
-
var _variables_v;
|
|
86
|
-
return (_variables_v = variables[v]) === null || _variables_v === void 0 ? void 0 : _variables_v.loading;
|
|
87
|
-
});
|
|
84
|
+
waitToLoad = dependsOnVariables.some((v)=>variables[v]?.loading);
|
|
88
85
|
}
|
|
89
86
|
const variablesValueKey = getVariableValuesKey(variables);
|
|
90
87
|
return (0, _reactquery.useQuery)({
|
|
@@ -95,11 +92,11 @@ function useListVariablePluginValues(definition) {
|
|
|
95
92
|
refreshKey
|
|
96
93
|
],
|
|
97
94
|
queryFn: async ()=>{
|
|
98
|
-
const resp = await
|
|
95
|
+
const resp = await variablePlugin?.getVariableOptions(spec, {
|
|
99
96
|
datasourceStore,
|
|
100
97
|
variables,
|
|
101
98
|
timeRange
|
|
102
|
-
})
|
|
99
|
+
});
|
|
103
100
|
if (resp === undefined) {
|
|
104
101
|
return [];
|
|
105
102
|
}
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
17
17
|
_export_star(require("./CalculationSelector"), exports);
|
|
18
18
|
_export_star(require("./DatasourceEditorForm"), exports);
|
|
19
19
|
_export_star(require("./DatasourceSelect"), exports);
|
|
20
|
+
_export_star(require("./HTTPSettingsEditor"), exports);
|
|
20
21
|
_export_star(require("./LegendOptionsEditor"), exports);
|
|
21
22
|
_export_star(require("./MultiQueryEditor"), exports);
|
|
22
23
|
_export_star(require("./OptionsEditorRadios"), exports);
|
|
@@ -29,6 +30,7 @@ _export_star(require("./PluginSpecEditor"), exports);
|
|
|
29
30
|
_export_star(require("./TimeRangeControls"), exports);
|
|
30
31
|
_export_star(require("./Variables"), exports);
|
|
31
32
|
_export_star(require("./ProjectSelect"), exports);
|
|
33
|
+
_export_star(require("./MetricLabelInput"), exports);
|
|
32
34
|
function _export_star(from, to) {
|
|
33
35
|
Object.keys(from).forEach(function(k) {
|
|
34
36
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,6 +21,7 @@ _export_star(require("./runtime"), exports);
|
|
|
21
21
|
_export_star(require("./test-utils"), exports);
|
|
22
22
|
_export_star(require("./utils"), exports);
|
|
23
23
|
_export_star(require("./context"), exports);
|
|
24
|
+
_export_star(require("./remote"), exports);
|
|
24
25
|
function _export_star(from, to) {
|
|
25
26
|
Object.keys(from).forEach(function(k) {
|
|
26
27
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-ts-comment */ // Copyright 2024 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "PluginLoaderComponent", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return PluginLoaderComponent;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _react = require("react");
|
|
25
|
+
const _PluginRuntime = require("./PluginRuntime");
|
|
26
|
+
function PluginContainer({ pluginFn, props }) {
|
|
27
|
+
return pluginFn(props);
|
|
28
|
+
}
|
|
29
|
+
function PluginLoaderComponent({ plugin, props, field }) {
|
|
30
|
+
const { loadPlugin } = (0, _PluginRuntime.usePluginRuntime)({
|
|
31
|
+
plugin
|
|
32
|
+
});
|
|
33
|
+
const [pluginModule, setPluginModule] = (0, _react.useState)(null);
|
|
34
|
+
const [error, setError] = (0, _react.useState)(null);
|
|
35
|
+
const name = `${plugin.moduleName}-${plugin.name}`;
|
|
36
|
+
const previousPluginName = (0, _react.useRef)(name);
|
|
37
|
+
(0, _react.useEffect)(()=>{
|
|
38
|
+
previousPluginName.current = name;
|
|
39
|
+
setError(null);
|
|
40
|
+
loadPlugin().then((module)=>{
|
|
41
|
+
setPluginModule(module);
|
|
42
|
+
}).catch((error)=>{
|
|
43
|
+
setPluginModule(null);
|
|
44
|
+
console.error(`PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}:`, error);
|
|
45
|
+
setError(new Error(`PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}`));
|
|
46
|
+
});
|
|
47
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
|
+
}, [
|
|
49
|
+
name
|
|
50
|
+
]);
|
|
51
|
+
if (error) {
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
if (!pluginModule) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
let pluginFunction = pluginModule[plugin.name];
|
|
58
|
+
if (field && pluginFunction && typeof pluginFunction === 'object' && field in pluginFunction) {
|
|
59
|
+
pluginFunction = pluginFunction[field];
|
|
60
|
+
}
|
|
61
|
+
if (!pluginFunction) {
|
|
62
|
+
throw new Error(`PluginLoaderComponent: Plugin module ${plugin.moduleName} does not have a ${plugin.name} export`);
|
|
63
|
+
}
|
|
64
|
+
if (typeof pluginFunction !== 'function') {
|
|
65
|
+
throw new Error(`PluginLoaderComponent: Plugin ${plugin.name} export is not a function`);
|
|
66
|
+
}
|
|
67
|
+
// make sure to re mount the plugin when changes, to avoid mismatch in hooks ordering when re rendering
|
|
68
|
+
if (previousPluginName.current !== name) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(PluginContainer, {
|
|
72
|
+
pluginFn: pluginFunction,
|
|
73
|
+
props: props
|
|
74
|
+
}, name);
|
|
75
|
+
}
|