@perses-dev/plugin-system 0.54.0-beta.6 → 0.54.0-beta.8
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 +3 -3
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +9 -64
- package/dist/cjs/components/Annotations/constants.js +23 -0
- package/dist/cjs/components/Annotations/index.js +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +9 -23
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -1
- 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 +1 -0
- package/dist/components/Annotations/index.d.ts.map +1 -1
- package/dist/components/Annotations/index.js +1 -0
- package/dist/components/Annotations/index.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.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 +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.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.map +1 -1
- package/dist/model/annotations.d.ts +3 -3
- package/dist/model/annotations.d.ts.map +1 -1
- package/dist/model/annotations.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/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/runtime/datasources.d.ts +6 -0
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js.map +1 -1
- package/package.json +4 -4
|
@@ -30,13 +30,13 @@ const _reactquery = require("@tanstack/react-query");
|
|
|
30
30
|
const _InvertColors = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/InvertColors"));
|
|
31
31
|
const _PluginEditor = require("../../PluginEditor");
|
|
32
32
|
const _context = require("../../../context");
|
|
33
|
+
const _constants = require("../constants");
|
|
33
34
|
const _AnnotationPreview = require("./AnnotationPreview");
|
|
34
35
|
function _interop_require_default(obj) {
|
|
35
36
|
return obj && obj.__esModule ? obj : {
|
|
36
37
|
default: obj
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
const DEFAULT_ANNOTATION_COLOR = '#FF6B6B';
|
|
40
40
|
function FallbackPreview() {
|
|
41
41
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
42
42
|
children: "Error previewing annotations"
|
|
@@ -207,12 +207,12 @@ function AnnotationEditorForm({ initialAnnotationSpec, action, isDraft, isReadon
|
|
|
207
207
|
children: isEnabled ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsColorPicker, {
|
|
208
208
|
size: "medium",
|
|
209
209
|
label: "annotation",
|
|
210
|
-
color: field.value ?? DEFAULT_ANNOTATION_COLOR,
|
|
210
|
+
color: field.value ?? _constants.DEFAULT_ANNOTATION_COLOR,
|
|
211
211
|
onColorChange: (color)=>field.onChange(color),
|
|
212
212
|
onClear: ()=>field.onChange(undefined)
|
|
213
213
|
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
214
214
|
size: "medium",
|
|
215
|
-
onClick: ()=>field.onChange(DEFAULT_ANNOTATION_COLOR),
|
|
215
|
+
onClick: ()=>field.onChange(_constants.DEFAULT_ANNOTATION_COLOR),
|
|
216
216
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_InvertColors.default, {})
|
|
217
217
|
})
|
|
218
218
|
});
|
|
@@ -21,74 +21,19 @@ Object.defineProperty(exports, "AnnotationPreview", {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _react =
|
|
24
|
+
const _react = require("react");
|
|
25
25
|
const _material = require("@mui/material");
|
|
26
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
27
26
|
const _components = require("@perses-dev/components");
|
|
28
27
|
const _Alert = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Alert"));
|
|
28
|
+
const _runtime = require("../../../runtime");
|
|
29
29
|
function _interop_require_default(obj) {
|
|
30
30
|
return obj && obj.__esModule ? obj : {
|
|
31
31
|
default: obj
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
35
|
-
if (typeof WeakMap !== "function") return null;
|
|
36
|
-
var cacheBabelInterop = new WeakMap();
|
|
37
|
-
var cacheNodeInterop = new WeakMap();
|
|
38
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
39
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
40
|
-
})(nodeInterop);
|
|
41
|
-
}
|
|
42
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
43
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
44
|
-
return obj;
|
|
45
|
-
}
|
|
46
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
47
|
-
return {
|
|
48
|
-
default: obj
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
52
|
-
if (cache && cache.has(obj)) {
|
|
53
|
-
return cache.get(obj);
|
|
54
|
-
}
|
|
55
|
-
var newObj = {
|
|
56
|
-
__proto__: null
|
|
57
|
-
};
|
|
58
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
59
|
-
for(var key in obj){
|
|
60
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
61
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
62
|
-
if (desc && (desc.get || desc.set)) {
|
|
63
|
-
Object.defineProperty(newObj, key, desc);
|
|
64
|
-
} else {
|
|
65
|
-
newObj[key] = obj[key];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
newObj.default = obj;
|
|
70
|
-
if (cache) {
|
|
71
|
-
cache.set(obj, newObj);
|
|
72
|
-
}
|
|
73
|
-
return newObj;
|
|
74
|
-
}
|
|
75
|
-
const formatDate = (timeMs, format)=>{
|
|
76
|
-
// Disallows NaN, Infinity, and -Infinity
|
|
77
|
-
if (!Number.isFinite(timeMs)) {
|
|
78
|
-
return {
|
|
79
|
-
date: 'N/A',
|
|
80
|
-
time: 'N/A'
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
const d = new Date(timeMs);
|
|
84
|
-
return {
|
|
85
|
-
date: format(d, 'MMM dd, yyyy'),
|
|
86
|
-
time: format(d, 'HH:mm:ss')
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
34
|
function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
|
|
90
|
-
const start =
|
|
91
|
-
const end = value.end !== undefined ?
|
|
35
|
+
const start = (0, _components.getDateAndTime)(value.start, formatWithUserTimeZone);
|
|
36
|
+
const end = value.end !== undefined ? (0, _components.getDateAndTime)(value.start, formatWithUserTimeZone) : null;
|
|
92
37
|
const tags = (0, _react.useMemo)(()=>{
|
|
93
38
|
return Object.entries(value.tags ?? []).map(([key, value])=>{
|
|
94
39
|
return {
|
|
@@ -136,10 +81,10 @@ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
|
|
|
136
81
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
|
|
137
82
|
variant: "caption",
|
|
138
83
|
children: [
|
|
139
|
-
start.
|
|
84
|
+
start.formattedDate,
|
|
140
85
|
" - ",
|
|
141
86
|
/*#__PURE__*/ (0, _jsxruntime.jsx)("strong", {
|
|
142
|
-
children: start.
|
|
87
|
+
children: start.formattedTime
|
|
143
88
|
})
|
|
144
89
|
]
|
|
145
90
|
}),
|
|
@@ -152,10 +97,10 @@ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
|
|
|
152
97
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
|
|
153
98
|
variant: "caption",
|
|
154
99
|
children: [
|
|
155
|
-
end.
|
|
100
|
+
end.formattedDate,
|
|
156
101
|
" - ",
|
|
157
102
|
/*#__PURE__*/ (0, _jsxruntime.jsx)("strong", {
|
|
158
|
-
children: end.
|
|
103
|
+
children: end.formattedTime
|
|
159
104
|
})
|
|
160
105
|
]
|
|
161
106
|
})
|
|
@@ -168,7 +113,7 @@ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
|
|
|
168
113
|
});
|
|
169
114
|
}
|
|
170
115
|
function AnnotationPreview({ spec, ...props }) {
|
|
171
|
-
const { data, isFetching, error } = (0,
|
|
116
|
+
const { data, isFetching, error } = (0, _runtime.useAnnotationData)(spec);
|
|
172
117
|
const { formatWithUserTimeZone } = (0, _components.useTimeZone)();
|
|
173
118
|
const [showAll, setShowAll] = (0, _react.useState)(false);
|
|
174
119
|
const annotationsToShow = showAll ? data : data?.slice(0, 1);
|
|
@@ -0,0 +1,23 @@
|
|
|
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, "DEFAULT_ANNOTATION_COLOR", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return DEFAULT_ANNOTATION_COLOR;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const DEFAULT_ANNOTATION_COLOR = '#FF6B6B';
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
_export_star(require("./AnnotationEditorForm"), exports);
|
|
18
|
+
_export_star(require("./constants"), exports);
|
|
18
19
|
function _export_star(from, to) {
|
|
19
20
|
Object.keys(from).forEach(function(k) {
|
|
20
21
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DispatchWithoutAction, ReactElement } from 'react';
|
|
2
2
|
import { AnnotationSpec } from '@perses-dev/spec';
|
|
3
|
-
import { Action } from '@perses-dev/
|
|
3
|
+
import { Action } from '@perses-dev/client';
|
|
4
4
|
interface AnnotationEditorFormProps {
|
|
5
5
|
initialAnnotationSpec: AnnotationSpec;
|
|
6
6
|
action: Action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnotationEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"AnnotationEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAclD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmD5C,UAAU,yBAAyB;IACjC,qBAAqB,EAAE,cAAc,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;IACtC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,EACnC,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,UAAU,EACV,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,yBAAyB,GAAG,YAAY,CAuK1C"}
|
|
@@ -20,8 +20,8 @@ import { useQueryClient } from '@tanstack/react-query';
|
|
|
20
20
|
import InvertColorsIcon from 'mdi-material-ui/InvertColors';
|
|
21
21
|
import { PluginEditor } from '../../PluginEditor';
|
|
22
22
|
import { useValidationSchemas } from '../../../context';
|
|
23
|
+
import { DEFAULT_ANNOTATION_COLOR } from '../constants';
|
|
23
24
|
import { AnnotationPreview } from './AnnotationPreview';
|
|
24
|
-
const DEFAULT_ANNOTATION_COLOR = '#FF6B6B';
|
|
25
25
|
function FallbackPreview() {
|
|
26
26
|
return /*#__PURE__*/ _jsx("div", {
|
|
27
27
|
children: "Error previewing annotations"
|
|
@@ -1 +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 Action,\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 { PluginEditor } from '../../PluginEditor';\nimport { useValidationSchemas } from '../../../context';\nimport { AnnotationPreview } from './AnnotationPreview';\n\nconst DEFAULT_ANNOTATION_COLOR = '#FF6B6B';\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","AnnotationPreview","DEFAULT_ANNOTATION_COLOR","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,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAE7F,SACEC,gCAAgC,EAChCC,UAAU,EACVC,aAAa,EACbC,WAAW,EACXC,kBAAkB,EAElBC,aAAa,EACbC,cAAc,QACT,yBAAyB;AAChC,SAAkBC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,EAAEC,QAAQ,QAAQ,kBAAkB;AACtG,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,cAAc,QAAQ,wBAAwB;AACvD,OAAOC,sBAAsB,+BAA+B;AAC5D,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,oBAAoB,QAAQ,mBAAmB;AACxD,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD,MA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,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,KAAC1C;4BAAkBY,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"}
|
|
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,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAE7F,SACEC,gCAAgC,EAChCC,UAAU,EACVC,aAAa,EACbC,WAAW,EACXC,kBAAkB,EAClBC,aAAa,EACbC,cAAc,QACT,yBAAy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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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnnotationPreview.d.ts","sourceRoot":"","sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationPreview.tsx"],"names":[],"mappings":"AAaA,
|
|
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"}
|
|
@@ -11,28 +11,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import
|
|
14
|
+
import { useMemo, useState } from 'react';
|
|
15
15
|
import { Card, CardContent, CardHeader, Chip, CircularProgress, Divider, IconButton, Stack, Typography } from '@mui/material';
|
|
16
|
-
import {
|
|
17
|
-
import { InfoTooltip, useTimeZone } from '@perses-dev/components';
|
|
16
|
+
import { getDateAndTime, InfoTooltip, useTimeZone } from '@perses-dev/components';
|
|
18
17
|
import AlertIcon from 'mdi-material-ui/Alert';
|
|
19
|
-
|
|
20
|
-
// Disallows NaN, Infinity, and -Infinity
|
|
21
|
-
if (!Number.isFinite(timeMs)) {
|
|
22
|
-
return {
|
|
23
|
-
date: 'N/A',
|
|
24
|
-
time: 'N/A'
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
const d = new Date(timeMs);
|
|
28
|
-
return {
|
|
29
|
-
date: format(d, 'MMM dd, yyyy'),
|
|
30
|
-
time: format(d, 'HH:mm:ss')
|
|
31
|
-
};
|
|
32
|
-
};
|
|
18
|
+
import { useAnnotationData } from '../../../runtime';
|
|
33
19
|
function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
|
|
34
|
-
const start =
|
|
35
|
-
const end = value.end !== undefined ?
|
|
20
|
+
const start = getDateAndTime(value.start, formatWithUserTimeZone);
|
|
21
|
+
const end = value.end !== undefined ? getDateAndTime(value.start, formatWithUserTimeZone) : null;
|
|
36
22
|
const tags = useMemo(()=>{
|
|
37
23
|
return Object.entries(value.tags ?? []).map(([key, value])=>{
|
|
38
24
|
return {
|
|
@@ -80,10 +66,10 @@ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
|
|
|
80
66
|
/*#__PURE__*/ _jsxs(Typography, {
|
|
81
67
|
variant: "caption",
|
|
82
68
|
children: [
|
|
83
|
-
start.
|
|
69
|
+
start.formattedDate,
|
|
84
70
|
" - ",
|
|
85
71
|
/*#__PURE__*/ _jsx("strong", {
|
|
86
|
-
children: start.
|
|
72
|
+
children: start.formattedTime
|
|
87
73
|
})
|
|
88
74
|
]
|
|
89
75
|
}),
|
|
@@ -96,10 +82,10 @@ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
|
|
|
96
82
|
/*#__PURE__*/ _jsxs(Typography, {
|
|
97
83
|
variant: "caption",
|
|
98
84
|
children: [
|
|
99
|
-
end.
|
|
85
|
+
end.formattedDate,
|
|
100
86
|
" - ",
|
|
101
87
|
/*#__PURE__*/ _jsx("strong", {
|
|
102
|
-
children: end.
|
|
88
|
+
children: end.formattedTime
|
|
103
89
|
})
|
|
104
90
|
]
|
|
105
91
|
})
|
|
@@ -1 +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
|
|
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,IAAI,EACJC,WAAW,EACXC,UAAU,EAEVC,IAAI,EACJC,gBAAgB,EAChBC,OAAO,EACPC,UAAU,EACVC,KAAK,EACLC,UAAU,QACL,gBAAgB;AACvB,SAASC,cAAc,EAAEC,WAAW,EAAEC,WAAW,QAAQ,yBAAyB;AAClF,OAAOC,eAAe,wBAAwB;AAC9C,SAASC,iBAAiB,QAAQ,mBAAmB;AAOrD,SAASC,sBAAsB,EAAEC,KAAK,EAAEC,sBAAsB,EAAE,GAAGC,OAAmC;IACpG,MAAMC,QAAQT,eAAeM,MAAMG,KAAK,EAAEF;IAC1C,MAAMG,MAAMJ,MAAMI,GAAG,KAAKC,YAAYX,eAAeM,MAAMG,KAAK,EAAEF,0BAA0B;IAE5F,MAAMK,OAAOvB,QAAQ;QACnB,OAAOwB,OAAOC,OAAO,CAACR,MAAMM,IAAI,IAAI,EAAE,EAAEG,GAAG,CAAC,CAAC,CAACC,KAAKV,MAAM;YACvD,O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QC,OAAM;;;;;;AAKxF"}
|
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Annotations/index.ts"],"names":[],"mappings":"AAaA,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Annotations/index.ts"],"names":[],"mappings":"AAaA,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC"}
|
|
@@ -1 +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';\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"}
|
|
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,6 +1,5 @@
|
|
|
1
|
-
import { Action } from '@perses-dev/components';
|
|
2
1
|
import { DispatchWithoutAction, ReactElement } from 'react';
|
|
3
|
-
import { DatasourceDefinition } from '@perses-dev/client';
|
|
2
|
+
import { Action, DatasourceDefinition } from '@perses-dev/client';
|
|
4
3
|
interface DatasourceEditorFormProps {
|
|
5
4
|
initialDatasourceDefinition: DatasourceDefinition;
|
|
6
5
|
action: Action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatasourceEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DatasourceEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAIlE,UAAU,yBAAyB;IACjC,2BAA2B,EAAE,oBAAoB,CAAC;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC5C,OAAO,EAAE,qBAAqB,CAAC;IAC/B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,GAAG,YAAY,CA8MnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.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 { zodResolver } from '@hookform/resolvers/zod';\nimport { Box, Divider, FormControlLabel, Grid, Stack, Switch, TextField, Typography } from '@mui/material';\nimport {\n DiscardChangesConfirmationDialog,\n FormActions,\n Action,\n getSubmitText,\n getTitleAction,\n} from '@perses-dev/components';\nimport { DispatchWithoutAction, ReactElement, useState } from 'react';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { DatasourceDefinition } from '@perses-dev/client';\nimport { useValidationSchemas } from '../../context';\nimport { PluginEditor } from '../PluginEditor';\n\ninterface DatasourceEditorFormProps {\n initialDatasourceDefinition: DatasourceDefinition;\n action: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onActionChange?: (action: Action) => void;\n onSave: (def: DatasourceDefinition) => void;\n onClose: DispatchWithoutAction;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function DatasourceEditorForm(props: DatasourceEditorFormProps): ReactElement {\n const { initialDatasourceDefinition, action, isDraft, isReadonly, onActionChange, onSave, onClose, onDelete } = props;\n\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const { datasourceEditorSchema } = useValidationSchemas();\n const form = useForm<DatasourceDefinition>({\n resolver: zodResolver(datasourceEditorSchema),\n mode: 'onBlur',\n defaultValues: initialDatasourceDefinition,\n });\n\n /*\n * Remove empty fields that are optional\n */\n function clearFormData(data: DatasourceDefinition): DatasourceDefinition {\n const result = { ...data };\n if (result.spec.display?.name === undefined && result.spec.display?.description === undefined) {\n delete result.spec.display;\n }\n return result;\n }\n\n const processForm: SubmitHandler<DatasourceDefinition> = (data: DatasourceDefinition) => {\n onSave(clearFormData(data));\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel(): void {\n if (JSON.stringify(initialDatasourceDefinition) !== JSON.stringify(clearFormData(form.getValues()))) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Datasource</Typography>\n <FormActions\n action={action}\n submitText={submitText}\n isReadonly={isReadonly}\n isValid={form.formState.isValid}\n onActionChange={onActionChange}\n onSubmit={form.handleSubmit(processForm)}\n onDelete={onDelete}\n onCancel={handleCancel}\n />\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n name=\"name\"\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"spec.display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"title\"\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Controller\n control={form.control}\n name=\"spec.display.description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"description\"\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={6} sx={{ paddingTop: '5px !important' }}>\n <Stack>\n <Controller\n control={form.control}\n name=\"spec.default\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Set as default\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n <Typography variant=\"caption\">\n Whether this datasource should be the default {form.getValues().spec.plugin.kind} to be used\n </Typography>\n </Stack>\n </Grid>\n </Grid>\n <Divider />\n <Typography py={1} variant=\"h3\">\n Plugin Options\n </Typography>\n <Controller\n control={form.control}\n name=\"spec.plugin\"\n render={({ field }) => (\n <PluginEditor\n width=\"100%\"\n pluginTypes={['Datasource']}\n pluginKindLabel=\"Source\"\n withRunQueryButton={false}\n value={{\n selection: {\n type: 'Datasource',\n kind: field.value.kind,\n },\n spec: field.value.spec,\n }}\n isReadonly={action === 'read'}\n onChange={(v) => {\n field.onChange({ kind: v.selection.kind, spec: v.spec });\n }}\n />\n )}\n />\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard your changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => setDiscardDialogOpened(false)}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["zodResolver","Box","Divider","FormControlLabel","Grid","Stack","Switch","TextField","Typography","DiscardChangesConfirmationDialog","FormActions","getSubmitText","getTitleAction","useState","Controller","FormProvider","useForm","useValidationSchemas","PluginEditor","DatasourceEditorForm","props","initialDatasourceDefinition","action","isDraft","isReadonly","onActionChange","onSave","onClose","onDelete","isDiscardDialogOpened","setDiscardDialogOpened","titleAction","submitText","datasourceEditorSchema","form","resolver","mode","defaultValues","clearFormData","data","result","spec","display","name","undefined","description","processForm","handleCancel","JSON","stringify","getValues","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","isValid","formState","onSubmit","handleSubmit","onCancel","overflowY","container","mb","item","xs","control","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","InputProps","disabled","readOnly","error","helperText","message","value","onChange","event","paddingTop","checked","plugin","kind","py","width","pluginTypes","pluginKindLabel","withRunQueryButton","selection","type","v","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,SAASA,WAAW,QAAQ,0BAA0B;AACtD,SAASC,GAAG,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAC3G,SACEC,gCAAgC,EAChCC,WAAW,EAEXC,aAAa,EACbC,cAAc,QACT,yBAAyB;AAChC,SAA8CC,QAAQ,QAAQ,QAAQ;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oD;4DACnFkD,MAAMc,QAAQ,CAACC;wDACjB;;;;sDAMV,MAAC/E;4CAAWmD,SAAQ;;gDAAU;gDACmBzB,KAAKgB,SAAS,GAAGT,IAAI,CAACiD,MAAM,CAACC,IAAI;gDAAC;;;;;;;;kCAKzF,KAACzF;kCACD,KAACM;wBAAWoF,IAAI;wBAAGjC,SAAQ;kCAAK;;kCAGhC,KAAC7C;wBACCwD,SAASpC,KAAKoC,OAAO;wBACrB3B,MAAK;wBACL4B,QAAQ,CAAC,EAAEC,KAAK,EAAE,iBAChB,KAACtD;gCACC2E,OAAM;gCACNC,aAAa;oCAAC;iCAAa;gCAC3BC,iBAAgB;gCAChBC,oBAAoB;gCACpBX,OAAO;oCACLY,WAAW;wCACTC,MAAM;wCACNP,MAAMnB,MAAMa,KAAK,CAACM,IAAI;oCACxB;oCACAlD,MAAM+B,MAAMa,KAAK,CAAC5C,IAAI;gCACxB;gCACAjB,YAAYF,WAAW;gCACvBgE,UAAU,CAACa;oCACT3B,MAAMc,QAAQ,CAAC;wCAAEK,MAAMQ,EAAEF,SAAS,CAACN,IAAI;wCAAElD,MAAM0D,EAAE1D,IAAI;oCAAC;gCACxD;;;;;0BAKR,KAAChC;gBACCoC,aAAY;gBACZuD,QAAQvE;gBACRmC,UAAU,IAAMlC,uBAAuB;gBACvCuE,kBAAkB;oBAChBvE,uBAAuB;oBACvBH;gBACF;;;;AAIR"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.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 { zodResolver } from '@hookform/resolvers/zod';\nimport { Box, Divider, FormControlLabel, Grid, Stack, Switch, TextField, Typography } from '@mui/material';\nimport { DiscardChangesConfirmationDialog, FormActions, getSubmitText, getTitleAction } from '@perses-dev/components';\nimport { DispatchWithoutAction, ReactElement, useState } from 'react';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { Action, DatasourceDefinition } from '@perses-dev/client';\nimport { useValidationSchemas } from '../../context';\nimport { PluginEditor } from '../PluginEditor';\n\ninterface DatasourceEditorFormProps {\n initialDatasourceDefinition: DatasourceDefinition;\n action: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onActionChange?: (action: Action) => void;\n onSave: (def: DatasourceDefinition) => void;\n onClose: DispatchWithoutAction;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function DatasourceEditorForm(props: DatasourceEditorFormProps): ReactElement {\n const { initialDatasourceDefinition, action, isDraft, isReadonly, onActionChange, onSave, onClose, onDelete } = props;\n\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const { datasourceEditorSchema } = useValidationSchemas();\n const form = useForm<DatasourceDefinition>({\n resolver: zodResolver(datasourceEditorSchema),\n mode: 'onBlur',\n defaultValues: initialDatasourceDefinition,\n });\n\n /*\n * Remove empty fields that are optional\n */\n function clearFormData(data: DatasourceDefinition): DatasourceDefinition {\n const result = { ...data };\n if (result.spec.display?.name === undefined && result.spec.display?.description === undefined) {\n delete result.spec.display;\n }\n return result;\n }\n\n const processForm: SubmitHandler<DatasourceDefinition> = (data: DatasourceDefinition) => {\n onSave(clearFormData(data));\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel(): void {\n if (JSON.stringify(initialDatasourceDefinition) !== JSON.stringify(clearFormData(form.getValues()))) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Datasource</Typography>\n <FormActions\n action={action}\n submitText={submitText}\n isReadonly={isReadonly}\n isValid={form.formState.isValid}\n onActionChange={onActionChange}\n onSubmit={form.handleSubmit(processForm)}\n onDelete={onDelete}\n onCancel={handleCancel}\n />\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n name=\"name\"\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"spec.display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"title\"\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Controller\n control={form.control}\n name=\"spec.display.description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n name=\"description\"\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={6} sx={{ paddingTop: '5px !important' }}>\n <Stack>\n <Controller\n control={form.control}\n name=\"spec.default\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Set as default\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n <Typography variant=\"caption\">\n Whether this datasource should be the default {form.getValues().spec.plugin.kind} to be used\n </Typography>\n </Stack>\n </Grid>\n </Grid>\n <Divider />\n <Typography py={1} variant=\"h3\">\n Plugin Options\n </Typography>\n <Controller\n control={form.control}\n name=\"spec.plugin\"\n render={({ field }) => (\n <PluginEditor\n width=\"100%\"\n pluginTypes={['Datasource']}\n pluginKindLabel=\"Source\"\n withRunQueryButton={false}\n value={{\n selection: {\n type: 'Datasource',\n kind: field.value.kind,\n },\n spec: field.value.spec,\n }}\n isReadonly={action === 'read'}\n onChange={(v) => {\n field.onChange({ kind: v.selection.kind, spec: v.spec });\n }}\n />\n )}\n />\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard your changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => setDiscardDialogOpened(false)}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["zodResolver","Box","Divider","FormControlLabel","Grid","Stack","Switch","TextField","Typography","DiscardChangesConfirmationDialog","FormActions","getSubmitText","getTitleAction","useState","Controller","FormProvider","useForm","useValidationSchemas","PluginEditor","DatasourceEditorForm","props","initialDatasourceDefinition","action","isDraft","isReadonly","onActionChange","onSave","onClose","onDelete","isDiscardDialogOpened","setDiscardDialogOpened","titleAction","submitText","datasourceEditorSchema","form","resolver","mode","defaultValues","clearFormData","data","result","spec","display","name","undefined","description","processForm","handleCancel","JSON","stringify","getValues","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","isValid","formState","onSubmit","handleSubmit","onCancel","overflowY","container","mb","item","xs","control","render","field","fieldState","required","fullWidth","label","InputLabelProps","shrink","InputProps","disabled","readOnly","error","helperText","message","value","onChange","event","paddingTop","checked","plugin","kind","py","width","pluginTypes","pluginKindLabel","withRunQueryButton","selection","type","v","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,SAASA,WAAW,QAAQ,0BAA0B;AACtD,SAASC,GAAG,EAAEC,OAAO,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,KAAK,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAC3G,SAASC,gCAAgC,EAAEC,WAAW,EAAEC,aAAa,EAAEC,cAAc,QAAQ,yBAAyB;AACtH,SAA8CC,QAAQ,QAAQ,QAAQ;AACtE,SAASC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,QAAQ,kBAAkB;AAEnF,SAASC,oBAAoB,QAAQ,gBAAgB;AACrD,SAASC,YAAY,QAAQ,kBAAkB;AAa/C,OAAO,SAASC,qBAAqBC,KAAgC;IACnE,MAAM,EAAEC,2BAA2B,EAAEC,MAAM,EAAEC,OAAO,EAAEC,UAAU,EAAEC,cAAc,EAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGR;IAEhH,MAAM,CAACS,uBAAuBC,uBAAuB,GAAGjB,SAAkB;IAC1E,MAAMkB,cAAcnB,eAAeU,QAAQC;IAC3C,MAAMS,aAAarB,cAAcW,QAAQC;IAEzC,MAAM,EAAEU,sBAAsB,EAAE,GAAGhB;IACnC,MAAMiB,OAAOlB,QAA8B;QACzCmB,UAAUnC,YAAYiC;QACtBG,MAAM;QACNC,eAAehB;IACjB;I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ACxB;gCACAjB,YAAYF,WAAW;gCACvBgE,UAAU,CAACa;oCACT3B,MAAMc,QAAQ,CAAC;wCAAEK,MAAMQ,EAAEF,SAAS,CAACN,IAAI;wCAAElD,MAAM0D,EAAE1D,IAAI;oCAAC;gCACxD;;;;;0BAKR,KAAChC;gBACCoC,aAAY;gBACZuD,QAAQvE;gBACRmC,UAAU,IAAMlC,uBAAuB;gBACvCuE,kBAAkB;oBAChBvE,uBAAuB;oBACvBH;gBACF;;;;AAIR"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { HTTPDatasourceSpec } from '@perses-dev/
|
|
2
|
+
import { HTTPDatasourceSpec } from '@perses-dev/spec';
|
|
3
3
|
export interface HTTPSettingsEditor {
|
|
4
4
|
value: HTTPDatasourceSpec;
|
|
5
5
|
onChange: (next: HTTPDatasourceSpec) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HTTPSettingsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/HTTPSettingsEditor/HTTPSettingsEditor.tsx"],"names":[],"mappings":"AAcA,OAAc,EAAY,YAAY,EAAY,MAAM,OAAO,CAAC;AAKhE,OAAO,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"HTTPSettingsEditor.d.ts","sourceRoot":"","sources":["../../../src/components/HTTPSettingsEditor/HTTPSettingsEditor.tsx"],"names":[],"mappings":"AAcA,OAAc,EAAY,YAAY,EAAY,MAAM,OAAO,CAAC;AAKhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAatD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,kBAAkB,CAAC;IAC1B,QAAQ,EAAE,CAAC,IAAI,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,gBAAgB,EAAE,kBAAkB,CAAC;CACtC;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,CA8b1E"}
|
|
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
14
14
|
import { Grid, IconButton, MenuItem, TextField, Typography } from '@mui/material';
|
|
15
15
|
import React, { Fragment, useState } from 'react';
|
|
16
16
|
import { produce } from 'immer';
|
|
17
|
-
import { Controller,
|
|
17
|
+
import { Controller, useFieldArray, useForm } from 'react-hook-form';
|
|
18
18
|
import MinusIcon from 'mdi-material-ui/Minus';
|
|
19
19
|
import PlusIcon from 'mdi-material-ui/Plus';
|
|
20
20
|
import { OptionsEditorRadios } from '../OptionsEditorRadios';
|