@perses-dev/plugin-system 0.54.0-beta.1 → 0.54.0-beta.11
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/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +283 -0
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +197 -0
- package/dist/cjs/components/Annotations/AnnotationEditorForm/index.js +30 -0
- package/dist/cjs/components/Annotations/constants.js +23 -0
- package/dist/cjs/components/Annotations/index.js +31 -0
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +97 -12
- package/dist/cjs/components/MultiQueryEditor/index.js +1 -0
- package/dist/cjs/components/MultiQueryEditor/utils.js +36 -0
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +3 -6
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -15
- package/dist/cjs/components/PluginRegistry/getPluginSearchHelper.js +92 -0
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +16 -13
- package/dist/cjs/components/Variables/variable-model.js +115 -29
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/context/ValidationProvider.js +10 -4
- package/dist/cjs/model/alerts-queries.js +16 -0
- package/dist/cjs/model/annotations.js +16 -0
- package/dist/cjs/model/index.js +3 -0
- package/dist/cjs/model/log-volume-utils.js +10 -10
- package/dist/cjs/model/plugin-loading.js +24 -8
- package/dist/cjs/model/plugins.js +10 -0
- package/dist/cjs/model/silences-queries.js +16 -0
- package/dist/cjs/remote/PluginRuntime.js +46 -10
- package/dist/cjs/remote/remotePluginLoader.js +28 -5
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +33 -24
- package/dist/cjs/runtime/DataQueriesProvider/model.js +3 -93
- package/dist/cjs/runtime/UsageMetricsProvider.js +2 -2
- package/dist/cjs/runtime/alerts-queries.js +101 -0
- package/dist/cjs/runtime/annotations.js +148 -0
- package/dist/cjs/runtime/index.js +3 -1
- package/dist/cjs/runtime/item-actions.js +3 -3
- package/dist/cjs/runtime/log-queries.js +4 -1
- package/dist/cjs/runtime/plugin-registry.js +12 -3
- package/dist/cjs/runtime/profile-queries.js +4 -1
- package/dist/cjs/runtime/silences-queries.js +101 -0
- package/dist/cjs/runtime/time-series-queries.js +4 -1
- package/dist/cjs/runtime/trace-queries.js +4 -1
- package/dist/cjs/test/mock-data.js +51 -0
- package/dist/cjs/test/test-plugins/bert/index.js +9 -12
- package/dist/cjs/test/test-plugins/ernie/index.js +9 -12
- package/dist/cjs/test/test-plugins/index.js +2 -2
- package/dist/cjs/test-utils/mock-plugin-registry.js +8 -2
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +16 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +270 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts +8 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +184 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/index.d.ts +2 -0
- package/dist/components/Annotations/AnnotationEditorForm/index.d.ts.map +1 -0
- package/dist/{runtime/QueryCountProvider.js → components/Annotations/AnnotationEditorForm/index.js} +2 -13
- package/dist/components/Annotations/AnnotationEditorForm/index.js.map +1 -0
- package/dist/components/Annotations/constants.d.ts +2 -0
- package/dist/components/Annotations/constants.d.ts.map +1 -0
- package/dist/components/Annotations/constants.js +15 -0
- package/dist/components/Annotations/constants.js.map +1 -0
- package/dist/components/Annotations/index.d.ts +3 -0
- package/dist/components/Annotations/index.d.ts.map +1 -0
- package/dist/components/Annotations/index.js +16 -0
- package/dist/components/Annotations/index.js.map +1 -0
- package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +1 -2
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js +2 -2
- package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +2 -2
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +100 -15
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/MultiQueryEditor/index.d.ts +1 -0
- package/dist/components/MultiQueryEditor/index.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/index.js +1 -0
- package/dist/components/MultiQueryEditor/index.js.map +1 -1
- package/dist/components/MultiQueryEditor/utils.d.ts +8 -0
- package/dist/components/MultiQueryEditor/utils.d.ts.map +1 -0
- package/dist/components/MultiQueryEditor/utils.js +23 -0
- package/dist/components/MultiQueryEditor/utils.js.map +1 -0
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +5 -8
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +1 -1
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +12 -16
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts +12 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.js +88 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -0
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -6
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +15 -13
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts +9 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +117 -31
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/ValidationProvider.d.ts +4 -2
- package/dist/context/ValidationProvider.d.ts.map +1 -1
- package/dist/context/ValidationProvider.js +10 -4
- package/dist/context/ValidationProvider.js.map +1 -1
- package/dist/model/alerts-queries.d.ts +33 -0
- package/dist/model/alerts-queries.d.ts.map +1 -0
- package/dist/model/alerts-queries.js +15 -0
- package/dist/model/alerts-queries.js.map +1 -0
- package/dist/model/annotations.d.ts +28 -0
- package/dist/model/annotations.d.ts.map +1 -0
- package/dist/model/annotations.js +17 -0
- package/dist/model/annotations.js.map +1 -0
- package/dist/model/datasource.d.ts +1 -8
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/index.d.ts +3 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +3 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/log-queries.d.ts +2 -1
- package/dist/model/log-queries.d.ts.map +1 -1
- package/dist/model/log-queries.js.map +1 -1
- package/dist/model/plugin-loading.d.ts.map +1 -1
- package/dist/model/plugin-loading.js +24 -8
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.d.ts +23 -0
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js +4 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/silences-queries.d.ts +33 -0
- package/dist/model/silences-queries.d.ts.map +1 -0
- package/dist/model/silences-queries.js +15 -0
- package/dist/model/silences-queries.js.map +1 -0
- package/dist/model/trace-queries.d.ts +2 -3
- package/dist/model/trace-queries.d.ts.map +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/remote/PersesPlugin.types.d.ts +2 -0
- package/dist/remote/PersesPlugin.types.d.ts.map +1 -1
- package/dist/remote/PersesPlugin.types.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.js +1 -1
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts +7 -1
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +46 -10
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.d.ts.map +1 -1
- package/dist/remote/remotePluginLoader.js +28 -5
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +35 -26
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +4 -4
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +0 -82
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/RouterProvider.js +1 -1
- package/dist/runtime/RouterProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.js +2 -2
- package/dist/runtime/UsageMetricsProvider.js.map +1 -1
- package/dist/runtime/alerts-queries.d.ts +11 -0
- package/dist/runtime/alerts-queries.d.ts.map +1 -0
- package/dist/runtime/alerts-queries.js +89 -0
- package/dist/runtime/alerts-queries.js.map +1 -0
- package/dist/runtime/annotations.d.ts +6 -0
- package/dist/runtime/annotations.d.ts.map +1 -0
- package/dist/runtime/annotations.js +129 -0
- package/dist/runtime/annotations.js.map +1 -0
- package/dist/runtime/datasources.d.ts +6 -0
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/item-actions.js +1 -1
- package/dist/runtime/item-actions.js.map +1 -1
- package/dist/runtime/log-queries.js +4 -1
- package/dist/runtime/log-queries.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +2 -2
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +12 -3
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/profile-queries.js +4 -1
- package/dist/runtime/profile-queries.js.map +1 -1
- package/dist/runtime/silences-queries.d.ts +11 -0
- package/dist/runtime/silences-queries.d.ts.map +1 -0
- package/dist/runtime/silences-queries.js +89 -0
- package/dist/runtime/silences-queries.js.map +1 -0
- package/dist/runtime/time-series-queries.js +4 -1
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.js +4 -1
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/test/mock-data.d.ts +3 -1
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js +45 -0
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts +12 -6
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js +6 -2
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.d.ts +8 -6
- package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +6 -2
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test/test-plugins/index.js +2 -2
- package/dist/test/test-plugins/index.js.map +1 -1
- package/dist/test/utils.js +1 -1
- package/dist/test/utils.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +8 -2
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/package.json +7 -6
- package/dist/cjs/runtime/QueryCountProvider.js +0 -83
- package/dist/runtime/QueryCountProvider.d.ts +0 -9
- package/dist/runtime/QueryCountProvider.d.ts.map +0 -1
- package/dist/runtime/QueryCountProvider.js.map +0 -1
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { useCallback, useState } from 'react';
|
|
15
|
+
import { Box, Typography, TextField, Grid, Divider, Stack, IconButton } from '@mui/material';
|
|
16
|
+
import { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary, FormActions, OptionsColorPicker, getSubmitText, getTitleAction } from '@perses-dev/components';
|
|
17
|
+
import { Controller, FormProvider, useForm, useWatch } from 'react-hook-form';
|
|
18
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
19
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
20
|
+
import InvertColorsIcon from 'mdi-material-ui/InvertColors';
|
|
21
|
+
import { PluginEditor } from '../../PluginEditor';
|
|
22
|
+
import { useValidationSchemas } from '../../../context';
|
|
23
|
+
import { DEFAULT_ANNOTATION_COLOR } from '../constants';
|
|
24
|
+
import { AnnotationPreview } from './AnnotationPreview';
|
|
25
|
+
function FallbackPreview() {
|
|
26
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
27
|
+
children: "Error previewing annotations"
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function AnnotationPluginControl({ action, control, onRunQuery }) {
|
|
31
|
+
const plugin = useWatch({
|
|
32
|
+
control,
|
|
33
|
+
name: 'plugin'
|
|
34
|
+
});
|
|
35
|
+
const kind = plugin?.kind;
|
|
36
|
+
const pluginSpec = plugin?.spec;
|
|
37
|
+
return /*#__PURE__*/ _jsx(Controller, {
|
|
38
|
+
control: control,
|
|
39
|
+
name: "plugin",
|
|
40
|
+
render: ({ field })=>{
|
|
41
|
+
return /*#__PURE__*/ _jsx(PluginEditor, {
|
|
42
|
+
withRunQueryButton: true,
|
|
43
|
+
width: "100%",
|
|
44
|
+
pluginTypes: [
|
|
45
|
+
'Annotation'
|
|
46
|
+
],
|
|
47
|
+
pluginKindLabel: "Source",
|
|
48
|
+
value: {
|
|
49
|
+
selection: {
|
|
50
|
+
type: 'Annotation',
|
|
51
|
+
kind: kind ?? 'StaticListAnnotation'
|
|
52
|
+
},
|
|
53
|
+
spec: pluginSpec ?? {}
|
|
54
|
+
},
|
|
55
|
+
isReadonly: action === 'read',
|
|
56
|
+
onChange: (v)=>{
|
|
57
|
+
field.onChange({
|
|
58
|
+
kind: v.selection.kind,
|
|
59
|
+
spec: v.spec
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
onRunQuery: onRunQuery
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export function AnnotationEditorForm({ initialAnnotationSpec, action, isDraft, isReadonly, onActionChange, onSave, onClose, onDelete }) {
|
|
68
|
+
const queryClient = useQueryClient();
|
|
69
|
+
const [isDiscardDialogOpened, setDiscardDialogOpened] = useState(false);
|
|
70
|
+
const titleAction = getTitleAction(action, isDraft);
|
|
71
|
+
const submitText = getSubmitText(action, isDraft);
|
|
72
|
+
const { annotationEditorSchema } = useValidationSchemas();
|
|
73
|
+
const form = useForm({
|
|
74
|
+
resolver: zodResolver(annotationEditorSchema),
|
|
75
|
+
mode: 'onBlur',
|
|
76
|
+
defaultValues: initialAnnotationSpec
|
|
77
|
+
});
|
|
78
|
+
/* We use `previewDefinition` to explicitly update the spec
|
|
79
|
+
* that will be used for preview when running query. The reason why we do this is to avoid
|
|
80
|
+
* having to re-fetch the values when the user is still editing the spec.
|
|
81
|
+
* Using structuredClone to not have reference issues with nested objects.
|
|
82
|
+
*/ const [previewSpec, setPreviewSpec] = useState(structuredClone(form.getValues()));
|
|
83
|
+
const handleRunQuery = useCallback(async ()=>{
|
|
84
|
+
const values = form.getValues();
|
|
85
|
+
if (JSON.stringify(previewSpec) === JSON.stringify(values)) {
|
|
86
|
+
await queryClient.invalidateQueries({
|
|
87
|
+
queryKey: [
|
|
88
|
+
'annotation',
|
|
89
|
+
previewSpec
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
setPreviewSpec(structuredClone(values));
|
|
94
|
+
}
|
|
95
|
+
}, [
|
|
96
|
+
form,
|
|
97
|
+
previewSpec,
|
|
98
|
+
queryClient
|
|
99
|
+
]);
|
|
100
|
+
const processForm = (data)=>{
|
|
101
|
+
// reset display attributes to undefined when empty, because we don't want to save empty strings
|
|
102
|
+
onSave(data);
|
|
103
|
+
};
|
|
104
|
+
function handleCancel() {
|
|
105
|
+
if (JSON.stringify(initialAnnotationSpec) !== JSON.stringify(form.getValues())) {
|
|
106
|
+
setDiscardDialogOpened(true);
|
|
107
|
+
} else {
|
|
108
|
+
onClose();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return /*#__PURE__*/ _jsxs(FormProvider, {
|
|
112
|
+
...form,
|
|
113
|
+
children: [
|
|
114
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
115
|
+
sx: {
|
|
116
|
+
display: 'flex',
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
padding: (theme)=>theme.spacing(1, 2),
|
|
119
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
120
|
+
},
|
|
121
|
+
children: [
|
|
122
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
123
|
+
variant: "h2",
|
|
124
|
+
children: [
|
|
125
|
+
titleAction,
|
|
126
|
+
" Annotation"
|
|
127
|
+
]
|
|
128
|
+
}),
|
|
129
|
+
/*#__PURE__*/ _jsx(FormActions, {
|
|
130
|
+
action: action,
|
|
131
|
+
submitText: submitText,
|
|
132
|
+
isReadonly: isReadonly,
|
|
133
|
+
isValid: form.formState.isValid,
|
|
134
|
+
onActionChange: onActionChange,
|
|
135
|
+
onSubmit: form.handleSubmit(processForm),
|
|
136
|
+
onDelete: onDelete,
|
|
137
|
+
onCancel: handleCancel
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
}),
|
|
141
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
142
|
+
padding: 2,
|
|
143
|
+
sx: {
|
|
144
|
+
overflowY: 'scroll'
|
|
145
|
+
},
|
|
146
|
+
children: [
|
|
147
|
+
/*#__PURE__*/ _jsxs(Grid, {
|
|
148
|
+
container: true,
|
|
149
|
+
spacing: 2,
|
|
150
|
+
mb: 2,
|
|
151
|
+
children: [
|
|
152
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
153
|
+
item: true,
|
|
154
|
+
xs: 12,
|
|
155
|
+
children: /*#__PURE__*/ _jsx(Controller, {
|
|
156
|
+
control: form.control,
|
|
157
|
+
name: "display.name",
|
|
158
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
|
|
159
|
+
...field,
|
|
160
|
+
required: true,
|
|
161
|
+
fullWidth: true,
|
|
162
|
+
label: "Name",
|
|
163
|
+
InputLabelProps: {
|
|
164
|
+
shrink: action === 'read' ? true : undefined
|
|
165
|
+
},
|
|
166
|
+
InputProps: {
|
|
167
|
+
disabled: action === 'update' && !isDraft,
|
|
168
|
+
readOnly: action === 'read'
|
|
169
|
+
},
|
|
170
|
+
error: !!fieldState.error,
|
|
171
|
+
helperText: fieldState.error?.message,
|
|
172
|
+
value: field.value ?? '',
|
|
173
|
+
onChange: (event)=>{
|
|
174
|
+
field.onChange(event);
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
}),
|
|
179
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
180
|
+
item: true,
|
|
181
|
+
xs: 12,
|
|
182
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
183
|
+
direction: "row",
|
|
184
|
+
gap: 1,
|
|
185
|
+
children: [
|
|
186
|
+
/*#__PURE__*/ _jsx(Controller, {
|
|
187
|
+
control: form.control,
|
|
188
|
+
name: "display.color",
|
|
189
|
+
render: ({ field })=>{
|
|
190
|
+
const isEnabled = field.value !== undefined;
|
|
191
|
+
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
192
|
+
children: isEnabled ? /*#__PURE__*/ _jsx(OptionsColorPicker, {
|
|
193
|
+
size: "medium",
|
|
194
|
+
label: "annotation",
|
|
195
|
+
color: field.value ?? DEFAULT_ANNOTATION_COLOR,
|
|
196
|
+
onColorChange: (color)=>field.onChange(color),
|
|
197
|
+
onClear: ()=>field.onChange(undefined)
|
|
198
|
+
}) : /*#__PURE__*/ _jsx(IconButton, {
|
|
199
|
+
size: "medium",
|
|
200
|
+
onClick: ()=>field.onChange(DEFAULT_ANNOTATION_COLOR),
|
|
201
|
+
children: /*#__PURE__*/ _jsx(InvertColorsIcon, {})
|
|
202
|
+
})
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}),
|
|
206
|
+
/*#__PURE__*/ _jsx(Controller, {
|
|
207
|
+
control: form.control,
|
|
208
|
+
name: "display.description",
|
|
209
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
|
|
210
|
+
...field,
|
|
211
|
+
fullWidth: true,
|
|
212
|
+
label: "Description",
|
|
213
|
+
InputLabelProps: {
|
|
214
|
+
shrink: action === 'read' ? true : undefined
|
|
215
|
+
},
|
|
216
|
+
InputProps: {
|
|
217
|
+
readOnly: action === 'read'
|
|
218
|
+
},
|
|
219
|
+
error: !!fieldState.error,
|
|
220
|
+
helperText: fieldState.error?.message,
|
|
221
|
+
value: field.value ?? '',
|
|
222
|
+
onChange: (event)=>{
|
|
223
|
+
field.onChange(event);
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
]
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
]
|
|
231
|
+
}),
|
|
232
|
+
/*#__PURE__*/ _jsx(Divider, {}),
|
|
233
|
+
/*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
234
|
+
FallbackComponent: FallbackPreview,
|
|
235
|
+
resetKeys: [
|
|
236
|
+
previewSpec
|
|
237
|
+
],
|
|
238
|
+
children: /*#__PURE__*/ _jsx(AnnotationPreview, {
|
|
239
|
+
spec: previewSpec,
|
|
240
|
+
sx: {
|
|
241
|
+
marginY: 2
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
}),
|
|
245
|
+
/*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
246
|
+
FallbackComponent: ErrorAlert,
|
|
247
|
+
children: /*#__PURE__*/ _jsx(AnnotationPluginControl, {
|
|
248
|
+
action: action,
|
|
249
|
+
control: form.control,
|
|
250
|
+
onRunQuery: handleRunQuery
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
]
|
|
254
|
+
}),
|
|
255
|
+
/*#__PURE__*/ _jsx(DiscardChangesConfirmationDialog, {
|
|
256
|
+
description: "Are you sure you want to discard these changes? Changes cannot be recovered.",
|
|
257
|
+
isOpen: isDiscardDialogOpened,
|
|
258
|
+
onCancel: ()=>{
|
|
259
|
+
setDiscardDialogOpened(false);
|
|
260
|
+
},
|
|
261
|
+
onDiscardChanges: ()=>{
|
|
262
|
+
setDiscardDialogOpened(false);
|
|
263
|
+
onClose();
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
]
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
//# sourceMappingURL=AnnotationEditorForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.tsx"],"sourcesContent":["// Copyright 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 { DispatchWithoutAction, ReactElement, useCallback, useState } from 'react';\nimport { Box, Typography, TextField, Grid, Divider, Stack, IconButton } from '@mui/material';\nimport { AnnotationSpec } from '@perses-dev/spec';\nimport {\n DiscardChangesConfirmationDialog,\n ErrorAlert,\n ErrorBoundary,\n FormActions,\n OptionsColorPicker,\n getSubmitText,\n getTitleAction,\n} from '@perses-dev/components';\nimport { Control, Controller, FormProvider, SubmitHandler, useForm, useWatch } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useQueryClient } from '@tanstack/react-query';\nimport InvertColorsIcon from 'mdi-material-ui/InvertColors';\nimport { Action } from '@perses-dev/client';\nimport { PluginEditor } from '../../PluginEditor';\nimport { useValidationSchemas } from '../../../context';\nimport { DEFAULT_ANNOTATION_COLOR } from '../constants';\nimport { AnnotationPreview } from './AnnotationPreview';\n\nfunction FallbackPreview(): ReactElement {\n return <div>Error previewing annotations</div>;\n}\n\ninterface KindAnnotationEditorFormProps {\n action: Action;\n control: Control<AnnotationSpec>;\n onRunQuery: () => void;\n}\n\nfunction AnnotationPluginControl({ action, control, onRunQuery }: KindAnnotationEditorFormProps): ReactElement {\n const plugin = useWatch<AnnotationSpec, 'plugin'>({ control, name: 'plugin' });\n const kind = plugin?.kind;\n const pluginSpec = plugin?.spec;\n\n return (\n <Controller\n control={control}\n name=\"plugin\"\n render={({ field }) => {\n return (\n <PluginEditor\n withRunQueryButton\n width=\"100%\"\n pluginTypes={['Annotation']}\n pluginKindLabel=\"Source\"\n value={{\n selection: {\n type: 'Annotation',\n kind: kind ?? 'StaticListAnnotation',\n },\n spec: pluginSpec ?? {},\n }}\n isReadonly={action === 'read'}\n onChange={(v) => {\n field.onChange({ kind: v.selection.kind, spec: v.spec });\n }}\n onRunQuery={onRunQuery}\n />\n );\n }}\n />\n );\n}\n\ninterface AnnotationEditorFormProps {\n initialAnnotationSpec: AnnotationSpec;\n action: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onActionChange?: (action: Action) => void;\n onSave: (def: AnnotationSpec) => void;\n onClose: () => void;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function AnnotationEditorForm({\n initialAnnotationSpec,\n action,\n isDraft,\n isReadonly,\n onActionChange,\n onSave,\n onClose,\n onDelete,\n}: AnnotationEditorFormProps): ReactElement {\n const queryClient = useQueryClient();\n\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const { annotationEditorSchema } = useValidationSchemas();\n const form = useForm<AnnotationSpec>({\n resolver: zodResolver(annotationEditorSchema),\n mode: 'onBlur',\n defaultValues: initialAnnotationSpec,\n });\n\n /* We use `previewDefinition` to explicitly update the spec\n * that will be used for preview when running query. The reason why we do this is to avoid\n * having to re-fetch the values when the user is still editing the spec.\n * Using structuredClone to not have reference issues with nested objects.\n */\n const [previewSpec, setPreviewSpec] = useState(structuredClone(form.getValues()));\n\n const handleRunQuery = useCallback(async () => {\n const values = form.getValues();\n if (JSON.stringify(previewSpec) === JSON.stringify(values)) {\n await queryClient.invalidateQueries({ queryKey: ['annotation', previewSpec] });\n } else {\n setPreviewSpec(structuredClone(values));\n }\n }, [form, previewSpec, queryClient]);\n\n const processForm: SubmitHandler<AnnotationSpec> = (data: AnnotationSpec) => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(data);\n };\n\n function handleCancel(): void {\n if (JSON.stringify(initialAnnotationSpec) !== JSON.stringify(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} Annotation</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={12}>\n <Controller\n control={form.control}\n name=\"display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\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={12}>\n <Stack direction=\"row\" gap={1}>\n <Controller\n control={form.control}\n name=\"display.color\"\n render={({ field }) => {\n const isEnabled = field.value !== undefined;\n return (\n <>\n {isEnabled ? (\n <OptionsColorPicker\n size=\"medium\"\n label=\"annotation\"\n color={field.value ?? DEFAULT_ANNOTATION_COLOR}\n onColorChange={(color) => field.onChange(color)}\n onClear={() => field.onChange(undefined)}\n />\n ) : (\n <IconButton size=\"medium\" onClick={() => field.onChange(DEFAULT_ANNOTATION_COLOR)}>\n <InvertColorsIcon />\n </IconButton>\n )}\n </>\n );\n }}\n />\n\n <Controller\n control={form.control}\n name=\"display.description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\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 </Stack>\n </Grid>\n </Grid>\n\n <Divider />\n\n <ErrorBoundary FallbackComponent={FallbackPreview} resetKeys={[previewSpec]}>\n <AnnotationPreview spec={previewSpec} sx={{ marginY: 2 }} />\n </ErrorBoundary>\n\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <AnnotationPluginControl action={action} control={form.control} onRunQuery={handleRunQuery} />\n </ErrorBoundary>\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["useCallback","useState","Box","Typography","TextField","Grid","Divider","Stack","IconButton","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","FormActions","OptionsColorPicker","getSubmitText","getTitleAction","Controller","FormProvider","useForm","useWatch","zodResolver","useQueryClient","InvertColorsIcon","PluginEditor","useValidationSchemas","DEFAULT_ANNOTATION_COLOR","AnnotationPreview","FallbackPreview","div","AnnotationPluginControl","action","control","onRunQuery","plugin","name","kind","pluginSpec","spec","render","field","withRunQueryButton","width","pluginTypes","pluginKindLabel","value","selection","type","isReadonly","onChange","v","AnnotationEditorForm","initialAnnotationSpec","isDraft","onActionChange","onSave","onClose","onDelete","queryClient","isDiscardDialogOpened","setDiscardDialogOpened","titleAction","submitText","annotationEditorSchema","form","resolver","mode","defaultValues","previewSpec","setPreviewSpec","structuredClone","getValues","handleRunQuery","values","JSON","stringify","invalidateQueries","queryKey","processForm","data","handleCancel","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","isValid","formState","onSubmit","handleSubmit","onCancel","overflowY","container","mb","item","xs","fieldState","required","fullWidth","label","InputLabelProps","shrink","undefined","InputProps","disabled","readOnly","error","helperText","message","event","direction","gap","isEnabled","size","color","onColorChange","onClear","onClick","FallbackComponent","resetKeys","marginY","description","isOpen","onDiscardChanges"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAA8CA,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AACnF,SAASC,GAAG,EAAEC,UAAU,EAAEC,SAAS,EAAEC,IAAI,EAAEC,OAAO,EAAEC,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,QAAU/E,MAAMS,QAAQ,CAACsE;wDACzCE,SAAS,IAAMjF,MAAMS,QAAQ,CAAC0D;uEAGhC,KAAClG;wDAAW6G,MAAK;wDAASI,SAAS,IAAMlF,MAAMS,QAAQ,CAACvB;kEACtD,cAAA,KAACH;;;4CAKX;;sDAGF,KAACN;4CACCe,SAASgC,KAAKhC,OAAO;4CACrBG,MAAK;4CACLI,QAAQ,CAAC,EAAEC,KAAK,EAAE6D,UAAU,EAAE,iBAC5B,KAAChG;oDACE,GAAGmC,KAAK;oDACT+D,SAAS;oDACTC,OAAM;oDACNC,iBAAiB;wDAAEC,QAAQ3E,WAAW,SAAS,OAAO4E;oDAAU;oDAChEC,YAAY;wDACVE,UAAU/E,WAAW;oDACvB;oDACAgF,OAAO,CAAC,CAACV,WAAWU,KAAK;oDACzBC,YAAYX,WAAWU,KAAK,EAAEE;oDAC9BpE,OAAOL,MAAMK,KAAK,IAAI;oDACtBI,UAAU,CAACiE;wDACT1E,MAAMS,QAAQ,CAACiE;oDACjB;;;;;;;;kCAQZ,KAAC3G;kCAED,KAACK;wBAAc+G,mBAAmB/F;wBAAiBgG,WAAW;4BAACxD;yBAAY;kCACzE,cAAA,KAACzC;4BAAkBW,MAAM8B;4BAAaa,IAAI;gCAAE4C,SAAS;4BAAE;;;kCAGzD,KAACjH;wBAAc+G,mBAAmBhH;kCAChC,cAAA,KAACmB;4BAAwBC,QAAQA;4BAAQC,SAASgC,KAAKhC,OAAO;4BAAEC,YAAYuC;;;;;0BAGhF,KAAC9D;gBACCoH,aAAY;gBACZC,QAAQpE;gBACRoC,UAAU;oBACRnC,uBAAuB;gBACzB;gBACAoE,kBAAkB;oBAChBpE,uBAAuB;oBACvBJ;gBACF;;;;AAIR"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AnnotationSpec } from '@perses-dev/spec';
|
|
3
|
+
import { CardProps } from '@mui/material';
|
|
4
|
+
export interface AnnotationPreviewProps extends CardProps {
|
|
5
|
+
spec: AnnotationSpec;
|
|
6
|
+
}
|
|
7
|
+
export declare function AnnotationPreview({ spec, ...props }: AnnotationPreviewProps): ReactNode;
|
|
8
|
+
//# sourceMappingURL=AnnotationPreview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationPreview.d.ts","sourceRoot":"","sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationPreview.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAqB,MAAM,OAAO,CAAC;AACrD,OAAO,EAAkB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAIL,SAAS,EAOV,MAAM,eAAe,CAAC;AAsDvB,MAAM,WAAW,sBAAuB,SAAQ,SAAS;IACvD,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE,sBAAsB,GAAG,SAAS,CA0DvF"}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { useMemo, useState } from 'react';
|
|
15
|
+
import { Card, CardContent, CardHeader, Chip, CircularProgress, Divider, IconButton, Stack, Typography } from '@mui/material';
|
|
16
|
+
import { getDateAndTime, InfoTooltip, useTimeZone } from '@perses-dev/components';
|
|
17
|
+
import AlertIcon from 'mdi-material-ui/Alert';
|
|
18
|
+
import { useAnnotationData } from '../../../runtime';
|
|
19
|
+
function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
|
|
20
|
+
const start = getDateAndTime(value.start, formatWithUserTimeZone);
|
|
21
|
+
const end = value.end !== undefined ? getDateAndTime(value.start, formatWithUserTimeZone) : null;
|
|
22
|
+
const tags = useMemo(()=>{
|
|
23
|
+
return Object.entries(value.tags ?? []).map(([key, value])=>{
|
|
24
|
+
return {
|
|
25
|
+
key: key,
|
|
26
|
+
value: value
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
}, [
|
|
30
|
+
value.tags
|
|
31
|
+
]);
|
|
32
|
+
return /*#__PURE__*/ _jsx(Card, {
|
|
33
|
+
...props,
|
|
34
|
+
children: /*#__PURE__*/ _jsxs(CardContent, {
|
|
35
|
+
children: [
|
|
36
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
37
|
+
gap: 2,
|
|
38
|
+
children: [
|
|
39
|
+
value.title && /*#__PURE__*/ _jsx(Typography, {
|
|
40
|
+
variant: "h3",
|
|
41
|
+
children: value.title
|
|
42
|
+
}),
|
|
43
|
+
value.legend && /*#__PURE__*/ _jsx(Typography, {
|
|
44
|
+
children: value.legend
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ _jsx(Stack, {
|
|
47
|
+
flexWrap: "wrap",
|
|
48
|
+
direction: "row",
|
|
49
|
+
gap: 0.5,
|
|
50
|
+
children: tags.map((tag)=>/*#__PURE__*/ _jsx(Chip, {
|
|
51
|
+
size: "small",
|
|
52
|
+
label: `${tag.key}: ${tag.value}`
|
|
53
|
+
}, `${tag.key}=${tag.value}`))
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
}),
|
|
57
|
+
/*#__PURE__*/ _jsx(Divider, {
|
|
58
|
+
sx: {
|
|
59
|
+
marginY: 2
|
|
60
|
+
}
|
|
61
|
+
}),
|
|
62
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
63
|
+
gap: 0.5,
|
|
64
|
+
direction: "row",
|
|
65
|
+
children: [
|
|
66
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
67
|
+
variant: "caption",
|
|
68
|
+
children: [
|
|
69
|
+
start.formattedDate,
|
|
70
|
+
" - ",
|
|
71
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
72
|
+
children: start.formattedTime
|
|
73
|
+
})
|
|
74
|
+
]
|
|
75
|
+
}),
|
|
76
|
+
end && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
77
|
+
children: [
|
|
78
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
79
|
+
variant: "caption",
|
|
80
|
+
children: ' → '
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
83
|
+
variant: "caption",
|
|
84
|
+
children: [
|
|
85
|
+
end.formattedDate,
|
|
86
|
+
" - ",
|
|
87
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
88
|
+
children: end.formattedTime
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
]
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export function AnnotationPreview({ spec, ...props }) {
|
|
101
|
+
const { data, isFetching, error } = useAnnotationData(spec);
|
|
102
|
+
const { formatWithUserTimeZone } = useTimeZone();
|
|
103
|
+
const [showAll, setShowAll] = useState(false);
|
|
104
|
+
const annotationsToShow = showAll ? data : data?.slice(0, 1);
|
|
105
|
+
let notShown = 0;
|
|
106
|
+
if (data && data?.length > 0 && annotationsToShow) {
|
|
107
|
+
notShown = data.length - annotationsToShow.length;
|
|
108
|
+
}
|
|
109
|
+
const stateIndicator = useMemo(()=>{
|
|
110
|
+
if (isFetching) {
|
|
111
|
+
return /*#__PURE__*/ _jsx(CircularProgress, {
|
|
112
|
+
"aria-label": "loading",
|
|
113
|
+
size: "1.125rem"
|
|
114
|
+
});
|
|
115
|
+
} else if (error) {
|
|
116
|
+
return /*#__PURE__*/ _jsx(InfoTooltip, {
|
|
117
|
+
description: error.toString(),
|
|
118
|
+
children: /*#__PURE__*/ _jsx(IconButton, {
|
|
119
|
+
"aria-label": "preview errors",
|
|
120
|
+
size: "small",
|
|
121
|
+
children: /*#__PURE__*/ _jsx(AlertIcon, {
|
|
122
|
+
fontSize: "inherit",
|
|
123
|
+
sx: {
|
|
124
|
+
color: (theme)=>theme.palette.error.main
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
})
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}, [
|
|
131
|
+
isFetching,
|
|
132
|
+
error
|
|
133
|
+
]);
|
|
134
|
+
return /*#__PURE__*/ _jsxs(Card, {
|
|
135
|
+
variant: "outlined",
|
|
136
|
+
...props,
|
|
137
|
+
children: [
|
|
138
|
+
/*#__PURE__*/ _jsx(CardHeader, {
|
|
139
|
+
title: /*#__PURE__*/ _jsxs(Stack, {
|
|
140
|
+
direction: "row",
|
|
141
|
+
justifyContent: "space-between",
|
|
142
|
+
children: [
|
|
143
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
144
|
+
variant: "h4",
|
|
145
|
+
children: "Preview Annotations"
|
|
146
|
+
}),
|
|
147
|
+
stateIndicator
|
|
148
|
+
]
|
|
149
|
+
})
|
|
150
|
+
}),
|
|
151
|
+
/*#__PURE__*/ _jsxs(CardContent, {
|
|
152
|
+
sx: {
|
|
153
|
+
display: 'flex',
|
|
154
|
+
flexWrap: 'wrap',
|
|
155
|
+
gap: 1,
|
|
156
|
+
paddingY: 0
|
|
157
|
+
},
|
|
158
|
+
children: [
|
|
159
|
+
annotationsToShow?.map((item, index)=>/*#__PURE__*/ _jsx(AnnotationPreviewCard, {
|
|
160
|
+
value: item,
|
|
161
|
+
formatWithUserTimeZone: formatWithUserTimeZone,
|
|
162
|
+
sx: {
|
|
163
|
+
width: '100%'
|
|
164
|
+
}
|
|
165
|
+
}, index)),
|
|
166
|
+
notShown > 0 && /*#__PURE__*/ _jsx(Chip, {
|
|
167
|
+
onClick: ()=>setShowAll(true),
|
|
168
|
+
variant: "outlined",
|
|
169
|
+
size: "small",
|
|
170
|
+
label: `+${notShown} more`
|
|
171
|
+
}),
|
|
172
|
+
showAll && data && data.length > 1 && /*#__PURE__*/ _jsx(Chip, {
|
|
173
|
+
onClick: ()=>setShowAll(false),
|
|
174
|
+
variant: "outlined",
|
|
175
|
+
size: "small",
|
|
176
|
+
label: "-"
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
})
|
|
180
|
+
]
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
//# sourceMappingURL=AnnotationPreview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationPreview.tsx"],"sourcesContent":["// Copyright 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 { ReactNode, useMemo, useState } from 'react';\nimport { AnnotationData, AnnotationSpec } from '@perses-dev/spec';\nimport {\n Card,\n CardContent,\n CardHeader,\n CardProps,\n Chip,\n CircularProgress,\n Divider,\n IconButton,\n Stack,\n Typography,\n} from '@mui/material';\nimport { getDateAndTime, InfoTooltip, useTimeZone } from '@perses-dev/components';\nimport AlertIcon from 'mdi-material-ui/Alert';\nimport { useAnnotationData } from '../../../runtime';\n\ninterface AnnotationPreviewCardProps extends CardProps {\n value: AnnotationData;\n formatWithUserTimeZone: (date: Date, format: string) => string;\n}\n\nfunction AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }: AnnotationPreviewCardProps): ReactNode {\n const start = getDateAndTime(value.start, formatWithUserTimeZone);\n const end = value.end !== undefined ? getDateAndTime(value.start, formatWithUserTimeZone) : null;\n\n const tags = useMemo(() => {\n return Object.entries(value.tags ?? []).map(([key, value]) => {\n return { key: key, value: value };\n });\n }, [value.tags]);\n\n return (\n <Card {...props}>\n <CardContent>\n <Stack gap={2}>\n {value.title && <Typography variant=\"h3\">{value.title}</Typography>}\n {value.legend && <Typography>{value.legend}</Typography>}\n\n <Stack flexWrap=\"wrap\" direction=\"row\" gap={0.5}>\n {tags.map((tag) => (\n <Chip size=\"small\" key={`${tag.key}=${tag.value}`} label={`${tag.key}: ${tag.value}`} />\n ))}\n </Stack>\n </Stack>\n\n <Divider sx={{ marginY: 2 }} />\n\n <Stack gap={0.5} direction=\"row\">\n <Typography variant=\"caption\">\n {start.formattedDate} - <strong>{start.formattedTime}</strong>\n </Typography>\n {end && (\n <>\n <Typography variant=\"caption\">{' → '}</Typography>\n <Typography variant=\"caption\">\n {end.formattedDate} - <strong>{end.formattedTime}</strong>\n </Typography>\n </>\n )}\n </Stack>\n </CardContent>\n </Card>\n );\n}\n\nexport interface AnnotationPreviewProps extends CardProps {\n spec: AnnotationSpec;\n}\n\nexport function AnnotationPreview({ spec, ...props }: AnnotationPreviewProps): ReactNode {\n const { data, isFetching, error } = useAnnotationData(spec);\n const { formatWithUserTimeZone } = useTimeZone();\n\n const [showAll, setShowAll] = useState<boolean>(false);\n const annotationsToShow = showAll ? data : data?.slice(0, 1);\n let notShown = 0;\n if (data && data?.length > 0 && annotationsToShow) {\n notShown = data.length - annotationsToShow.length;\n }\n\n const stateIndicator = useMemo((): ReactNode | undefined => {\n if (isFetching) {\n return <CircularProgress aria-label=\"loading\" size=\"1.125rem\" />;\n } else if (error) {\n return (\n <InfoTooltip description={error.toString()}>\n <IconButton aria-label=\"preview errors\" size=\"small\">\n <AlertIcon\n fontSize=\"inherit\"\n sx={{\n color: (theme) => theme.palette.error.main,\n }}\n />\n </IconButton>\n </InfoTooltip>\n );\n }\n }, [isFetching, error]);\n\n return (\n <Card variant=\"outlined\" {...props}>\n <CardHeader\n title={\n <Stack direction=\"row\" justifyContent=\"space-between\">\n <Typography variant=\"h4\">Preview Annotations</Typography>\n {stateIndicator}\n </Stack>\n }\n />\n <CardContent sx={{ display: 'flex', flexWrap: 'wrap', gap: 1, paddingY: 0 }}>\n {annotationsToShow?.map((item, index) => (\n <AnnotationPreviewCard\n key={index}\n value={item}\n formatWithUserTimeZone={formatWithUserTimeZone}\n sx={{ width: '100%' }}\n />\n ))}\n {notShown > 0 && (\n <Chip onClick={() => setShowAll(true)} variant=\"outlined\" size=\"small\" label={`+${notShown} more`} />\n )}\n {showAll && data && data.length > 1 && (\n <Chip onClick={() => setShowAll(false)} variant=\"outlined\" size=\"small\" label=\"-\" />\n )}\n </CardContent>\n </Card>\n );\n}\n"],"names":["useMemo","useState","Card","CardContent","CardHeader","Chip","CircularProgress","Divider","IconButton","Stack","Typography","getDateAndTime","InfoTooltip","useTimeZone","AlertIcon","useAnnotationData","AnnotationPreviewCard","value","formatWithUserTimeZone","props","start","end","undefined","tags","Object","entries","map","key","gap","title","variant","legend","flexWrap","direction","tag","size","label","sx","marginY","formattedDate","strong","formattedTime","AnnotationPreview","spec","data","isFetching","error","showAll","setShowAll","annotationsToShow","slice","notShown","length","stateIndicator","aria-label","description","toString","fontSize","color","theme","palette","main","justifyContent","display","paddingY","item","index","width","onClick"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAoBA,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAErD,SACEC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BAAMwB,WAAU;oBAAM6B,gBAAe;;sCACpC,KAACpD;4BAAWoB,SAAQ;sCAAK;;wBACxBuB;;;;0BAIP,MAAClD;gBAAYkC,IAAI;oBAAE0B,SAAS;oBAAQ/B,UAAU;oBAAQJ,KAAK;oBAAGoC,UAAU;gBAAE;;oBACvEf,mBAAmBvB,IAAI,CAACuC,MAAMC,sBAC7B,KAAClD;4BAECC,OAAOgD;4BACP/C,wBAAwBA;4BACxBmB,IAAI;gCAAE8B,OAAO;4BAAO;2BAHfD;oBAMRf,WAAW,mBACV,KAAC9C;wBAAK+D,SAAS,IAAMpB,WAAW;wBAAOlB,SAAQ;wBAAWK,MAAK;wBAAQC,OAAO,CAAC,CAAC,EAAEe,SAAS,KAAK,CAAC;;oBAElGJ,WAAWH,QAAQA,KAAKQ,MAAM,GAAG,mBAChC,KAAC/C;wBAAK+D,SAAS,IAAMpB,WAAW;wBAAQlB,SAAQ;wBAAWK,MAAK;wBAAQC,OAAM;;;;;;AAKxF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/Annotations/AnnotationEditorForm/index.ts"],"names":[],"mappings":"AAaA,cAAc,wBAAwB,CAAC"}
|
package/dist/{runtime/QueryCountProvider.js → components/Annotations/AnnotationEditorForm/index.js}
RENAMED
|
@@ -10,17 +10,6 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
|
|
14
|
-
import React, { createContext, useContext } from 'react';
|
|
15
|
-
const QueryCountContext = /*#__PURE__*/ createContext(0);
|
|
16
|
-
export const QueryCountProvider = ({ queryCount, children })=>{
|
|
17
|
-
return /*#__PURE__*/ _jsx(QueryCountContext.Provider, {
|
|
18
|
-
value: queryCount,
|
|
19
|
-
children: children
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
export const useQueryCountContext = ()=>{
|
|
23
|
-
return useContext(QueryCountContext);
|
|
24
|
-
};
|
|
13
|
+
export * from './AnnotationEditorForm';
|
|
25
14
|
|
|
26
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Annotations/AnnotationEditorForm/index.ts"],"sourcesContent":["// Copyright 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\nexport * from './AnnotationEditorForm';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,yBAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/components/Annotations/constants.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,wBAAwB,YAAY,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export const DEFAULT_ANNOTATION_COLOR = '#FF6B6B';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Annotations/constants.ts"],"sourcesContent":["// Copyright 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\nexport const DEFAULT_ANNOTATION_COLOR = '#FF6B6B';\n"],"names":["DEFAULT_ANNOTATION_COLOR"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,MAAMA,2BAA2B,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Annotations/index.ts"],"names":[],"mappings":"AAaA,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './AnnotationEditorForm';
|
|
14
|
+
export * from './constants';
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Annotations/index.ts"],"sourcesContent":["// Copyright 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\nexport * from './AnnotationEditorForm';\nexport * from './constants';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,yBAAyB;AACvC,cAAc,cAAc"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { OptionsEditorControl, SettingsAutocomplete } from '@perses-dev/components';
|
|
15
15
|
import { CALCULATIONS_CONFIG } from '../../model'; // TODO weird this is part of the model from the core package ...
|
|
16
16
|
const CALC_OPTIONS = Object.entries(CALCULATIONS_CONFIG).map(([id, config])=>{
|