@perses-dev/plugin-system 0.55.0-beta.2 → 0.55.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +4 -4
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +1 -1
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +3 -2
- package/dist/cjs/components/DatasourceSelect/DatasourceSelect.js +1 -1
- package/dist/cjs/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js +53 -0
- package/dist/cjs/components/DatasourceTestConnectionButton/index.js +30 -0
- package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +49 -24
- package/dist/cjs/components/LayoutEditor/LayoutEditor.js +123 -0
- package/dist/cjs/components/LayoutEditor/RepeatLayoutPreview.js +105 -0
- package/dist/cjs/components/LayoutEditor/RepeatVariableEditor.js +176 -0
- package/dist/cjs/components/LayoutEditor/index.js +32 -0
- package/dist/cjs/components/LinksEditor/LinksEditor.js +4 -4
- package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +8 -5
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +7 -7
- package/dist/cjs/components/PanelSpecEditor/PanelAnnotationsEditor.js +4 -4
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +14 -5
- package/dist/cjs/components/PluginEditor/PluginEditor.js +4 -3
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +1 -1
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
- package/dist/cjs/components/PluginSpecEditor/DatasourceSpecEditor.js +70 -0
- package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +17 -3
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +6 -7
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +5 -5
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
- package/dist/cjs/components/index.js +2 -0
- package/dist/cjs/constants/index.js +1 -0
- package/dist/cjs/constants/repeat.js +32 -0
- package/dist/cjs/context/ValidationProvider.js +2 -2
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/model/json-queries.js +16 -0
- package/dist/cjs/remote/PluginRuntime.js +12 -20
- package/dist/cjs/remote/remotePluginLoader.js +1 -1
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +14 -6
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +18 -4
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviders.js +2 -2
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +14 -1
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +2 -2
- package/dist/cjs/runtime/alerts-queries.js +1 -1
- package/dist/cjs/runtime/annotations.js +2 -2
- package/dist/cjs/runtime/index.js +1 -0
- package/dist/cjs/runtime/item-actions.js +1 -1
- package/dist/cjs/runtime/json-queries.js +70 -0
- package/dist/cjs/runtime/silences-queries.js +1 -1
- package/dist/cjs/runtime/time-series-queries.js +1 -1
- package/dist/cjs/runtime/trace-queries.js +1 -1
- package/dist/cjs/schema/panel.js +17 -3
- package/dist/cjs/test/mock-data.js +9 -0
- package/dist/cjs/test/setup-tests.js +9 -3
- package/dist/cjs/test/test-plugins/ernie/index.js +58 -1
- package/dist/cjs/utils/csv-export.js +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +2 -2
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +4 -4
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts +2 -2
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +1 -1
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +2 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +3 -2
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.d.ts +8 -0
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.d.ts.map +1 -0
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js +45 -0
- package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js.map +1 -0
- package/dist/components/DatasourceTestConnectionButton/index.d.ts +2 -0
- package/dist/components/DatasourceTestConnectionButton/index.d.ts.map +1 -0
- package/dist/components/DatasourceTestConnectionButton/index.js +15 -0
- package/dist/components/DatasourceTestConnectionButton/index.js.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +2 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +50 -25
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
- package/dist/components/LayoutEditor/LayoutEditor.d.ts +16 -0
- package/dist/components/LayoutEditor/LayoutEditor.d.ts.map +1 -0
- package/dist/components/LayoutEditor/LayoutEditor.js +115 -0
- package/dist/components/LayoutEditor/LayoutEditor.js.map +1 -0
- package/dist/components/LayoutEditor/RepeatLayoutPreview.d.ts +7 -0
- package/dist/components/LayoutEditor/RepeatLayoutPreview.d.ts.map +1 -0
- package/dist/components/LayoutEditor/RepeatLayoutPreview.js +92 -0
- package/dist/components/LayoutEditor/RepeatLayoutPreview.js.map +1 -0
- package/dist/components/LayoutEditor/RepeatVariableEditor.d.ts +18 -0
- package/dist/components/LayoutEditor/RepeatVariableEditor.d.ts.map +1 -0
- package/dist/components/LayoutEditor/RepeatVariableEditor.js +168 -0
- package/dist/components/LayoutEditor/RepeatVariableEditor.js.map +1 -0
- package/dist/components/LayoutEditor/index.d.ts +4 -0
- package/dist/components/LayoutEditor/index.d.ts.map +1 -0
- package/dist/components/LayoutEditor/index.js +17 -0
- package/dist/components/LayoutEditor/index.js.map +1 -0
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/LinksEditor/LinksEditor.d.ts.map +1 -1
- package/dist/components/LinksEditor/LinksEditor.js +4 -4
- package/dist/components/LinksEditor/LinksEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +0 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +8 -5
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +0 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +7 -7
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.d.ts +1 -1
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.js +4 -4
- package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +3 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +14 -5
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +4 -3
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +2 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +0 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.d.ts +10 -0
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.d.ts.map +1 -0
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.js +62 -0
- package/dist/components/PluginSpecEditor/DatasourceSpecEditor.js.map +1 -0
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +2 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +17 -3
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +9 -10
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +2 -2
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +5 -5
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +1 -0
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/repeat.d.ts +3 -0
- package/dist/constants/repeat.d.ts.map +1 -0
- package/dist/constants/repeat.js +16 -0
- package/dist/constants/repeat.js.map +1 -0
- package/dist/context/ValidationProvider.d.ts +2 -2
- package/dist/context/ValidationProvider.d.ts.map +1 -1
- package/dist/context/ValidationProvider.js +2 -2
- package/dist/context/ValidationProvider.js.map +1 -1
- package/dist/model/alerts-queries.d.ts +1 -1
- package/dist/model/alerts-queries.d.ts.map +1 -1
- package/dist/model/alerts-queries.js.map +1 -1
- package/dist/model/annotations.d.ts.map +1 -1
- package/dist/model/annotations.js.map +1 -1
- package/dist/model/calculations.js.map +1 -1
- package/dist/model/datasource.d.ts +9 -2
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/explore.d.ts +0 -1
- package/dist/model/explore.d.ts.map +1 -1
- package/dist/model/explore.js.map +1 -1
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/json-queries.d.ts +29 -0
- package/dist/model/json-queries.d.ts.map +1 -0
- package/dist/model/json-queries.js +17 -0
- package/dist/model/json-queries.js.map +1 -0
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js.map +1 -1
- package/dist/model/log-queries.d.ts.map +1 -1
- package/dist/model/log-queries.js.map +1 -1
- package/dist/model/panels.d.ts +10 -1
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.d.ts +2 -2
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugins.d.ts +8 -6
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/profile-queries.d.ts +1 -1
- package/dist/model/profile-queries.d.ts.map +1 -1
- package/dist/model/profile-queries.js.map +1 -1
- package/dist/model/silences-queries.d.ts +1 -1
- package/dist/model/silences-queries.d.ts.map +1 -1
- package/dist/model/silences-queries.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +1 -1
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/trace-queries.d.ts +1 -1
- package/dist/model/trace-queries.d.ts.map +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/model/variables.d.ts +5 -1
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js +1 -3
- package/dist/model/variables.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.d.ts +0 -1
- package/dist/remote/PluginLoaderComponent.d.ts.map +1 -1
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +12 -20
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.d.ts +1 -1
- package/dist/remote/remotePluginLoader.d.ts.map +1 -1
- package/dist/remote/remotePluginLoader.js +1 -1
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +2 -2
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +15 -7
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +18 -4
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js +3 -3
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +8 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +14 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +2 -2
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -1
- package/dist/runtime/alerts-queries.d.ts.map +1 -1
- package/dist/runtime/alerts-queries.js +1 -1
- package/dist/runtime/alerts-queries.js.map +1 -1
- package/dist/runtime/annotations.d.ts.map +1 -1
- package/dist/runtime/annotations.js +2 -2
- package/dist/runtime/annotations.js.map +1 -1
- package/dist/runtime/builtin-variables.d.ts +0 -1
- package/dist/runtime/builtin-variables.d.ts.map +1 -1
- package/dist/runtime/builtin-variables.js.map +1 -1
- package/dist/runtime/datasources.d.ts +0 -1
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/item-actions.d.ts +1 -1
- package/dist/runtime/item-actions.d.ts.map +1 -1
- package/dist/runtime/item-actions.js +1 -1
- package/dist/runtime/item-actions.js.map +1 -1
- package/dist/runtime/json-queries.d.ts +11 -0
- package/dist/runtime/json-queries.d.ts.map +1 -0
- package/dist/runtime/json-queries.js +58 -0
- package/dist/runtime/json-queries.js.map +1 -0
- package/dist/runtime/log-queries.d.ts.map +1 -1
- package/dist/runtime/log-queries.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +0 -1
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/profile-queries.d.ts.map +1 -1
- package/dist/runtime/profile-queries.js.map +1 -1
- package/dist/runtime/silences-queries.d.ts.map +1 -1
- package/dist/runtime/silences-queries.js +1 -1
- package/dist/runtime/silences-queries.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +1 -1
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts.map +1 -1
- package/dist/runtime/trace-queries.js +1 -1
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/variables.d.ts +0 -1
- package/dist/runtime/variables.d.ts.map +1 -1
- package/dist/runtime/variables.js.map +1 -1
- package/dist/schema/panel.d.ts +1 -1
- package/dist/schema/panel.d.ts.map +1 -1
- package/dist/schema/panel.js +17 -3
- package/dist/schema/panel.js.map +1 -1
- package/dist/test/mock-data.d.ts +2 -1
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js +6 -0
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/render-hook.d.ts.map +1 -1
- package/dist/test/render-hook.js.map +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.d.ts +1 -1
- package/dist/test/setup-tests.d.ts.map +1 -1
- package/dist/test/setup-tests.js +3 -2
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.d.ts +7 -1
- package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +58 -1
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test/utils.d.ts.map +1 -1
- package/dist/test/utils.js +1 -1
- package/dist/test/utils.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/dist/utils/csv-export.d.ts.map +1 -1
- package/dist/utils/csv-export.js +1 -1
- package/dist/utils/csv-export.js.map +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PluginKindSelect/PluginKindSelect.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MenuItem, TextField, TextFieldProps } from '@mui/material';\nimport { forwardRef, ReactElement, useCallback, useMemo } from 'react';\nimport { PluginType } from '../../model';\nimport { useListPluginMetadata } from '../../runtime';\nimport { PluginEditorSelection } from '../PluginEditor';\n\nexport interface PluginKindSelectProps extends Omit<TextFieldProps, 'value' | 'onChange' | 'children'> {\n filteredQueryPlugins?: string[];\n pluginTypes: PluginType[];\n value?: PluginEditorSelection;\n onChange?: (s: PluginEditorSelection) => void;\n}\n\n/**\n * Displays a MUI Select input for selecting a plugin's kind from a list of all the available plugins of some specific\n * plugin types. (e.g. \"Show a list of all the Panel plugins\", or \"Show a list of all the Variable plugins\", or \"Show\n * a list of all the TimeSeriesQuery, TraceQuery, ProfileQuery, and LogQuery plugins\").\n * The value of the select is the kind of the plugin, but you can also listen to the `onPluginTypeChange` event to know\n * when the user changes the plugin type (it fires at start for the default value.)\n */\nexport const PluginKindSelect = forwardRef((props: PluginKindSelectProps, ref): ReactElement => {\n const { pluginTypes, value: propValue, onChange, filteredQueryPlugins, ...others } = props;\n const { data, isLoading } = useListPluginMetadata(pluginTypes);\n\n const sortedData = useMemo(() => {\n if (filteredQueryPlugins?.length) {\n return data\n ?.filter((i) => filteredQueryPlugins.includes(i.spec.name))\n ?.sort((a, b) => a.spec.display.name.localeCompare(b.spec.display.name));\n }\n\n return data?.sort((a, b) => a.spec.display.name.localeCompare(b.spec.display.name));\n }, [data, filteredQueryPlugins]);\n\n // Pass an empty value while options are still loading so MUI doesn't complain about us using an \"out of range\" value\n const value = !propValue || isLoading ? '' : selectionToOptionValue(propValue);\n\n const handleChange = (event: { target: { value: string } }): void => {\n onChange?.(optionValueToSelection(event.target.value));\n };\n\n const renderValue = useCallback(\n (selected: unknown) => {\n if (selected === '') {\n return '';\n }\n const selectedValue = optionValueToSelection(selected as string);\n return sortedData?.find((v) => v.kind === selectedValue.type && v.spec.name === selectedValue.kind)?.spec.display\n .name;\n },\n [sortedData]
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PluginKindSelect/PluginKindSelect.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MenuItem, TextField, TextFieldProps } from '@mui/material';\nimport { forwardRef, ReactElement, useCallback, useMemo } from 'react';\n\nimport { PluginType } from '../../model';\nimport { useListPluginMetadata } from '../../runtime';\nimport { PluginEditorSelection } from '../PluginEditor';\n\nexport interface PluginKindSelectProps extends Omit<TextFieldProps, 'value' | 'onChange' | 'children'> {\n filteredQueryPlugins?: string[];\n pluginTypes: PluginType[];\n value?: PluginEditorSelection;\n onChange?: (s: PluginEditorSelection) => void;\n}\n\n/**\n * Displays a MUI Select input for selecting a plugin's kind from a list of all the available plugins of some specific\n * plugin types. (e.g. \"Show a list of all the Panel plugins\", or \"Show a list of all the Variable plugins\", or \"Show\n * a list of all the TimeSeriesQuery, TraceQuery, ProfileQuery, and LogQuery plugins\").\n * The value of the select is the kind of the plugin, but you can also listen to the `onPluginTypeChange` event to know\n * when the user changes the plugin type (it fires at start for the default value.)\n */\nexport const PluginKindSelect = forwardRef((props: PluginKindSelectProps, ref): ReactElement => {\n const { pluginTypes, value: propValue, onChange, filteredQueryPlugins, ...others } = props;\n const { data, isLoading } = useListPluginMetadata(pluginTypes);\n\n const sortedData = useMemo(() => {\n if (filteredQueryPlugins?.length) {\n return data\n ?.filter((i) => filteredQueryPlugins.includes(i.spec.name))\n ?.sort((a, b) => a.spec.display.name.localeCompare(b.spec.display.name));\n }\n\n return data?.sort((a, b) => a.spec.display.name.localeCompare(b.spec.display.name));\n }, [data, filteredQueryPlugins]);\n\n // Pass an empty value while options are still loading so MUI doesn't complain about us using an \"out of range\" value\n const value = !propValue || isLoading ? '' : selectionToOptionValue(propValue);\n\n const handleChange = (event: { target: { value: string } }): void => {\n onChange?.(optionValueToSelection(event.target.value));\n };\n\n const renderValue = useCallback(\n (selected: unknown) => {\n if (selected === '') {\n return '';\n }\n const selectedValue = optionValueToSelection(selected as string);\n return sortedData?.find((v) => v.kind === selectedValue.type && v.spec.name === selectedValue.kind)?.spec.display\n .name;\n },\n [sortedData],\n );\n\n // TODO: Does this need a loading indicator of some kind?\n return (\n <TextField\n select\n inputRef={ref}\n {...others}\n value={value}\n aria-label={value}\n onChange={handleChange}\n SelectProps={{ renderValue }}\n data-testid=\"plugin-kind-select\"\n >\n {isLoading && <MenuItem value=\"\">Loading...</MenuItem>}\n {sortedData?.map((metadata) => (\n <MenuItem\n data-testid=\"option\"\n key={metadata.kind + metadata.spec.name}\n value={selectionToOptionValue({ type: metadata.kind, kind: metadata.spec.name })}\n >\n {metadata.spec.display.name}\n </MenuItem>\n ))}\n </TextField>\n );\n});\nPluginKindSelect.displayName = 'PluginKindSelect';\n\n// Delimiter used to stringify/parse option values\nconst OPTION_VALUE_DELIMITER = '_____';\n\n/**\n * Given a PluginEditorSelection,\n * returns a string value like `{type}_____{kind}` that can be used as a Select input value.\n * @param selector\n */\nfunction selectionToOptionValue(selector: PluginEditorSelection): string {\n return [selector.type, selector.kind].join(OPTION_VALUE_DELIMITER);\n}\n\n/**\n * Given an option value name like `{type}_____{kind}`,\n * returns a PluginEditorSelection to be used by the query data model.\n * @param optionValue\n */\nfunction optionValueToSelection(optionValue: string): PluginEditorSelection {\n const words = optionValue.split(OPTION_VALUE_DELIMITER);\n const type = words[0] as PluginType | undefined;\n const kind = words[1];\n if (type === undefined || kind === undefined) {\n throw new Error('Invalid optionValue string');\n }\n return {\n type,\n kind,\n };\n}\n"],"names":["MenuItem","TextField","forwardRef","useCallback","useMemo","useListPluginMetadata","PluginKindSelect","props","ref","pluginTypes","value","propValue","onChange","filteredQueryPlugins","others","data","isLoading","sortedData","length","filter","i","includes","spec","name","sort","a","b","display","localeCompare","selectionToOptionValue","handleChange","event","optionValueToSelection","target","renderValue","selected","selectedValue","find","v","kind","type","select","inputRef","aria-label","SelectProps","data-testid","map","metadata","displayName","OPTION_VALUE_DELIMITER","selector","join","optionValue","words","split","undefined","Error"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,QAAQ,EAAEC,SAAS,QAAwB,gBAAgB;AACpE,SAASC,UAAU,EAAgBC,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAGvE,SAASC,qBAAqB,QAAQ,gBAAgB;AAUtD;;;;;;CAMC,GACD,OAAO,MAAMC,iCAAmBJ,WAAW,CAACK,OAA8BC;IACxE,MAAM,EAAEC,WAAW,EAAEC,OAAOC,SAAS,EAAEC,QAAQ,EAAEC,oBAAoB,EAAE,GAAGC,QAAQ,GAAGP;IACrF,MAAM,EAAEQ,IAAI,EAAEC,SAAS,EAAE,GAAGX,sBAAsBI;IAElD,MAAMQ,aAAab,QAAQ;QACzB,IAAIS,sBAAsBK,QAAQ;YAChC,OAAOH,MACH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AO,CAACJ,IAAI;mBAHtBwB,SAASR,IAAI,GAAGQ,SAASzB,IAAI,CAACC,IAAI;;;AAQjD,GAAG;AACHjB,iBAAiB0C,WAAW,GAAG;AAE/B,kDAAkD;AAClD,MAAMC,yBAAyB;AAE/B;;;;CAIC,GACD,SAASpB,uBAAuBqB,QAA+B;IAC7D,OAAO;QAACA,SAASV,IAAI;QAAEU,SAASX,IAAI;KAAC,CAACY,IAAI,CAACF;AAC7C;AAEA;;;;CAIC,GACD,SAASjB,uBAAuBoB,WAAmB;IACjD,MAAMC,QAAQD,YAAYE,KAAK,CAACL;IAChC,MAAMT,OAAOa,KAAK,CAAC,EAAE;IACrB,MAAMd,OAAOc,KAAK,CAAC,EAAE;IACrB,IAAIb,SAASe,aAAahB,SAASgB,WAAW;QAC5C,MAAM,IAAIC,MAAM;IAClB;IACA,OAAO;QACLhB;QACAD;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginRegistry.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAgC,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PluginRegistry.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAgC,SAAS,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE9E,OAAO,EAKL,YAAY,EACZ,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAMrB,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,YAAY,CAoEvE"}
|
|
@@ -14,8 +14,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
import { useRef, useCallback, useMemo } from 'react';
|
|
15
15
|
import { PluginRegistryContext } from '../../runtime';
|
|
16
16
|
import { useEvent } from '../../utils';
|
|
17
|
-
import { usePluginIndexes } from './plugin-indexes';
|
|
18
17
|
import { resolvePluginKeys } from './getPluginSearchHelper';
|
|
18
|
+
import { usePluginIndexes } from './plugin-indexes';
|
|
19
19
|
/**
|
|
20
20
|
* PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or
|
|
21
21
|
* querying the metadata about them.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec } from '@perses-dev/spec';\nimport { useRef, useCallback, useMemo, ReactNode, ReactElement } from 'react';\nimport {\n PluginModuleResource,\n PluginType,\n PluginImplementation,\n Plugin,\n PluginLoader,\n DefaultPluginKinds,\n} from '../../model';\nimport { PluginRegistryContext } from '../../runtime';\nimport { useEvent } from '../../utils';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec } from '@perses-dev/spec';\nimport { useRef, useCallback, useMemo, ReactNode, ReactElement } from 'react';\n\nimport {\n PluginModuleResource,\n PluginType,\n PluginImplementation,\n Plugin,\n PluginLoader,\n DefaultPluginKinds,\n} from '../../model';\nimport { PluginRegistryContext } from '../../runtime';\nimport { useEvent } from '../../utils';\nimport { resolvePluginKeys } from './getPluginSearchHelper';\nimport { usePluginIndexes, PluginCompoundKey } from './plugin-indexes';\n\nexport interface PluginRegistryProps {\n pluginLoader: PluginLoader;\n defaultPluginKinds?: DefaultPluginKinds;\n children?: ReactNode;\n}\n\n/**\n * PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or\n * querying the metadata about them.\n */\nexport function PluginRegistry(props: PluginRegistryProps): ReactElement {\n const {\n pluginLoader: { getInstalledPlugins, importPluginModule },\n children,\n defaultPluginKinds,\n } = props;\n\n const getPluginIndexes = usePluginIndexes(getInstalledPlugins);\n\n // De-dupe calls to import plugin modules\n const importCache = useRef(new Map<PluginModuleResource, Promise<unknown>>());\n\n // Do useEvent here since this accesses the importPluginModule prop and we want a stable reference to it for the\n // callback below\n const loadPluginModule = useEvent((resource: PluginModuleResource) => {\n let request = importCache.current.get(resource);\n if (request === undefined) {\n request = importPluginModule(resource);\n importCache.current.set(resource, request);\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => importCache.current.delete(resource));\n }\n return request;\n });\n\n const getPlugin = useCallback(\n async <T extends PluginType>(compoundKeyObj: PluginCompoundKey<T>): Promise<PluginImplementation<T>> => {\n const pluginIndexes = await getPluginIndexes();\n const { kind, name } = compoundKeyObj;\n\n const candidateKeys = resolvePluginKeys(\n pluginIndexes.pluginResourcesByNameKindRegistryVersion.keys(),\n compoundKeyObj,\n );\n\n for (const resourceKey of candidateKeys) {\n const resource = pluginIndexes.pluginResourcesByNameKindRegistryVersion.get(resourceKey);\n if (!resource) continue;\n\n const pluginModule = (await loadPluginModule(resource)) as Record<string, Plugin<UnknownSpec>>;\n // Try to get the plugin implementation from the module using the versioned export first\n const plugin = pluginModule?.[resourceKey];\n if (plugin) return plugin as PluginImplementation<T>;\n // If the plugin module doesn't have a versioned export, fallback to the plugin name\n const versionlessPlugin = pluginModule?.[name];\n if (versionlessPlugin) return versionlessPlugin as PluginImplementation<T>;\n }\n\n throw new Error(`A ${name} plugin for kind '${kind}' is not installed`);\n },\n [getPluginIndexes, loadPluginModule],\n );\n\n const listPluginMetadata = useCallback(\n async (pluginTypes: PluginType[]) => {\n const pluginIndexes = await getPluginIndexes();\n return pluginTypes.flatMap((type) => pluginIndexes.pluginMetadataByKind.get(type) ?? []);\n },\n [getPluginIndexes],\n );\n\n // Create the registry's context value and render\n const context = useMemo(\n () => ({ getPlugin, listPluginMetadata, defaultPluginKinds }),\n [getPlugin, listPluginMetadata, defaultPluginKinds],\n );\n return <PluginRegistryContext.Provider value={context}>{children}</PluginRegistryContext.Provider>;\n}\n"],"names":["useRef","useCallback","useMemo","PluginRegistryContext","useEvent","resolvePluginKeys","usePluginIndexes","PluginRegistry","props","pluginLoader","getInstalledPlugins","importPluginModule","children","defaultPluginKinds","getPluginIndexes","importCache","Map","loadPluginModule","resource","request","current","get","undefined","set","catch","delete","getPlugin","compoundKeyObj","pluginIndexes","kind","name","candidateKeys","pluginResourcesByNameKindRegistryVersion","keys","resourceKey","pluginModule","plugin","versionlessPlugin","Error","listPluginMetadata","pluginTypes","flatMap","type","pluginMetadataByKind","context","Provider","value"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAGjC,SAASA,MAAM,EAAEC,WAAW,EAAEC,OAAO,QAAiC,QAAQ;AAU9E,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,QAAQ,QAAQ,cAAc;AACvC,SA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QAACf;QAAkBG;KAAiB;IAGtC,MAAMsB,qBAAqBtC,YACzB,OAAOuC;QACL,MAAMZ,gBAAgB,MAAMd;QAC5B,OAAO0B,YAAYC,OAAO,CAAC,CAACC,OAASd,cAAce,oBAAoB,CAACtB,GAAG,CAACqB,SAAS,EAAE;IACzF,GACA;QAAC5B;KAAiB;IAGpB,iDAAiD;IACjD,MAAM8B,UAAU1C,QACd,IAAO,CAAA;YAAEwB;YAAWa;YAAoB1B;QAAmB,CAAA,GAC3D;QAACa;QAAWa;QAAoB1B;KAAmB;IAErD,qBAAO,KAACV,sBAAsB0C,QAAQ;QAACC,OAAOF;kBAAUhC;;AAC1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPluginSearchHelper.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/getPluginSearchHelper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPluginSearchHelper.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/getPluginSearchHelper.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAA8B,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAIrD,MAAM,WAAW,2BAA2B;IAC1C,mBAAmB,EAAE,OAAO,CAAC;CAC9B;AAID;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,UAAU,EACpD,SAAS,QAAQ,CAAC,MAAM,CAAC,EACzB,OAAO,iBAAiB,CAAC,CAAC,CAAC,EAC3B,kBAAiB,2BAA4D,KAC5E,MAAM,EAkER,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PluginRegistry/getPluginSearchHelper.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { gt } from 'semver';\nimport { PluginType, getPluginModuleCompoundKey } from '../../model';\nimport { PluginCompoundKey } from './plugin-indexes';\n\n// When both a registry and non-registry variant exist at the same version,\n// `registryOverVersion: true` prefers the registry variant.\nexport interface PluginLookupPrecedenceLogic {\n registryOverVersion: boolean;\n}\n\nconst PLUGIN_LOOKUP_PRECEDENCE_LOGIC: PluginLookupPrecedenceLogic = { registryOverVersion: false };\n\n/**\n * Returns an ordered list of candidate 4-part keys to try when resolving a plugin.\n * If version/registry are specified, the exact-match key comes first.\n * The best fallback key (highest version, tie-broken by precedence policy) follows.\n */\nexport const resolvePluginKeys = <T extends PluginType>(\n allKeys: Iterable<string>,\n query: PluginCompoundKey<T>,\n precedenceLogic: PluginLookupPrecedenceLogic = PLUGIN_LOOKUP_PRECEDENCE_LOGIC
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PluginRegistry/getPluginSearchHelper.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { gt } from 'semver';\n\nimport { PluginType, getPluginModuleCompoundKey } from '../../model';\nimport { PluginCompoundKey } from './plugin-indexes';\n\n// When both a registry and non-registry variant exist at the same version,\n// `registryOverVersion: true` prefers the registry variant.\nexport interface PluginLookupPrecedenceLogic {\n registryOverVersion: boolean;\n}\n\nconst PLUGIN_LOOKUP_PRECEDENCE_LOGIC: PluginLookupPrecedenceLogic = { registryOverVersion: false };\n\n/**\n * Returns an ordered list of candidate 4-part keys to try when resolving a plugin.\n * If version/registry are specified, the exact-match key comes first.\n * The best fallback key (highest version, tie-broken by precedence policy) follows.\n */\nexport const resolvePluginKeys = <T extends PluginType>(\n allKeys: Iterable<string>,\n query: PluginCompoundKey<T>,\n precedenceLogic: PluginLookupPrecedenceLogic = PLUGIN_LOOKUP_PRECEDENCE_LOGIC,\n): string[] => {\n const { kind, name, version, registry } = query;\n const candidates: string[] = [];\n\n // Exact match first when version or registry is specified\n if (version || registry) {\n candidates.push(getPluginModuleCompoundKey({ kind, name, registry, version }));\n }\n\n // Find the best fallback by scanning all matching keys\n type PluginBucket = { key: string; version: string };\n const latestWithRegistry: PluginBucket = { key: '', version: '' };\n const latestWithoutRegistry: PluginBucket = { key: '', version: '' };\n\n const prefix = `${kind}:${name}:`;\n for (const key of allKeys) {\n if (!key.startsWith(prefix)) continue;\n const split = key.split(':');\n\n if (split.length !== 4) {\n console.warn(`An invalid Plugin Resource key detected during default plugin lookup: ${key}`);\n continue;\n }\n\n const [, , reg, ver] = split;\n if (!ver) {\n console.warn(`An invalid Plugin Resource key detected during default plugin lookup: ${key}`);\n continue;\n }\n\n if (reg) {\n if (!latestWithRegistry.key || gt(ver, latestWithRegistry.version)) {\n latestWithRegistry.key = key;\n latestWithRegistry.version = ver;\n }\n } else {\n if (!latestWithoutRegistry.key || gt(ver, latestWithoutRegistry.version)) {\n latestWithoutRegistry.key = key;\n latestWithoutRegistry.version = ver;\n }\n }\n }\n\n // Determine the best fallback key from the two buckets\n let fallbackKey: string | undefined;\n\n if (latestWithRegistry.key && latestWithoutRegistry.key) {\n const { registryOverVersion } = precedenceLogic;\n\n if (gt(latestWithRegistry.version, latestWithoutRegistry.version)) {\n fallbackKey = latestWithRegistry.key;\n } else if (gt(latestWithoutRegistry.version, latestWithRegistry.version)) {\n fallbackKey = latestWithoutRegistry.key;\n } else {\n // Versions are equal — use the tie-breaker\n fallbackKey = registryOverVersion ? latestWithRegistry.key : latestWithoutRegistry.key;\n }\n } else {\n fallbackKey = latestWithRegistry.key || latestWithoutRegistry.key || undefined;\n }\n\n if (fallbackKey && !candidates.includes(fallbackKey)) {\n candidates.push(fallbackKey);\n }\n\n return candidates;\n};\n"],"names":["gt","getPluginModuleCompoundKey","PLUGIN_LOOKUP_PRECEDENCE_LOGIC","registryOverVersion","resolvePluginKeys","allKeys","query","precedenceLogic","kind","name","version","registry","candidates","push","latestWithRegistry","key","latestWithoutRegistry","prefix","startsWith","split","length","console","warn","reg","ver","fallbackKey","undefined","includes"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,EAAE,QAAQ,SAAS;AAE5B,SAAqBC,0BAA0B,QAAQ,cAAc;AASrE,MAAMC,iCAA8D;IAAEC,qBAAqB;AAAM;AAEjG;;;;CAIC,GACD,OAAO,MAAMC,oBAAoB,CAC/BC,SACAC,OACAC,kBAA+CL,8BAA8B;IAE7E,MAAM,EAAEM,IAAI,EAAEC,IAAI,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGL;IAC1C,MAAMM,aAAuB,EAAE;IAE/B,0DAA0D;IAC1D,IAAIF,WAAWC,UAAU;QACvBC,WAAWC,IAAI,CAACZ,2BAA2B;YAAEO;YAAMC;YAAME;YAAUD;QAAQ;IAC7E;IAIA,MAAMI,qBAAmC;QAAEC,KAAK;QAAIL,SAAS;IAAG;IAChE,MAAMM,wBAAsC;QAAED,KAAK;QAAIL,SAAS;IAAG;IAEnE,MAAMO,SAAS,GAAGT,KAAK,CAAC,EAAEC,KAAK,CAAC,CAAC;IACjC,KAAK,MAAMM,OAAOV,QAAS;QACzB,IAAI,CAACU,IAAIG,UAAU,CAACD,SAAS;QAC7B,MAAME,QAA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|
-
{"version":3,"file":"plugin-indexes.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/plugin-indexes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin-indexes.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/plugin-indexes.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,YAAY,EACZ,wBAAwB,EACxB,oBAAoB,EACpB,UAAU,EACV,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,aAAa,CAAC;AAGrB,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAClC,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAEtC,MAAM,WAAW,aAAa;IAE5B,wCAAwC,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAE5E,oBAAoB,EAAE,GAAG,CAAC,UAAU,EAAE,wBAAwB,EAAE,CAAC,CAAC;CACnE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,mBAAmB,EAAE,YAAY,CAAC,qBAAqB,CAAC,GACvD,MAAM,OAAO,CAAC,aAAa,CAAC,CA2D9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PluginRegistry/plugin-indexes.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useCallback, useRef } from 'react';\nimport {\n PluginLoader,\n PluginMetadataWithModule,\n PluginModuleResource,\n PluginType,\n PluginCompoundKey,\n getPluginModuleCompoundKey,\n} from '../../model';\nimport { useEvent } from '../../utils';\n\nexport type { PluginCompoundKey };\nexport { getPluginModuleCompoundKey };\n\nexport interface PluginIndexes {\n // Plugin resources by plugin type, kind, registry, and version\n pluginResourcesByNameKindRegistryVersion: Map<string, PluginModuleResource>;\n // Plugin metadata by plugin type\n pluginMetadataByKind: Map<PluginType, PluginMetadataWithModule[]>;\n}\n\n/**\n * Returns an async callback for getting indexes of the installed plugin data.\n */\nexport function usePluginIndexes(\n getInstalledPlugins: PluginLoader['getInstalledPlugins']
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PluginRegistry/plugin-indexes.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useCallback, useRef } from 'react';\n\nimport {\n PluginLoader,\n PluginMetadataWithModule,\n PluginModuleResource,\n PluginType,\n PluginCompoundKey,\n getPluginModuleCompoundKey,\n} from '../../model';\nimport { useEvent } from '../../utils';\n\nexport type { PluginCompoundKey };\nexport { getPluginModuleCompoundKey };\n\nexport interface PluginIndexes {\n // Plugin resources by plugin type, kind, registry, and version\n pluginResourcesByNameKindRegistryVersion: Map<string, PluginModuleResource>;\n // Plugin metadata by plugin type\n pluginMetadataByKind: Map<PluginType, PluginMetadataWithModule[]>;\n}\n\n/**\n * Returns an async callback for getting indexes of the installed plugin data.\n */\nexport function usePluginIndexes(\n getInstalledPlugins: PluginLoader['getInstalledPlugins'],\n): () => Promise<PluginIndexes> {\n // Creates indexes from the installed plugins data (does useEvent because this accesses the getInstalledPlugins prop\n // and we want a stable reference for the callback below)\n const createPluginIndexes = useEvent(async (): Promise<PluginIndexes> => {\n const installedPlugins = await getInstalledPlugins();\n\n // Create the two indexes from the installed plugins\n const pluginResourcesByNameKindRegistryVersion = new Map<string, PluginModuleResource>();\n const pluginMetadataByKind = new Map<PluginType, PluginMetadataWithModule[]>();\n\n for (const resource of installedPlugins) {\n const {\n metadata: { version, registry },\n } = resource;\n for (const pluginMetadata of resource.spec.plugins) {\n const {\n kind,\n spec: { name },\n } = pluginMetadata;\n\n const key = getPluginModuleCompoundKey({ kind, name, registry, version });\n if (pluginResourcesByNameKindRegistryVersion.has(key)) {\n console.warn(\n `Got more than one ${kind} plugin for kind ${name}, registry '${registry || 'undefined'}', and version '${version || 'undefined'}'`,\n );\n }\n pluginResourcesByNameKindRegistryVersion.set(key, resource);\n\n // Index the metadata by plugin type\n let list = pluginMetadataByKind.get(kind);\n if (list === undefined) {\n list = [];\n pluginMetadataByKind.set(kind, list);\n }\n list.push({ ...pluginMetadata, module: resource.metadata });\n }\n }\n\n return {\n pluginResourcesByNameKindRegistryVersion,\n pluginMetadataByKind,\n };\n });\n\n // De-dupe creating plugin indexes (i.e. requests to get installed plugins)\n const pluginIndexesCache = useRef<Promise<PluginIndexes> | undefined>(undefined);\n const getPluginIndexes = useCallback(() => {\n let request = pluginIndexesCache.current;\n if (request === undefined) {\n request = createPluginIndexes();\n pluginIndexesCache.current = request;\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => (pluginIndexesCache.current = undefined));\n }\n return request;\n }, [createPluginIndexes]);\n\n return getPluginIndexes;\n}\n"],"names":["useCallback","useRef","getPluginModuleCompoundKey","useEvent","usePluginIndexes","getInstalledPlugins","createPluginIndexes","installedPlugins","pluginResourcesByNameKindRegistryVersion","Map","pluginMetadataByKind","resource","metadata","version","registry","pluginMetadata","spec","plugins","kind","name","key","has","console","warn","set","list","get","undefined","push","module","pluginIndexesCache","getPluginIndexes","request","current","catch"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,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OAA2C0B;IACtE,MAAMI,mBAAmB/B,YAAY;QACnC,IAAIgC,UAAUF,mBAAmBG,OAAO;QACxC,IAAID,YAAYL,WAAW;YACzBK,UAAU1B;YACVwB,mBAAmBG,OAAO,GAAGD;YAE7B,2EAA2E;YAC3EA,QAAQE,KAAK,CAAC,IAAOJ,mBAAmBG,OAAO,GAAGN;QACpD;QACA,OAAOK;IACT,GAAG;QAAC1B;KAAoB;IAExB,OAAOyB;AACT"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DatasourceSpec, UnknownSpec } from '@perses-dev/spec';
|
|
2
|
+
import { ReactElement } from 'react';
|
|
3
|
+
import { DatasourcePlugin, OptionsEditorProps } from '../../model';
|
|
4
|
+
export interface DatasourceSpecEditorProps extends OptionsEditorProps<UnknownSpec> {
|
|
5
|
+
plugin: DatasourcePlugin;
|
|
6
|
+
pluginKind: string;
|
|
7
|
+
testConnection?: (spec: DatasourceSpec, healthCheckPath: string) => Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export declare function DatasourceSpecEditor({ plugin, pluginKind, value, testConnection, ...others }: DatasourceSpecEditorProps): ReactElement | null;
|
|
10
|
+
//# sourceMappingURL=DatasourceSpecEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatasourceSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginSpecEditor/DatasourceSpecEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAW,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnE,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB,CAAC,WAAW,CAAC;IAChF,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnF;AAMD,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,UAAU,EACV,KAAK,EACL,cAAc,EACd,GAAG,MAAM,EACV,EAAE,yBAAyB,GAAG,YAAY,GAAG,IAAI,CAyBjD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { hasHTTPProxy } from '@perses-dev/client';
|
|
15
|
+
import { produce } from 'immer';
|
|
16
|
+
import { useMemo } from 'react';
|
|
17
|
+
function escapeRegExp(str) {
|
|
18
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
19
|
+
}
|
|
20
|
+
export function DatasourceSpecEditor({ plugin, pluginKind, value, testConnection, ...others }) {
|
|
21
|
+
const healthCheckPath = plugin.healthCheckPath;
|
|
22
|
+
const boundTestConnection = useMemo(()=>{
|
|
23
|
+
if (!testConnection || !healthCheckPath) return undefined;
|
|
24
|
+
return ()=>{
|
|
25
|
+
const escapedPattern = escapeRegExp(healthCheckPath);
|
|
26
|
+
const augmentedPluginSpec = hasHTTPProxy(value) ? produce(value, (draft)=>{
|
|
27
|
+
const existing = draft.proxy.spec.allowedEndpoints ?? [];
|
|
28
|
+
const alreadyAllowed = existing.some((e)=>e.endpointPattern === escapedPattern && e.method === 'GET');
|
|
29
|
+
if (!alreadyAllowed) {
|
|
30
|
+
draft.proxy.spec.allowedEndpoints = [
|
|
31
|
+
...existing,
|
|
32
|
+
{
|
|
33
|
+
endpointPattern: escapedPattern,
|
|
34
|
+
method: 'GET'
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
}) : value;
|
|
39
|
+
const spec = {
|
|
40
|
+
default: false,
|
|
41
|
+
plugin: {
|
|
42
|
+
kind: pluginKind,
|
|
43
|
+
spec: augmentedPluginSpec
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
return testConnection(spec, healthCheckPath);
|
|
47
|
+
};
|
|
48
|
+
}, [
|
|
49
|
+
testConnection,
|
|
50
|
+
healthCheckPath,
|
|
51
|
+
pluginKind,
|
|
52
|
+
value
|
|
53
|
+
]);
|
|
54
|
+
const { OptionsEditorComponent } = plugin;
|
|
55
|
+
return OptionsEditorComponent ? /*#__PURE__*/ _jsx(OptionsEditorComponent, {
|
|
56
|
+
...others,
|
|
57
|
+
value: value,
|
|
58
|
+
testConnection: boundTestConnection
|
|
59
|
+
}) : null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=DatasourceSpecEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PluginSpecEditor/DatasourceSpecEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { hasHTTPProxy } from '@perses-dev/client';\nimport { DatasourceSpec, UnknownSpec } from '@perses-dev/spec';\nimport { produce } from 'immer';\nimport { ReactElement, useMemo } from 'react';\n\nimport { DatasourcePlugin, OptionsEditorProps } from '../../model';\n\nexport interface DatasourceSpecEditorProps extends OptionsEditorProps<UnknownSpec> {\n plugin: DatasourcePlugin;\n pluginKind: string;\n testConnection?: (spec: DatasourceSpec, healthCheckPath: string) => Promise<void>;\n}\n\nfunction escapeRegExp(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nexport function DatasourceSpecEditor({\n plugin,\n pluginKind,\n value,\n testConnection,\n ...others\n}: DatasourceSpecEditorProps): ReactElement | null {\n const healthCheckPath = plugin.healthCheckPath;\n\n const boundTestConnection = useMemo((): (() => Promise<void>) | undefined => {\n if (!testConnection || !healthCheckPath) return undefined;\n return () => {\n const escapedPattern = escapeRegExp(healthCheckPath);\n const augmentedPluginSpec = hasHTTPProxy(value)\n ? produce(value, (draft) => {\n const existing = draft.proxy.spec.allowedEndpoints ?? [];\n const alreadyAllowed = existing.some((e) => e.endpointPattern === escapedPattern && e.method === 'GET');\n if (!alreadyAllowed) {\n draft.proxy.spec.allowedEndpoints = [...existing, { endpointPattern: escapedPattern, method: 'GET' }];\n }\n })\n : value;\n const spec: DatasourceSpec = { default: false, plugin: { kind: pluginKind, spec: augmentedPluginSpec } };\n return testConnection(spec, healthCheckPath);\n };\n }, [testConnection, healthCheckPath, pluginKind, value]);\n\n const { OptionsEditorComponent } = plugin;\n return OptionsEditorComponent ? (\n <OptionsEditorComponent {...others} value={value} testConnection={boundTestConnection} />\n ) : null;\n}\n"],"names":["hasHTTPProxy","produce","useMemo","escapeRegExp","str","replace","DatasourceSpecEditor","plugin","pluginKind","value","testConnection","others","healthCheckPath","boundTestConnection","undefined","escapedPattern","augmentedPluginSpec","draft","existing","proxy","spec","allowedEndpoints","alreadyAllowed","some","e","endpointPattern","method","default","kind","OptionsEditorComponent"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mE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GlB,MAAM;QAAEF,OAAOA;QAAOC,gBAAgBG;SAChE;AACN"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { UnknownSpec } from '@perses-dev/spec';
|
|
1
|
+
import { DatasourceSpec, UnknownSpec } from '@perses-dev/spec';
|
|
2
2
|
import { ReactElement } from 'react';
|
|
3
3
|
import { OptionsEditorProps } from '../../model';
|
|
4
4
|
import { PluginEditorSelection } from '../PluginEditor';
|
|
5
5
|
export interface PluginSpecEditorProps extends OptionsEditorProps<UnknownSpec> {
|
|
6
6
|
pluginSelection: PluginEditorSelection;
|
|
7
7
|
isEditor?: boolean;
|
|
8
|
+
testConnection?: (spec: DatasourceSpec, healthCheckPath: string) => Promise<void>;
|
|
8
9
|
}
|
|
9
10
|
export declare function PluginSpecEditor(props: PluginSpecEditorProps): ReactElement | null;
|
|
10
11
|
//# sourceMappingURL=PluginSpecEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginSpecEditor/PluginSpecEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PluginSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginSpecEditor/PluginSpecEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAoB,kBAAkB,EAAsB,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB,CAAC,WAAW,CAAC;IAC5E,eAAe,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACnF;AASD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,GAAG,IAAI,CA2ClF"}
|
|
@@ -11,11 +11,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { ErrorAlert } from '@perses-dev/components';
|
|
15
14
|
import { CircularProgress, Stack } from '@mui/material';
|
|
15
|
+
import { ErrorAlert } from '@perses-dev/components';
|
|
16
16
|
import { usePlugin } from '../../runtime';
|
|
17
|
+
import { DatasourceSpecEditor } from './DatasourceSpecEditor';
|
|
18
|
+
function isDatasourcePlugin(pluginType, plugin) {
|
|
19
|
+
return pluginType === 'Datasource' && 'createClient' in plugin;
|
|
20
|
+
}
|
|
17
21
|
export function PluginSpecEditor(props) {
|
|
18
|
-
const { pluginSelection: { type: pluginType, kind: pluginKind }, ...others } = props;
|
|
22
|
+
const { pluginSelection: { type: pluginType, kind: pluginKind }, value, testConnection, ...others } = props;
|
|
19
23
|
const { data: plugin, isLoading, error } = usePlugin(pluginType, pluginKind);
|
|
20
24
|
if (error) {
|
|
21
25
|
return /*#__PURE__*/ _jsx(ErrorAlert, {
|
|
@@ -38,9 +42,19 @@ export function PluginSpecEditor(props) {
|
|
|
38
42
|
if (pluginType === 'Panel') {
|
|
39
43
|
throw new Error('This editor should not be used for panel type. Please use Panel Spec Editor instead.');
|
|
40
44
|
}
|
|
45
|
+
if (isDatasourcePlugin(pluginType, plugin)) {
|
|
46
|
+
return /*#__PURE__*/ _jsx(DatasourceSpecEditor, {
|
|
47
|
+
plugin: plugin,
|
|
48
|
+
pluginKind: pluginKind,
|
|
49
|
+
value: value,
|
|
50
|
+
testConnection: testConnection,
|
|
51
|
+
...others
|
|
52
|
+
});
|
|
53
|
+
}
|
|
41
54
|
const { OptionsEditorComponent } = plugin;
|
|
42
55
|
return OptionsEditorComponent ? /*#__PURE__*/ _jsx(OptionsEditorComponent, {
|
|
43
|
-
...others
|
|
56
|
+
...others,
|
|
57
|
+
value: value
|
|
44
58
|
}) : null;
|
|
45
59
|
}
|
|
46
60
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PluginSpecEditor/PluginSpecEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ErrorAlert } from '@perses-dev/components';\nimport { UnknownSpec } from '@perses-dev/spec';\nimport { ReactElement } from 'react';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PluginSpecEditor/PluginSpecEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { CircularProgress, Stack } from '@mui/material';\nimport { ErrorAlert } from '@perses-dev/components';\nimport { DatasourceSpec, UnknownSpec } from '@perses-dev/spec';\nimport { ReactElement } from 'react';\n\nimport { DatasourcePlugin, OptionsEditorProps, Plugin, PluginType } from '../../model';\nimport { usePlugin } from '../../runtime';\nimport { PluginEditorSelection } from '../PluginEditor';\nimport { DatasourceSpecEditor } from './DatasourceSpecEditor';\n\nexport interface PluginSpecEditorProps extends OptionsEditorProps<UnknownSpec> {\n pluginSelection: PluginEditorSelection;\n isEditor?: boolean;\n testConnection?: (spec: DatasourceSpec, healthCheckPath: string) => Promise<void>;\n}\n\nfunction isDatasourcePlugin(\n pluginType: PluginType,\n plugin: Plugin<UnknownSpec>,\n): plugin is DatasourcePlugin<UnknownSpec> {\n return pluginType === 'Datasource' && 'createClient' in plugin;\n}\n\nexport function PluginSpecEditor(props: PluginSpecEditorProps): ReactElement | null {\n const {\n pluginSelection: { type: pluginType, kind: pluginKind },\n value,\n testConnection,\n ...others\n } = props;\n const { data: plugin, isLoading, error } = usePlugin(pluginType, pluginKind);\n\n if (error) {\n return <ErrorAlert error={error} />;\n }\n\n if (isLoading) {\n return (\n <Stack width=\"100%\" sx={{ alignItems: 'center', justifyContent: 'center' }}>\n <CircularProgress />\n </Stack>\n );\n }\n\n if (!plugin) {\n throw new Error(`Missing implementation for ${pluginType} plugin with kind '${pluginKind}'`);\n }\n\n if (pluginType === 'Panel') {\n throw new Error('This editor should not be used for panel type. Please use Panel Spec Editor instead.');\n }\n\n if (isDatasourcePlugin(pluginType, plugin)) {\n return (\n <DatasourceSpecEditor\n plugin={plugin}\n pluginKind={pluginKind}\n value={value}\n testConnection={testConnection}\n {...others}\n />\n );\n }\n\n const { OptionsEditorComponent } = plugin;\n return OptionsEditorComponent ? <OptionsEditorComponent {...others} value={value} /> : null;\n}\n"],"names":["CircularProgress","Stack","ErrorAlert","usePlugin","DatasourceSpecEditor","isDatasourcePlugin","pluginType","plugin","PluginSpecEditor","props","pluginSelection","type","kind","pluginKind","value","testConnection","others","data","isLoading","error","width","sx","alignItems","justifyContent","Error","OptionsEditorComponent"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCA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.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TimeRangeControls.d.ts","sourceRoot":"","sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"names":[],"mappings":"AAcA,OAAO,EAGL,UAAU,EAGV,cAAc,EAGf,MAAM,wBAAwB,CAAC;AAQhC,OAAO,EAAE,YAAY,EAAe,MAAM,OAAO,CAAC;AAUlD,eAAO,MAAM,gCAAgC,EAAE,UAAU,EAOxD,CAAC;AAIF,UAAU,sBAAsB;IAE9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,IAAI,CAAC;CACtD;AAED,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,qBAA4B,EAC5B,iBAAwB,EACxB,mBAA0B,EAC1B,mBAAmB,EACnB,eAAsB,EACtB,WAAW,EACX,QAAQ,EACR,gBAAgB,GACjB,EAAE,sBAAsB,GAAG,YAAY,CAoKvC"}
|
|
@@ -11,18 +11,18 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import RefreshIcon from 'mdi-material-ui/Refresh';
|
|
15
|
-
// eslint-disable-next-line import/no-duplicates
|
|
16
|
-
import ZoomIn from 'mdi-material-ui/PlusCircleOutline';
|
|
17
|
-
// eslint-disable-next-line import/no-duplicates
|
|
18
|
-
import ZoomOut from 'mdi-material-ui/MinusCircleOutline';
|
|
19
14
|
import { Stack } from '@mui/material';
|
|
20
15
|
import { RefreshIntervalPicker, InfoTooltip, ToolbarIconButton, TimeRangeSelector, getTimeZoneOptions, buildRelativeTimeOption } from '@perses-dev/components';
|
|
21
16
|
import { parseDurationString } from '@perses-dev/spec';
|
|
22
17
|
import { milliseconds } from 'date-fns';
|
|
18
|
+
// eslint-disable-next-line import/no-duplicates
|
|
19
|
+
import ZoomOut from 'mdi-material-ui/MinusCircleOutline';
|
|
20
|
+
// eslint-disable-next-line import/no-duplicates
|
|
21
|
+
import ZoomIn from 'mdi-material-ui/PlusCircleOutline';
|
|
22
|
+
import RefreshIcon from 'mdi-material-ui/Refresh';
|
|
23
23
|
import { useCallback } from 'react';
|
|
24
24
|
import { TOOLTIP_TEXT } from '../../constants';
|
|
25
|
-
import { useTimeRange, useShowCustomTimeRangeSetting, useTimeRangeOptionsSetting, useShowZoomRangeSetting } from '../../runtime';
|
|
25
|
+
import { useTimeRange, useShowCustomTimeRangeSetting, useTimeRangeOptionsSetting, useShowZoomRangeSetting, useDisableAutoRefreshSetting } from '../../runtime';
|
|
26
26
|
export const DEFAULT_REFRESH_INTERVAL_OPTIONS = [
|
|
27
27
|
{
|
|
28
28
|
value: {
|
|
@@ -66,6 +66,7 @@ export function TimeRangeControls({ heightPx, showTimeRangeSelector = true, show
|
|
|
66
66
|
const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = useTimeRange();
|
|
67
67
|
const showCustomTimeRangeValue = useShowCustomTimeRangeSetting(showCustomTimeRange);
|
|
68
68
|
const showZoomInOutButtons = useShowZoomRangeSetting(showZoomButtons);
|
|
69
|
+
const isAutoRefreshDisabled = useDisableAutoRefreshSetting();
|
|
69
70
|
const timePresetsValue = useTimeRangeOptionsSetting(timePresets);
|
|
70
71
|
// Convert height to a string, then use the string for styling
|
|
71
72
|
const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
|
|
@@ -83,10 +84,8 @@ export function TimeRangeControls({ heightPx, showTimeRangeSelector = true, show
|
|
|
83
84
|
]);
|
|
84
85
|
const fromDurationToMillis = (strDuration)=>{
|
|
85
86
|
const duration = parseDurationString(strDuration);
|
|
86
|
-
const millis = //
|
|
87
|
-
((duration.seconds ?? 0) + (duration.minutes ?? 0) * 60 + (duration.hours ?? 0) * 3600 + (duration.days ?? 0) * 86400 + (duration.weeks ?? 0) * 7 * 86400 + (duration.months ?? 0) * 30.436875 * 86400 + // avg month duration is ok for zoom purposes
|
|
87
|
+
const millis = ((duration.seconds ?? 0) + (duration.minutes ?? 0) * 60 + (duration.hours ?? 0) * 3600 + (duration.days ?? 0) * 86400 + (duration.weeks ?? 0) * 7 * 86400 + (duration.months ?? 0) * 30.436875 * 86400 + // avg month duration is ok for zoom purposes
|
|
88
88
|
(duration.years ?? 0) * 365.2425 * 86400) * // avg year duration is ok for zoom purposes
|
|
89
|
-
// eslint-disable-next-line prettier/prettier
|
|
90
89
|
1000; // to milliseconds
|
|
91
90
|
return millis;
|
|
92
91
|
};
|
|
@@ -197,7 +196,7 @@ export function TimeRangeControls({ heightPx, showTimeRangeSelector = true, show
|
|
|
197
196
|
children: /*#__PURE__*/ _jsx(RefreshIcon, {})
|
|
198
197
|
})
|
|
199
198
|
}),
|
|
200
|
-
showRefreshInterval && /*#__PURE__*/ _jsx(InfoTooltip, {
|
|
199
|
+
showRefreshInterval && !isAutoRefreshDisabled && /*#__PURE__*/ _jsx(InfoTooltip, {
|
|
201
200
|
description: TOOLTIP_TEXT.refreshInterval,
|
|
202
201
|
children: /*#__PURE__*/ _jsx(RefreshIntervalPicker, {
|
|
203
202
|
timeOptions: DEFAULT_REFRESH_INTERVAL_OPTIONS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport RefreshIcon from 'mdi-material-ui/Refresh';\n// eslint-disable-next-line import/no-duplicates\nimport ZoomIn from 'mdi-material-ui/PlusCircleOutline';\n// eslint-disable-next-line import/no-duplicates\nimport ZoomOut from 'mdi-material-ui/MinusCircleOutline';\nimport { Stack } from '@mui/material';\nimport {\n RefreshIntervalPicker,\n InfoTooltip,\n TimeOption,\n ToolbarIconButton,\n TimeRangeSelector,\n TimeZoneOption,\n getTimeZoneOptions,\n buildRelativeTimeOption,\n} from '@perses-dev/components';\nimport { AbsoluteTimeRange, DurationString, parseDurationString, RelativeTimeRange } from '@perses-dev/spec';\nimport { milliseconds } from 'date-fns';\nimport { ReactElement, useCallback } from 'react';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport {\n useTimeRange,\n useShowCustomTimeRangeSetting,\n useTimeRangeOptionsSetting,\n useShowZoomRangeSetting,\n} from '../../runtime';\nexport const DEFAULT_REFRESH_INTERVAL_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '0s' }, display: 'Off' },\n { value: { pastDuration: '5s' }, display: '5s' },\n { value: { pastDuration: '10s' }, display: '10s' },\n { value: { pastDuration: '15s' }, display: '15s' },\n { value: { pastDuration: '30s' }, display: '30s' },\n { value: { pastDuration: '60s' }, display: '1m' },\n];\n\nconst DEFAULT_HEIGHT = '34px';\n\ninterface TimeRangeControlsProps {\n // The controls look best at heights >= 28 pixels\n heightPx?: number;\n showTimeRangeSelector?: boolean;\n showRefreshButton?: boolean;\n showRefreshInterval?: boolean;\n showCustomTimeRange?: boolean;\n showZoomButtons?: boolean;\n timePresets?: TimeOption[];\n timeZone: string;\n onTimeZoneChange: (timeZone: TimeZoneOption) => void;\n}\n\nexport function TimeRangeControls({\n heightPx,\n showTimeRangeSelector = true,\n showRefreshButton = true,\n showRefreshInterval = true,\n showCustomTimeRange,\n showZoomButtons = true,\n timePresets,\n timeZone,\n onTimeZoneChange,\n}: TimeRangeControlsProps): ReactElement {\n const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = useTimeRange();\n\n const showCustomTimeRangeValue = useShowCustomTimeRangeSetting(showCustomTimeRange);\n const showZoomInOutButtons = useShowZoomRangeSetting(showZoomButtons);\n const timePresetsValue = useTimeRangeOptionsSetting(timePresets);\n\n // Convert height to a string, then use the string for styling\n const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;\n\n // add time preset if one does not match duration given in time range, keeping the list ordered by duration\n if (\n 'pastDuration' in timeRange &&\n !timePresetsValue.some((option) => option.value.pastDuration === timeRange['pastDuration'])\n ) {\n const durationMs = milliseconds(parseDurationString(timeRange['pastDuration']));\n const insertionIndex = timePresetsValue.findIndex(\n (option) => milliseconds(parseDurationString(option.value.pastDuration)) > durationMs\n );\n timePresetsValue.splice(\n insertionIndex === -1 ? timePresetsValue.length : insertionIndex,\n 0,\n buildRelativeTimeOption(timeRange['pastDuration'])\n );\n }\n\n // set the new refresh interval both in the dashboard context & as query param\n const handleRefreshIntervalChange = useCallback(\n (duration: DurationString) => {\n setRefreshInterval(duration);\n },\n [setRefreshInterval]\n );\n\n const fromDurationToMillis = (strDuration: string): number => {\n const duration = parseDurationString(strDuration);\n const millis =\n // eslint-disable-next-line prettier/prettier\n ((duration.seconds ?? 0) +\n (duration.minutes ?? 0) * 60 +\n (duration.hours ?? 0) * 3600 +\n (duration.days ?? 0) * 86400 +\n (duration.weeks ?? 0) * 7 * 86400 +\n (duration.months ?? 0) * 30.436875 * 86400 + // avg month duration is ok for zoom purposes\n (duration.years ?? 0) * 365.2425 * 86400) * // avg year duration is ok for zoom purposes\n // eslint-disable-next-line prettier/prettier\n 1000; // to milliseconds\n return millis;\n };\n\n // Function to double current time range, adding 50% before current start and 50% after current end\n const doubleTimeRange = (): AbsoluteTimeRange => {\n let newStart, newEnd, extendEndsBy;\n const now = new Date();\n if (Object.hasOwn(timeRange, 'start')) {\n // current range is absolute\n const absVal = timeRange as AbsoluteTimeRange;\n extendEndsBy = (absVal.end.getTime() - absVal.start.getTime()) / 2; // half it to add 50% before current start and after current end\n newStart = new Date(absVal.start.getTime() - extendEndsBy);\n newEnd = new Date(absVal.end.getTime() + extendEndsBy);\n } else {\n // current range is relative\n const relVal = timeRange as RelativeTimeRange;\n extendEndsBy = fromDurationToMillis(relVal.pastDuration) / 2;\n newEnd = typeof relVal.end === 'undefined' ? now : new Date(relVal.end.getTime() + extendEndsBy);\n newStart = new Date(newEnd.getTime() - extendEndsBy * 4);\n }\n if (newEnd.getTime() > now.getTime()) {\n // if the new computed end is in the future\n newEnd = now;\n newStart.setTime(now.getTime() - extendEndsBy * 4);\n }\n if (newStart.getTime() < 1) {\n newStart.setTime(1);\n }\n return { start: newStart, end: newEnd };\n };\n\n // Function to half current time range, cutting 25% before current start and 25% after current end\n const halfTimeRange = (): AbsoluteTimeRange => {\n let newStart, newEnd;\n if (Object.hasOwn(timeRange, 'start')) {\n const absVal = timeRange as AbsoluteTimeRange;\n const shrinkEndsBy = (absVal.end.getTime() - absVal.start.getTime()) / 4;\n newStart = new Date(absVal.start.getTime() + shrinkEndsBy);\n newEnd = new Date(absVal.end.getTime() - shrinkEndsBy);\n } else {\n const relVal = timeRange as RelativeTimeRange;\n const shrinkEndsBy = fromDurationToMillis(relVal.pastDuration) / 4; // 25% of it to cut after current start and before current end\n const endIsAbsolute = typeof relVal.end !== 'undefined';\n newEnd = endIsAbsolute ? new Date(relVal.end!.getTime() - shrinkEndsBy) : new Date();\n newStart = new Date(newEnd.getTime() - shrinkEndsBy * 2);\n }\n if (newStart.getTime() >= newEnd.getTime() - 1000) {\n newStart.setTime(newEnd.getTime() - 1000);\n }\n return { start: newStart, end: newEnd };\n };\n\n const setHalfTimeRange = (): void => setTimeRange(halfTimeRange());\n const setDoubleTimeRange = (): void => setTimeRange(doubleTimeRange());\n\n const handleTimeZoneChange = useCallback(\n (tz: TimeZoneOption) => {\n onTimeZoneChange(tz);\n },\n [onTimeZoneChange]\n );\n\n return (\n <Stack direction=\"row\" spacing={1}>\n {showTimeRangeSelector && (\n <TimeRangeSelector\n timeOptions={timePresetsValue}\n value={timeRange}\n onChange={setTimeRange}\n height={height}\n showCustomTimeRange={showCustomTimeRangeValue}\n timeZone={timeZone}\n timeZoneOptions={getTimeZoneOptions()}\n onTimeZoneChange={handleTimeZoneChange}\n />\n )}\n {showZoomInOutButtons && (\n <InfoTooltip description={TOOLTIP_TEXT.zoomOut}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.zoomOut} onClick={setDoubleTimeRange} sx={{ height }}>\n <ZoomOut />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showZoomInOutButtons && (\n <InfoTooltip description={TOOLTIP_TEXT.zoomIn}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.zoomIn} onClick={setHalfTimeRange} sx={{ height }}>\n <ZoomIn />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showRefreshButton && (\n <InfoTooltip description={TOOLTIP_TEXT.refresh}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.refresh} onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showRefreshInterval && (\n <InfoTooltip description={TOOLTIP_TEXT.refreshInterval}>\n <RefreshIntervalPicker\n timeOptions={DEFAULT_REFRESH_INTERVAL_OPTIONS}\n value={\n /* TODO: There is a bug here which should be fixed in a proper way. (This is only a quick remedy)\n display: 1m has the pastDuration of 60s. Initially (if the persisted value is 1m) when the page is loaded, instead of 60s, 1m is passed down. \n This only happens for 1m, because for other items the display and the pastDuration are the same. Example 30s-30s\n HERE The value MUST always be pastDuration, otherwise the component would not work as expected. \n */\n DEFAULT_REFRESH_INTERVAL_OPTIONS.some((i) => i.value.pastDuration === refreshInterval)\n ? refreshInterval\n : DEFAULT_REFRESH_INTERVAL_OPTIONS.find((i) => i.display === refreshInterval)?.value.pastDuration\n }\n onChange={handleRefreshIntervalChange}\n height={height}\n />\n </InfoTooltip>\n )}\n </Stack>\n );\n}\n"],"names":["RefreshIcon","ZoomIn","ZoomOut","Stack","RefreshIntervalPicker","InfoTooltip","ToolbarIconButton","TimeRangeSelector","getTimeZoneOptions","buildRelativeTimeOption","parseDurationString","milliseconds","useCallback","TOOLTIP_TEXT","useTimeRange","useShowCustomTimeRangeSetting","useTimeRangeOptionsSetting","useShowZoomRangeSetting","DEFAULT_REFRESH_INTERVAL_OPTIONS","value","pastDuration","display","DEFAULT_HEIGHT","TimeRangeControls","heightPx","showTimeRangeSelector","showRefreshButton","showRefreshInterval","showCustomTimeRange","showZoomButtons","timePresets","timeZone","onTimeZoneChange","timeRange","setTimeRange","refresh","refreshInterval","setRefreshInterval","showCustomTimeRangeValue","showZoomInOutButtons","timePresetsValue","height","undefined","some","option","durationMs","insertionIndex","findIndex","splice","length","handleRefreshIntervalChange","duration","fromDurationToMillis","strDuration","millis","seconds","minutes","hours","days","weeks","months","years","doubleTimeRange","newStart","newEnd","extendEndsBy","now","Date","Object","hasOwn","absVal","end","getTime","start","relVal","setTime","halfTimeRange","shrinkEndsBy","endIsAbsolute","setHalfTimeRange","setDoubleTimeRange","handleTimeZoneChange","tz","direction","spacing","timeOptions","onChange","timeZoneOptions","description","zoomOut","aria-label","onClick","sx","zoomIn","i","find"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAOA,iBAAiB,0BAA0B;AAClD,gDAAgD;AAChD,OAAOC,YAAY,oCAAoC;AACvD,gDAAgD;AAChD,OAAOC,aAA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AASxD;oBAASyD,IAAI;wBAAEnD;oBAAO;8BAClF,cAAA,KAACzC;;;YAIN2B,qCACC,KAACtB;gBAAYmF,aAAa3E,aAAauB,eAAe;0BACpD,cAAA,KAAChC;oBACCiF,aAAanE;oBACbC,OACE;;;;cAIA,GACAD,iCAAiCyB,IAAI,CAAC,CAACmD,IAAMA,EAAE3E,KAAK,CAACC,YAAY,KAAKgB,mBAClEA,kBACAlB,iCAAiC6E,IAAI,CAAC,CAACD,IAAMA,EAAEzE,OAAO,KAAKe,kBAAkBjB,MAAMC;oBAEzFkE,UAAUpC;oBACVT,QAAQA;;;;;AAMpB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Stack } from '@mui/material';\nimport {\n RefreshIntervalPicker,\n InfoTooltip,\n TimeOption,\n ToolbarIconButton,\n TimeRangeSelector,\n TimeZoneOption,\n getTimeZoneOptions,\n buildRelativeTimeOption,\n} from '@perses-dev/components';\nimport { AbsoluteTimeRange, DurationString, parseDurationString, RelativeTimeRange } from '@perses-dev/spec';\nimport { milliseconds } from 'date-fns';\n// eslint-disable-next-line import/no-duplicates\nimport ZoomOut from 'mdi-material-ui/MinusCircleOutline';\n// eslint-disable-next-line import/no-duplicates\nimport ZoomIn from 'mdi-material-ui/PlusCircleOutline';\nimport RefreshIcon from 'mdi-material-ui/Refresh';\nimport { ReactElement, useCallback } from 'react';\n\nimport { TOOLTIP_TEXT } from '../../constants';\nimport {\n useTimeRange,\n useShowCustomTimeRangeSetting,\n useTimeRangeOptionsSetting,\n useShowZoomRangeSetting,\n useDisableAutoRefreshSetting,\n} from '../../runtime';\nexport const DEFAULT_REFRESH_INTERVAL_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '0s' }, display: 'Off' },\n { value: { pastDuration: '5s' }, display: '5s' },\n { value: { pastDuration: '10s' }, display: '10s' },\n { value: { pastDuration: '15s' }, display: '15s' },\n { value: { pastDuration: '30s' }, display: '30s' },\n { value: { pastDuration: '60s' }, display: '1m' },\n];\n\nconst DEFAULT_HEIGHT = '34px';\n\ninterface TimeRangeControlsProps {\n // The controls look best at heights >= 28 pixels\n heightPx?: number;\n showTimeRangeSelector?: boolean;\n showRefreshButton?: boolean;\n showRefreshInterval?: boolean;\n showCustomTimeRange?: boolean;\n showZoomButtons?: boolean;\n timePresets?: TimeOption[];\n timeZone: string;\n onTimeZoneChange: (timeZone: TimeZoneOption) => void;\n}\n\nexport function TimeRangeControls({\n heightPx,\n showTimeRangeSelector = true,\n showRefreshButton = true,\n showRefreshInterval = true,\n showCustomTimeRange,\n showZoomButtons = true,\n timePresets,\n timeZone,\n onTimeZoneChange,\n}: TimeRangeControlsProps): ReactElement {\n const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = useTimeRange();\n\n const showCustomTimeRangeValue = useShowCustomTimeRangeSetting(showCustomTimeRange);\n const showZoomInOutButtons = useShowZoomRangeSetting(showZoomButtons);\n const isAutoRefreshDisabled = useDisableAutoRefreshSetting();\n const timePresetsValue = useTimeRangeOptionsSetting(timePresets);\n\n // Convert height to a string, then use the string for styling\n const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;\n\n // add time preset if one does not match duration given in time range, keeping the list ordered by duration\n if (\n 'pastDuration' in timeRange &&\n !timePresetsValue.some((option) => option.value.pastDuration === timeRange['pastDuration'])\n ) {\n const durationMs = milliseconds(parseDurationString(timeRange['pastDuration']));\n const insertionIndex = timePresetsValue.findIndex(\n (option) => milliseconds(parseDurationString(option.value.pastDuration)) > durationMs,\n );\n timePresetsValue.splice(\n insertionIndex === -1 ? timePresetsValue.length : insertionIndex,\n 0,\n buildRelativeTimeOption(timeRange['pastDuration']),\n );\n }\n\n // set the new refresh interval both in the dashboard context & as query param\n const handleRefreshIntervalChange = useCallback(\n (duration: DurationString) => {\n setRefreshInterval(duration);\n },\n [setRefreshInterval],\n );\n\n const fromDurationToMillis = (strDuration: string): number => {\n const duration = parseDurationString(strDuration);\n const millis =\n ((duration.seconds ?? 0) +\n (duration.minutes ?? 0) * 60 +\n (duration.hours ?? 0) * 3600 +\n (duration.days ?? 0) * 86400 +\n (duration.weeks ?? 0) * 7 * 86400 +\n (duration.months ?? 0) * 30.436875 * 86400 + // avg month duration is ok for zoom purposes\n (duration.years ?? 0) * 365.2425 * 86400) * // avg year duration is ok for zoom purposes\n 1000; // to milliseconds\n return millis;\n };\n\n // Function to double current time range, adding 50% before current start and 50% after current end\n const doubleTimeRange = (): AbsoluteTimeRange => {\n let newStart, newEnd, extendEndsBy;\n const now = new Date();\n if (Object.hasOwn(timeRange, 'start')) {\n // current range is absolute\n const absVal = timeRange as AbsoluteTimeRange;\n extendEndsBy = (absVal.end.getTime() - absVal.start.getTime()) / 2; // half it to add 50% before current start and after current end\n newStart = new Date(absVal.start.getTime() - extendEndsBy);\n newEnd = new Date(absVal.end.getTime() + extendEndsBy);\n } else {\n // current range is relative\n const relVal = timeRange as RelativeTimeRange;\n extendEndsBy = fromDurationToMillis(relVal.pastDuration) / 2;\n newEnd = typeof relVal.end === 'undefined' ? now : new Date(relVal.end.getTime() + extendEndsBy);\n newStart = new Date(newEnd.getTime() - extendEndsBy * 4);\n }\n if (newEnd.getTime() > now.getTime()) {\n // if the new computed end is in the future\n newEnd = now;\n newStart.setTime(now.getTime() - extendEndsBy * 4);\n }\n if (newStart.getTime() < 1) {\n newStart.setTime(1);\n }\n return { start: newStart, end: newEnd };\n };\n\n // Function to half current time range, cutting 25% before current start and 25% after current end\n const halfTimeRange = (): AbsoluteTimeRange => {\n let newStart, newEnd;\n if (Object.hasOwn(timeRange, 'start')) {\n const absVal = timeRange as AbsoluteTimeRange;\n const shrinkEndsBy = (absVal.end.getTime() - absVal.start.getTime()) / 4;\n newStart = new Date(absVal.start.getTime() + shrinkEndsBy);\n newEnd = new Date(absVal.end.getTime() - shrinkEndsBy);\n } else {\n const relVal = timeRange as RelativeTimeRange;\n const shrinkEndsBy = fromDurationToMillis(relVal.pastDuration) / 4; // 25% of it to cut after current start and before current end\n const endIsAbsolute = typeof relVal.end !== 'undefined';\n newEnd = endIsAbsolute ? new Date(relVal.end!.getTime() - shrinkEndsBy) : new Date();\n newStart = new Date(newEnd.getTime() - shrinkEndsBy * 2);\n }\n if (newStart.getTime() >= newEnd.getTime() - 1000) {\n newStart.setTime(newEnd.getTime() - 1000);\n }\n return { start: newStart, end: newEnd };\n };\n\n const setHalfTimeRange = (): void => setTimeRange(halfTimeRange());\n const setDoubleTimeRange = (): void => setTimeRange(doubleTimeRange());\n\n const handleTimeZoneChange = useCallback(\n (tz: TimeZoneOption) => {\n onTimeZoneChange(tz);\n },\n [onTimeZoneChange],\n );\n\n return (\n <Stack direction=\"row\" spacing={1}>\n {showTimeRangeSelector && (\n <TimeRangeSelector\n timeOptions={timePresetsValue}\n value={timeRange}\n onChange={setTimeRange}\n height={height}\n showCustomTimeRange={showCustomTimeRangeValue}\n timeZone={timeZone}\n timeZoneOptions={getTimeZoneOptions()}\n onTimeZoneChange={handleTimeZoneChange}\n />\n )}\n {showZoomInOutButtons && (\n <InfoTooltip description={TOOLTIP_TEXT.zoomOut}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.zoomOut} onClick={setDoubleTimeRange} sx={{ height }}>\n <ZoomOut />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showZoomInOutButtons && (\n <InfoTooltip description={TOOLTIP_TEXT.zoomIn}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.zoomIn} onClick={setHalfTimeRange} sx={{ height }}>\n <ZoomIn />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showRefreshButton && (\n <InfoTooltip description={TOOLTIP_TEXT.refresh}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.refresh} onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showRefreshInterval && !isAutoRefreshDisabled && (\n <InfoTooltip description={TOOLTIP_TEXT.refreshInterval}>\n <RefreshIntervalPicker\n timeOptions={DEFAULT_REFRESH_INTERVAL_OPTIONS}\n value={\n /* TODO: There is a bug here which should be fixed in a proper way. (This is only a quick remedy)\n display: 1m has the pastDuration of 60s. Initially (if the persisted value is 1m) when the page is loaded, instead of 60s, 1m is passed down. \n This only happens for 1m, because for other items the display and the pastDuration are the same. Example 30s-30s\n HERE The value MUST always be pastDuration, otherwise the component would not work as expected. \n */\n DEFAULT_REFRESH_INTERVAL_OPTIONS.some((i) => i.value.pastDuration === refreshInterval)\n ? refreshInterval\n : DEFAULT_REFRESH_INTERVAL_OPTIONS.find((i) => i.display === refreshInterval)?.value.pastDuration\n }\n onChange={handleRefreshIntervalChange}\n height={height}\n />\n </InfoTooltip>\n )}\n </Stack>\n );\n}\n"],"names":["Stack","RefreshIntervalPicker","InfoTooltip","ToolbarIconButton","TimeRangeSelector","getTimeZoneOptions","buildRelativeTimeOption","parseDurationString","milliseconds","ZoomOut","ZoomIn","RefreshIcon","useCallback","TOOLTIP_TEXT","useTimeRange","useShowCustomTimeRangeSetting","useTimeRangeOptionsSetting","useShowZoomRangeSetting","useDisableAutoRefreshSetting","DEFAULT_REFRESH_INTERVAL_OPTIONS","value","pastDuration","display","DEFAULT_HEIGHT","TimeRangeControls","heightPx","showTimeRangeSelector","showRefreshButton","showRefreshInterval","showCustomTimeRange","showZoomButtons","timePresets","timeZone","onTimeZoneChange","timeRange","setTimeRange","refresh","refreshInterval","setRefreshInterval","showCustomTimeRangeValue","showZoomInOutButtons","isAutoRefreshDisabled","timePresetsValue","height","undefined","some","option","durationMs","insertionIndex","findIndex","splice","length","handleRefreshIntervalChange","duration","fromDurationToMillis","strDuration","millis","seconds","minutes","hours","days","weeks","months","years","doubleTimeRange","newStart","newEnd","extendEndsBy","now","Date","Object","hasOwn","absVal","end","getTime","start","relVal","setTime","halfTimeRange","shrinkEndsBy","endIsAbsolute","setHalfTimeRange","setDoubleTimeRange","handleTimeZoneChange","tz","direction","spacing","timeOptions","onChange","timeZoneOptions","description","zoomOut","aria-label","onClick","sx","zoomIn","i","find"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,KAAK,QAAQ,gBAAgB;AACtC,SACEC,qBAAqB,EACrBC,WAAW,EAEXC,iBAAiB,EACjBC,iBAAiB,EAEjBC,kBAAkB,EAClBC,uBAAuB,QAClB,yBAAyB;AAChC,SAA4CC,mBAAmB,QAA2B,mBAAmB;AAC7G,SAASC,YAAY,QAAQ,WAAW;AACxC,gDAAgD;AAChD,OAAOC,aAAa,qCAAqC;AACzD,gDAAgD;AAChD,OAAOC,YAAY,oCAAoC;AACvD,OAAOC,iBAAiB,0BAA0B;AAClD,SAAuBC,WAAW,QAAQ,QAAQ;AAElD,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SACEC,YAAY,EACZC,6BAA6B,EAC7BC,0BAA0B,EAC1BC,uBAAuB,EACvBC,4BAA4B,QACvB,gBAAgB;AACvB,OAAO,MAAMC,mCAAiD;IAC5D;QAAEC,OAAO;YAAEC,cAAc;QAAK;QAAGC,SAAS;IAAM;IAChD;QAAEF,OAAO;YAAEC,cAAc;QAAK;QAAGC,SAAS;IAAK;IAC/C;QAAEF,OAAO;YAAEC,cAAc;QAAM;QAAGC,SAAS;IAAM;IACjD;QAAEF,OAAO;YAAEC,cAAc;QAAM;QAAGC,SAAS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C;gBACbtB,OAAOc;gBACPsD,UAAUrD;gBACVQ,QAAQA;gBACRd,qBAAqBU;gBACrBP,UAAUA;gBACVyD,iBAAiBpF;gBACjB4B,kBAAkBkD;;YAGrB3C,sCACC,KAACtC;gBAAYwF,aAAa7E,aAAa8E,OAAO;0BAC5C,cAAA,KAACxF;oBAAkByF,cAAY/E,aAAa8E,OAAO;oBAAEE,SAASX;oBAAoBY,IAAI;wBAAEnD;oBAAO;8BAC7F,cAAA,KAAClC;;;YAIN+B,sCACC,KAACtC;gBAAYwF,aAAa7E,aAAakF,MAAM;0BAC3C,cAAA,KAAC5F;oBAAkByF,cAAY/E,aAAakF,MAAM;oBAAEF,SAASZ;oBAAkBa,IAAI;wBAAEnD;oBAAO;8BAC1F,cAAA,KAACjC;;;YAINiB,mCACC,KAACzB;gBAAYwF,aAAa7E,aAAauB,OAAO;0BAC5C,cAAA,KAACjC;oBAAkByF,cAAY/E,aAAauB,OAAO;oBAAEyD,SAASzD;oBAAS0D,IAAI;wBAAEnD;oBAAO;8BAClF,cAAA,KAAChC;;;YAINiB,uBAAuB,CAACa,uCACvB,KAACvC;gBAAYwF,aAAa7E,aAAawB,eAAe;0BACpD,cAAA,KAACpC;oBACCsF,aAAapE;oBACbC,OACE;;;;cAIA,GACAD,iCAAiC0B,IAAI,CAAC,CAACmD,IAAMA,EAAE5E,KAAK,CAACC,YAAY,KAAKgB,mBAClEA,kBACAlB,iCAAiC8E,IAAI,CAAC,CAACD,IAAMA,EAAE1E,OAAO,KAAKe,kBAAkBjB,MAAMC;oBAEzFmE,UAAUpC;oBACVT,QAAQA;;;;;AAMpB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { DispatchWithoutAction, ReactElement } from 'react';
|
|
2
|
-
import { VariableDefinition } from '@perses-dev/spec';
|
|
3
1
|
import { Action } from '@perses-dev/client';
|
|
2
|
+
import { VariableDefinition } from '@perses-dev/spec';
|
|
3
|
+
import { DispatchWithoutAction, ReactElement } from 'react';
|
|
4
4
|
interface VariableEditorFormProps {
|
|
5
5
|
initialVariableDefinition: VariableDefinition;
|
|
6
6
|
action: Action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariableEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"VariableEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAS5C,OAAO,EAAE,kBAAkB,EAA0B,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AA+VnF,UAAU,uBAAuB;IAC/B,yBAAyB,EAAE,kBAAkB,CAAC;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC1C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,kBAAkB,CAAC,EACjC,yBAAyB,EACzB,MAAM,EACN,OAAO,EACP,UAAU,EACV,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,uBAAuB,GAAG,YAAY,CAoMxC"}
|
|
@@ -11,17 +11,17 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import {
|
|
14
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
15
15
|
import { Box, Typography, Switch, TextField, Grid, FormControlLabel, MenuItem, Stack, Divider } from '@mui/material';
|
|
16
16
|
import { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary, FormActions, getSubmitText, getTitleAction } from '@perses-dev/components';
|
|
17
|
-
import { Controller, FormProvider, useForm, useFormContext, useWatch } from 'react-hook-form';
|
|
18
|
-
import { zodResolver } from '@hookform/resolvers/zod';
|
|
19
17
|
import { useQueryClient } from '@tanstack/react-query';
|
|
20
|
-
import {
|
|
18
|
+
import { useCallback, useState } from 'react';
|
|
19
|
+
import { Controller, FormProvider, useForm, useFormContext, useWatch } from 'react-hook-form';
|
|
21
20
|
import { useValidationSchemas } from '../../../context';
|
|
21
|
+
import { PluginEditor } from '../../PluginEditor';
|
|
22
22
|
import { VARIABLE_TYPES } from '../variable-model';
|
|
23
|
-
import { VariableListPreview, VariablePreview } from './VariablePreview';
|
|
24
23
|
import { SORT_METHODS } from './variable-editor-form-model';
|
|
24
|
+
import { VariableListPreview, VariablePreview } from './VariablePreview';
|
|
25
25
|
function FallbackPreview() {
|
|
26
26
|
return /*#__PURE__*/ _jsx("div", {
|
|
27
27
|
children: "Error previewing values"
|