@perses-dev/plugin-system 0.46.0 → 0.47.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 +70 -99
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +2 -1
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +49 -19
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +1 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +10 -71
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +408 -376
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +2 -2
- package/dist/cjs/components/Variables/variable-model.js +24 -22
- package/dist/cjs/context/ProjectStoreProvider.js +7 -4
- package/dist/cjs/context/ValidationProvider.js +69 -0
- package/dist/cjs/context/index.js +1 -0
- package/dist/cjs/index.js +0 -1
- package/dist/cjs/runtime/QueryCountProvider.js +83 -0
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +100 -0
- package/dist/cjs/runtime/TimeRangeProvider/index.js +2 -1
- package/dist/cjs/runtime/builtin-variables.js +1 -1
- package/dist/cjs/runtime/datasources.js +22 -13
- package/dist/cjs/runtime/index.js +3 -2
- package/dist/cjs/runtime/plugin-registry.js +33 -22
- package/dist/cjs/runtime/time-series-queries.js +3 -3
- package/dist/cjs/runtime/trace-queries.js +5 -1
- package/dist/cjs/runtime/{template-variables.js → variables.js} +19 -19
- package/dist/cjs/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +8 -8
- package/dist/cjs/stories/shared-utils/decorators/index.js +2 -2
- package/dist/cjs/test/mock-data.js +25 -4
- package/dist/cjs/test/render.js +1 -9
- package/dist/cjs/test/test-plugins/bert/index.js +20 -19
- package/dist/cjs/utils/variables.js +23 -23
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +2 -2
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +71 -100
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -3
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +3 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +50 -20
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +1 -0
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +2 -2
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +12 -70
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +411 -379
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +2 -2
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +25 -23
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/context/ProjectStoreProvider.d.ts.map +1 -1
- package/dist/context/ProjectStoreProvider.js +7 -4
- package/dist/context/ProjectStoreProvider.js.map +1 -1
- package/dist/context/ValidationProvider.d.ts +19 -0
- package/dist/context/ValidationProvider.d.ts.map +1 -0
- package/dist/context/ValidationProvider.js +52 -0
- package/dist/context/ValidationProvider.js.map +1 -0
- package/dist/context/index.d.ts +1 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +1 -0
- package/dist/context/index.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/model/panels.d.ts +2 -2
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/QueryCountProvider.d.ts +9 -0
- package/dist/runtime/QueryCountProvider.d.ts.map +1 -0
- package/dist/{validation/duration.js → runtime/QueryCountProvider.js} +13 -4
- package/dist/runtime/QueryCountProvider.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +32 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +82 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/index.js +2 -1
- package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
- package/dist/runtime/builtin-variables.d.ts +1 -1
- package/dist/runtime/builtin-variables.d.ts.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.map +1 -1
- package/dist/runtime/datasources.js +22 -13
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +33 -22
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts +2 -2
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +3 -3
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts.map +1 -1
- package/dist/runtime/trace-queries.js +5 -1
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/{template-variables.d.ts → variables.d.ts} +4 -4
- package/dist/runtime/variables.d.ts.map +1 -0
- package/dist/runtime/{template-variables.js → variables.js} +18 -17
- package/dist/runtime/variables.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +12 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +9 -9
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +1 -0
- package/dist/stories/shared-utils/decorators/index.d.ts +1 -1
- package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/index.js +2 -2
- package/dist/stories/shared-utils/decorators/index.js.map +1 -1
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js +25 -4
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +1 -9
- package/dist/test/render.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js +20 -19
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/utils/variables.d.ts +4 -4
- package/dist/utils/variables.d.ts.map +1 -1
- package/dist/utils/variables.js +18 -18
- package/dist/utils/variables.js.map +1 -1
- package/package.json +5 -5
- package/dist/cjs/validation/datasource.js +0 -30
- package/dist/cjs/validation/duration.js +0 -25
- package/dist/cjs/validation/index.js +0 -34
- package/dist/cjs/validation/resource.js +0 -24
- package/dist/cjs/validation/role.js +0 -86
- package/dist/cjs/validation/rolebinding.js +0 -55
- package/dist/cjs/validation/secret.js +0 -176
- package/dist/cjs/validation/user.js +0 -46
- package/dist/cjs/validation/variable.js +0 -48
- package/dist/runtime/template-variables.d.ts.map +0 -1
- package/dist/runtime/template-variables.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +0 -12
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +0 -1
- package/dist/validation/datasource.d.ts +0 -19
- package/dist/validation/datasource.d.ts.map +0 -1
- package/dist/validation/datasource.js +0 -22
- package/dist/validation/datasource.js.map +0 -1
- package/dist/validation/duration.d.ts +0 -3
- package/dist/validation/duration.d.ts.map +0 -1
- package/dist/validation/duration.js.map +0 -1
- package/dist/validation/index.d.ts +0 -6
- package/dist/validation/index.d.ts.map +0 -1
- package/dist/validation/index.js +0 -19
- package/dist/validation/index.js.map +0 -1
- package/dist/validation/resource.d.ts +0 -3
- package/dist/validation/resource.d.ts.map +0 -1
- package/dist/validation/resource.js +0 -16
- package/dist/validation/resource.js.map +0 -1
- package/dist/validation/role.d.ts +0 -228
- package/dist/validation/role.d.ts.map +0 -1
- package/dist/validation/role.js +0 -67
- package/dist/validation/role.js.map +0 -1
- package/dist/validation/rolebinding.d.ts +0 -137
- package/dist/validation/rolebinding.d.ts.map +0 -1
- package/dist/validation/rolebinding.js +0 -47
- package/dist/validation/rolebinding.js.map +0 -1
- package/dist/validation/secret.d.ts +0 -964
- package/dist/validation/secret.d.ts.map +0 -1
- package/dist/validation/secret.js +0 -157
- package/dist/validation/secret.js.map +0 -1
- package/dist/validation/user.d.ts +0 -93
- package/dist/validation/user.d.ts.map +0 -1
- package/dist/validation/user.js +0 -38
- package/dist/validation/user.js.map +0 -1
- package/dist/validation/variable.d.ts +0 -96
- package/dist/validation/variable.d.ts.map +0 -1
- package/dist/validation/variable.js +0 -40
- package/dist/validation/variable.js.map +0 -1
|
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "DatasourceEditorForm", {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _useimmer = require("use-immer");
|
|
25
24
|
const _material = require("@mui/material");
|
|
26
25
|
const _react = require("react");
|
|
27
26
|
const _components = require("@perses-dev/components");
|
|
@@ -29,71 +28,45 @@ const _reacthookform = require("react-hook-form");
|
|
|
29
28
|
const _zod = require("@hookform/resolvers/zod");
|
|
30
29
|
const _PluginEditor = require("../PluginEditor");
|
|
31
30
|
const _utils = require("../../utils");
|
|
32
|
-
const
|
|
33
|
-
/**
|
|
34
|
-
* This preprocessing ensures that we always have a defined object for the `display` property
|
|
35
|
-
* @param datasource
|
|
36
|
-
*/ function getInitialState(datasourceDefinition) {
|
|
37
|
-
var _datasourceDefinition_spec_display, _datasourceDefinition_spec_display1;
|
|
38
|
-
var _datasourceDefinition_spec_display_name, _datasourceDefinition_spec_display_description;
|
|
39
|
-
const patchedDisplay = {
|
|
40
|
-
name: (_datasourceDefinition_spec_display_name = (_datasourceDefinition_spec_display = datasourceDefinition.spec.display) === null || _datasourceDefinition_spec_display === void 0 ? void 0 : _datasourceDefinition_spec_display.name) !== null && _datasourceDefinition_spec_display_name !== void 0 ? _datasourceDefinition_spec_display_name : '',
|
|
41
|
-
description: (_datasourceDefinition_spec_display_description = (_datasourceDefinition_spec_display1 = datasourceDefinition.spec.display) === null || _datasourceDefinition_spec_display1 === void 0 ? void 0 : _datasourceDefinition_spec_display1.description) !== null && _datasourceDefinition_spec_display_description !== void 0 ? _datasourceDefinition_spec_display_description : ''
|
|
42
|
-
};
|
|
43
|
-
return {
|
|
44
|
-
name: datasourceDefinition.name,
|
|
45
|
-
spec: {
|
|
46
|
-
...datasourceDefinition.spec,
|
|
47
|
-
display: patchedDisplay
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
31
|
+
const _context = require("../../context");
|
|
51
32
|
function DatasourceEditorForm(props) {
|
|
52
|
-
var _state_spec_display, _state_spec_display1;
|
|
53
33
|
const { initialDatasourceDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;
|
|
54
|
-
const initialState = getInitialState(initialDatasourceDefinition);
|
|
55
|
-
const [state, setState] = (0, _useimmer.useImmer)(initialState);
|
|
56
34
|
const [isDiscardDialogOpened, setDiscardDialogOpened] = (0, _react.useState)(false);
|
|
57
35
|
const [action, setAction] = (0, _react.useState)(initialAction);
|
|
58
36
|
const titleAction = (0, _utils.getTitleAction)(action, isDraft);
|
|
59
37
|
const submitText = (0, _utils.getSubmitText)(action, isDraft);
|
|
38
|
+
const { datasourceEditorSchema } = (0, _context.useValidationSchemas)();
|
|
60
39
|
const form = (0, _reacthookform.useForm)({
|
|
61
|
-
resolver: (0, _zod.zodResolver)(
|
|
40
|
+
resolver: (0, _zod.zodResolver)(datasourceEditorSchema),
|
|
62
41
|
mode: 'onBlur',
|
|
63
|
-
defaultValues:
|
|
64
|
-
name: state.name,
|
|
65
|
-
title: (_state_spec_display = state.spec.display) === null || _state_spec_display === void 0 ? void 0 : _state_spec_display.name,
|
|
66
|
-
description: (_state_spec_display1 = state.spec.display) === null || _state_spec_display1 === void 0 ? void 0 : _state_spec_display1.description,
|
|
67
|
-
default: state.spec.default
|
|
68
|
-
}
|
|
42
|
+
defaultValues: initialDatasourceDefinition
|
|
69
43
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
44
|
+
/*
|
|
45
|
+
* Remove empty fields that are optional
|
|
46
|
+
*/ function clearFormData(data) {
|
|
47
|
+
var _result_spec_display, _result_spec_display1;
|
|
48
|
+
const result = {
|
|
49
|
+
...data
|
|
50
|
+
};
|
|
51
|
+
if (((_result_spec_display = result.spec.display) === null || _result_spec_display === void 0 ? void 0 : _result_spec_display.name) === undefined && ((_result_spec_display1 = result.spec.display) === null || _result_spec_display1 === void 0 ? void 0 : _result_spec_display1.description) === undefined) {
|
|
52
|
+
delete result.spec.display;
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
const processForm = (data)=>{
|
|
57
|
+
onSave(clearFormData(data));
|
|
80
58
|
};
|
|
81
59
|
// When user click on cancel, several possibilities:
|
|
82
60
|
// - create action: ask for discard approval
|
|
83
61
|
// - update action: ask for discard approval if changed
|
|
84
62
|
// - read action: don´t ask for discard approval
|
|
85
|
-
|
|
86
|
-
if (JSON.stringify(
|
|
63
|
+
function handleCancel() {
|
|
64
|
+
if (JSON.stringify(initialDatasourceDefinition) !== JSON.stringify(clearFormData(form.getValues()))) {
|
|
87
65
|
setDiscardDialogOpened(true);
|
|
88
66
|
} else {
|
|
89
67
|
onClose();
|
|
90
68
|
}
|
|
91
|
-
}
|
|
92
|
-
state,
|
|
93
|
-
initialState,
|
|
94
|
-
setDiscardDialogOpened,
|
|
95
|
-
onClose
|
|
96
|
-
]);
|
|
69
|
+
}
|
|
97
70
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reacthookform.FormProvider, {
|
|
98
71
|
...form,
|
|
99
72
|
children: [
|
|
@@ -185,10 +158,12 @@ function DatasourceEditorForm(props) {
|
|
|
185
158
|
item: true,
|
|
186
159
|
xs: 4,
|
|
187
160
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
161
|
+
control: form.control,
|
|
188
162
|
name: "name",
|
|
189
|
-
render: ({ field, fieldState })
|
|
163
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
190
164
|
var _fieldState_error;
|
|
191
|
-
|
|
165
|
+
var _field_value;
|
|
166
|
+
return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
192
167
|
...field,
|
|
193
168
|
required: true,
|
|
194
169
|
fullWidth: true,
|
|
@@ -203,11 +178,9 @@ function DatasourceEditorForm(props) {
|
|
|
203
178
|
},
|
|
204
179
|
error: !!fieldState.error,
|
|
205
180
|
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
181
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
|
|
206
182
|
onChange: (event)=>{
|
|
207
183
|
field.onChange(event);
|
|
208
|
-
setState((draft)=>{
|
|
209
|
-
draft.name = event.target.value;
|
|
210
|
-
});
|
|
211
184
|
}
|
|
212
185
|
});
|
|
213
186
|
}
|
|
@@ -217,10 +190,12 @@ function DatasourceEditorForm(props) {
|
|
|
217
190
|
item: true,
|
|
218
191
|
xs: 8,
|
|
219
192
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
220
|
-
|
|
221
|
-
|
|
193
|
+
control: form.control,
|
|
194
|
+
name: "spec.display.name",
|
|
195
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
222
196
|
var _fieldState_error;
|
|
223
|
-
|
|
197
|
+
var _field_value;
|
|
198
|
+
return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
224
199
|
...field,
|
|
225
200
|
fullWidth: true,
|
|
226
201
|
name: "title",
|
|
@@ -233,13 +208,9 @@ function DatasourceEditorForm(props) {
|
|
|
233
208
|
},
|
|
234
209
|
error: !!fieldState.error,
|
|
235
210
|
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
211
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
|
|
236
212
|
onChange: (event)=>{
|
|
237
|
-
|
|
238
|
-
field.onChange(event);
|
|
239
|
-
if (draft.spec.display) {
|
|
240
|
-
draft.spec.display.name = event.target.value;
|
|
241
|
-
}
|
|
242
|
-
});
|
|
213
|
+
field.onChange(event);
|
|
243
214
|
}
|
|
244
215
|
});
|
|
245
216
|
}
|
|
@@ -249,10 +220,12 @@ function DatasourceEditorForm(props) {
|
|
|
249
220
|
item: true,
|
|
250
221
|
xs: 12,
|
|
251
222
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
252
|
-
|
|
253
|
-
|
|
223
|
+
control: form.control,
|
|
224
|
+
name: "spec.display.description",
|
|
225
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ {
|
|
254
226
|
var _fieldState_error;
|
|
255
|
-
|
|
227
|
+
var _field_value;
|
|
228
|
+
return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
256
229
|
...field,
|
|
257
230
|
fullWidth: true,
|
|
258
231
|
name: "description",
|
|
@@ -265,13 +238,9 @@ function DatasourceEditorForm(props) {
|
|
|
265
238
|
},
|
|
266
239
|
error: !!fieldState.error,
|
|
267
240
|
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
241
|
+
value: (_field_value = field.value) !== null && _field_value !== void 0 ? _field_value : '',
|
|
268
242
|
onChange: (event)=>{
|
|
269
243
|
field.onChange(event);
|
|
270
|
-
setState((draft)=>{
|
|
271
|
-
if (draft.spec.display) {
|
|
272
|
-
draft.spec.display.description = event.target.value;
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
244
|
}
|
|
276
245
|
});
|
|
277
246
|
}
|
|
@@ -286,28 +255,26 @@ function DatasourceEditorForm(props) {
|
|
|
286
255
|
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
287
256
|
children: [
|
|
288
257
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
289
|
-
|
|
258
|
+
control: form.control,
|
|
259
|
+
name: "spec.default",
|
|
290
260
|
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
291
|
-
|
|
261
|
+
label: "Set as default",
|
|
292
262
|
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
293
|
-
|
|
263
|
+
...field,
|
|
264
|
+
checked: !!field.value,
|
|
294
265
|
readOnly: action === 'read',
|
|
295
266
|
onChange: (event)=>{
|
|
296
267
|
if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
|
|
297
268
|
field.onChange(event);
|
|
298
|
-
setState((draft)=>{
|
|
299
|
-
draft.spec.default = event.target.checked;
|
|
300
|
-
});
|
|
301
269
|
}
|
|
302
|
-
})
|
|
303
|
-
label: "Set as default"
|
|
270
|
+
})
|
|
304
271
|
})
|
|
305
272
|
}),
|
|
306
273
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
|
|
307
274
|
variant: "caption",
|
|
308
275
|
children: [
|
|
309
276
|
"Whether this datasource should be the default ",
|
|
310
|
-
|
|
277
|
+
form.getValues().spec.plugin.kind,
|
|
311
278
|
" to be used"
|
|
312
279
|
]
|
|
313
280
|
})
|
|
@@ -322,26 +289,30 @@ function DatasourceEditorForm(props) {
|
|
|
322
289
|
variant: "h3",
|
|
323
290
|
children: "Plugin Options"
|
|
324
291
|
}),
|
|
325
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
292
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
293
|
+
control: form.control,
|
|
294
|
+
name: "spec.plugin",
|
|
295
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginEditor.PluginEditor, {
|
|
296
|
+
width: "100%",
|
|
297
|
+
pluginTypes: [
|
|
298
|
+
'Datasource'
|
|
299
|
+
],
|
|
300
|
+
pluginKindLabel: "Source",
|
|
301
|
+
value: {
|
|
302
|
+
selection: {
|
|
303
|
+
type: 'Datasource',
|
|
304
|
+
kind: field.value.kind
|
|
305
|
+
},
|
|
306
|
+
spec: field.value.spec
|
|
307
|
+
},
|
|
308
|
+
isReadonly: action === 'read',
|
|
309
|
+
onChange: (v)=>{
|
|
310
|
+
field.onChange({
|
|
311
|
+
kind: v.selection.kind,
|
|
312
|
+
spec: v.spec
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
})
|
|
345
316
|
})
|
|
346
317
|
]
|
|
347
318
|
}),
|
|
@@ -104,7 +104,8 @@ function LegendOptionsEditor({ value, onChange }) {
|
|
|
104
104
|
}
|
|
105
105
|
return result;
|
|
106
106
|
}, []);
|
|
107
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(
|
|
107
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
|
|
108
|
+
title: "Legend",
|
|
108
109
|
children: [
|
|
109
110
|
!isValidLegend && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorAlert, {
|
|
110
111
|
error: {
|
|
@@ -22,11 +22,12 @@ Object.defineProperty(exports, "PanelSpecEditor", {
|
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _components = require("@perses-dev/components");
|
|
25
|
+
const _reacthookform = require("react-hook-form");
|
|
25
26
|
const _runtime = require("../../runtime");
|
|
26
27
|
const _OptionsEditorTabs = require("../OptionsEditorTabs");
|
|
27
28
|
const _MultiQueryEditor = require("../MultiQueryEditor");
|
|
28
29
|
function PanelSpecEditor(props) {
|
|
29
|
-
const { panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;
|
|
30
|
+
const { control, panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;
|
|
30
31
|
const { kind } = panelDefinition.spec.plugin;
|
|
31
32
|
const { data: plugin, isLoading, error } = (0, _runtime.usePlugin)('Panel', kind);
|
|
32
33
|
if (error) {
|
|
@@ -44,39 +45,68 @@ function PanelSpecEditor(props) {
|
|
|
44
45
|
const { panelOptionsEditorComponents, hideQueryEditor } = plugin;
|
|
45
46
|
let tabs = [];
|
|
46
47
|
if (!hideQueryEditor) {
|
|
47
|
-
var _plugin_supportedQueryTypes, _panelDefinition_spec_queries;
|
|
48
48
|
tabs.push({
|
|
49
49
|
label: 'Query',
|
|
50
|
-
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
51
|
+
control: control,
|
|
52
|
+
name: "panelDefinition.spec.queries",
|
|
53
|
+
render: ({ field })=>/*#__PURE__*/ {
|
|
54
|
+
var _plugin_supportedQueryTypes, _panelDefinition_spec_queries;
|
|
55
|
+
return (0, _jsxruntime.jsx)(_MultiQueryEditor.MultiQueryEditor, {
|
|
56
|
+
queryTypes: (_plugin_supportedQueryTypes = plugin.supportedQueryTypes) !== null && _plugin_supportedQueryTypes !== void 0 ? _plugin_supportedQueryTypes : [],
|
|
57
|
+
queries: (_panelDefinition_spec_queries = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries !== void 0 ? _panelDefinition_spec_queries : [],
|
|
58
|
+
onChange: (queries)=>{
|
|
59
|
+
field.onChange(queries);
|
|
60
|
+
onQueriesChange(queries);
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
54
64
|
})
|
|
55
65
|
});
|
|
56
66
|
}
|
|
57
67
|
if (panelOptionsEditorComponents !== undefined) {
|
|
58
68
|
tabs = tabs.concat(panelOptionsEditorComponents.map(({ label, content: OptionsEditorComponent })=>({
|
|
59
69
|
label,
|
|
60
|
-
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
71
|
+
control: control,
|
|
72
|
+
name: "panelDefinition.spec.plugin.spec",
|
|
73
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(OptionsEditorComponent, {
|
|
74
|
+
value: panelDefinition.spec.plugin.spec,
|
|
75
|
+
onChange: (spec)=>{
|
|
76
|
+
field.onChange(spec);
|
|
77
|
+
onPluginSpecChange(spec);
|
|
78
|
+
}
|
|
79
|
+
})
|
|
63
80
|
})
|
|
64
81
|
})));
|
|
65
82
|
}
|
|
66
83
|
// always show json editor and links editor by default
|
|
67
84
|
tabs.push({
|
|
68
|
-
label: '
|
|
69
|
-
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.
|
|
70
|
-
|
|
71
|
-
value: panelDefinition,
|
|
72
|
-
onChange: onJSONChange
|
|
85
|
+
label: 'Links',
|
|
86
|
+
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.LinksEditor, {
|
|
87
|
+
control: control
|
|
73
88
|
})
|
|
74
89
|
});
|
|
75
90
|
tabs.push({
|
|
76
|
-
label: '
|
|
77
|
-
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(
|
|
91
|
+
label: 'JSON',
|
|
92
|
+
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
93
|
+
control: control,
|
|
94
|
+
name: "panelDefinition.spec.plugin.spec",
|
|
95
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.JSONEditor, {
|
|
96
|
+
maxHeight: "80vh",
|
|
97
|
+
value: panelDefinition,
|
|
98
|
+
onChange: (json)=>{
|
|
99
|
+
field.onChange(json);
|
|
100
|
+
onJSONChange(json);
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
var _panelDefinition_spec_queries;
|
|
106
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.QueryCountProvider, {
|
|
107
|
+
queryCount: ((_panelDefinition_spec_queries = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries !== void 0 ? _panelDefinition_spec_queries : []).length,
|
|
108
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorTabs.OptionsEditorTabs, {
|
|
109
|
+
tabs: tabs
|
|
110
|
+
}, tabs.length)
|
|
78
111
|
});
|
|
79
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorTabs.OptionsEditorTabs, {
|
|
80
|
-
tabs: tabs
|
|
81
|
-
}, tabs.length);
|
|
82
112
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright 2024 The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -24,9 +24,6 @@ _export(exports, {
|
|
|
24
24
|
DEFAULT_REFRESH_INTERVAL_OPTIONS: function() {
|
|
25
25
|
return DEFAULT_REFRESH_INTERVAL_OPTIONS;
|
|
26
26
|
},
|
|
27
|
-
DEFAULT_TIME_RANGE_OPTIONS: function() {
|
|
28
|
-
return DEFAULT_TIME_RANGE_OPTIONS;
|
|
29
|
-
},
|
|
30
27
|
TimeRangeControls: function() {
|
|
31
28
|
return TimeRangeControls;
|
|
32
29
|
}
|
|
@@ -43,62 +40,6 @@ function _interop_require_default(obj) {
|
|
|
43
40
|
default: obj
|
|
44
41
|
};
|
|
45
42
|
}
|
|
46
|
-
const DEFAULT_TIME_RANGE_OPTIONS = [
|
|
47
|
-
{
|
|
48
|
-
value: {
|
|
49
|
-
pastDuration: '5m'
|
|
50
|
-
},
|
|
51
|
-
display: 'Last 5 minutes'
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
value: {
|
|
55
|
-
pastDuration: '15m'
|
|
56
|
-
},
|
|
57
|
-
display: 'Last 15 minutes'
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
value: {
|
|
61
|
-
pastDuration: '30m'
|
|
62
|
-
},
|
|
63
|
-
display: 'Last 30 minutes'
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
value: {
|
|
67
|
-
pastDuration: '1h'
|
|
68
|
-
},
|
|
69
|
-
display: 'Last 1 hour'
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
value: {
|
|
73
|
-
pastDuration: '6h'
|
|
74
|
-
},
|
|
75
|
-
display: 'Last 6 hours'
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
value: {
|
|
79
|
-
pastDuration: '12h'
|
|
80
|
-
},
|
|
81
|
-
display: 'Last 12 hours'
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
value: {
|
|
85
|
-
pastDuration: '24h'
|
|
86
|
-
},
|
|
87
|
-
display: 'Last 1 day'
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
value: {
|
|
91
|
-
pastDuration: '7d'
|
|
92
|
-
},
|
|
93
|
-
display: 'Last 7 days'
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
value: {
|
|
97
|
-
pastDuration: '14d'
|
|
98
|
-
},
|
|
99
|
-
display: 'Last 14 days'
|
|
100
|
-
}
|
|
101
|
-
];
|
|
102
43
|
const DEFAULT_REFRESH_INTERVAL_OPTIONS = [
|
|
103
44
|
{
|
|
104
45
|
value: {
|
|
@@ -138,18 +79,15 @@ const DEFAULT_REFRESH_INTERVAL_OPTIONS = [
|
|
|
138
79
|
}
|
|
139
80
|
];
|
|
140
81
|
const DEFAULT_HEIGHT = '34px';
|
|
141
|
-
function TimeRangeControls({ heightPx, showTimeRangeSelector = true, showRefreshButton = true, showRefreshInterval = true, timePresets
|
|
82
|
+
function TimeRangeControls({ heightPx, showTimeRangeSelector = true, showRefreshButton = true, showRefreshInterval = true, showCustomTimeRange, timePresets }) {
|
|
142
83
|
const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = (0, _runtime.useTimeRange)();
|
|
84
|
+
const showCustomTimeRangeValue = (0, _runtime.useShowCustomTimeRangeSetting)(showCustomTimeRange);
|
|
85
|
+
const timePresetsValue = (0, _runtime.useTimeRangeOptionsSetting)(timePresets);
|
|
143
86
|
// Convert height to a string, then use the string for styling
|
|
144
87
|
const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
|
|
145
88
|
// add time preset if one does not match duration given in time range
|
|
146
|
-
if ('pastDuration' in timeRange && !
|
|
147
|
-
|
|
148
|
-
value: {
|
|
149
|
-
pastDuration: timeRange['pastDuration']
|
|
150
|
-
},
|
|
151
|
-
display: `Last ${timeRange['pastDuration']}`
|
|
152
|
-
});
|
|
89
|
+
if ('pastDuration' in timeRange && !timePresetsValue.some((option)=>option.value.pastDuration === timeRange['pastDuration'])) {
|
|
90
|
+
timePresetsValue.push((0, _components.buildRelativeTimeOption)(timeRange['pastDuration']));
|
|
153
91
|
}
|
|
154
92
|
// set the new refresh interval both in the dashboard context & as query param
|
|
155
93
|
const handleRefreshIntervalChange = (0, _react.useCallback)((duration)=>{
|
|
@@ -161,11 +99,12 @@ function TimeRangeControls({ heightPx, showTimeRangeSelector = true, showRefresh
|
|
|
161
99
|
direction: "row",
|
|
162
100
|
spacing: 1,
|
|
163
101
|
children: [
|
|
164
|
-
showTimeRangeSelector && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.
|
|
165
|
-
timeOptions:
|
|
102
|
+
showTimeRangeSelector && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.TimeRangeSelector, {
|
|
103
|
+
timeOptions: timePresetsValue,
|
|
166
104
|
value: timeRange,
|
|
167
105
|
onChange: setTimeRange,
|
|
168
|
-
height: height
|
|
106
|
+
height: height,
|
|
107
|
+
showCustomTimeRange: showCustomTimeRangeValue
|
|
169
108
|
}),
|
|
170
109
|
showRefreshButton && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
|
|
171
110
|
description: _constants.TOOLTIP_TEXT.refresh,
|