@perses-dev/plugin-system 0.54.0-beta.7 → 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.
Files changed (29) hide show
  1. package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +3 -3
  2. package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +8 -22
  3. package/dist/cjs/components/Annotations/constants.js +23 -0
  4. package/dist/cjs/components/Annotations/index.js +1 -0
  5. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -1
  6. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +1 -1
  7. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -1
  8. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -1
  9. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +8 -22
  10. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -1
  11. package/dist/components/Annotations/constants.d.ts +2 -0
  12. package/dist/components/Annotations/constants.d.ts.map +1 -0
  13. package/dist/components/Annotations/constants.js +15 -0
  14. package/dist/components/Annotations/constants.js.map +1 -0
  15. package/dist/components/Annotations/index.d.ts +1 -0
  16. package/dist/components/Annotations/index.d.ts.map +1 -1
  17. package/dist/components/Annotations/index.js +1 -0
  18. package/dist/components/Annotations/index.js.map +1 -1
  19. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +1 -1
  20. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
  21. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +1 -1
  22. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
  23. package/dist/model/annotations.d.ts +1 -1
  24. package/dist/model/annotations.d.ts.map +1 -1
  25. package/dist/model/annotations.js.map +1 -1
  26. package/dist/model/log-queries.d.ts +2 -1
  27. package/dist/model/log-queries.d.ts.map +1 -1
  28. package/dist/model/log-queries.js.map +1 -1
  29. 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
  });
@@ -23,31 +23,17 @@ Object.defineProperty(exports, "AnnotationPreview", {
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
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
- 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
34
  function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
49
- const start = formatDate(value.start, formatWithUserTimeZone);
50
- const end = value.end !== undefined ? formatDate(value.start, formatWithUserTimeZone) : null;
35
+ const start = (0, _components.getDateAndTime)(value.start, formatWithUserTimeZone);
36
+ const end = value.end !== undefined ? (0, _components.getDateAndTime)(value.start, formatWithUserTimeZone) : null;
51
37
  const tags = (0, _react.useMemo)(()=>{
52
38
  return Object.entries(value.tags ?? []).map(([key, value])=>{
53
39
  return {
@@ -95,10 +81,10 @@ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
95
81
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
96
82
  variant: "caption",
97
83
  children: [
98
- start.date,
84
+ start.formattedDate,
99
85
  " - ",
100
86
  /*#__PURE__*/ (0, _jsxruntime.jsx)("strong", {
101
- children: start.time
87
+ children: start.formattedTime
102
88
  })
103
89
  ]
104
90
  }),
@@ -111,10 +97,10 @@ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
111
97
  /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Typography, {
112
98
  variant: "caption",
113
99
  children: [
114
- end.date,
100
+ end.formattedDate,
115
101
  " - ",
116
102
  /*#__PURE__*/ (0, _jsxruntime.jsx)("strong", {
117
- children: end.time
103
+ children: end.formattedTime
118
104
  })
119
105
  ]
120
106
  })
@@ -127,7 +113,7 @@ function AnnotationPreviewCard({ value, formatWithUserTimeZone, ...props }) {
127
113
  });
128
114
  }
129
115
  function AnnotationPreview({ spec, ...props }) {
130
- const { data, isFetching, error } = (0, _pluginsystem.useAnnotationData)(spec);
116
+ const { data, isFetching, error } = (0, _runtime.useAnnotationData)(spec);
131
117
  const { formatWithUserTimeZone } = (0, _components.useTimeZone)();
132
118
  const [showAll, setShowAll] = (0, _react.useState)(false);
133
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 +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;AAclD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAoD5C,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"}
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 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 { 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,EAClBC,aAAa,EACbC,cAAc,QACT,yBAAyB;AAChC,SAAkBC,UAAU,EAAEC,YAAY,EAAiBC,O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Ce,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,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,QAA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["../../../../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;AAmEvB,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"}
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"}
@@ -13,26 +13,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
13
13
  // limitations under the License.
14
14
  import { useMemo, useState } from 'react';
15
15
  import { Card, CardContent, CardHeader, Chip, CircularProgress, Divider, IconButton, Stack, Typography } from '@mui/material';
16
- import { useAnnotationData } from '@perses-dev/plugin-system';
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
- const formatDate = (timeMs, format)=>{
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 = formatDate(value.start, formatWithUserTimeZone);
35
- const end = value.end !== undefined ? formatDate(value.start, formatWithUserTimeZone) : null;
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.date,
69
+ start.formattedDate,
84
70
  " - ",
85
71
  /*#__PURE__*/ _jsx("strong", {
86
- children: start.time
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.date,
85
+ end.formattedDate,
100
86
  " - ",
101
87
  /*#__PURE__*/ _jsx("strong", {
102
- children: end.time
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 { 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 { useAnnotationData } from '@perses-dev/plugin-system';\nimport { InfoTooltip, useTimeZone } from '@perses-dev/components';\nimport AlertIcon from 'mdi-material-ui/Alert';\n\nconst formatDate = (timeMs: number, format: (date: Date, format: string) => string): { date: string; time: string } => {\n // Disallows NaN, Infinity, and -Infinity\n if (!Number.isFinite(timeMs)) {\n return { date: 'N/A', time: 'N/A' };\n }\n\n const d = new Date(timeMs);\n return {\n date: format(d, 'MMM dd, yyyy'),\n time: format(d, 'HH:mm:ss'),\n };\n};\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 = formatDate(value.start, formatWithUserTimeZone);\n const end = value.end !== undefined ? formatDate(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.date} - <strong>{start.time}</strong>\n </Typography>\n {end && (\n <>\n <Typography variant=\"caption\">{' → '}</Typography>\n <Typography variant=\"caption\">\n {end.date} - <strong>{end.time}</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","useAnnotationData","InfoTooltip","useTimeZone","AlertIcon","formatDate","timeMs","format","Number","isFinite","date","time","d","Date","AnnotationPreviewCard","value","formatWithUserTimeZone","props","start","end","undefined","tags","Object","entries","map","key","gap","title","variant","legend","flexWrap","direction","tag","size","label","sx","marginY","strong","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,iBAAiB,QAAQ,4BAA4B;AAC9D,SAASC,WAAW,EAAEC,WAAW,QAAQ,yBAAyB;AAClE,OAAOC,eAAe,wBAAwB;AAE9C,MAAMC,aAAa,CAACC,QAAgBC;IAClC,yCAAyC;IACzC,IAAI,CAACC,OAAOC,QAAQ,CAACH,SAAS;QAC5B,OAAO;YAAEI,MAAM;YAAOC,MAAM;QAAM;IACpC;IAEA,MAAMC,IAAI,IAAIC,KAAKP;IACnB,OAAO;QACLI,MAAMH,OAAOK,GAAG;QAChBD,MAAMJ,OAAOK,GAAG;IAClB;AACF;AAOA,SAASE,sBAAsB,EAAEC,KAAK,EAAEC,sBAAsB,EAAE,GAAGC,OAAmC;IACpG,MAAMC,QAAQb,WAAWU,MAAMG,KAAK,EAAEF;IACtC,MAAMG,MAAMJ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,WAAW;wBAAOhB,SAAQ;wBAAWK,MAAK;wBAAQC,OAAO,CAAC,CAAC,EAAEa,SAAS,KAAK,CAAC;;oBAElGJ,WAAWH,QAAQA,KAAKQ,MAAM,GAAG,mBAChC,KAACrD;wBAAKqE,SAAS,IAAMpB,WAAW;wBAAQhB,SAAQ;wBAAWK,MAAK;wBAAQC,OAAM;;;;;;AAKxF"}
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,QAA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AW,mBACV,KAAC9C;wBAAK+D,SAAS,IAAMpB,WAAW;wBAAOlB,SAAQ;wBAAWK,MAAK;wBAAQC,OAAO,CAAC,CAAC,EAAEe,SAAS,KAAK,CAAC;;oBAElGJ,WAAWH,QAAQA,KAAKQ,MAAM,GAAG,mBAChC,KAAC/C;wBAAK+D,SAAS,IAAMpB,WAAW;wBAAQlB,SAAQ;wBAAWK,MAAK;wBAAQC,OAAM;;;;;;AAKxF"}
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_ANNOTATION_COLOR = "#FF6B6B";
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -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,2 +1,3 @@
1
1
  export * from './AnnotationEditorForm';
2
+ export * from './constants';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -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"}
@@ -11,5 +11,6 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  export * from './AnnotationEditorForm';
14
+ export * from './constants';
14
15
 
15
16
  //# sourceMappingURL=index.js.map
@@ -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,5 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
- import { HTTPDatasourceSpec } from '@perses-dev/client';
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,EAAkB,MAAM,oBAAoB,CAAC;AAYxE,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"}
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, useForm, useFieldArray } from 'react-hook-form';
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';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/HTTPSettingsEditor/HTTPSettingsEditor.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 { Grid, IconButton, MenuItem, TextField, Typography } from '@mui/material';\nimport React, { Fragment, ReactElement, useState } from 'react';\nimport { produce } from 'immer';\nimport { Controller, useForm, useFieldArray } from 'react-hook-form';\nimport MinusIcon from 'mdi-material-ui/Minus';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport { HTTPDatasourceSpec, RequestHeaders } from '@perses-dev/client';\nimport { OptionsEditorRadios } from '../OptionsEditorRadios';\n\ntype HeaderEntry = {\n name: string;\n value: string;\n};\n\ntype HeaderFormValues = {\n headers: HeaderEntry[];\n};\n\nexport interface HTTPSettingsEditor {\n value: HTTPDatasourceSpec;\n onChange: (next: HTTPDatasourceSpec) => void;\n isReadonly?: boolean;\n initialSpecDirect: HTTPDatasourceSpec;\n initialSpecProxy: HTTPDatasourceSpec;\n}\n\nexport function HTTPSettingsEditor(props: HTTPSettingsEditor): ReactElement {\n const { value, onChange, isReadonly, initialSpecDirect, initialSpecProxy } = props;\n const strDirect = 'Direct access';\n const strProxy = 'Proxy';\n\n // Initialize Proxy mode by default, if neither direct nor proxy mode is selected.\n if (value.directUrl === undefined && value.proxy === undefined) {\n Object.assign(value, initialSpecProxy);\n }\n\n // Use local state to maintain an array of header entries during editing, instead of\n // manipulating a map directly which causes weird UX.\n const headersForm = useForm<HeaderFormValues>({\n defaultValues: {\n headers: Object.entries(value.proxy?.spec.headers ?? {}).map(([name, headerValue]) => ({\n name,\n value: headerValue as string,\n })),\n },\n });\n\n const { fields, append, remove } = useFieldArray({\n control: headersForm.control,\n name: 'headers',\n });\n\n // Watch the headers array for changes to detect duplicates\n const watchedHeaders = headersForm.watch('headers');\n\n // Check for duplicate header names\n // TODO: duplication detection logic to be replaced by proper zod schema validation in the future\n // ref https://github.com/perses/perses/issues/3014\n const nameMap = new Map<string, number>();\n const duplicateNames = new Set<string>();\n watchedHeaders.forEach(({ name }) => {\n if (name !== '') {\n const count = (nameMap.get(name) || 0) + 1;\n nameMap.set(name, count);\n if (count > 1) {\n duplicateNames.add(name);\n }\n }\n });\n const hasDuplicates = duplicateNames.size > 0;\n\n // Sync headers to parent\n const syncHeadersToParent = (headers: HeaderEntry[]): void => {\n const headersObject: RequestHeaders = {};\n headers.forEach(({ name, value: headerValue }) => {\n if (name !== '') {\n headersObject[name] = headerValue;\n }\n });\n\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.headers = Object.keys(headersObject).length > 0 ? headersObject : undefined;\n }\n })\n );\n };\n\n const tabs = [\n {\n label: strProxy,\n content: (\n <>\n <Controller\n name=\"URL\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"URL\"\n value={value.proxy?.spec.url || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.url = e.target.value;\n }\n })\n );\n }}\n sx={{ mb: 2 }}\n />\n )}\n />\n <Typography variant=\"h5\" mb={2}>\n Allowed endpoints\n </Typography>\n <Grid container spacing={2} mb={2}>\n {value.proxy?.spec.allowedEndpoints && value.proxy?.spec.allowedEndpoints.length !== 0 ? (\n value.proxy.spec.allowedEndpoints.map(({ endpointPattern, method }, i) => {\n return (\n <Fragment key={i}>\n <Grid item xs={8}>\n <Controller\n name={`Endpoint pattern ${i}`}\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Endpoint pattern\"\n value={endpointPattern}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = draft.proxy.spec.allowedEndpoints?.map(\n (item, itemIndex) => {\n if (i === itemIndex) {\n return {\n endpointPattern: e.target.value,\n method: item.method,\n };\n } else {\n return item;\n }\n }\n );\n }\n })\n );\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={3}>\n <Controller\n name={`Method ${i}`}\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n select\n fullWidth\n label=\"Method\"\n value={method}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = draft.proxy.spec.allowedEndpoints?.map(\n (item, itemIndex) => {\n if (i === itemIndex) {\n return {\n endpointPattern: item.endpointPattern,\n method: e.target.value,\n };\n } else {\n return item;\n }\n }\n );\n }\n })\n );\n }}\n >\n <MenuItem value=\"GET\">GET</MenuItem>\n <MenuItem value=\"POST\">POST</MenuItem>\n <MenuItem value=\"PUT\">PUT</MenuItem>\n <MenuItem value=\"PATCH\">PATCH</MenuItem>\n <MenuItem value=\"DELETE\">DELETE</MenuItem>\n </TextField>\n )}\n />\n </Grid>\n <Grid item xs={1}>\n <Controller\n name={`Remove Endpoint ${i}`}\n render={({ field }) => (\n <IconButton\n {...field}\n disabled={isReadonly}\n // Remove the given allowed endpoint from the list\n onClick={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = [\n ...(draft.proxy.spec.allowedEndpoints?.filter((item, itemIndex) => {\n return itemIndex !== i;\n }) || []),\n ];\n }\n })\n );\n }}\n >\n <MinusIcon />\n </IconButton>\n )}\n />\n </Grid>\n </Fragment>\n );\n })\n ) : (\n <Grid item xs={4}>\n <Typography sx={{ fontStyle: 'italic' }}>None</Typography>\n </Grid>\n )}\n <Grid item xs={12} sx={{ paddingTop: '0px !important', paddingLeft: '5px !important' }}>\n <IconButton\n disabled={isReadonly}\n // Add a new (empty) allowed endpoint to the list\n onClick={() =>\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = [\n ...(draft.proxy.spec.allowedEndpoints ?? []),\n { endpointPattern: '', method: '' },\n ];\n }\n })\n )\n }\n >\n <PlusIcon />\n </IconButton>\n </Grid>\n </Grid>\n <Typography variant=\"h5\" mb={2}>\n Request Headers\n </Typography>\n <Grid container spacing={2} mb={2}>\n {fields.length > 0 ? (\n fields.map((field, index) => (\n <Fragment key={field.id}>\n <Grid item xs={4}>\n <Controller\n control={headersForm.control}\n name={`headers.${index}.name`}\n render={({ field: controllerField, fieldState }) => (\n <TextField\n {...controllerField}\n fullWidth\n label=\"Header name\"\n error={!!fieldState.error || duplicateNames.has(controllerField.value)}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n controllerField.onChange(e);\n const updatedHeaders = [...watchedHeaders];\n updatedHeaders[index] = { name: e.target.value, value: updatedHeaders[index]?.value ?? '' };\n syncHeadersToParent(updatedHeaders);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={7}>\n <Controller\n control={headersForm.control}\n name={`headers.${index}.value`}\n render={({ field: controllerField, fieldState }) => (\n <TextField\n {...controllerField}\n fullWidth\n label=\"Header value\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n controllerField.onChange(e);\n const updatedHeaders = [...watchedHeaders];\n updatedHeaders[index] = { name: updatedHeaders[index]?.name ?? '', value: e.target.value };\n syncHeadersToParent(updatedHeaders);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={1}>\n <IconButton\n disabled={isReadonly}\n aria-label={`Remove header ${watchedHeaders[index]?.name || index}`}\n onClick={() => {\n remove(index);\n const updatedHeaders = watchedHeaders.filter((_, i) => i !== index);\n syncHeadersToParent(updatedHeaders);\n }}\n >\n <MinusIcon />\n </IconButton>\n </Grid>\n </Fragment>\n ))\n ) : (\n <Grid item xs={4}>\n <Typography sx={{ fontStyle: 'italic' }}>None</Typography>\n </Grid>\n )}\n {hasDuplicates && (\n <Grid item xs={12}>\n <Typography variant=\"body2\" color=\"error\">\n Duplicate header names detected. Each header name must be unique.\n </Typography>\n </Grid>\n )}\n <Grid item xs={12} sx={{ paddingTop: '0px !important', paddingLeft: '5px !important' }}>\n <IconButton disabled={isReadonly} onClick={() => append({ name: '', value: '' })}>\n <PlusIcon />\n </IconButton>\n </Grid>\n </Grid>\n\n <Controller\n name=\"Secret\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Secret\"\n value={value.proxy?.spec.secret || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.secret = e.target.value;\n }\n })\n );\n }}\n />\n )}\n />\n </>\n ),\n },\n {\n label: strDirect,\n content: (\n <Controller\n name=\"URL\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"URL\"\n value={value.directUrl || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n draft.directUrl = e.target.value;\n })\n );\n }}\n />\n )}\n />\n ),\n },\n ];\n\n // Use of findIndex instead of providing hardcoded values to avoid desynchronisatio or\n // bug in case the tabs get eventually swapped in the future.\n const directModeId = tabs.findIndex((tab) => tab.label === strDirect);\n const proxyModeId = tabs.findIndex((tab) => tab.label === strProxy);\n\n // Set defaultTab to the mode that this datasource is currently relying on.\n const defaultTab = value.proxy ? proxyModeId : directModeId;\n\n // For better user experience, save previous states in mind for both mode.\n // This avoids losing everything when the user changes their mind back.\n const [previousSpecDirect, setPreviousSpecDirect] = useState(initialSpecDirect);\n const [previousSpecProxy, setPreviousSpecProxy] = useState(initialSpecProxy);\n\n // When changing mode, remove previous mode's config + append default values for the new mode.\n const handleModeChange = (v: number): void => {\n if (tabs[v]?.label === strDirect) {\n setPreviousSpecProxy(value);\n\n // Copy all settings (for example, scrapeInterval), except 'proxy'\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { proxy, ...newValue } = value;\n onChange({ ...newValue, directUrl: previousSpecDirect.directUrl });\n } else if (tabs[v]?.label === strProxy) {\n setPreviousSpecDirect(value);\n\n // Copy all settings (for example, scrapeInterval), except 'directUrl'\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { directUrl, ...newValue } = value;\n onChange({ ...newValue, proxy: previousSpecProxy.proxy });\n }\n };\n\n return (\n <>\n <Typography variant=\"h4\" mt={2}>\n HTTP Settings\n </Typography>\n <OptionsEditorRadios\n isReadonly={isReadonly}\n tabs={tabs}\n defaultTab={defaultTab}\n onModeChange={handleModeChange}\n />\n </>\n );\n}\n"],"names":["Grid","IconButton","MenuItem","TextField","Typography","React","Fragment","useState","produce","Controller","useForm","useFieldArray","MinusIcon","PlusIcon","OptionsEditorRadios","HTTPSettingsEditor","props","value","onChange","isReadonly","initialSpecDirect","initialSpecProxy","strDirect","strProxy","directUrl","undefined","proxy","Object","assign","headersForm","defaultValues","headers","entries","spec","map","name","headerValue","fields","append","remove","control","watchedHeaders","watch","nameMap","Map","duplicateNames","Set","forEach","count","get","set","add","hasDuplicates","size","syncHeadersToParent","headersObject","draft","keys","length","tabs","label","content","render","field","fieldState","fullWidth","url","error","helperText","message","InputProps","readOnly","InputLabelProps","shrink","e","target","sx","mb","variant","container","spacing","allowedEndpoints","endpointPattern","method","i","item","xs","itemIndex","select","disabled","onClick","filter","fontStyle","paddingTop","paddingLeft","index","controllerField","has","updatedHeaders","aria-label","_","id","color","secret","directModeId","findIndex","tab","proxyModeId","defaultTab","previousSpecDirect","setPreviousSpecDirect","previousSpecProxy","setPreviousSpecProxy","handleModeChange","v","newValue","mt","onModeChange"],"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,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAClF,OAAOC,SAASC,QAAQ,EAAgBC,QAAQ,QAAQ,QAAQ;AAChE,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,UAAU,EAAEC,OAAO,EAAEC,aAAa,QAAQ,kBAAkB;AACrE,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,cAAc,uBAAuB;AAE5C,SAASC,mBAAmB,QAAQ,yBAAyB;AAmB7D,OAAO,SAASC,mBAAmBC,KAAyB;IAC1D,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,iBAAiB,EAAEC,gBAAgB,EAAE,GAAGL;IAC7E,MAAMM,YAAY;IAClB,MAAMC,WAAW;IAEjB,kFAAkF;IAClF,IAAIN,MAAMO,SAAS,KAAKC,aAAaR,MAAMS,KAAK,KAAKD,WAAW;QAC9DE,OAAOC,MAAM,CAACX,OAAOI;IACvB;IAEA,oFAAoF;IACpF,qDAAqD;IACrD,MAAMQ,cAAcnB,QAA0B;QAC5CoB,eAAe;YACbC,SA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AAC;QACzD;IACF;IAEA,qBACE;;0BACE,KAACtB;gBAAW0E,SAAQ;gBAAKsC,IAAI;0BAAG;;0BAGhC,KAACtG;gBACCK,YAAYA;gBACZwC,MAAMA;gBACNiD,YAAYA;gBACZS,cAAcJ;;;;AAItB"}
1
+ {"version":3,"sources":["../../../src/components/HTTPSettingsEditor/HTTPSettingsEditor.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 { Grid, IconButton, MenuItem, TextField, Typography } from '@mui/material';\nimport React, { Fragment, ReactElement, useState } from 'react';\nimport { produce } from 'immer';\nimport { Controller, useFieldArray, useForm } from 'react-hook-form';\nimport MinusIcon from 'mdi-material-ui/Minus';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport { HTTPDatasourceSpec } from '@perses-dev/spec';\nimport { RequestHeaders } from '@perses-dev/client';\nimport { OptionsEditorRadios } from '../OptionsEditorRadios';\n\ntype HeaderEntry = {\n name: string;\n value: string;\n};\n\ntype HeaderFormValues = {\n headers: HeaderEntry[];\n};\n\nexport interface HTTPSettingsEditor {\n value: HTTPDatasourceSpec;\n onChange: (next: HTTPDatasourceSpec) => void;\n isReadonly?: boolean;\n initialSpecDirect: HTTPDatasourceSpec;\n initialSpecProxy: HTTPDatasourceSpec;\n}\n\nexport function HTTPSettingsEditor(props: HTTPSettingsEditor): ReactElement {\n const { value, onChange, isReadonly, initialSpecDirect, initialSpecProxy } = props;\n const strDirect = 'Direct access';\n const strProxy = 'Proxy';\n\n // Initialize Proxy mode by default, if neither direct nor proxy mode is selected.\n if (value.directUrl === undefined && value.proxy === undefined) {\n Object.assign(value, initialSpecProxy);\n }\n\n // Use local state to maintain an array of header entries during editing, instead of\n // manipulating a map directly which causes weird UX.\n const headersForm = useForm<HeaderFormValues>({\n defaultValues: {\n headers: Object.entries(value.proxy?.spec.headers ?? {}).map(([name, headerValue]) => ({\n name,\n value: headerValue as string,\n })),\n },\n });\n\n const { fields, append, remove } = useFieldArray({\n control: headersForm.control,\n name: 'headers',\n });\n\n // Watch the headers array for changes to detect duplicates\n const watchedHeaders = headersForm.watch('headers');\n\n // Check for duplicate header names\n // TODO: duplication detection logic to be replaced by proper zod schema validation in the future\n // ref https://github.com/perses/perses/issues/3014\n const nameMap = new Map<string, number>();\n const duplicateNames = new Set<string>();\n watchedHeaders.forEach(({ name }) => {\n if (name !== '') {\n const count = (nameMap.get(name) || 0) + 1;\n nameMap.set(name, count);\n if (count > 1) {\n duplicateNames.add(name);\n }\n }\n });\n const hasDuplicates = duplicateNames.size > 0;\n\n // Sync headers to parent\n const syncHeadersToParent = (headers: HeaderEntry[]): void => {\n const headersObject: RequestHeaders = {};\n headers.forEach(({ name, value: headerValue }) => {\n if (name !== '') {\n headersObject[name] = headerValue;\n }\n });\n\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.headers = Object.keys(headersObject).length > 0 ? headersObject : undefined;\n }\n })\n );\n };\n\n const tabs = [\n {\n label: strProxy,\n content: (\n <>\n <Controller\n name=\"URL\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"URL\"\n value={value.proxy?.spec.url || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.url = e.target.value;\n }\n })\n );\n }}\n sx={{ mb: 2 }}\n />\n )}\n />\n <Typography variant=\"h5\" mb={2}>\n Allowed endpoints\n </Typography>\n <Grid container spacing={2} mb={2}>\n {value.proxy?.spec.allowedEndpoints && value.proxy?.spec.allowedEndpoints.length !== 0 ? (\n value.proxy.spec.allowedEndpoints.map(({ endpointPattern, method }, i) => {\n return (\n <Fragment key={i}>\n <Grid item xs={8}>\n <Controller\n name={`Endpoint pattern ${i}`}\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Endpoint pattern\"\n value={endpointPattern}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = draft.proxy.spec.allowedEndpoints?.map(\n (item, itemIndex) => {\n if (i === itemIndex) {\n return {\n endpointPattern: e.target.value,\n method: item.method,\n };\n } else {\n return item;\n }\n }\n );\n }\n })\n );\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={3}>\n <Controller\n name={`Method ${i}`}\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n select\n fullWidth\n label=\"Method\"\n value={method}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = draft.proxy.spec.allowedEndpoints?.map(\n (item, itemIndex) => {\n if (i === itemIndex) {\n return {\n endpointPattern: item.endpointPattern,\n method: e.target.value,\n };\n } else {\n return item;\n }\n }\n );\n }\n })\n );\n }}\n >\n <MenuItem value=\"GET\">GET</MenuItem>\n <MenuItem value=\"POST\">POST</MenuItem>\n <MenuItem value=\"PUT\">PUT</MenuItem>\n <MenuItem value=\"PATCH\">PATCH</MenuItem>\n <MenuItem value=\"DELETE\">DELETE</MenuItem>\n </TextField>\n )}\n />\n </Grid>\n <Grid item xs={1}>\n <Controller\n name={`Remove Endpoint ${i}`}\n render={({ field }) => (\n <IconButton\n {...field}\n disabled={isReadonly}\n // Remove the given allowed endpoint from the list\n onClick={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = [\n ...(draft.proxy.spec.allowedEndpoints?.filter((item, itemIndex) => {\n return itemIndex !== i;\n }) || []),\n ];\n }\n })\n );\n }}\n >\n <MinusIcon />\n </IconButton>\n )}\n />\n </Grid>\n </Fragment>\n );\n })\n ) : (\n <Grid item xs={4}>\n <Typography sx={{ fontStyle: 'italic' }}>None</Typography>\n </Grid>\n )}\n <Grid item xs={12} sx={{ paddingTop: '0px !important', paddingLeft: '5px !important' }}>\n <IconButton\n disabled={isReadonly}\n // Add a new (empty) allowed endpoint to the list\n onClick={() =>\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.allowedEndpoints = [\n ...(draft.proxy.spec.allowedEndpoints ?? []),\n { endpointPattern: '', method: '' },\n ];\n }\n })\n )\n }\n >\n <PlusIcon />\n </IconButton>\n </Grid>\n </Grid>\n <Typography variant=\"h5\" mb={2}>\n Request Headers\n </Typography>\n <Grid container spacing={2} mb={2}>\n {fields.length > 0 ? (\n fields.map((field, index) => (\n <Fragment key={field.id}>\n <Grid item xs={4}>\n <Controller\n control={headersForm.control}\n name={`headers.${index}.name`}\n render={({ field: controllerField, fieldState }) => (\n <TextField\n {...controllerField}\n fullWidth\n label=\"Header name\"\n error={!!fieldState.error || duplicateNames.has(controllerField.value)}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n controllerField.onChange(e);\n const updatedHeaders = [...watchedHeaders];\n updatedHeaders[index] = { name: e.target.value, value: updatedHeaders[index]?.value ?? '' };\n syncHeadersToParent(updatedHeaders);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={7}>\n <Controller\n control={headersForm.control}\n name={`headers.${index}.value`}\n render={({ field: controllerField, fieldState }) => (\n <TextField\n {...controllerField}\n fullWidth\n label=\"Header value\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n controllerField.onChange(e);\n const updatedHeaders = [...watchedHeaders];\n updatedHeaders[index] = { name: updatedHeaders[index]?.name ?? '', value: e.target.value };\n syncHeadersToParent(updatedHeaders);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={1}>\n <IconButton\n disabled={isReadonly}\n aria-label={`Remove header ${watchedHeaders[index]?.name || index}`}\n onClick={() => {\n remove(index);\n const updatedHeaders = watchedHeaders.filter((_, i) => i !== index);\n syncHeadersToParent(updatedHeaders);\n }}\n >\n <MinusIcon />\n </IconButton>\n </Grid>\n </Fragment>\n ))\n ) : (\n <Grid item xs={4}>\n <Typography sx={{ fontStyle: 'italic' }}>None</Typography>\n </Grid>\n )}\n {hasDuplicates && (\n <Grid item xs={12}>\n <Typography variant=\"body2\" color=\"error\">\n Duplicate header names detected. Each header name must be unique.\n </Typography>\n </Grid>\n )}\n <Grid item xs={12} sx={{ paddingTop: '0px !important', paddingLeft: '5px !important' }}>\n <IconButton disabled={isReadonly} onClick={() => append({ name: '', value: '' })}>\n <PlusIcon />\n </IconButton>\n </Grid>\n </Grid>\n\n <Controller\n name=\"Secret\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Secret\"\n value={value.proxy?.spec.secret || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n if (draft.proxy !== undefined) {\n draft.proxy.spec.secret = e.target.value;\n }\n })\n );\n }}\n />\n )}\n />\n </>\n ),\n },\n {\n label: strDirect,\n content: (\n <Controller\n name=\"URL\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"URL\"\n value={value.directUrl || ''}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n InputProps={{\n readOnly: isReadonly,\n }}\n InputLabelProps={{ shrink: isReadonly ? true : undefined }}\n onChange={(e) => {\n field.onChange(e);\n onChange(\n produce(value, (draft) => {\n draft.directUrl = e.target.value;\n })\n );\n }}\n />\n )}\n />\n ),\n },\n ];\n\n // Use of findIndex instead of providing hardcoded values to avoid desynchronisatio or\n // bug in case the tabs get eventually swapped in the future.\n const directModeId = tabs.findIndex((tab) => tab.label === strDirect);\n const proxyModeId = tabs.findIndex((tab) => tab.label === strProxy);\n\n // Set defaultTab to the mode that this datasource is currently relying on.\n const defaultTab = value.proxy ? proxyModeId : directModeId;\n\n // For better user experience, save previous states in mind for both mode.\n // This avoids losing everything when the user changes their mind back.\n const [previousSpecDirect, setPreviousSpecDirect] = useState(initialSpecDirect);\n const [previousSpecProxy, setPreviousSpecProxy] = useState(initialSpecProxy);\n\n // When changing mode, remove previous mode's config + append default values for the new mode.\n const handleModeChange = (v: number): void => {\n if (tabs[v]?.label === strDirect) {\n setPreviousSpecProxy(value);\n\n // Copy all settings (for example, scrapeInterval), except 'proxy'\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { proxy, ...newValue } = value;\n onChange({ ...newValue, directUrl: previousSpecDirect.directUrl });\n } else if (tabs[v]?.label === strProxy) {\n setPreviousSpecDirect(value);\n\n // Copy all settings (for example, scrapeInterval), except 'directUrl'\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { directUrl, ...newValue } = value;\n onChange({ ...newValue, proxy: previousSpecProxy.proxy });\n }\n };\n\n return (\n <>\n <Typography variant=\"h4\" mt={2}>\n HTTP Settings\n </Typography>\n <OptionsEditorRadios\n isReadonly={isReadonly}\n tabs={tabs}\n defaultTab={defaultTab}\n onModeChange={handleModeChange}\n />\n </>\n );\n}\n"],"names":["Grid","IconButton","MenuItem","TextField","Typography","React","Fragment","useState","produce","Controller","useFieldArray","useForm","MinusIcon","PlusIcon","OptionsEditorRadios","HTTPSettingsEditor","props","value","onChange","isReadonly","initialSpecDirect","initialSpecProxy","strDirect","strProxy","directUrl","undefined","proxy","Object","assign","headersForm","defaultValues","headers","entries","spec","map","name","headerValue","fields","append","remove","control","watchedHeaders","watch","nameMap","Map","duplicateNames","Set","forEach","count","get","set","add","hasDuplicates","size","syncHeadersToParent","headersObject","draft","keys","length","tabs","label","content","render","field","fieldState","fullWidth","url","error","helperText","message","InputProps","readOnly","InputLabelProps","shrink","e","target","sx","mb","variant","container","spacing","allowedEndpoints","endpointPattern","method","i","item","xs","itemIndex","select","disabled","onClick","filter","fontStyle","paddingTop","paddingLeft","index","controllerField","has","updatedHeaders","aria-label","_","id","color","secret","directModeId","findIndex","tab","proxyModeId","defaultTab","previousSpecDirect","setPreviousSpecDirect","previousSpecProxy","setPreviousSpecProxy","handleModeChange","v","newValue","mt","onModeChange"],"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,IAAI,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,UAAU,QAAQ,gBAAgB;AAClF,OAAOC,SAASC,QAAQ,EAAgBC,QAAQ,QAAQ,QAAQ;AAChE,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,UAAU,EAAEC,aAAa,EAAEC,OAAO,QAAQ,kBAAkB;AACrE,OAAOC,eAAe,wBAAwB;AAC9C,OAAOC,cAAc,uBAAuB;AAG5C,SAASC,mBAAmB,QAAQ,yBAAyB;AAmB7D,OAAO,SAASC,mBAAmBC,KAAyB;IAC1D,MAA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F,UAAU,GAAGlG;YAC/BC,SAAS;gBAAE,GAAGiG,QAAQ;gBAAE3F,WAAWqF,mBAAmBrF,SAAS;YAAC;QAClE,OAAO,IAAImC,IAAI,CAACuD,EAAE,EAAEtD,UAAUrC,UAAU;YACtCuF,sBAAsB7F;YAEtB,sEAAsE;YACtE,6DAA6D;YAC7D,MAAM,EAAEO,SAAS,EAAE,GAAG2F,UAAU,GAAGlG;YACnCC,SAAS;gBAAE,GAAGiG,QAAQ;gBAAEzF,OAAOqF,kBAAkBrF,KAAK;YAAC;QACzD;IACF;IAEA,qBACE;;0BACE,KAACtB;gBAAW0E,SAAQ;gBAAKsC,IAAI;0BAAG;;0BAGhC,KAACtG;gBACCK,YAAYA;gBACZwC,MAAMA;gBACNiD,YAAYA;gBACZS,cAAcJ;;;;AAItB"}
@@ -1,5 +1,5 @@
1
1
  import { AbsoluteTimeRange, AnnotationData, UnknownSpec } from '@perses-dev/spec';
2
- import { DatasourceStore, VariableStateMap } from '@perses-dev/plugin-system';
2
+ import { DatasourceStore, VariableStateMap } from '../runtime';
3
3
  import { Plugin } from './plugin-base';
4
4
  /**
5
5
  * An object containing all the dependencies of a AnnotationQuery.
@@ -1 +1 @@
1
- {"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../../src/model/annotations.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC9C;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAgB,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IACxE,iBAA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ACjC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/annotations.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\nimport { AbsoluteTimeRange, AnnotationData, UnknownSpec } from '@perses-dev/spec';\nimport { DatasourceStore, VariableStateMap } from '@perses-dev/plugin-system';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a AnnotationQuery.\n */\nexport type AnnotationQueryPluginDependencies = {\n /**\n * Returns a list of variables name this annotation query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running annotation queries.\n */\nexport interface AnnotationPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getAnnotationData: (spec: Spec, ctx: AnnotationContext, abortSignal?: AbortSignal) => Promise<AnnotationData[]>;\n dependsOn?: (spec: Spec, ctx: AnnotationContext) => AnnotationQueryPluginDependencies;\n}\n\n/**\n * Context available to AnnotationQuery plugins at runtime.\n */\nexport interface AnnotationContext {\n datasourceStore: DatasourceStore;\n absoluteTimeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n}\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;AAwBjC;;CAEC,GACD,WAIC"}
1
+ {"version":3,"sources":["../../src/model/annotations.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\nimport { AbsoluteTimeRange, AnnotationData, UnknownSpec } from '@perses-dev/spec';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a AnnotationQuery.\n */\nexport type AnnotationQueryPluginDependencies = {\n /**\n * Returns a list of variables name this annotation query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running annotation queries.\n */\nexport interface AnnotationPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getAnnotationData: (spec: Spec, ctx: AnnotationContext, abortSignal?: AbortSignal) => Promise<AnnotationData[]>;\n dependsOn?: (spec: Spec, ctx: AnnotationContext) => AnnotationQueryPluginDependencies;\n}\n\n/**\n * Context available to AnnotationQuery plugins at runtime.\n */\nexport interface AnnotationContext {\n datasourceStore: DatasourceStore;\n absoluteTimeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n}\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;AAwBjC;;CAEC,GACD,WAIC"}
@@ -1,5 +1,6 @@
1
1
  import { AbsoluteTimeRange, UnknownSpec, LogData, QueryDefinition } from '@perses-dev/spec';
2
- import { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system';
2
+ import { DatasourceStore, VariableStateMap } from '../runtime';
3
+ import { Plugin } from './plugin-base';
3
4
  export interface LogQueryResult {
4
5
  logs: LogData;
5
6
  timeRange: AbsoluteTimeRange;
@@ -1 +1 @@
1
- {"version":3,"file":"log-queries.d.ts","sourceRoot":"","sources":["../../src/model/log-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAEtF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,CAAC,EAAE;QACT,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,EAAE,gBAAgB,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,0BAA0B,GAAG;IAChC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,WAAW,cAAc,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IACtE,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACrG,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,KAAK,0BAA0B,CAAC;IAC7E,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,KAAK,eAAe,GAAG,IAAI,CAAC;CAClF"}
1
+ {"version":3,"file":"log-queries.d.ts","sourceRoot":"","sources":["../../src/model/log-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,iBAAiB,CAAC;IAC7B,QAAQ,CAAC,EAAE;QACT,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,EAAE,gBAAgB,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,KAAK,0BAA0B,GAAG;IAChC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF,MAAM,WAAW,cAAc,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IACtE,UAAU,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,EAAE,WAAW,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IACrG,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,KAAK,0BAA0B,CAAC;IAC7E,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,eAAe,KAAK,eAAe,GAAG,IAAI,CAAC;CAClF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/log-queries.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\nimport { AbsoluteTimeRange, UnknownSpec, LogData, QueryDefinition } from '@perses-dev/spec';\nimport { DatasourceStore, Plugin, VariableStateMap } from '@perses-dev/plugin-system';\n\nexport interface LogQueryResult {\n logs: LogData;\n timeRange: AbsoluteTimeRange;\n metadata?: {\n executedQueryString: string;\n };\n}\n\nexport interface LogQueryContext {\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n refreshKey: string;\n}\n\ntype LogQueryPluginDependencies = {\n variables?: string[];\n};\n\nexport interface LogQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getLogData: (spec: Spec, ctx: LogQueryContext, abortSignal?: AbortSignal) => Promise<LogQueryResult>;\n dependsOn?: (spec: Spec, ctx: LogQueryContext) => LogQueryPluginDependencies;\n createVolumeQuery?: (spec: Spec, ctx: LogQueryContext) => QueryDefinition | null;\n}\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;AAwBjC,WAIC"}
1
+ {"version":3,"sources":["../../src/model/log-queries.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\nimport { AbsoluteTimeRange, UnknownSpec, LogData, QueryDefinition } from '@perses-dev/spec';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\nexport interface LogQueryResult {\n logs: LogData;\n timeRange: AbsoluteTimeRange;\n metadata?: {\n executedQueryString: string;\n };\n}\n\nexport interface LogQueryContext {\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n refreshKey: string;\n}\n\ntype LogQueryPluginDependencies = {\n variables?: string[];\n};\n\nexport interface LogQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getLogData: (spec: Spec, ctx: LogQueryContext, abortSignal?: AbortSignal) => Promise<LogQueryResult>;\n dependsOn?: (spec: Spec, ctx: LogQueryContext) => LogQueryPluginDependencies;\n createVolumeQuery?: (spec: Spec, ctx: LogQueryContext) => QueryDefinition | null;\n}\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;AAyBjC,WAIC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/plugin-system",
3
- "version": "0.54.0-beta.7",
3
+ "version": "0.54.0-beta.8",
4
4
  "description": "The plugin feature in Pereses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -29,10 +29,10 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@module-federation/enhanced": "^2.3.3",
32
- "@perses-dev/components": "0.54.0-beta.7",
32
+ "@perses-dev/components": "0.54.0-beta.8",
33
33
  "@perses-dev/core": "0.53.0",
34
- "@perses-dev/spec": "0.2.0-beta.3",
35
- "@perses-dev/client": "0.54.0-beta.7",
34
+ "@perses-dev/spec": "0.2.0-beta.6",
35
+ "@perses-dev/client": "0.54.0-beta.8",
36
36
  "date-fns": "^4.1.0",
37
37
  "date-fns-tz": "^3.2.0",
38
38
  "immer": "^10.1.1",