@perses-dev/plugin-system 0.51.0-beta.0 → 0.51.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +2 -2
- package/dist/cjs/remote/PluginRuntime.js +16 -16
- package/dist/cjs/runtime/plugin-registry.js +13 -4
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.js +16 -16
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +13 -4
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/package.json +7 -9
- package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +0 -41
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +0 -34
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -42
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -101
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemVariables.js +0 -42
- package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +0 -41
- package/dist/cjs/stories/shared-utils/decorators/index.js +0 -35
- package/dist/cjs/stories/shared-utils/index.js +0 -30
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.js +0 -33
- package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +0 -4
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +0 -26
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -39
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -95
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js +0 -39
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.js +0 -33
- package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +0 -1
- package/dist/stories/shared-utils/decorators/index.d.ts +0 -7
- package/dist/stories/shared-utils/decorators/index.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/index.js +0 -20
- package/dist/stories/shared-utils/decorators/index.js.map +0 -1
- package/dist/stories/shared-utils/index.d.ts +0 -2
- package/dist/stories/shared-utils/index.d.ts.map +0 -1
- package/dist/stories/shared-utils/index.js +0 -15
- package/dist/stories/shared-utils/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"sourcesContent":["// Copyright 2023 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 React, { DispatchWithoutAction, ReactElement, useState } from 'react';\nimport {\n Box,\n Typography,\n Switch,\n TextField,\n Grid,\n FormControlLabel,\n MenuItem,\n Stack,\n ClickAwayListener,\n Divider,\n} from '@mui/material';\nimport { VariableDefinition, ListVariableDefinition, Action } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary, FormActions } from '@perses-dev/components';\nimport { Control, Controller, FormProvider, SubmitHandler, useForm, useFormContext, useWatch } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { getSubmitText, getTitleAction } from '../../../utils';\nimport { VARIABLE_TYPES } from '../variable-model';\nimport { PluginEditor } from '../../PluginEditor';\nimport { useValidationSchemas } from '../../../context';\nimport { VariableListPreview, VariablePreview } from './VariablePreview';\n\nfunction FallbackPreview(): ReactElement {\n return <div>Error previewing values</div>;\n}\n\ninterface KindVariableEditorFormProps {\n action: Action;\n control: Control<VariableDefinition>;\n}\n\nfunction TextVariableEditorForm({ action, control }: KindVariableEditorFormProps): ReactElement {\n return (\n <>\n <Typography py={1} variant=\"subtitle1\">\n Text Options\n </Typography>\n <Stack spacing={2}>\n <Controller\n control={control}\n name=\"spec.value\"\n render={({ field, fieldState }) => (\n <>\n <Box>\n <VariablePreview values={[field.value]} />\n </Box>\n <TextField\n {...field}\n label=\"Value\"\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 />\n <Controller\n control={control}\n name=\"spec.constant\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Constant\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={field.value ?? false}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n </Stack>\n </>\n );\n}\n\nfunction ListVariableEditorForm({ action, control }: KindVariableEditorFormProps): ReactElement {\n const form = useFormContext<VariableDefinition>();\n /** We use `previewSpec` to know when to explicitly update the\n * spec that will be used for preview. 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 */\n const [previewSpec, setPreviewSpec] = useState<ListVariableDefinition>(form.getValues() as ListVariableDefinition);\n const refreshPreview = (): void => {\n setPreviewSpec(form.getValues() as ListVariableDefinition);\n };\n\n const kind = useWatch<VariableDefinition, 'spec.plugin.kind'>({ control: control, name: 'spec.plugin.kind' });\n const _allowAllValue = useWatch<VariableDefinition, 'spec.allowAllValue'>({\n control: control,\n name: 'spec.allowAllValue',\n });\n\n // When variable kind is selected we need to provide default values\n // TODO: check if react-hook-form has a better way to do this\n const values = form.getValues() as ListVariableDefinition;\n if (values.spec.allowAllValue === undefined) {\n form.setValue('spec.allowAllValue', false);\n }\n\n if (values.spec.allowMultiple === undefined) {\n form.setValue('spec.allowMultiple', false);\n }\n\n return (\n <>\n <Typography py={1} variant=\"subtitle1\">\n List Options\n </Typography>\n <Stack spacing={2} mb={2}>\n {kind ? (\n <Box>\n <ErrorBoundary FallbackComponent={FallbackPreview} resetKeys={[previewSpec]}>\n <VariableListPreview definition={previewSpec} onRefresh={refreshPreview} />\n </ErrorBoundary>\n </Box>\n ) : (\n <VariablePreview isLoading={true} />\n )}\n\n <Stack>\n {/** Hack?: Cool technique to refresh the preview to simulate onBlur event */}\n <ClickAwayListener onClickAway={() => refreshPreview()}>\n <Box />\n </ClickAwayListener>\n {/** **/}\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Controller\n control={control}\n name=\"spec.plugin\"\n render={({ field }) => (\n <PluginEditor\n width=\"100%\"\n pluginTypes={['Variable']}\n pluginKindLabel=\"Source\"\n value={{\n selection: {\n type: 'Variable',\n kind: field.value?.kind ?? 'StaticListVariable',\n },\n spec: field.value?.spec ?? { values: [] },\n }}\n isReadonly={action === 'read'}\n onChange={(v) => {\n field.onChange({ kind: v.selection.kind, spec: v.spec });\n }}\n />\n )}\n />\n </ErrorBoundary>\n </Stack>\n\n <Stack>\n <Controller\n control={control}\n name=\"spec.capturingRegexp\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n label=\"Capturing Regexp Filter\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n value={field.value ?? ''}\n onChange={(event) => {\n if (event.target.value === '') {\n field.onChange(undefined);\n } else {\n field.onChange(event);\n }\n }}\n helperText={\n fieldState.error?.message\n ? fieldState.error.message\n : 'Optional, if you want to filter on captured result.'\n }\n />\n )}\n />\n </Stack>\n\n <Stack>\n <Controller\n control={control}\n name=\"spec.sort\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n fullWidth\n label=\"Sort\"\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 ?? 'none'}\n onChange={(event) => {\n field.onChange(event);\n }}\n >\n <MenuItem value=\"none\">None</MenuItem>\n <MenuItem value=\"alphabetical-asc\">Alphabetical, asc</MenuItem>\n <MenuItem value=\"alphabetical-desc\">Alphabetical, desc</MenuItem>\n <MenuItem value=\"numerical-asc\">Numerical, asc</MenuItem>\n <MenuItem value=\"numerical-desc\">Numerical, desc</MenuItem>\n <MenuItem value=\"alphabetical-ci-asc\">Alphabetical, case-insensitive, asc</MenuItem>\n <MenuItem value=\"alphabetical-ci-desc\">Alphabetical, case-insensitive, desc</MenuItem>\n </TextField>\n )}\n />\n </Stack>\n </Stack>\n\n <Divider />\n\n <Typography py={1} variant=\"subtitle1\">\n Dropdown Options\n </Typography>\n <Stack spacing=\"2\">\n <Stack>\n <Controller\n control={control}\n name=\"spec.allowMultiple\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Allow Multiple Values\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={field.value ?? false}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n <Typography variant=\"caption\">Enables multiple values to be selected at the same time</Typography>\n </Stack>\n <Stack>\n <Controller\n control={control}\n name=\"spec.allowAllValue\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Allow All option\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={field.value ?? false}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n <Typography mb={1} variant=\"caption\">\n Enables an option to include all variable values\n </Typography>\n {_allowAllValue && (\n <Controller\n control={control}\n name=\"spec.customAllValue\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Custom All Value\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={\n fieldState.error?.message\n ? fieldState.error.message\n : 'When All is selected, this value will be used'\n }\n value={field.value ?? ''}\n onChange={(event) => {\n if (event.target.value === '') {\n field.onChange(undefined);\n } else {\n field.onChange(event);\n }\n }}\n />\n )}\n />\n )}\n </Stack>\n </Stack>\n </>\n );\n}\n\ninterface VariableEditorFormProps {\n initialVariableDefinition: VariableDefinition;\n action: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onActionChange?: (action: Action) => void;\n onSave: (def: VariableDefinition) => void;\n onClose: () => void;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function VariableEditorForm({\n initialVariableDefinition,\n action,\n isDraft,\n isReadonly,\n onActionChange,\n onSave,\n onClose,\n onDelete,\n}: VariableEditorFormProps): ReactElement {\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const { variableEditorSchema } = useValidationSchemas();\n const form = useForm<VariableDefinition>({\n resolver: zodResolver(variableEditorSchema),\n mode: 'onBlur',\n defaultValues: initialVariableDefinition,\n });\n\n const kind = useWatch({ control: form.control, name: 'kind' });\n\n function clearFormData(data: VariableDefinition): VariableDefinition {\n const result = { ...data };\n if (\n result.spec.display?.name === undefined &&\n result.spec.display?.description === undefined &&\n result.spec.display?.hidden === undefined\n ) {\n delete result.spec.display;\n }\n return result;\n }\n\n const processForm: SubmitHandler<VariableDefinition> = (data: VariableDefinition) => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(clearFormData(data));\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel(): void {\n if (JSON.stringify(initialVariableDefinition) !== JSON.stringify(clearFormData(form.getValues()))) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Variable</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={8}>\n <Controller\n control={form.control}\n name=\"spec.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={4}>\n <Controller\n control={form.control}\n name=\"spec.display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"spec.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 </Grid>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"kind\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n fullWidth\n label=\"Type\"\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 ?? 'TextVariable'}\n onChange={(event) => {\n field.onChange(event);\n }}\n >\n {VARIABLE_TYPES.map((v) => (\n <MenuItem key={v.kind} value={v.kind}>\n {v.label}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n </Grid>\n\n <Divider />\n\n {kind === 'TextVariable' && (\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TextVariableEditorForm action={action} control={form.control} />\n </ErrorBoundary>\n )}\n {kind === 'ListVariable' && (\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <ListVariableEditorForm action={action} control={form.control} />\n </ErrorBoundary>\n )}\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":["React","useState","Box","Typography","Switch","TextField","Grid","FormControlLabel","MenuItem","Stack","ClickAwayListener","Divider","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","FormActions","Controller","FormProvider","useForm","useFormContext","useWatch","zodResolver","getSubmitText","getTitleAction","VARIABLE_TYPES","PluginEditor","useValidationSchemas","VariableListPreview","VariablePreview","FallbackPreview","div","TextVariableEditorForm","action","control","py","variant","spacing","name","render","field","fieldState","values","value","label","InputLabelProps","shrink","undefined","InputProps","readOnly","error","helperText","message","onChange","event","checked","ListVariableEditorForm","form","previewSpec","setPreviewSpec","getValues","refreshPreview","kind","_allowAllValue","spec","allowAllValue","setValue","allowMultiple","mb","FallbackComponent","resetKeys","definition","onRefresh","isLoading","onClickAway","width","pluginTypes","pluginKindLabel","selection","type","isReadonly","v","target","select","fullWidth","VariableEditorForm","initialVariableDefinition","isDraft","onActionChange","onSave","onClose","onDelete","isDiscardDialogOpened","setDiscardDialogOpened","titleAction","submitText","variableEditorSchema","resolver","mode","defaultValues","clearFormData","data","result","display","description","hidden","processForm","handleCancel","JSON","stringify","sx","alignItems","padding","theme","borderBottom","palette","divider","isValid","formState","onSubmit","handleSubmit","onCancel","overflowY","container","item","xs","required","disabled","map","isOpen","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAA8CC,QAAQ,QAAQ,QAAQ;AAC7E,SACEC,GAAG,EACHC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,QAAQ,EACRC,KAAK,EACLC,iBAAiB,EACjBC,OAAO,QACF,gBAAgB;AAEvB,SAASC,gCAAgC,EAAEC,UAAU,EAAEC,aAAa,EAAEC,WAAW,QAAQ,yBAAyB;AAClH,SAAkBC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,EAAEC,cAAc,EAAEC,QAAQ,QAAQ,kBAAkB;AACtH,SAASC,WAAW,QAAQ,0BAA0B;AACtD,SAASC,aAAa,EAAEC,cAAc,QAAQ,iBAAiB;AAC/D,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,oBAAoB,QAAQ,mBAAmB;AACxD,SAASC,mBAA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AAK,IAAI;4CACtBU,UAAU,CAACC;gDACTd,MAAMa,QAAQ,CAACC;4CACjB;;;;0CAKR,KAAC/C;gCAAKqH,IAAI;gCAACC,IAAI;0CACb,cAAA,KAAC5G;oCACCiB,SAASuB,KAAKvB,OAAO;oCACrBI,MAAK;oCACLC,QAAQ,CAAC,EAAEC,KAAK,EAAEC,UAAU,EAAE,iBAC5B,KAACnC;4CACC6E,MAAM;4CACL,GAAG3C,KAAK;4CACT4C,SAAS;4CACTxC,OAAM;4CACNC,iBAAiB;gDAAEC,QAAQb,WAAW,SAAS,OAAOc;4CAAU;4CAChEC,YAAY;gDACVC,UAAUhB,WAAW;4CACvB;4CACAiB,OAAO,CAAC,CAACT,WAAWS,KAAK;4CACzBC,YAAYV,WAAWS,KAAK,EAAEE;4CAC9BT,OAAOH,MAAMG,KAAK,IAAI;4CACtBU,UAAU,CAACC;gDACTd,MAAMa,QAAQ,CAACC;4CACjB;sDAEC7B,eAAeuG,GAAG,CAAC,CAAC/C,kBACnB,KAACxE;oDAAsBkC,OAAOsC,EAAEnB,IAAI;8DACjCmB,EAAErC,KAAK;mDADKqC,EAAEnB,IAAI;;;;;;kCAUjC,KAAClD;oBAEAkD,SAAS,gCACR,KAAC/C;wBAAcsD,mBAAmBvD;kCAChC,cAAA,KAACkB;4BAAuBC,QAAQA;4BAAQC,SAASuB,KAAKvB,OAAO;;;oBAGhE4B,SAAS,gCACR,KAAC/C;wBAAcsD,mBAAmBvD;kCAChC,cAAA,KAAC0C;4BAAuBvB,QAAQA;4BAAQC,SAASuB,KAAKvB,OAAO;;;;;0BAInE,KAACrB;gBACC2F,aAAY;gBACZyB,QAAQrC;gBACR6B,UAAU;oBACR5B,uBAAuB;gBACzB;gBACAqC,kBAAkB;oBAChBrC,uBAAuB;oBACvBH;gBACF;;;;AAIR"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"sourcesContent":["// Copyright 2023 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 React, { DispatchWithoutAction, ReactElement, useState } from 'react';\nimport {\n Box,\n Typography,\n Switch,\n TextField,\n Grid,\n FormControlLabel,\n MenuItem,\n Stack,\n ClickAwayListener,\n Divider,\n} from '@mui/material';\nimport { VariableDefinition, ListVariableDefinition, Action } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary, FormActions } from '@perses-dev/components';\nimport { Control, Controller, FormProvider, SubmitHandler, useForm, useFormContext, useWatch } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { getSubmitText, getTitleAction } from '../../../utils';\nimport { VARIABLE_TYPES } from '../variable-model';\nimport { PluginEditor } from '../../PluginEditor';\nimport { useValidationSchemas } from '../../../context';\nimport { VariableListPreview, VariablePreview } from './VariablePreview';\n\nfunction FallbackPreview(): ReactElement {\n return <div>Error previewing values</div>;\n}\n\ninterface KindVariableEditorFormProps {\n action: Action;\n control: Control<VariableDefinition>;\n}\n\nfunction TextVariableEditorForm({ action, control }: KindVariableEditorFormProps): ReactElement {\n return (\n <>\n <Typography py={1} variant=\"subtitle1\">\n Text Options\n </Typography>\n <Stack spacing={2}>\n <Controller\n control={control}\n name=\"spec.value\"\n render={({ field, fieldState }) => (\n <>\n <Box>\n <VariablePreview values={[field.value]} />\n </Box>\n <TextField\n {...field}\n label=\"Value\"\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 />\n <Controller\n control={control}\n name=\"spec.constant\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Constant\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={field.value ?? false}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n </Stack>\n </>\n );\n}\n\nfunction ListVariableEditorForm({ action, control }: KindVariableEditorFormProps): ReactElement {\n const form = useFormContext<VariableDefinition>();\n /** We use `previewSpec` to know when to explicitly update the\n * spec that will be used for preview. 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 */\n const [previewSpec, setPreviewSpec] = useState<ListVariableDefinition>(form.getValues() as ListVariableDefinition);\n const refreshPreview = (): void => {\n setPreviewSpec(form.getValues() as ListVariableDefinition);\n };\n\n const kind = useWatch<VariableDefinition, 'spec.plugin.kind'>({ control: control, name: 'spec.plugin.kind' });\n const _allowAllValue = useWatch<VariableDefinition, 'spec.allowAllValue'>({\n control: control,\n name: 'spec.allowAllValue',\n });\n\n // When variable kind is selected we need to provide default values\n // TODO: check if react-hook-form has a better way to do this\n const values = form.getValues() as ListVariableDefinition;\n if (values.spec.allowAllValue === undefined) {\n form.setValue('spec.allowAllValue', false);\n }\n\n if (values.spec.allowMultiple === undefined) {\n form.setValue('spec.allowMultiple', false);\n }\n\n return (\n <>\n <Typography py={1} variant=\"subtitle1\">\n List Options\n </Typography>\n <Stack spacing={2} mb={2}>\n {kind ? (\n <Box>\n <ErrorBoundary FallbackComponent={FallbackPreview} resetKeys={[previewSpec]}>\n <VariableListPreview definition={previewSpec} onRefresh={refreshPreview} />\n </ErrorBoundary>\n </Box>\n ) : (\n <VariablePreview isLoading={true} />\n )}\n\n <Stack>\n {/** Hack?: Cool technique to refresh the preview to simulate onBlur event */}\n <ClickAwayListener onClickAway={() => refreshPreview()}>\n <Box />\n </ClickAwayListener>\n {/** **/}\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Controller\n control={control}\n name=\"spec.plugin\"\n render={({ field }) => (\n <PluginEditor\n width=\"100%\"\n pluginTypes={['Variable']}\n pluginKindLabel=\"Source\"\n value={{\n selection: {\n type: 'Variable',\n kind: field.value?.kind ?? 'StaticListVariable',\n },\n spec: field.value?.spec ?? { values: [] },\n }}\n isReadonly={action === 'read'}\n onChange={(v) => {\n field.onChange({ kind: v.selection.kind, spec: v.spec });\n }}\n />\n )}\n />\n </ErrorBoundary>\n </Stack>\n\n <Stack>\n <Controller\n control={control}\n name=\"spec.capturingRegexp\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n label=\"Capturing Regexp Filter\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n value={field.value ?? ''}\n onChange={(event) => {\n if (event.target.value === '') {\n field.onChange(undefined);\n } else {\n field.onChange(event);\n }\n }}\n helperText={\n fieldState.error?.message\n ? fieldState.error.message\n : 'Optional, if you want to filter on captured result.'\n }\n />\n )}\n />\n </Stack>\n\n <Stack>\n <Controller\n control={control}\n name=\"spec.sort\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n fullWidth\n label=\"Sort\"\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 ?? 'none'}\n onChange={(event) => {\n field.onChange(event);\n }}\n >\n <MenuItem value=\"none\">None</MenuItem>\n <MenuItem value=\"alphabetical-asc\">Alphabetical, asc</MenuItem>\n <MenuItem value=\"alphabetical-desc\">Alphabetical, desc</MenuItem>\n <MenuItem value=\"numerical-asc\">Numerical, asc</MenuItem>\n <MenuItem value=\"numerical-desc\">Numerical, desc</MenuItem>\n <MenuItem value=\"alphabetical-ci-asc\">Alphabetical, case-insensitive, asc</MenuItem>\n <MenuItem value=\"alphabetical-ci-desc\">Alphabetical, case-insensitive, desc</MenuItem>\n </TextField>\n )}\n />\n </Stack>\n </Stack>\n\n <Divider />\n\n <Typography py={1} variant=\"subtitle1\">\n Dropdown Options\n </Typography>\n <Stack spacing=\"2\">\n <Stack>\n <Controller\n control={control}\n name=\"spec.allowMultiple\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Allow Multiple Values\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={field.value ?? false}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n <Typography variant=\"caption\">Enables multiple values to be selected at the same time</Typography>\n </Stack>\n <Stack>\n <Controller\n control={control}\n name=\"spec.allowAllValue\"\n render={({ field }) => (\n <FormControlLabel\n label=\"Allow All option\"\n control={\n <Switch\n {...field}\n checked={!!field.value}\n readOnly={action === 'read'}\n value={field.value ?? false}\n onChange={(event) => {\n if (action === 'read') return; // ReadOnly prop is not blocking user interaction...\n field.onChange(event);\n }}\n />\n }\n />\n )}\n />\n <Typography mb={1} variant=\"caption\">\n Enables an option to include all variable values\n </Typography>\n {_allowAllValue && (\n <Controller\n control={control}\n name=\"spec.customAllValue\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Custom All Value\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={\n fieldState.error?.message\n ? fieldState.error.message\n : 'When All is selected, this value will be used'\n }\n value={field.value ?? ''}\n onChange={(event) => {\n if (event.target.value === '') {\n field.onChange(undefined);\n } else {\n field.onChange(event);\n }\n }}\n />\n )}\n />\n )}\n </Stack>\n </Stack>\n </>\n );\n}\n\ninterface VariableEditorFormProps {\n initialVariableDefinition: VariableDefinition;\n action: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onActionChange?: (action: Action) => void;\n onSave: (def: VariableDefinition) => void;\n onClose: () => void;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function VariableEditorForm({\n initialVariableDefinition,\n action,\n isDraft,\n isReadonly,\n onActionChange,\n onSave,\n onClose,\n onDelete,\n}: VariableEditorFormProps): ReactElement {\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const { variableEditorSchema } = useValidationSchemas();\n const form = useForm<VariableDefinition>({\n resolver: zodResolver(variableEditorSchema),\n mode: 'onBlur',\n defaultValues: initialVariableDefinition,\n });\n\n const kind = useWatch({ control: form.control, name: 'kind' });\n\n function clearFormData(data: VariableDefinition): VariableDefinition {\n const result = { ...data };\n if (\n result.spec.display?.name === undefined &&\n result.spec.display?.description === undefined &&\n result.spec.display?.hidden === undefined\n ) {\n delete result.spec.display;\n }\n return result;\n }\n\n const processForm: SubmitHandler<VariableDefinition> = (data: VariableDefinition) => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(clearFormData(data));\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel(): void {\n if (JSON.stringify(initialVariableDefinition) !== JSON.stringify(clearFormData(form.getValues()))) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Variable</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={8}>\n <Controller\n control={form.control}\n name=\"spec.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={4}>\n <Controller\n control={form.control}\n name=\"spec.display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Display Label\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n control={form.control}\n name=\"spec.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 </Grid>\n <Grid item xs={4}>\n <Controller\n control={form.control}\n name=\"kind\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n fullWidth\n label=\"Type\"\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 ?? 'TextVariable'}\n onChange={(event) => {\n field.onChange(event);\n }}\n >\n {VARIABLE_TYPES.map((v) => (\n <MenuItem key={v.kind} value={v.kind}>\n {v.label}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n </Grid>\n\n <Divider />\n\n {kind === 'TextVariable' && (\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <TextVariableEditorForm action={action} control={form.control} />\n </ErrorBoundary>\n )}\n {kind === 'ListVariable' && (\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <ListVariableEditorForm action={action} control={form.control} />\n </ErrorBoundary>\n )}\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":["React","useState","Box","Typography","Switch","TextField","Grid","FormControlLabel","MenuItem","Stack","ClickAwayListener","Divider","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","FormActions","Controller","FormProvider","useForm","useFormContext","useWatch","zodResolver","getSubmitText","getTitleAction","VARIABLE_TYPES","PluginEditor","useValidationSchemas","VariableListPreview","VariablePreview","FallbackPreview","div","TextVariableEditorForm","action","control","py","variant","spacing","name","render","field","fieldState","values","value","label","InputLabelProps","shrink","undefined","InputProps","readOnly","error","helperText","message","onChange","event","checked","ListVariableEditorForm","form","previewSpec","setPreviewSpec","getValues","refreshPreview","kind","_allowAllValue","spec","allowAllValue","setValue","allowMultiple","mb","FallbackComponent","resetKeys","definition","onRefresh","isLoading","onClickAway","width","pluginTypes","pluginKindLabel","selection","type","isReadonly","v","target","select","fullWidth","VariableEditorForm","initialVariableDefinition","isDraft","onActionChange","onSave","onClose","onDelete","isDiscardDialogOpened","setDiscardDialogOpened","titleAction","submitText","variableEditorSchema","resolver","mode","defaultValues","clearFormData","data","result","display","description","hidden","processForm","handleCancel","JSON","stringify","sx","alignItems","padding","theme","borderBottom","palette","divider","isValid","formState","onSubmit","handleSubmit","onCancel","overflowY","container","item","xs","required","disabled","map","isOpen","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;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AG,CAAC,CAAC/C,kBACnB,KAACxE;oDAAsBkC,OAAOsC,EAAEnB,IAAI;8DACjCmB,EAAErC,KAAK;mDADKqC,EAAEnB,IAAI;;;;;;kCAUjC,KAAClD;oBAEAkD,SAAS,gCACR,KAAC/C;wBAAcsD,mBAAmBvD;kCAChC,cAAA,KAACkB;4BAAuBC,QAAQA;4BAAQC,SAASuB,KAAKvB,OAAO;;;oBAGhE4B,SAAS,gCACR,KAAC/C;wBAAcsD,mBAAmBvD;kCAChC,cAAA,KAAC0C;4BAAuBvB,QAAQA;4BAAQC,SAASuB,KAAKvB,OAAO;;;;;0BAInE,KAACrB;gBACC2F,aAAY;gBACZyB,QAAQrC;gBACR6B,UAAU;oBACR5B,uBAAuB;gBACzB;gBACAqC,kBAAkB;oBAChBrC,uBAAuB;oBACvBH;gBACF;;;;AAIR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"sourcesContent":["// Copyright 2023 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 { ListVariableSpec, TextVariableDefinition, TextVariableSpec, VariableDefinition } from '@perses-dev/core';\n\nexport type VariableEditorState = {\n name: string;\n title?: string;\n kind: 'TextVariable' | 'ListVariable' | 'BuiltinVariable';\n description?: string;\n listVariableFields: Omit<ListVariableSpec, 'name' | 'display'>;\n textVariableFields: Omit<TextVariableSpec, 'name' | 'display'>;\n};\n\nexport function getInitialState(initialVariableDefinition: VariableDefinition): VariableEditorState {\n const textVariableFields: Omit<TextVariableSpec, 'name' | 'display'> = {\n value: (initialVariableDefinition as TextVariableDefinition).spec.value ?? '',\n constant: (initialVariableDefinition as TextVariableDefinition).spec.constant ?? false,\n };\n\n const listVariableFields: Omit<ListVariableSpec, 'name' | 'display'> = {\n allowMultiple: false,\n allowAllValue: false,\n customAllValue: undefined,\n capturingRegexp: undefined,\n sort: undefined,\n plugin: {\n kind: '',\n spec: {},\n },\n };\n if (initialVariableDefinition.kind === 'ListVariable') {\n listVariableFields.allowMultiple = initialVariableDefinition.spec.allowMultiple ?? false;\n listVariableFields.allowAllValue = initialVariableDefinition.spec.allowAllValue ?? false;\n listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;\n listVariableFields.capturingRegexp = initialVariableDefinition.spec.capturingRegexp;\n listVariableFields.sort = initialVariableDefinition.spec.sort;\n listVariableFields.plugin = initialVariableDefinition.spec.plugin;\n }\n\n return {\n name: initialVariableDefinition.spec.name,\n title: initialVariableDefinition.spec.display?.name ?? '',\n kind: initialVariableDefinition.kind,\n description: initialVariableDefinition.spec.display?.description ?? '',\n listVariableFields,\n textVariableFields,\n };\n}\n\nexport function getVariableDefinitionFromState(state: VariableEditorState): VariableDefinition {\n const { name, title, kind, description } = state;\n\n const display = { name: title, description: description };\n\n if (kind === 'TextVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n ...state.textVariableFields,\n },\n };\n }\n\n if (kind === 'ListVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n allowMultiple: state.listVariableFields.allowMultiple,\n allowAllValue: state.listVariableFields.allowAllValue,\n customAllValue: state.listVariableFields.customAllValue,\n capturingRegexp: state.listVariableFields.capturingRegexp,\n sort: state.listVariableFields.sort,\n plugin: state.listVariableFields.plugin,\n },\n };\n }\n throw new Error(`Unknown variable kind: ${kind}`);\n}\n"],"names":["getInitialState","initialVariableDefinition","textVariableFields","value","spec","constant","listVariableFields","allowMultiple","allowAllValue","customAllValue","undefined","capturingRegexp","sort","plugin","kind","name","title","display","description","getVariableDefinitionFromState","state","Error"],"mappings":"AAAA,oCAAoC;AACpC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,UAAU;QAAEF,MAAMC;QAAOE,aAAaA;IAAY;IAExD,IAAIJ,SAAS,gBAAgB;QAC3B,OAAO;YACLA;YACAV,MAAM;gBACJW;gBACAE;gBACA,GAAGG,MAAMlB,kBAAkB;YAC7B;QACF;IACF;IAEA,IAAIY,SAAS,gBAAgB;QAC3B,OAAO;YACLA;YACAV,MAAM;gBACJW;gBACAE;gBACAV,eAAea,MAAMd,kBAAkB,CAACC,aAAa;gBACrDC,eAAeY,MAAMd,kBAAkB,CAACE,aAAa;gBACrDC,gBAAgBW,MAAMd,kBAAkB,CAACG,cAAc;gBACvDE,iBAAiBS,MAAMd,kBAAkB,CAACK,eAAe;gBACzDC,MAAMQ,MAAMd,kBAAkB,CAACM,IAAI;gBACnCC,QAAQO,MAAMd,kBAAkB,CAACO,MAAM;YACzC;QACF;IACF;IACA,MAAM,IAAIQ,MAAM,CAAC,uBAAuB,EAAEP,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/Variables/VariableEditorForm/variable-editor-form-model.ts"],"sourcesContent":["// Copyright 2023 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 { ListVariableSpec, TextVariableDefinition, TextVariableSpec, VariableDefinition } from '@perses-dev/core';\n\nexport type VariableEditorState = {\n name: string;\n title?: string;\n kind: 'TextVariable' | 'ListVariable' | 'BuiltinVariable';\n description?: string;\n listVariableFields: Omit<ListVariableSpec, 'name' | 'display'>;\n textVariableFields: Omit<TextVariableSpec, 'name' | 'display'>;\n};\n\nexport function getInitialState(initialVariableDefinition: VariableDefinition): VariableEditorState {\n const textVariableFields: Omit<TextVariableSpec, 'name' | 'display'> = {\n value: (initialVariableDefinition as TextVariableDefinition).spec.value ?? '',\n constant: (initialVariableDefinition as TextVariableDefinition).spec.constant ?? false,\n };\n\n const listVariableFields: Omit<ListVariableSpec, 'name' | 'display'> = {\n allowMultiple: false,\n allowAllValue: false,\n customAllValue: undefined,\n capturingRegexp: undefined,\n sort: undefined,\n plugin: {\n kind: '',\n spec: {},\n },\n };\n if (initialVariableDefinition.kind === 'ListVariable') {\n listVariableFields.allowMultiple = initialVariableDefinition.spec.allowMultiple ?? false;\n listVariableFields.allowAllValue = initialVariableDefinition.spec.allowAllValue ?? false;\n listVariableFields.customAllValue = initialVariableDefinition.spec.customAllValue;\n listVariableFields.capturingRegexp = initialVariableDefinition.spec.capturingRegexp;\n listVariableFields.sort = initialVariableDefinition.spec.sort;\n listVariableFields.plugin = initialVariableDefinition.spec.plugin;\n }\n\n return {\n name: initialVariableDefinition.spec.name,\n title: initialVariableDefinition.spec.display?.name ?? '',\n kind: initialVariableDefinition.kind,\n description: initialVariableDefinition.spec.display?.description ?? '',\n listVariableFields,\n textVariableFields,\n };\n}\n\nexport function getVariableDefinitionFromState(state: VariableEditorState): VariableDefinition {\n const { name, title, kind, description } = state;\n\n const display = { name: title, description: description };\n\n if (kind === 'TextVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n ...state.textVariableFields,\n },\n };\n }\n\n if (kind === 'ListVariable') {\n return {\n kind,\n spec: {\n name,\n display,\n allowMultiple: state.listVariableFields.allowMultiple,\n allowAllValue: state.listVariableFields.allowAllValue,\n customAllValue: state.listVariableFields.customAllValue,\n capturingRegexp: state.listVariableFields.capturingRegexp,\n sort: state.listVariableFields.sort,\n plugin: state.listVariableFields.plugin,\n },\n };\n }\n throw new Error(`Unknown variable kind: ${kind}`);\n}\n"],"names":["getInitialState","initialVariableDefinition","textVariableFields","value","spec","constant","listVariableFields","allowMultiple","allowAllValue","customAllValue","undefined","capturingRegexp","sort","plugin","kind","name","title","display","description","getVariableDefinitionFromState","state","Error"],"mappings":"AA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GE;IAE3C,MAAMH,UAAU;QAAEF,MAAMC;QAAOE,aAAaA;IAAY;IAExD,IAAIJ,SAAS,gBAAgB;QAC3B,OAAO;YACLA;YACAV,MAAM;gBACJW;gBACAE;gBACA,GAAGG,MAAMlB,kBAAkB;YAC7B;QACF;IACF;IAEA,IAAIY,SAAS,gBAAgB;QAC3B,OAAO;YACLA;YACAV,MAAM;gBACJW;gBACAE;gBACAV,eAAea,MAAMd,kBAAkB,CAACC,aAAa;gBACrDC,eAAeY,MAAMd,kBAAkB,CAACE,aAAa;gBACrDC,gBAAgBW,MAAMd,kBAAkB,CAACG,cAAc;gBACvDE,iBAAiBS,MAAMd,kBAAkB,CAACK,eAAe;gBACzDC,MAAMQ,MAAMd,kBAAkB,CAACM,IAAI;gBACnCC,QAAQO,MAAMd,kBAAkB,CAACO,MAAM;YACzC;QACF;IACF;IACA,MAAM,IAAIQ,MAAM,CAAC,uBAAuB,EAAEP,MAAM;AAClD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/Variables/variable-model.ts"],"sourcesContent":["// Copyright 2024 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 { ListVariableDefinition } from '@perses-dev/core';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { VariableOption } from '../../model';\nimport { useDatasourceStore, usePlugin, useTimeRange, useAllVariableValues, VariableStateMap } from '../../runtime';\n\nexport function filterVariableList(data: VariableOption[], capturedRegexp: RegExp): VariableOption[] {\n const result: VariableOption[] = [];\n const filteredSet = new Set<string>();\n for (const variableValue of data) {\n const matches = variableValue.value.matchAll(capturedRegexp);\n let concat = '';\n for (const match of matches) {\n for (let i = 1; i < match.length; i++) {\n const m = match[i];\n if (m !== undefined) {\n concat = `${concat}${m}`;\n }\n }\n }\n if (concat !== '' && !filteredSet.has(concat)) {\n // like that we are avoiding to have duplicating variable value\n filteredSet.add(concat);\n result.push({ label: variableValue.label, value: concat });\n }\n }\n return result;\n}\n\nexport function useListVariablePluginValues(definition: ListVariableDefinition): UseQueryResult<VariableOption[]> {\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const datasourceStore = useDatasourceStore();\n const allVariables = useAllVariableValues();\n const { absoluteTimeRange: timeRange, refreshKey } = useTimeRange();\n\n const variablePluginCtx = { timeRange, datasourceStore, variables: allVariables };\n\n const spec = definition.spec.plugin.spec;\n const capturingRegexp =\n definition.spec.capturingRegexp !== undefined ? new RegExp(definition.spec.capturingRegexp, 'g') : undefined;\n\n let dependsOnVariables: string[] | undefined;\n if (variablePlugin?.dependsOn) {\n const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);\n dependsOnVariables = dependencies.variables;\n }\n\n const variables = useAllVariableValues(dependsOnVariables);\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n\n return useQuery({\n queryKey: [definition, variablesValueKey, timeRange, refreshKey],\n queryFn: async () => {\n const resp = await variablePlugin?.getVariableOptions(spec, { datasourceStore, variables, timeRange });\n if (resp === undefined) {\n return [];\n }\n if (!capturingRegexp) {\n return resp.data;\n }\n return filterVariableList(resp.data, capturingRegexp);\n },\n enabled: !!variablePlugin || waitToLoad,\n });\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nexport function getVariableValuesKey(v: VariableStateMap): string {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nexport const VARIABLE_TYPES = [\n { label: 'List', kind: 'ListVariable' },\n { label: 'Text', kind: 'TextVariable' },\n] as const;\n"],"names":["useQuery","useDatasourceStore","usePlugin","useTimeRange","useAllVariableValues","filterVariableList","data","capturedRegexp","result","filteredSet","Set","variableValue","matches","value","matchAll","concat","match","i","length","m","undefined","has","add","push","label","useListVariablePluginValues","definition","variablePlugin","spec","plugin","kind","datasourceStore","allVariables","absoluteTimeRange","timeRange","refreshKey","variablePluginCtx","variables","capturingRegexp","RegExp","dependsOnVariables","dependsOn","dependencies","waitToLoad","some","v","loading","variablesValueKey","getVariableValuesKey","queryKey","queryFn","resp","getVariableOptions","enabled","Object","values","map","JSON","stringify","join","VARIABLE_TYPES"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,QAAQ,QAAwB,wBAAwB;AAEjE,SAASC,kBAAkB,EAAEC,SAAS,EAAEC,YAAY,EAAEC,oBAAoB,QAA0B,gBAAgB;AAEpH,OAAO,SAASC,mBAAmBC,IAAsB,EAAEC,cAAsB;IAC/E,MAAMC,SAA2B,EAAE;IACnC,MAAMC,cAAc,IAAIC;IACxB,KAAK,MAAMC,iBAAiBL,KAAM;QAChC,MAAMM,UAAUD,cAAcE,KAAK,CAACC,QAAQ,CAACP;QAC7C,IAAIQ,SAAS;QACb,KAAK,MAAMC,SAASJ,QAAS;YAC3B,IAAK,IAAIK,IAAI,GAAGA,IAAID,MAAME,MAAM,EAAED,IAAK;gBACrC,MAAME,IAAIH,KAAK,CAACC,EAAE;gBAClB,IAAIE,MAAMC,WAAW;oBACnBL,SAAS,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/Variables/variable-model.ts"],"sourcesContent":["// Copyright 2024 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 { ListVariableDefinition } from '@perses-dev/core';\nimport { useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { VariableOption } from '../../model';\nimport { useDatasourceStore, usePlugin, useTimeRange, useAllVariableValues, VariableStateMap } from '../../runtime';\n\nexport function filterVariableList(data: VariableOption[], capturedRegexp: RegExp): VariableOption[] {\n const result: VariableOption[] = [];\n const filteredSet = new Set<string>();\n for (const variableValue of data) {\n const matches = variableValue.value.matchAll(capturedRegexp);\n let concat = '';\n for (const match of matches) {\n for (let i = 1; i < match.length; i++) {\n const m = match[i];\n if (m !== undefined) {\n concat = `${concat}${m}`;\n }\n }\n }\n if (concat !== '' && !filteredSet.has(concat)) {\n // like that we are avoiding to have duplicating variable value\n filteredSet.add(concat);\n result.push({ label: variableValue.label, value: concat });\n }\n }\n return result;\n}\n\nexport function useListVariablePluginValues(definition: ListVariableDefinition): UseQueryResult<VariableOption[]> {\n const { data: variablePlugin } = usePlugin('Variable', definition.spec.plugin.kind);\n const datasourceStore = useDatasourceStore();\n const allVariables = useAllVariableValues();\n const { absoluteTimeRange: timeRange, refreshKey } = useTimeRange();\n\n const variablePluginCtx = { timeRange, datasourceStore, variables: allVariables };\n\n const spec = definition.spec.plugin.spec;\n const capturingRegexp =\n definition.spec.capturingRegexp !== undefined ? new RegExp(definition.spec.capturingRegexp, 'g') : undefined;\n\n let dependsOnVariables: string[] | undefined;\n if (variablePlugin?.dependsOn) {\n const dependencies = variablePlugin.dependsOn(spec, variablePluginCtx);\n dependsOnVariables = dependencies.variables;\n }\n\n const variables = useAllVariableValues(dependsOnVariables);\n\n let waitToLoad = false;\n if (dependsOnVariables) {\n waitToLoad = dependsOnVariables.some((v) => variables[v]?.loading);\n }\n\n const variablesValueKey = getVariableValuesKey(variables);\n\n return useQuery({\n queryKey: [definition, variablesValueKey, timeRange, refreshKey],\n queryFn: async () => {\n const resp = await variablePlugin?.getVariableOptions(spec, { datasourceStore, variables, timeRange });\n if (resp === undefined) {\n return [];\n }\n if (!capturingRegexp) {\n return resp.data;\n }\n return filterVariableList(resp.data, capturingRegexp);\n },\n enabled: !!variablePlugin || waitToLoad,\n });\n}\n\n/**\n * Returns a serialized string of the current state of variable values.\n */\nexport function getVariableValuesKey(v: VariableStateMap): string {\n return Object.values(v)\n .map((v) => JSON.stringify(v.value))\n .join(',');\n}\n\nexport const VARIABLE_TYPES = [\n { label: 'List', kind: 'ListVariable' },\n { label: 'Text', kind: 'TextVariable' },\n] as const;\n"],"names":["useQuery","useDatasourceStore","usePlugin","useTimeRange","useAllVariableValues","filterVariableList","data","capturedRegexp","result","filteredSet","Set","variableValue","matches","value","matchAll","concat","match","i","length","m","undefined","has","add","push","label","useListVariablePluginValues","definition","variablePlugin","spec","plugin","kind","datasourceStore","allVariables","absoluteTimeRange","timeRange","refreshKey","variablePluginCtx","variables","capturingRegexp","RegExp","dependsOnVariables","dependsOn","dependencies","waitToLoad","some","v","loading","variablesValueKey","getVariableValuesKey","queryKey","queryFn","resp","getVariableOptions","enabled","Object","values","map","JSON","stringify","join","VARIABLE_TYPES"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,QAAQ,QAAwB,wBAAwB;AAEjE,SAASC,kBAAkB,EAAEC,SAAS,EAAEC,YAAY,EAAEC,oBAAoB,QAA0B,gBAAgB;AAEpH,OAAO,SAASC,mBAAmBC,IAAsB,EAAEC,cAAsB;IAC/E,MAAMC,SAA2B,EAAE;IACnC,MAAMC,cAAc,IAAIC;IACxB,KAAK,MAAMC,iBAAiBL,KAAM;Q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CAACQ,EAAE,EAAEC;IAC5D;IAEA,MAAMC,oBAAoBC,qBAAqBX;IAE/C,OAAOrC,SAAS;QACdiD,UAAU;YAACvB;YAAYqB;YAAmBb;YAAWC;SAAW;QAChEe,SAAS;YACP,MAAMC,OAAO,MAAMxB,gBAAgByB,mBAAmBxB,MAAM;gBAAEG;gBAAiBM;gBAAWH;YAAU;YACpG,IAAIiB,SAAS/B,WAAW;gBACtB,OAAO,EAAE;YACX;YACA,IAAI,CAACkB,iBAAiB;gBACpB,OAAOa,KAAK7C,IAAI;YAClB;YACA,OAAOD,mBAAmB8C,KAAK7C,IAAI,EAAEgC;QACvC;QACAe,SAAS,CAAC,CAAC1B,kBAAkBgB;IAC/B;AACF;AAEA;;CAEC,GACD,OAAO,SAASK,qBAAqBH,CAAmB;IACtD,OAAOS,OAAOC,MAAM,CAACV,GAClBW,GAAG,CAAC,CAACX,IAAMY,KAAKC,SAAS,CAACb,EAAEhC,KAAK,GACjC8C,IAAI,CAAC;AACV;AAEA,OAAO,MAAMC,iBAAiB;IAC5B;QAAEpC,OAAO;QAAQM,MAAM;IAAe;IACtC;QAAEN,OAAO;QAAQM,MAAM;IAAe;CACvC,CAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/remote/PluginLoaderComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// Copyright 2024 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 { useEffect, useRef, useState } from 'react';\nimport { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';\nimport { usePluginRuntime } from './PluginRuntime';\n\ninterface PluginLoaderProps<P> {\n plugin: PersesPlugin;\n props?: P;\n field?: string;\n}\n\nfunction PluginContainer<P>({\n pluginFn,\n props,\n}: {\n pluginFn: (props: P | undefined) => JSX.Element;\n props: P | undefined;\n}): JSX.Element {\n return pluginFn(props);\n}\n\nexport function PluginLoaderComponent<P>({ plugin, props, field }: PluginLoaderProps<P>): JSX.Element | null {\n const { loadPlugin } = usePluginRuntime({ plugin });\n const [pluginModule, setPluginModule] = useState<RemotePluginModule | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n const name = `${plugin.moduleName}-${plugin.name}`;\n const previousPluginName = useRef<string>(name);\n\n useEffect(() => {\n previousPluginName.current = name;\n setError(null);\n\n loadPlugin()\n .then((module) => {\n setPluginModule(module);\n })\n .catch((error) => {\n setPluginModule(null);\n console.error(\n `PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}:`,\n error\n );\n setError(\n new Error(`PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}`)\n );\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [name]);\n\n if (error) {\n throw error;\n }\n\n if (!pluginModule) {\n return null;\n }\n\n let pluginFunction = pluginModule[plugin.name];\n\n if (field && pluginFunction && typeof pluginFunction === 'object' && field in pluginFunction) {\n pluginFunction = (pluginFunction as Record<string, unknown>)[field];\n }\n\n if (!pluginFunction) {\n throw new Error(`PluginLoaderComponent: Plugin module ${plugin.moduleName} does not have a ${plugin.name} export`);\n }\n\n if (typeof pluginFunction !== 'function') {\n throw new Error(`PluginLoaderComponent: Plugin ${plugin.name} export is not a function`);\n }\n\n // make sure to re mount the plugin when changes, to avoid mismatch in hooks ordering when re rendering\n if (previousPluginName.current !== name) {\n return null;\n }\n\n return (\n <PluginContainer key={name} pluginFn={pluginFunction as (props: P | undefined) => JSX.Element} props={props} />\n );\n}\n"],"names":["useEffect","useRef","useState","usePluginRuntime","PluginContainer","pluginFn","props","PluginLoaderComponent","plugin","field","loadPlugin","pluginModule","setPluginModule","error","setError","name","moduleName","previousPluginName","current","then","module","catch","console","Error","pluginFunction"],"mappings":"AAAA,oDAAoD,GACpD,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAEpD,SAASC,gBAAgB,QAAQ,kBAAkB;AAQnD,SAASC,gBAAmB,EAC1BC,QAAQ,EACRC,KAAK,EAIN;IACC,OAAOD,SAASC;AAClB;AAEA,OAAO,SAASC,sBAAyB,EAAEC,MAAM,EAAEF,KAAK,EAAEG,KAAK,EAAwB;IACrF,MAAM,EAAEC,UAAU,EAAE,GAAGP,iBAAiB;QAAEK;IAAO;IACjD,MAAM,CAACG,cAAcC,gBAAgB,GAAGV,SAAoC;IAC5E,MAAM,CAACW,OAAOC,SAAS,GAAGZ,SAAuB;IAEjD,MAAMa,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../src/remote/PluginLoaderComponent.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/ban-ts-comment */\n// Copyright 2024 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 { useEffect, useRef, useState } from 'react';\nimport { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';\nimport { usePluginRuntime } from './PluginRuntime';\n\ninterface PluginLoaderProps<P> {\n plugin: PersesPlugin;\n props?: P;\n field?: string;\n}\n\nfunction PluginContainer<P>({\n pluginFn,\n props,\n}: {\n pluginFn: (props: P | undefined) => JSX.Element;\n props: P | undefined;\n}): JSX.Element {\n return pluginFn(props);\n}\n\nexport function PluginLoaderComponent<P>({ plugin, props, field }: PluginLoaderProps<P>): JSX.Element | null {\n const { loadPlugin } = usePluginRuntime({ plugin });\n const [pluginModule, setPluginModule] = useState<RemotePluginModule | null>(null);\n const [error, setError] = useState<Error | null>(null);\n\n const name = `${plugin.moduleName}-${plugin.name}`;\n const previousPluginName = useRef<string>(name);\n\n useEffect(() => {\n previousPluginName.current = name;\n setError(null);\n\n loadPlugin()\n .then((module) => {\n setPluginModule(module);\n })\n .catch((error) => {\n setPluginModule(null);\n console.error(\n `PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}:`,\n error\n );\n setError(\n new Error(`PluginLoaderComponent: Error loading plugin ${plugin.name} from module ${plugin.moduleName}`)\n );\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [name]);\n\n if (error) {\n throw error;\n }\n\n if (!pluginModule) {\n return null;\n }\n\n let pluginFunction = pluginModule[plugin.name];\n\n if (field && pluginFunction && typeof pluginFunction === 'object' && field in pluginFunction) {\n pluginFunction = (pluginFunction as Record<string, unknown>)[field];\n }\n\n if (!pluginFunction) {\n throw new Error(`PluginLoaderComponent: Plugin module ${plugin.moduleName} does not have a ${plugin.name} export`);\n }\n\n if (typeof pluginFunction !== 'function') {\n throw new Error(`PluginLoaderComponent: Plugin ${plugin.name} export is not a function`);\n }\n\n // make sure to re mount the plugin when changes, to avoid mismatch in hooks ordering when re rendering\n if (previousPluginName.current !== name) {\n return null;\n }\n\n return (\n <PluginContainer key={name} pluginFn={pluginFunction as (props: P | undefined) => JSX.Element} props={props} />\n );\n}\n"],"names":["useEffect","useRef","useState","usePluginRuntime","PluginContainer","pluginFn","props","PluginLoaderComponent","plugin","field","loadPlugin","pluginModule","setPluginModule","error","setError","name","moduleName","previousPluginName","current","then","module","catch","console","Error","pluginFunction"],"mappings":"A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O,IAAI,CAAC;IAE9C,IAAIN,SAASe,kBAAkB,OAAOA,mBAAmB,YAAYf,SAASe,gBAAgB;QAC5FA,iBAAiB,AAACA,cAA0C,CAACf,MAAM;IACrE;IAEA,IAAI,CAACe,gBAAgB;QACnB,MAAM,IAAID,MAAM,CAAC,qCAAqC,EAAEf,OAAOQ,UAAU,CAAC,iBAAiB,EAAER,OAAOO,IAAI,CAAC,OAAO,CAAC;IACnH;IAEA,IAAI,OAAOS,mBAAmB,YAAY;QACxC,MAAM,IAAID,MAAM,CAAC,8BAA8B,EAAEf,OAAOO,IAAI,CAAC,yBAAyB,CAAC;IACzF;IAEA,uGAAuG;IACvG,IAAIE,mBAAmBC,OAAO,KAAKH,MAAM;QACvC,OAAO;IACT;IAEA,qBACE,KAACX;QAA2BC,UAAUmB;QAAyDlB,OAAOA;OAAhFS;AAE1B"}
|
|
@@ -45,11 +45,11 @@ export const pluginRuntime = init({
|
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
'@tanstack/react-query': {
|
|
48
|
-
version: '
|
|
48
|
+
version: '5.64.2',
|
|
49
49
|
lib: ()=>ReactQuery,
|
|
50
50
|
shareConfig: {
|
|
51
51
|
singleton: true,
|
|
52
|
-
requiredVersion: '^
|
|
52
|
+
requiredVersion: '^5.64.2'
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
'react-hook-form': {
|
|
@@ -69,52 +69,52 @@ export const pluginRuntime = init({
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
'@perses-dev/components': {
|
|
72
|
-
version: '0.
|
|
72
|
+
version: '0.51.0-beta.0',
|
|
73
73
|
lib: ()=>require('@perses-dev/components'),
|
|
74
74
|
shareConfig: {
|
|
75
75
|
singleton: true,
|
|
76
|
-
requiredVersion: '^0.
|
|
76
|
+
requiredVersion: '^0.51.0-beta.0'
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
'@perses-dev/plugin-system': {
|
|
80
|
-
version: '0.
|
|
80
|
+
version: '0.51.0-beta.0',
|
|
81
81
|
lib: ()=>require('@perses-dev/plugin-system'),
|
|
82
82
|
shareConfig: {
|
|
83
83
|
singleton: true,
|
|
84
|
-
requiredVersion: '^0.
|
|
84
|
+
requiredVersion: '^0.51.0-beta.0'
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
87
|
'@perses-dev/explore': {
|
|
88
|
-
version: '0.
|
|
88
|
+
version: '0.51.0-beta.0',
|
|
89
89
|
lib: ()=>require('@perses-dev/explore'),
|
|
90
90
|
shareConfig: {
|
|
91
91
|
singleton: true,
|
|
92
|
-
requiredVersion: '^0.
|
|
92
|
+
requiredVersion: '^0.51.0-beta.0'
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
'@perses-dev/dashboards': {
|
|
96
|
-
version: '0.
|
|
96
|
+
version: '0.51.0-beta.0',
|
|
97
97
|
lib: ()=>require('@perses-dev/dashboards'),
|
|
98
98
|
shareConfig: {
|
|
99
99
|
singleton: true,
|
|
100
|
-
requiredVersion: '^0.
|
|
100
|
+
requiredVersion: '^0.51.0-beta.0'
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
// Below are the shared modules that are used by the plugins, this can be part of the SDK
|
|
104
104
|
'date-fns': {
|
|
105
|
-
version: '
|
|
105
|
+
version: '4.1.0',
|
|
106
106
|
lib: ()=>require('date-fns'),
|
|
107
107
|
shareConfig: {
|
|
108
108
|
singleton: true,
|
|
109
|
-
requiredVersion: '^
|
|
109
|
+
requiredVersion: '^4.1.0'
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
112
|
'date-fns-tz': {
|
|
113
|
-
version: '
|
|
113
|
+
version: '3.2.0',
|
|
114
114
|
lib: ()=>require('date-fns-tz'),
|
|
115
115
|
shareConfig: {
|
|
116
116
|
singleton: true,
|
|
117
|
-
requiredVersion: '^
|
|
117
|
+
requiredVersion: '^3.2.0'
|
|
118
118
|
}
|
|
119
119
|
},
|
|
120
120
|
lodash: {
|
|
@@ -166,11 +166,11 @@ export const pluginRuntime = init({
|
|
|
166
166
|
}
|
|
167
167
|
},
|
|
168
168
|
immer: {
|
|
169
|
-
version: '
|
|
169
|
+
version: '10.1.1',
|
|
170
170
|
lib: ()=>require('immer'),
|
|
171
171
|
shareConfig: {
|
|
172
172
|
singleton: true,
|
|
173
|
-
requiredVersion: '^
|
|
173
|
+
requiredVersion: '^10.1.1'
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/remote/PluginRuntime.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-require-imports */\n// Copyright 2024 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 { FederationHost, init, loadRemote } from '@module-federation/enhanced/runtime';\nimport * as ReactQuery from '@tanstack/react-query';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport * as ReactRouterDOM from 'react-router-dom';\nimport * as ReactHookForm from 'react-hook-form';\nimport { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';\n\nexport const pluginRuntime = init({\n name: '@perses/perses-ui-host',\n remotes: [], // all remotes are loaded dynamically\n shared: {\n react: {\n version: React.version,\n lib: () => React,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n 'react-dom': {\n version: '18.3.1',\n lib: () => ReactDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: `^18.3.1`,\n },\n },\n 'react-router-dom': {\n version: '6.26.0',\n lib: () => ReactRouterDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: '^6.26.0',\n },\n },\n '@tanstack/react-query': {\n version: '
|
|
1
|
+
{"version":3,"sources":["../../src/remote/PluginRuntime.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-require-imports */\n// Copyright 2024 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 { FederationHost, init, loadRemote } from '@module-federation/enhanced/runtime';\nimport * as ReactQuery from '@tanstack/react-query';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport * as ReactRouterDOM from 'react-router-dom';\nimport * as ReactHookForm from 'react-hook-form';\nimport { PersesPlugin, RemotePluginModule } from './PersesPlugin.types';\n\nexport const pluginRuntime = init({\n name: '@perses/perses-ui-host',\n remotes: [], // all remotes are loaded dynamically\n shared: {\n react: {\n version: React.version,\n lib: () => React,\n shareConfig: {\n singleton: true,\n requiredVersion: `^${React.version}`,\n },\n },\n 'react-dom': {\n version: '18.3.1',\n lib: () => ReactDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: `^18.3.1`,\n },\n },\n 'react-router-dom': {\n version: '6.26.0',\n lib: () => ReactRouterDOM,\n shareConfig: {\n singleton: true,\n requiredVersion: '^6.26.0',\n },\n },\n '@tanstack/react-query': {\n version: '5.64.2',\n lib: () => ReactQuery,\n shareConfig: {\n singleton: true,\n requiredVersion: '^5.64.2',\n },\n },\n 'react-hook-form': {\n version: '7.52.2',\n lib: () => ReactHookForm,\n shareConfig: {\n singleton: true,\n requiredVersion: '^7.52.2',\n },\n },\n echarts: {\n version: '5.5.0',\n lib: () => require('echarts'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^5.5.0',\n },\n },\n '@perses-dev/components': {\n version: '0.51.0-beta.0',\n lib: () => require('@perses-dev/components'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-beta.0',\n },\n },\n '@perses-dev/plugin-system': {\n version: '0.51.0-beta.0',\n lib: () => require('@perses-dev/plugin-system'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-beta.0',\n },\n },\n '@perses-dev/explore': {\n version: '0.51.0-beta.0',\n lib: () => require('@perses-dev/explore'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-beta.0',\n },\n },\n '@perses-dev/dashboards': {\n version: '0.51.0-beta.0',\n lib: () => require('@perses-dev/dashboards'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^0.51.0-beta.0',\n },\n },\n // Below are the shared modules that are used by the plugins, this can be part of the SDK\n 'date-fns': {\n version: '4.1.0',\n lib: () => require('date-fns'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.1.0',\n },\n },\n 'date-fns-tz': {\n version: '3.2.0',\n lib: () => require('date-fns-tz'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^3.2.0',\n },\n },\n lodash: {\n version: '4.17.21',\n lib: () => require('lodash'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^4.17.21',\n },\n },\n '@emotion/react': {\n version: '11.11.3',\n lib: () => require('@emotion/react'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^11.11.3',\n },\n },\n '@emotion/styled': {\n version: '11.11.0',\n lib: () => require('@emotion/styled'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^11.11.0',\n },\n },\n '@hookform/resolvers/zod': {\n version: '3.3.4',\n lib: () => require('@hookform/resolvers/zod'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^3.3.4',\n },\n },\n 'use-resize-observer': {\n version: '9.1.0',\n lib: () => require('use-resize-observer'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^9.1.0',\n },\n },\n 'mdi-material-ui': {\n version: '7.4.0',\n lib: () => require('mdi-material-ui'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^7.4.0',\n },\n },\n immer: {\n version: '10.1.1',\n lib: () => require('immer'),\n shareConfig: {\n singleton: true,\n requiredVersion: '^10.1.1',\n },\n },\n },\n});\n\nconst registerRemote = (name: string, baseURL?: string): void => {\n const existingRemote = pluginRuntime.options.remotes.find((remote) => remote.name === name);\n if (!existingRemote) {\n const remoteEntryURL = baseURL ? `${baseURL}/${name}/mf-manifest.json` : `/plugins/${name}/mf-manifest.json`;\n pluginRuntime.registerRemotes([\n {\n name,\n entry: remoteEntryURL,\n alias: name,\n },\n ]);\n }\n};\n\nexport const loadPlugin = async (\n moduleName: string,\n pluginName: string,\n baseURL?: string\n): Promise<RemotePluginModule | null> => {\n registerRemote(moduleName, baseURL);\n\n return loadRemote<RemotePluginModule>(`${moduleName}/${pluginName}`);\n};\n\nexport function usePluginRuntime({ plugin }: { plugin: PersesPlugin }): {\n pluginRuntime: FederationHost;\n loadPlugin: () => Promise<RemotePluginModule | null>;\n} {\n return {\n pluginRuntime,\n loadPlugin: () => loadPlugin(plugin.moduleName, plugin.name, plugin.baseURL),\n };\n}\n"],"names":["init","loadRemote","ReactQuery","React","ReactDOM","ReactRouterDOM","ReactHookForm","pluginRuntime","name","remotes","shared","react","version","lib","shareConfig","singleton","requiredVersion","echarts","require","lodash","immer","registerRemote","baseURL","existingRemote","options","find","remote","remoteEntryURL","registerRemotes","entry","alias","loadPlugin","moduleName","pluginName","usePluginRuntime","plugin"],"mappings":"AAAA,wDAAwD,GACxD,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAyBA,IAAI,EAAEC,UAAU,QAAQ,sCAAsC;AACvF,YAAYC,gBAAgB,wBAAwB;AACpD,OAAOC,WAAW,QAAQ;AAC1B,OAAOC,cAAc,YAAY;AACjC,YAAYC,oBAAoB,mBAAmB;AACnD,YAAYC,m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iB,CAAC;QAC5GD,cAAcqB,eAAe,CAAC;YAC5B;gBACEpB;gBACAqB,OAAOF;gBACPG,OAAOtB;YACT;SACD;IACH;AACF;AAEA,OAAO,MAAMuB,aAAa,OACxBC,YACAC,YACAX;IAEAD,eAAeW,YAAYV;IAE3B,OAAOrB,WAA+B,GAAG+B,WAAW,CAAC,EAAEC,YAAY;AACrE,EAAE;AAEF,OAAO,SAASC,iBAAiB,EAAEC,MAAM,EAA4B;IAInE,OAAO;QACL5B;QACAwB,YAAY,IAAMA,WAAWI,OAAOH,UAAU,EAAEG,OAAO3B,IAAI,EAAE2B,OAAOb,OAAO;IAC7E;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/remote/remotePluginLoader.ts"],"sourcesContent":["// Copyright 2024 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 { PluginLoader, PluginMetadata, PluginModuleResource } from '@perses-dev/plugin-system';\nimport { RemotePluginModule } from './PersesPlugin.types';\nimport { loadPlugin } from './PluginRuntime';\n\nconst isPluginMetadata = (plugin: unknown): plugin is PluginMetadata => {\n return (\n typeof plugin === 'object' &&\n plugin !== null &&\n 'kind' in plugin &&\n 'spec' in plugin &&\n typeof plugin.spec === 'object' &&\n plugin.spec !== null &&\n 'name' in plugin.spec\n );\n};\n\nconst isPluginModuleResource = (pluginModule: unknown): pluginModule is PluginModuleResource => {\n return (\n typeof pluginModule === 'object' &&\n pluginModule !== null &&\n 'metadata' in pluginModule &&\n 'spec' in pluginModule &&\n typeof pluginModule.spec === 'object' &&\n pluginModule.spec !== null &&\n 'plugins' in pluginModule.spec &&\n Array.isArray(pluginModule.spec.plugins) &&\n pluginModule.spec.plugins.every(isPluginMetadata)\n );\n};\n\nexport const remotePluginLoader = (baseURL?: string): PluginLoader => {\n return {\n getInstalledPlugins: async (): Promise<PluginModuleResource[]> => {\n const pluginsResponse = await fetch(`${baseURL ? baseURL : ''}/api/v1/plugins`);\n\n const plugins = await pluginsResponse.json();\n\n let pluginModules: PluginModuleResource[] = [];\n\n if (Array.isArray(plugins)) {\n pluginModules = plugins.filter(isPluginModuleResource);\n } else {\n console.error('RemotePluginLoader: Error loading plugins, response is not an array');\n }\n\n if (!pluginModules.length) {\n console.error('RemotePluginLoader: No valid plugins found');\n }\n\n return pluginModules;\n },\n importPluginModule: async (resource): Promise<RemotePluginModule> => {\n const pluginModuleName = resource.metadata.name;\n\n const pluginModule: RemotePluginModule = {};\n\n for (const plugin of resource.spec.plugins) {\n const remotePluginModule = await loadPlugin(pluginModuleName, plugin.spec.name);\n\n const remotePlugin = remotePluginModule?.[plugin.spec.name];\n if (remotePlugin) {\n pluginModule[plugin.spec.name] = remotePlugin;\n } else {\n console.error(`RemotePluginLoader: Error loading plugin ${plugin.spec.name}`);\n }\n }\n\n return pluginModule;\n },\n };\n};\n"],"names":["loadPlugin","isPluginMetadata","plugin","spec","isPluginModuleResource","pluginModule","Array","isArray","plugins","every","remotePluginLoader","baseURL","getInstalledPlugins","pluginsResponse","fetch","json","pluginModules","filter","console","error","length","importPluginModule","resource","pluginModuleName","metadata","name","remotePluginModule","remotePlugin"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,UAAU,QAAQ,kBAAkB;AAE7C,MAAMC,mBAAmB,CAACC;IACxB,OACE,OAAOA,WAAW,YAClBA,WAAW,QACX,UAAUA,UACV,UAAUA,UACV,OAAOA,OAAOC,IAAI,KAAK,YACvBD,OAAOC,IAAI,KAAK,QAChB,UAAUD,OAAOC,IAAI;AAEzB;AAEA,MAAMC,yBAAyB,CAACC;IAC9B,OACE,OAAOA,iBAAiB,YACxBA,iBAAiB,QACjB,cAAcA,gBACd,UAAUA,gBACV,OAAOA,aAAaF,IAAI,KAAK,YAC7BE,aAAaF,IAAI,KAAK,QACtB,aAAaE,aAAaF,IAAI,IAC9BG,MAAMC,OAAO,CAACF,aAAaF,IAAI,CAACK,OAAO,KACvCH,aAAaF,IAAI,CAACK,OAAO,CAACC,KAAK,CAACR;AAEpC;AAEA,OAAO,MAAMS,qBAAqB,CAACC;IACjC,OAAO;QACLC,qBAAqB;YACnB,MAAMC,kBAAkB,MAAMC,MAAM,
|
|
1
|
+
{"version":3,"sources":["../../src/remote/remotePluginLoader.ts"],"sourcesContent":["// Copyright 2024 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 { PluginLoader, PluginMetadata, PluginModuleResource } from '@perses-dev/plugin-system';\nimport { RemotePluginModule } from './PersesPlugin.types';\nimport { loadPlugin } from './PluginRuntime';\n\nconst isPluginMetadata = (plugin: unknown): plugin is PluginMetadata => {\n return (\n typeof plugin === 'object' &&\n plugin !== null &&\n 'kind' in plugin &&\n 'spec' in plugin &&\n typeof plugin.spec === 'object' &&\n plugin.spec !== null &&\n 'name' in plugin.spec\n );\n};\n\nconst isPluginModuleResource = (pluginModule: unknown): pluginModule is PluginModuleResource => {\n return (\n typeof pluginModule === 'object' &&\n pluginModule !== null &&\n 'metadata' in pluginModule &&\n 'spec' in pluginModule &&\n typeof pluginModule.spec === 'object' &&\n pluginModule.spec !== null &&\n 'plugins' in pluginModule.spec &&\n Array.isArray(pluginModule.spec.plugins) &&\n pluginModule.spec.plugins.every(isPluginMetadata)\n );\n};\n\nexport const remotePluginLoader = (baseURL?: string): PluginLoader => {\n return {\n getInstalledPlugins: async (): Promise<PluginModuleResource[]> => {\n const pluginsResponse = await fetch(`${baseURL ? baseURL : ''}/api/v1/plugins`);\n\n const plugins = await pluginsResponse.json();\n\n let pluginModules: PluginModuleResource[] = [];\n\n if (Array.isArray(plugins)) {\n pluginModules = plugins.filter(isPluginModuleResource);\n } else {\n console.error('RemotePluginLoader: Error loading plugins, response is not an array');\n }\n\n if (!pluginModules.length) {\n console.error('RemotePluginLoader: No valid plugins found');\n }\n\n return pluginModules;\n },\n importPluginModule: async (resource): Promise<RemotePluginModule> => {\n const pluginModuleName = resource.metadata.name;\n\n const pluginModule: RemotePluginModule = {};\n\n for (const plugin of resource.spec.plugins) {\n const remotePluginModule = await loadPlugin(pluginModuleName, plugin.spec.name);\n\n const remotePlugin = remotePluginModule?.[plugin.spec.name];\n if (remotePlugin) {\n pluginModule[plugin.spec.name] = remotePlugin;\n } else {\n console.error(`RemotePluginLoader: Error loading plugin ${plugin.spec.name}`);\n }\n }\n\n return pluginModule;\n },\n };\n};\n"],"names":["loadPlugin","isPluginMetadata","plugin","spec","isPluginModuleResource","pluginModule","Array","isArray","plugins","every","remotePluginLoader","baseURL","getInstalledPlugins","pluginsResponse","fetch","json","pluginModules","filter","console","error","length","importPluginModule","resource","pluginModuleName","metadata","name","remotePluginModule","remotePlugin"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,UAAU,QAAQ,kBAAkB;AAE7C,MAAMC,mBAAmB,CAACC;IACxB,OAC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AI,CAAC,GAAGE;gBACnC,OAAO;oBACLT,QAAQC,KAAK,CAAC,CAAC,yCAAyC,EAAEjB,OAAOC,IAAI,CAACsB,IAAI,EAAE;gBAC9E;YACF;YAEA,OAAOpB;QACT;IACF;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"sourcesContent":["// Copyright 2023 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 { Definition, QueryDefinition, UnknownSpec, QueryDataType } from '@perses-dev/core';\nimport { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';\nimport { ReactNode, useCallback, useMemo } from 'react';\nimport { useListPluginMetadata } from '../plugin-registry';\n\nexport type QueryOptions = Record<string, unknown>;\nexport interface DataQueriesProviderProps<QueryPluginSpec = UnknownSpec> {\n definitions: Array<Definition<QueryPluginSpec>>;\n children?: ReactNode;\n options?: QueryOptions;\n queryOptions?: Omit<QueryObserverOptions, 'queryKey'>;\n}\n\nexport interface DataQueriesContextType {\n queryResults: QueryData[];\n refetchAll: () => void;\n isFetching: boolean;\n isLoading: boolean;\n errors: unknown[];\n}\n\nexport interface UseDataQueryResults<T> extends Omit<DataQueriesContextType, 'queryResults'> {\n queryResults: Array<QueryData<T>>;\n}\n\nexport type QueryData<T = QueryDataType> = {\n data?: T;\n definition: QueryDefinition;\n error: unknown;\n isFetching: boolean;\n isLoading: boolean;\n refetch?: () => void;\n};\n\nexport function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]): QueryData[] {\n return results.map(({ data, isFetching, isLoading, refetch, error }, i) => {\n return {\n definition: definitions[i],\n data,\n isFetching,\n isLoading,\n refetch,\n error,\n } as QueryData;\n });\n}\n\nexport function useQueryType(): (pluginKind: string) => string | undefined {\n const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = useListPluginMetadata([\n 'TimeSeriesQuery',\n ]);\n const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = useListPluginMetadata(['TraceQuery']);\n\n // For example, `map: {\"TimeSeriesQuery\":[\"PrometheusTimeSeriesQuery\"],\"TraceQuery\":[\"TempoTraceQuery\"]}`\n const queryTypeMap = useMemo(() => {\n const map: Record<string, string[]> = {\n TimeSeriesQuery: [],\n TraceQuery: [],\n };\n\n if (timeSeriesQueryPlugins) {\n timeSeriesQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (traceQueryPlugins) {\n traceQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n return map;\n }, [timeSeriesQueryPlugins, traceQueryPlugins]);\n\n const getQueryType = useCallback(\n (pluginKind: string) => {\n const isLoading = (pluginKind: string): boolean => {\n switch (pluginKind) {\n case 'PrometheusTimeSeriesQuery':\n return isTimeSeriesQueryLoading;\n case 'TempoTraceQuery':\n return isTraceQueryPluginLoading;\n }\n\n return isTraceQueryPluginLoading || isTimeSeriesQueryLoading;\n };\n\n if (isLoading(pluginKind)) {\n return undefined;\n }\n\n for (const queryType in queryTypeMap) {\n if (queryTypeMap[queryType]?.includes(pluginKind)) {\n return queryType;\n }\n }\n\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n },\n [queryTypeMap, isTimeSeriesQueryLoading, isTraceQueryPluginLoading]\n );\n\n return getQueryType;\n}\n"],"names":["useCallback","useMemo","useListPluginMetadata","transformQueryResults","results","definitions","map","data","isFetching","isLoading","refetch","error","i","definition","useQueryType","timeSeriesQueryPlugins","isTimeSeriesQueryLoading","traceQueryPlugins","isTraceQueryPluginLoading","queryTypeMap","TimeSeriesQuery","TraceQuery","forEach","plugin","kind","push","spec","name","getQueryType","pluginKind","undefined","queryType","includes","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAAoBA,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AACxD,SAASC,qBAAqB,QAAQ,qBAAqB;AA+B3D,OAAO,SAASC,sBAAsBC,OAAyB,EAAEC,WAA8B;IAC7F,OAAOD,QAAQE,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,KAAK,EAAE,EAAEC;QACnE,OAAO;YACLC,YAAYR,WAAW,CAACO,EAAE;YAC1BL;YACAC;YACAC;YACAC;YACAC;QACF;IACF;AACF;AAEA,OAAO,SAASG;IACd,MAAM,EAAEP,MAAMQ,sBAAsB,EAAEN,WAAWO,wBAAwB,EAAE,GAAGd,sBAAsB;QAClG;KACD;IACD,MAAM,EAAEK,MAAMU,iBAAiB,EAAER,WAAWS,yBAAyB,EAAE,GAAGhB,sBAAsB;QAAC;KAAa;IAE9G,yGAAyG;IACzG,MAAMiB,eAAelB,QAAQ;QAC3B,MAAMK,MAAgC;YACpCc,iBAAiB,EAAE;YACnBC,YAAY,EAAE;QAChB;QAEA,IAAIN,wBAAwB;YAC1BA,uBAAuBO,OAAO,CAAC,CAACC;gBAC9BjB,GAAG,CAACiB,OAAOC,IAAI,CAAC,EAAEC,KAAKF,OAAOG,IAAI,CAACC,IAAI;YACzC;QACF;QAEA,IAAIV,mBAAmB;YACrBA,kBAAkBK,OAAO,CAAC,CAACC;gBACzBjB,GAAG,CAACiB,OAAOC,IAAI,CAAC,EAAEC,KAAKF,OAAOG,IAAI,CAACC,IAAI;YACzC;QACF;QACA,OAAOrB;IACT,GAAG;QAACS;QAAwBE;KAAkB;IAE9C,MAAMW,eAAe5B,YACnB,CAAC6B;QACC,MAAMpB,YAAY,CAACoB;YACjB,OAAQA;gBACN,KAAK;oBACH,OAAOb;gBACT,KAAK;oBACH,OAAOE;YACX;YAEA,OAAOA,6BAA6BF;QACtC;QAEA,IAAIP,UAAUoB,aAAa;YACzB,OAAOC;QACT;QAEA,IAAK,MAAMC,aAAaZ,aAAc;YACpC,IAAIA,YAAY,CAACY,UAAU,EAAEC,SAASH,aAAa;gBACjD,OAAOE;YACT;QACF;QAEA,MAAM,IAAIE,MAAM,CAAC,oCAAoC,EAAEJ,
|
|
1
|
+
{"version":3,"sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"sourcesContent":["// Copyright 2023 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 { Definition, QueryDefinition, UnknownSpec, QueryDataType } from '@perses-dev/core';\nimport { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';\nimport { ReactNode, useCallback, useMemo } from 'react';\nimport { useListPluginMetadata } from '../plugin-registry';\n\nexport type QueryOptions = Record<string, unknown>;\nexport interface DataQueriesProviderProps<QueryPluginSpec = UnknownSpec> {\n definitions: Array<Definition<QueryPluginSpec>>;\n children?: ReactNode;\n options?: QueryOptions;\n queryOptions?: Omit<QueryObserverOptions, 'queryKey'>;\n}\n\nexport interface DataQueriesContextType {\n queryResults: QueryData[];\n refetchAll: () => void;\n isFetching: boolean;\n isLoading: boolean;\n errors: unknown[];\n}\n\nexport interface UseDataQueryResults<T> extends Omit<DataQueriesContextType, 'queryResults'> {\n queryResults: Array<QueryData<T>>;\n}\n\nexport type QueryData<T = QueryDataType> = {\n data?: T;\n definition: QueryDefinition;\n error: unknown;\n isFetching: boolean;\n isLoading: boolean;\n refetch?: () => void;\n};\n\nexport function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]): QueryData[] {\n return results.map(({ data, isFetching, isLoading, refetch, error }, i) => {\n return {\n definition: definitions[i],\n data,\n isFetching,\n isLoading,\n refetch,\n error,\n } as QueryData;\n });\n}\n\nexport function useQueryType(): (pluginKind: string) => string | undefined {\n const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = useListPluginMetadata([\n 'TimeSeriesQuery',\n ]);\n const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = useListPluginMetadata(['TraceQuery']);\n\n // For example, `map: {\"TimeSeriesQuery\":[\"PrometheusTimeSeriesQuery\"],\"TraceQuery\":[\"TempoTraceQuery\"]}`\n const queryTypeMap = useMemo(() => {\n const map: Record<string, string[]> = {\n TimeSeriesQuery: [],\n TraceQuery: [],\n };\n\n if (timeSeriesQueryPlugins) {\n timeSeriesQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n\n if (traceQueryPlugins) {\n traceQueryPlugins.forEach((plugin) => {\n map[plugin.kind]?.push(plugin.spec.name);\n });\n }\n return map;\n }, [timeSeriesQueryPlugins, traceQueryPlugins]);\n\n const getQueryType = useCallback(\n (pluginKind: string) => {\n const isLoading = (pluginKind: string): boolean => {\n switch (pluginKind) {\n case 'PrometheusTimeSeriesQuery':\n return isTimeSeriesQueryLoading;\n case 'TempoTraceQuery':\n return isTraceQueryPluginLoading;\n }\n\n return isTraceQueryPluginLoading || isTimeSeriesQueryLoading;\n };\n\n if (isLoading(pluginKind)) {\n return undefined;\n }\n\n for (const queryType in queryTypeMap) {\n if (queryTypeMap[queryType]?.includes(pluginKind)) {\n return queryType;\n }\n }\n\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n },\n [queryTypeMap, isTimeSeriesQueryLoading, isTraceQueryPluginLoading]\n );\n\n return getQueryType;\n}\n"],"names":["useCallback","useMemo","useListPluginMetadata","transformQueryResults","results","definitions","map","data","isFetching","isLoading","refetch","error","i","definition","useQueryType","timeSeriesQueryPlugins","isTimeSeriesQueryLoading","traceQueryPlugins","isTraceQueryPluginLoading","queryTypeMap","TimeSeriesQuery","TraceQuery","forEach","plugin","kind","push","spec","name","getQueryType","pluginKind","undefined","queryType","includes","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAAoBA,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AACxD,SAASC,qBAAqB,QAAQ,qBAAqB;AA+B3D,OAAO,SAASC,sBAAsBC,OAAyB,EAAEC,WAA8B;IAC7F,OAAOD,QAAQE,GAAG,CAAC,CAAC,EAAEC,IAAI,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,KAAK,EAAE,EAAEC;QACnE,OAAO;YACLC,YAAYR,WAAW,CAACO,EAAE;YAC1BL;YACAC;YACAC;YACAC;YACAC;QACF;IACF;AACF;AAEA,OAAO,SAASG;IACd,MAAM,EAAEP,MAAMQ,sBAAsB,EAAEN,WAAWO,wBAAwB,EAAE,GAAGd,sBAAsB;QAClG;KACD;IACD,MAAM,EAAEK,MAAMU,iBAAiB,EAAER,WAAWS,yBAAyB,EAAE,GAAGhB,sBAAsB;QAAC;KAAa;IAE9G,yGAAyG;IACzG,MAAMiB,eAAelB,QAAQ;QAC3B,MAAMK,MAAgC;YACpCc,iBAAiB,EAAE;YACnBC,YAAY,EAAE;QAChB;QAEA,IAAIN,wBAAwB;YAC1BA,uBAAuBO,OAAO,CAAC,CAACC;gBAC9BjB,GAAG,CAACiB,OAAOC,IAAI,CAAC,EAAEC,KAAKF,OAAOG,IAAI,CAACC,IAAI;YACzC;QACF;QAEA,IAAIV,mBAAmB;YACrBA,kBAAkBK,OAAO,CAAC,CAACC;gBACzBjB,GAAG,CAACiB,OAAOC,IAAI,CAAC,EAAEC,KAAKF,OAAOG,IAAI,CAACC,IAAI;YACzC;QACF;QACA,OAAOrB;IACT,GAAG;QAACS;QAAwBE;KAAkB;IAE9C,MAAMW,eAAe5B,YACnB,CAAC6B;QACC,MAAMpB,YAAY,CAACoB;YACjB,OAAQA;gBACN,KAAK;oBACH,OAAOb;gBACT,KAAK;oBACH,OAAOE;YACX;YAEA,OAAOA,6BAA6BF;QACtC;QAEA,IAAIP,UAAUoB,aAAa;YACzB,OAAOC;QACT;QAEA,IAAK,MAAMC,aAAaZ,aAAc;YACpC,IAAIA,YAAY,CAACY,UAAU,EAAEC,SAASH,aAAa;gBACjD,OAAOE;YACT;QACF;QAEA,MAAM,IAAIE,MAAM,CAAC,oCAAoC,EAAEJ,YAAY;IACrE,GACA;QAACV;QAAcH;QAA0BE;KAA0B;IAGrE,OAAOU;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"sourcesContent":["// Copyright 2023 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 React, { createContext, ReactElement, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n} from '@perses-dev/core';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange?: (value: TimeRangeValue) => void;\n setRefreshInterval?: (value: DurationString) => void;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshKey: string;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext(): TimeRange {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number): number {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps): ReactElement {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const [localTimeRange, setLocalTimeRange] = useState<TimeRangeValue>(timeRange);\n const [localRefreshInterval, setLocalRefreshInterval] = useState<DurationString | undefined>(refreshInterval);\n\n const [refreshCounter, setRefreshCounter] = useState(0);\n\n useEffect(() => {\n setLocalTimeRange(timeRange);\n }, [timeRange, refreshCounter]);\n\n useEffect(() => {\n setLocalRefreshInterval(refreshInterval);\n }, [refreshInterval]);\n\n const refresh = useCallback(() => {\n setRefreshCounter((counter) => counter + 1);\n }, [setRefreshCounter]);\n\n const refreshIntervalInMs = getRefreshIntervalInMs(localRefreshInterval);\n useEffect(() => {\n if (refreshIntervalInMs > 0) {\n const interval = setInterval(() => {\n refresh();\n }, refreshIntervalInMs);\n\n return (): void => clearInterval(interval);\n }\n }, [refresh, refreshIntervalInMs]);\n\n const ctx = useMemo(() => {\n const absoluteTimeRange = isRelativeTimeRange(localTimeRange)\n ? toAbsoluteTimeRange(localTimeRange)\n : localTimeRange;\n return {\n timeRange: localTimeRange,\n setTimeRange: setTimeRange ?? setLocalTimeRange,\n absoluteTimeRange,\n refresh,\n refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${localRefreshInterval}:${refreshCounter}`,\n refreshInterval: localRefreshInterval,\n refreshIntervalInMs: refreshIntervalInMs,\n setRefreshInterval: setRefreshInterval ?? setLocalRefreshInterval,\n };\n }, [\n localTimeRange,\n setTimeRange,\n refresh,\n localRefreshInterval,\n refreshCounter,\n refreshIntervalInMs,\n setRefreshInterval,\n ]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getSuggestedStepMs","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","localTimeRange","setLocalTimeRange","localRefreshInterval","setLocalRefreshInterval","refreshCounter","setRefreshCounter","refresh","counter","refreshIntervalInMs","interval","setInterval","clearInterval","refreshKey","start","end","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,aAAa,EAAgBC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAClH,SAIEC,mB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oBoB,kBAC1CnB,oBAAoBmB,kBACpBA;QACJ,OAAO;YACLL,WAAWK;YACXF,cAAcA,gBAAgBG;YAC9BT;YACAc;YACAM,YAAY,
|
|
1
|
+
{"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"sourcesContent":["// Copyright 2023 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 React, { createContext, ReactElement, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n} from '@perses-dev/core';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange?: (value: TimeRangeValue) => void;\n setRefreshInterval?: (value: DurationString) => void;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshKey: string;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext(): TimeRange {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number): number {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps): ReactElement {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const [localTimeRange, setLocalTimeRange] = useState<TimeRangeValue>(timeRange);\n const [localRefreshInterval, setLocalRefreshInterval] = useState<DurationString | undefined>(refreshInterval);\n\n const [refreshCounter, setRefreshCounter] = useState(0);\n\n useEffect(() => {\n setLocalTimeRange(timeRange);\n }, [timeRange, refreshCounter]);\n\n useEffect(() => {\n setLocalRefreshInterval(refreshInterval);\n }, [refreshInterval]);\n\n const refresh = useCallback(() => {\n setRefreshCounter((counter) => counter + 1);\n }, [setRefreshCounter]);\n\n const refreshIntervalInMs = getRefreshIntervalInMs(localRefreshInterval);\n useEffect(() => {\n if (refreshIntervalInMs > 0) {\n const interval = setInterval(() => {\n refresh();\n }, refreshIntervalInMs);\n\n return (): void => clearInterval(interval);\n }\n }, [refresh, refreshIntervalInMs]);\n\n const ctx = useMemo(() => {\n const absoluteTimeRange = isRelativeTimeRange(localTimeRange)\n ? toAbsoluteTimeRange(localTimeRange)\n : localTimeRange;\n return {\n timeRange: localTimeRange,\n setTimeRange: setTimeRange ?? setLocalTimeRange,\n absoluteTimeRange,\n refresh,\n refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${localRefreshInterval}:${refreshCounter}`,\n refreshInterval: localRefreshInterval,\n refreshIntervalInMs: refreshIntervalInMs,\n setRefreshInterval: setRefreshInterval ?? setLocalRefreshInterval,\n };\n }, [\n localTimeRange,\n setTimeRange,\n refresh,\n localRefreshInterval,\n refreshCounter,\n refreshIntervalInMs,\n setRefreshInterval,\n ]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getSuggestedStepMs","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","localTimeRange","setLocalTimeRange","localRefreshInterval","setLocalRefreshInterval","refreshCounter","setRefreshCounter","refresh","counter","refreshIntervalInMs","interval","setInterval","clearInterval","refreshKey","start","end","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,SAASC,aAAa,EAAgBC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AAClH,SAIEC,mBAAmB,EACnBC,mBAAmB,EACnBC,kBAAkB,QACb,mBAAmB;AAC1B,SAASC,sBAAsB,QAAQ,qBAAqB;AAqB5D,OAAO,MAAMC,iCAAmBV,cAAqCW,WAAW;AAEhF,OAAO,SAASC;IACd,MAAMC,MAAMX,WAAWQ;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA;;CAEC,GACD,OAAO,SAASE;IACd,OAAOH;AACT;AAEA;;CAEC,GACD,OAAO,SAASI,mBAAmBC,KAAc;IAC/C,MAAM,EAAEC,iBAAiB,EAAE,GAAGH;IAC9B,IAAIE,UAAUN,WAAW,OAAO;IAChC,OAAOH,mBAAmBU,mBAAmBD;AAC/C;AAEA;;CAEC,GACD,OAAO,SAASE,kBAAkBC,KAA6B;IAC7D,MAAM,EAAEC,SAAS,EAAEC,eAAe,EAAEC,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EAAE,KAAK,CAAC,CAYhD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,EAC7C,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAC/B,KAAK,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAoBhD;AAGD,KAAK,4BAA4B,GAAG,IAAI,CACtC,eAAe,CAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,wBAAwB,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,EAClG,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EAAE,EACrB,OAAO,CAAC,EAAE,4BAA4B,GACrC,cAAc,CAAC,wBAAwB,EAAE,CAAC,CAO5C;AAED,wBAAgB,mCAAmC,IAAI,cAAc,CAAC,yBAAyB,EAAE,CAAC,CAkBjG"}
|
|
@@ -46,18 +46,27 @@ export const PluginRegistryContext = createContext(undefined);
|
|
|
46
46
|
* Loads a list of plugins and returns the plugin implementation, along with loading/error state.
|
|
47
47
|
*/ export function usePlugins(pluginType, plugins) {
|
|
48
48
|
const { getPlugin } = usePluginRegistry();
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
// useQueries() does not support queries with duplicate keys, therefore we de-duplicate the plugin kinds before running useQueries()
|
|
50
|
+
// This resolves the following warning in the JS console: "[QueriesObserver]: Duplicate Queries found. This might result in unexpected behavior."
|
|
51
|
+
// https://github.com/TanStack/query/issues/8224#issuecomment-2523554831
|
|
52
|
+
// https://github.com/TanStack/query/issues/4187#issuecomment-1256336901
|
|
53
|
+
const kinds = [
|
|
54
|
+
...new Set(plugins.map((p)=>p.kind))
|
|
55
|
+
];
|
|
56
|
+
const result = useQueries({
|
|
57
|
+
queries: kinds.map((kind)=>{
|
|
51
58
|
return {
|
|
52
59
|
queryKey: [
|
|
53
60
|
'getPlugin',
|
|
54
61
|
pluginType,
|
|
55
|
-
|
|
62
|
+
kind
|
|
56
63
|
],
|
|
57
|
-
queryFn: ()=>getPlugin(pluginType,
|
|
64
|
+
queryFn: ()=>getPlugin(pluginType, kind)
|
|
58
65
|
};
|
|
59
66
|
})
|
|
60
67
|
});
|
|
68
|
+
// Re-assemble array in original order
|
|
69
|
+
return plugins.map((p)=>result[kinds.indexOf(p.kind)]);
|
|
61
70
|
}
|
|
62
71
|
/**
|
|
63
72
|
* Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.
|