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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +283 -0
  2. package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +211 -0
  3. package/dist/cjs/components/Annotations/AnnotationEditorForm/index.js +30 -0
  4. package/dist/cjs/components/Annotations/index.js +30 -0
  5. package/dist/cjs/components/index.js +1 -0
  6. package/dist/cjs/context/ValidationProvider.js +7 -1
  7. package/dist/cjs/model/annotations.js +16 -0
  8. package/dist/cjs/model/index.js +1 -0
  9. package/dist/cjs/runtime/annotations.js +148 -0
  10. package/dist/cjs/runtime/index.js +1 -0
  11. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +16 -0
  12. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -0
  13. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +270 -0
  14. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -0
  15. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts +8 -0
  16. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -0
  17. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +198 -0
  18. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -0
  19. package/dist/components/Annotations/AnnotationEditorForm/index.d.ts +2 -0
  20. package/dist/components/Annotations/AnnotationEditorForm/index.d.ts.map +1 -0
  21. package/dist/components/Annotations/AnnotationEditorForm/index.js +15 -0
  22. package/dist/components/Annotations/AnnotationEditorForm/index.js.map +1 -0
  23. package/dist/components/Annotations/index.d.ts +2 -0
  24. package/dist/components/Annotations/index.d.ts.map +1 -0
  25. package/dist/components/Annotations/index.js +15 -0
  26. package/dist/components/Annotations/index.js.map +1 -0
  27. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +1 -2
  28. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  29. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  30. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -1
  31. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  32. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  33. package/dist/components/index.d.ts +1 -0
  34. package/dist/components/index.d.ts.map +1 -1
  35. package/dist/components/index.js +1 -0
  36. package/dist/components/index.js.map +1 -1
  37. package/dist/context/ValidationProvider.d.ts +3 -1
  38. package/dist/context/ValidationProvider.d.ts.map +1 -1
  39. package/dist/context/ValidationProvider.js +8 -2
  40. package/dist/context/ValidationProvider.js.map +1 -1
  41. package/dist/model/annotations.d.ts +28 -0
  42. package/dist/model/annotations.d.ts.map +1 -0
  43. package/dist/model/annotations.js +17 -0
  44. package/dist/model/annotations.js.map +1 -0
  45. package/dist/model/index.d.ts +1 -0
  46. package/dist/model/index.d.ts.map +1 -1
  47. package/dist/model/index.js +1 -0
  48. package/dist/model/index.js.map +1 -1
  49. package/dist/model/plugins.d.ts +2 -0
  50. package/dist/model/plugins.d.ts.map +1 -1
  51. package/dist/model/plugins.js.map +1 -1
  52. package/dist/model/trace-queries.d.ts +2 -3
  53. package/dist/model/trace-queries.d.ts.map +1 -1
  54. package/dist/model/trace-queries.js.map +1 -1
  55. package/dist/runtime/annotations.d.ts +6 -0
  56. package/dist/runtime/annotations.d.ts.map +1 -0
  57. package/dist/runtime/annotations.js +129 -0
  58. package/dist/runtime/annotations.js.map +1 -0
  59. package/dist/runtime/datasources.d.ts +6 -0
  60. package/dist/runtime/datasources.d.ts.map +1 -1
  61. package/dist/runtime/datasources.js.map +1 -1
  62. package/dist/runtime/index.d.ts +1 -0
  63. package/dist/runtime/index.d.ts.map +1 -1
  64. package/dist/runtime/index.js +1 -0
  65. package/dist/runtime/index.js.map +1 -1
  66. package/package.json +4 -4
@@ -0,0 +1,283 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "AnnotationEditorForm", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return AnnotationEditorForm;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _react = require("react");
25
+ const _material = require("@mui/material");
26
+ const _components = require("@perses-dev/components");
27
+ const _reacthookform = require("react-hook-form");
28
+ const _zod = require("@hookform/resolvers/zod");
29
+ const _reactquery = require("@tanstack/react-query");
30
+ const _InvertColors = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/InvertColors"));
31
+ const _PluginEditor = require("../../PluginEditor");
32
+ const _context = require("../../../context");
33
+ const _AnnotationPreview = require("./AnnotationPreview");
34
+ function _interop_require_default(obj) {
35
+ return obj && obj.__esModule ? obj : {
36
+ default: obj
37
+ };
38
+ }
39
+ const DEFAULT_ANNOTATION_COLOR = '#FF6B6B';
40
+ function FallbackPreview() {
41
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
42
+ children: "Error previewing annotations"
43
+ });
44
+ }
45
+ function AnnotationPluginControl({ action, control, onRunQuery }) {
46
+ const plugin = (0, _reacthookform.useWatch)({
47
+ control,
48
+ name: 'plugin'
49
+ });
50
+ const kind = plugin?.kind;
51
+ const pluginSpec = plugin?.spec;
52
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
53
+ control: control,
54
+ name: "plugin",
55
+ render: ({ field })=>{
56
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginEditor.PluginEditor, {
57
+ withRunQueryButton: true,
58
+ width: "100%",
59
+ pluginTypes: [
60
+ 'Annotation'
61
+ ],
62
+ pluginKindLabel: "Source",
63
+ value: {
64
+ selection: {
65
+ type: 'Annotation',
66
+ kind: kind ?? 'StaticListAnnotation'
67
+ },
68
+ spec: pluginSpec ?? {}
69
+ },
70
+ isReadonly: action === 'read',
71
+ onChange: (v)=>{
72
+ field.onChange({
73
+ kind: v.selection.kind,
74
+ spec: v.spec
75
+ });
76
+ },
77
+ onRunQuery: onRunQuery
78
+ });
79
+ }
80
+ });
81
+ }
82
+ function AnnotationEditorForm({ initialAnnotationSpec, action, isDraft, isReadonly, onActionChange, onSave, onClose, onDelete }) {
83
+ const queryClient = (0, _reactquery.useQueryClient)();
84
+ const [isDiscardDialogOpened, setDiscardDialogOpened] = (0, _react.useState)(false);
85
+ const titleAction = (0, _components.getTitleAction)(action, isDraft);
86
+ const submitText = (0, _components.getSubmitText)(action, isDraft);
87
+ const { annotationEditorSchema } = (0, _context.useValidationSchemas)();
88
+ const form = (0, _reacthookform.useForm)({
89
+ resolver: (0, _zod.zodResolver)(annotationEditorSchema),
90
+ mode: 'onBlur',
91
+ defaultValues: initialAnnotationSpec
92
+ });
93
+ /* We use `previewDefinition` to explicitly update the spec
94
+ * that will be used for preview when running query. The reason why we do this is to avoid
95
+ * having to re-fetch the values when the user is still editing the spec.
96
+ * Using structuredClone to not have reference issues with nested objects.
97
+ */ const [previewSpec, setPreviewSpec] = (0, _react.useState)(structuredClone(form.getValues()));
98
+ const handleRunQuery = (0, _react.useCallback)(async ()=>{
99
+ const values = form.getValues();
100
+ if (JSON.stringify(previewSpec) === JSON.stringify(values)) {
101
+ await queryClient.invalidateQueries({
102
+ queryKey: [
103
+ 'annotation',
104
+ previewSpec
105
+ ]
106
+ });
107
+ } else {
108
+ setPreviewSpec(structuredClone(values));
109
+ }
110
+ }, [
111
+ form,
112
+ previewSpec,
113
+ queryClient
114
+ ]);
115
+ const processForm = (data)=>{
116
+ // reset display attributes to undefined when empty, because we don't want to save empty strings
117
+ onSave(data);
118
+ };
119
+ function handleCancel() {
120
+ if (JSON.stringify(initialAnnotationSpec) !== JSON.stringify(form.getValues())) {
121
+ setDiscardDialogOpened(true);
122
+ } else {
123
+ onClose();
124
+ }
125
+ }
126
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_reacthookform.FormProvider, {
127
+ ...form,
128
+ children: [
129
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
130
+ sx: {
131
+ display: 'flex',
132
+ alignItems: 'center',
133
+ padding: (theme)=>theme.spacing(1, 2),
134
+ borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
135
+ },
136
+ children: [
137
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
138
+ variant: "h2",
139
+ children: [
140
+ titleAction,
141
+ " Annotation"
142
+ ]
143
+ }),
144
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormActions, {
145
+ action: action,
146
+ submitText: submitText,
147
+ isReadonly: isReadonly,
148
+ isValid: form.formState.isValid,
149
+ onActionChange: onActionChange,
150
+ onSubmit: form.handleSubmit(processForm),
151
+ onDelete: onDelete,
152
+ onCancel: handleCancel
153
+ })
154
+ ]
155
+ }),
156
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
157
+ padding: 2,
158
+ sx: {
159
+ overflowY: 'scroll'
160
+ },
161
+ children: [
162
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
163
+ container: true,
164
+ spacing: 2,
165
+ mb: 2,
166
+ children: [
167
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
168
+ item: true,
169
+ xs: 12,
170
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
171
+ control: form.control,
172
+ name: "display.name",
173
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
174
+ ...field,
175
+ required: true,
176
+ fullWidth: true,
177
+ label: "Name",
178
+ InputLabelProps: {
179
+ shrink: action === 'read' ? true : undefined
180
+ },
181
+ InputProps: {
182
+ disabled: action === 'update' && !isDraft,
183
+ readOnly: action === 'read'
184
+ },
185
+ error: !!fieldState.error,
186
+ helperText: fieldState.error?.message,
187
+ value: field.value ?? '',
188
+ onChange: (event)=>{
189
+ field.onChange(event);
190
+ }
191
+ })
192
+ })
193
+ }),
194
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
195
+ item: true,
196
+ xs: 12,
197
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
198
+ direction: "row",
199
+ gap: 1,
200
+ children: [
201
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
202
+ control: form.control,
203
+ name: "display.color",
204
+ render: ({ field })=>{
205
+ const isEnabled = field.value !== undefined;
206
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
207
+ children: isEnabled ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsColorPicker, {
208
+ size: "medium",
209
+ label: "annotation",
210
+ color: field.value ?? DEFAULT_ANNOTATION_COLOR,
211
+ onColorChange: (color)=>field.onChange(color),
212
+ onClear: ()=>field.onChange(undefined)
213
+ }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
214
+ size: "medium",
215
+ onClick: ()=>field.onChange(DEFAULT_ANNOTATION_COLOR),
216
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_InvertColors.default, {})
217
+ })
218
+ });
219
+ }
220
+ }),
221
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
222
+ control: form.control,
223
+ name: "display.description",
224
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
225
+ ...field,
226
+ fullWidth: true,
227
+ label: "Description",
228
+ InputLabelProps: {
229
+ shrink: action === 'read' ? true : undefined
230
+ },
231
+ InputProps: {
232
+ readOnly: action === 'read'
233
+ },
234
+ error: !!fieldState.error,
235
+ helperText: fieldState.error?.message,
236
+ value: field.value ?? '',
237
+ onChange: (event)=>{
238
+ field.onChange(event);
239
+ }
240
+ })
241
+ })
242
+ ]
243
+ })
244
+ })
245
+ ]
246
+ }),
247
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {}),
248
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
249
+ FallbackComponent: FallbackPreview,
250
+ resetKeys: [
251
+ previewSpec
252
+ ],
253
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_AnnotationPreview.AnnotationPreview, {
254
+ spec: previewSpec,
255
+ sx: {
256
+ marginY: 2
257
+ }
258
+ })
259
+ }),
260
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
261
+ FallbackComponent: _components.ErrorAlert,
262
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(AnnotationPluginControl, {
263
+ action: action,
264
+ control: form.control,
265
+ onRunQuery: handleRunQuery
266
+ })
267
+ })
268
+ ]
269
+ }),
270
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.DiscardChangesConfirmationDialog, {
271
+ description: "Are you sure you want to discard these changes? Changes cannot be recovered.",
272
+ isOpen: isDiscardDialogOpened,
273
+ onCancel: ()=>{
274
+ setDiscardDialogOpened(false);
275
+ },
276
+ onDiscardChanges: ()=>{
277
+ setDiscardDialogOpened(false);
278
+ onClose();
279
+ }
280
+ })
281
+ ]
282
+ });
283
+ }
@@ -0,0 +1,211 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "AnnotationPreview", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return AnnotationPreview;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _react = require("react");
25
+ const _material = require("@mui/material");
26
+ const _pluginsystem = require("@perses-dev/plugin-system");
27
+ const _components = require("@perses-dev/components");
28
+ const _Alert = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Alert"));
29
+ function _interop_require_default(obj) {
30
+ return obj && obj.__esModule ? obj : {
31
+ default: obj
32
+ };
33
+ }
34
+ const formatDate = (timeMs, format)=>{
35
+ // Disallows NaN, Infinity, and -Infinity
36
+ if (!Number.isFinite(timeMs)) {
37
+ return {
38
+ date: 'N/A',
39
+ time: 'N/A'
40
+ };
41
+ }
42
+ const d = new Date(timeMs);
43
+ return {
44
+ date: format(d, 'MMM dd, yyyy'),
45
+ time: format(d, 'HH:mm:ss')
46
+ };
47
+ };
48
+ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
49
+ const start = formatDate(value.start, formatWithUserTimeZone);
50
+ const end = value.end !== undefined ? formatDate(value.start, formatWithUserTimeZone) : null;
51
+ const tags = (0, _react.useMemo)(()=>{
52
+ return Object.entries(value.tags ?? []).map(([key, value])=>{
53
+ return {
54
+ key: key,
55
+ value: value
56
+ };
57
+ });
58
+ }, [
59
+ value.tags
60
+ ]);
61
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Card, {
62
+ ...props,
63
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.CardContent, {
64
+ children: [
65
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
66
+ gap: 2,
67
+ children: [
68
+ value.title && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
69
+ variant: "h3",
70
+ children: value.title
71
+ }),
72
+ value.legend && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
73
+ children: value.legend
74
+ }),
75
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
76
+ flexWrap: "wrap",
77
+ direction: "row",
78
+ gap: 0.5,
79
+ children: tags.map((tag)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
80
+ size: "small",
81
+ label: `${tag.key}: ${tag.value}`
82
+ }, `${tag.key}=${tag.value}`))
83
+ })
84
+ ]
85
+ }),
86
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {
87
+ sx: {
88
+ marginY: 2
89
+ }
90
+ }),
91
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
92
+ gap: 0.5,
93
+ direction: "row",
94
+ children: [
95
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
96
+ variant: "caption",
97
+ children: [
98
+ start.date,
99
+ " - ",
100
+ /*#__PURE__*/ (0, _jsxruntime.jsx)("strong", {
101
+ children: start.time
102
+ })
103
+ ]
104
+ }),
105
+ end && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
106
+ children: [
107
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
108
+ variant: "caption",
109
+ children: ' → '
110
+ }),
111
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
112
+ variant: "caption",
113
+ children: [
114
+ end.date,
115
+ " - ",
116
+ /*#__PURE__*/ (0, _jsxruntime.jsx)("strong", {
117
+ children: end.time
118
+ })
119
+ ]
120
+ })
121
+ ]
122
+ })
123
+ ]
124
+ })
125
+ ]
126
+ })
127
+ });
128
+ }
129
+ function AnnotationPreview({ spec, ...props }) {
130
+ const { data, isFetching, error } = (0, _pluginsystem.useAnnotationData)(spec);
131
+ const { formatWithUserTimeZone } = (0, _components.useTimeZone)();
132
+ const [showAll, setShowAll] = (0, _react.useState)(false);
133
+ const annotationsToShow = showAll ? data : data?.slice(0, 1);
134
+ let notShown = 0;
135
+ if (data && data?.length > 0 && annotationsToShow) {
136
+ notShown = data.length - annotationsToShow.length;
137
+ }
138
+ const stateIndicator = (0, _react.useMemo)(()=>{
139
+ if (isFetching) {
140
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CircularProgress, {
141
+ "aria-label": "loading",
142
+ size: "1.125rem"
143
+ });
144
+ } else if (error) {
145
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
146
+ description: error.toString(),
147
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
148
+ "aria-label": "preview errors",
149
+ size: "small",
150
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Alert.default, {
151
+ fontSize: "inherit",
152
+ sx: {
153
+ color: (theme)=>theme.palette.error.main
154
+ }
155
+ })
156
+ })
157
+ });
158
+ }
159
+ }, [
160
+ isFetching,
161
+ error
162
+ ]);
163
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Card, {
164
+ variant: "outlined",
165
+ ...props,
166
+ children: [
167
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.CardHeader, {
168
+ title: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
169
+ direction: "row",
170
+ justifyContent: "space-between",
171
+ children: [
172
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
173
+ variant: "h4",
174
+ children: "Preview Annotations"
175
+ }),
176
+ stateIndicator
177
+ ]
178
+ })
179
+ }),
180
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.CardContent, {
181
+ sx: {
182
+ display: 'flex',
183
+ flexWrap: 'wrap',
184
+ gap: 1,
185
+ paddingY: 0
186
+ },
187
+ children: [
188
+ annotationsToShow?.map((item, index)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(AnnotationPreviewCard, {
189
+ value: item,
190
+ formatWithUserTimeZone: formatWithUserTimeZone,
191
+ sx: {
192
+ width: '100%'
193
+ }
194
+ }, index)),
195
+ notShown > 0 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
196
+ onClick: ()=>setShowAll(true),
197
+ variant: "outlined",
198
+ size: "small",
199
+ label: `+${notShown} more`
200
+ }),
201
+ showAll && data && data.length > 1 && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Chip, {
202
+ onClick: ()=>setShowAll(false),
203
+ variant: "outlined",
204
+ size: "small",
205
+ label: "-"
206
+ })
207
+ ]
208
+ })
209
+ ]
210
+ });
211
+ }
@@ -0,0 +1,30 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _export_star(require("./AnnotationEditorForm"), exports);
18
+ function _export_star(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
+ Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ }
28
+ });
29
+ return from;
30
+ }
@@ -0,0 +1,30 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _export_star(require("./AnnotationEditorForm"), exports);
18
+ function _export_star(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
+ Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ }
28
+ });
29
+ return from;
30
+ }
@@ -14,6 +14,7 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ _export_star(require("./Annotations"), exports);
17
18
  _export_star(require("./CalculationSelector"), exports);
18
19
  _export_star(require("./DatasourceEditorForm"), exports);
19
20
  _export_star(require("./DatasourceSelect"), exports);
@@ -47,6 +47,7 @@ function ValidationProvider({ children }) {
47
47
  const [datasourceEditorSchema, setDatasourceEditorSchema] = (0, _react.useState)(_client.datasourceDefinitionSchema);
48
48
  const [panelEditorSchema, setPanelEditorSchema] = (0, _react.useState)(_spec.panelEditorSchema); // TODO I don't get why this does not compile
49
49
  const [variableEditorSchema, setVariableEditorSchema] = (0, _react.useState)(_spec.variableDefinitionSchema);
50
+ const [annotationEditorSchema, setAnnotationEditorSchema] = (0, _react.useState)(_spec.annotationSpecSchema);
50
51
  function setDatasourceEditorSchemaPlugin(pluginSchema) {
51
52
  setDatasourceEditorSchema((0, _client.buildDatasourceDefinitionSchema)(pluginSchema));
52
53
  }
@@ -56,14 +57,19 @@ function ValidationProvider({ children }) {
56
57
  function setVariableEditorSchemaPlugin(pluginSchema) {
57
58
  setVariableEditorSchema((0, _spec.buildVariableDefinitionSchema)(pluginSchema));
58
59
  }
60
+ function setAnnotationEditorSchemaPlugin(pluginSchema) {
61
+ setAnnotationEditorSchema((0, _spec.buildAnnotationSpecSchema)(pluginSchema));
62
+ }
59
63
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(ValidationSchemasContext.Provider, {
60
64
  value: {
61
65
  datasourceEditorSchema,
62
66
  panelEditorSchema,
63
67
  variableEditorSchema,
68
+ annotationEditorSchema,
64
69
  setDatasourceEditorSchemaPlugin,
65
70
  setPanelEditorSchemaPlugin,
66
- setVariableEditorSchemaPlugin
71
+ setVariableEditorSchemaPlugin,
72
+ setAnnotationEditorSchemaPlugin
67
73
  },
68
74
  children: children
69
75
  });
@@ -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
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
@@ -14,6 +14,7 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ _export_star(require("./annotations"), exports);
17
18
  _export_star(require("./datasource"), exports);
18
19
  _export_star(require("./legend"), exports);
19
20
  _export_star(require("./log-queries"), exports);