@perses-dev/plugin-system 0.54.0-beta.1 → 0.54.0-beta.11
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 +283 -0
- package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +197 -0
- package/dist/cjs/components/Annotations/AnnotationEditorForm/index.js +30 -0
- package/dist/cjs/components/Annotations/constants.js +23 -0
- package/dist/cjs/components/Annotations/index.js +31 -0
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +97 -12
- package/dist/cjs/components/MultiQueryEditor/index.js +1 -0
- package/dist/cjs/components/MultiQueryEditor/utils.js +36 -0
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +3 -6
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -15
- package/dist/cjs/components/PluginRegistry/getPluginSearchHelper.js +92 -0
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +16 -13
- package/dist/cjs/components/Variables/variable-model.js +115 -29
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/context/ValidationProvider.js +10 -4
- package/dist/cjs/model/alerts-queries.js +16 -0
- package/dist/cjs/model/annotations.js +16 -0
- package/dist/cjs/model/index.js +3 -0
- package/dist/cjs/model/log-volume-utils.js +10 -10
- package/dist/cjs/model/plugin-loading.js +24 -8
- package/dist/cjs/model/plugins.js +10 -0
- package/dist/cjs/model/silences-queries.js +16 -0
- package/dist/cjs/remote/PluginRuntime.js +46 -10
- package/dist/cjs/remote/remotePluginLoader.js +28 -5
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +33 -24
- package/dist/cjs/runtime/DataQueriesProvider/model.js +3 -93
- package/dist/cjs/runtime/UsageMetricsProvider.js +2 -2
- package/dist/cjs/runtime/alerts-queries.js +101 -0
- package/dist/cjs/runtime/annotations.js +148 -0
- package/dist/cjs/runtime/index.js +3 -1
- package/dist/cjs/runtime/item-actions.js +3 -3
- package/dist/cjs/runtime/log-queries.js +4 -1
- package/dist/cjs/runtime/plugin-registry.js +12 -3
- package/dist/cjs/runtime/profile-queries.js +4 -1
- package/dist/cjs/runtime/silences-queries.js +101 -0
- package/dist/cjs/runtime/time-series-queries.js +4 -1
- package/dist/cjs/runtime/trace-queries.js +4 -1
- package/dist/cjs/test/mock-data.js +51 -0
- package/dist/cjs/test/test-plugins/bert/index.js +9 -12
- package/dist/cjs/test/test-plugins/ernie/index.js +9 -12
- package/dist/cjs/test/test-plugins/index.js +2 -2
- package/dist/cjs/test-utils/mock-plugin-registry.js +8 -2
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +16 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +270 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts +8 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +184 -0
- package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -0
- package/dist/components/Annotations/AnnotationEditorForm/index.d.ts +2 -0
- package/dist/components/Annotations/AnnotationEditorForm/index.d.ts.map +1 -0
- package/dist/{runtime/QueryCountProvider.js → components/Annotations/AnnotationEditorForm/index.js} +2 -13
- package/dist/components/Annotations/AnnotationEditorForm/index.js.map +1 -0
- package/dist/components/Annotations/constants.d.ts +2 -0
- package/dist/components/Annotations/constants.d.ts.map +1 -0
- package/dist/components/Annotations/constants.js +15 -0
- package/dist/components/Annotations/constants.js.map +1 -0
- package/dist/components/Annotations/index.d.ts +3 -0
- package/dist/components/Annotations/index.d.ts.map +1 -0
- package/dist/components/Annotations/index.js +16 -0
- package/dist/components/Annotations/index.js.map +1 -0
- package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +1 -2
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js +2 -2
- package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +2 -2
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js +1 -1
- package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +100 -15
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/MultiQueryEditor/index.d.ts +1 -0
- package/dist/components/MultiQueryEditor/index.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/index.js +1 -0
- package/dist/components/MultiQueryEditor/index.js.map +1 -1
- package/dist/components/MultiQueryEditor/utils.d.ts +8 -0
- package/dist/components/MultiQueryEditor/utils.d.ts.map +1 -0
- package/dist/components/MultiQueryEditor/utils.js +23 -0
- package/dist/components/MultiQueryEditor/utils.js.map +1 -0
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +5 -8
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +1 -1
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +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 +12 -16
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts +12 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.js +88 -0
- package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -0
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -6
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +15 -13
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js +1 -1
- package/dist/components/SelectionOptionsEditor/SelectionOptionsEditor.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.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/variable-model.d.ts +9 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +117 -31
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/context/ValidationProvider.d.ts +4 -2
- package/dist/context/ValidationProvider.d.ts.map +1 -1
- package/dist/context/ValidationProvider.js +10 -4
- package/dist/context/ValidationProvider.js.map +1 -1
- package/dist/model/alerts-queries.d.ts +33 -0
- package/dist/model/alerts-queries.d.ts.map +1 -0
- package/dist/model/alerts-queries.js +15 -0
- package/dist/model/alerts-queries.js.map +1 -0
- package/dist/model/annotations.d.ts +28 -0
- package/dist/model/annotations.d.ts.map +1 -0
- package/dist/model/annotations.js +17 -0
- package/dist/model/annotations.js.map +1 -0
- package/dist/model/datasource.d.ts +1 -8
- 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/index.d.ts +3 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +3 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/log-queries.d.ts +2 -1
- package/dist/model/log-queries.d.ts.map +1 -1
- package/dist/model/log-queries.js.map +1 -1
- package/dist/model/plugin-loading.d.ts.map +1 -1
- package/dist/model/plugin-loading.js +24 -8
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.d.ts +23 -0
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js +4 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/silences-queries.d.ts +33 -0
- package/dist/model/silences-queries.d.ts.map +1 -0
- package/dist/model/silences-queries.js +15 -0
- package/dist/model/silences-queries.js.map +1 -0
- package/dist/model/trace-queries.d.ts +2 -3
- package/dist/model/trace-queries.d.ts.map +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/remote/PersesPlugin.types.d.ts +2 -0
- package/dist/remote/PersesPlugin.types.d.ts.map +1 -1
- package/dist/remote/PersesPlugin.types.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.js +1 -1
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts +7 -1
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +46 -10
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.d.ts.map +1 -1
- package/dist/remote/remotePluginLoader.js +28 -5
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +35 -26
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +4 -4
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +0 -82
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/RouterProvider.js +1 -1
- package/dist/runtime/RouterProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.js +2 -2
- package/dist/runtime/UsageMetricsProvider.js.map +1 -1
- package/dist/runtime/alerts-queries.d.ts +11 -0
- package/dist/runtime/alerts-queries.d.ts.map +1 -0
- package/dist/runtime/alerts-queries.js +89 -0
- package/dist/runtime/alerts-queries.js.map +1 -0
- package/dist/runtime/annotations.d.ts +6 -0
- package/dist/runtime/annotations.d.ts.map +1 -0
- package/dist/runtime/annotations.js +129 -0
- package/dist/runtime/annotations.js.map +1 -0
- package/dist/runtime/datasources.d.ts +6 -0
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.d.ts +3 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/item-actions.js +1 -1
- package/dist/runtime/item-actions.js.map +1 -1
- package/dist/runtime/log-queries.js +4 -1
- package/dist/runtime/log-queries.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +2 -2
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +12 -3
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/profile-queries.js +4 -1
- package/dist/runtime/profile-queries.js.map +1 -1
- package/dist/runtime/silences-queries.d.ts +11 -0
- package/dist/runtime/silences-queries.d.ts.map +1 -0
- package/dist/runtime/silences-queries.js +89 -0
- package/dist/runtime/silences-queries.js.map +1 -0
- package/dist/runtime/time-series-queries.js +4 -1
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.js +4 -1
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/test/mock-data.d.ts +3 -1
- package/dist/test/mock-data.d.ts.map +1 -1
- package/dist/test/mock-data.js +45 -0
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/render.js +1 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts +12 -6
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js +6 -2
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.d.ts +8 -6
- package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +6 -2
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test/test-plugins/index.js +2 -2
- package/dist/test/test-plugins/index.js.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 +8 -2
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/package.json +7 -6
- package/dist/cjs/runtime/QueryCountProvider.js +0 -83
- package/dist/runtime/QueryCountProvider.d.ts +0 -9
- package/dist/runtime/QueryCountProvider.d.ts.map +0 -1
- package/dist/runtime/QueryCountProvider.js.map +0 -1
|
@@ -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;AAC9E,OAAO,EAKL,YAAY,EACZ,kBAAkB,EACnB,MAAM,aAAa,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;AAC9E,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,CAgEvE"}
|
|
@@ -14,7 +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
|
|
17
|
+
import { usePluginIndexes } from './plugin-indexes';
|
|
18
|
+
import { resolvePluginKeys } from './getPluginSearchHelper';
|
|
18
19
|
/**
|
|
19
20
|
* PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or
|
|
20
21
|
* querying the metadata about them.
|
|
@@ -35,23 +36,18 @@ import { usePluginIndexes, getTypeAndKindKey } from './plugin-indexes';
|
|
|
35
36
|
}
|
|
36
37
|
return request;
|
|
37
38
|
});
|
|
38
|
-
const getPlugin = useCallback(async (
|
|
39
|
-
// Get the indexes of the installed plugins
|
|
39
|
+
const getPlugin = useCallback(async (compoundKeyObj)=>{
|
|
40
40
|
const pluginIndexes = await getPluginIndexes();
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
const { kind, name } = compoundKeyObj;
|
|
42
|
+
const candidateKeys = resolvePluginKeys(pluginIndexes.pluginResourcesByNameKindRegistryVersion.keys(), compoundKeyObj);
|
|
43
|
+
for (const resourceKey of candidateKeys){
|
|
44
|
+
const resource = pluginIndexes.pluginResourcesByNameKindRegistryVersion.get(resourceKey);
|
|
45
|
+
if (!resource) continue;
|
|
46
|
+
const pluginModule = await loadPluginModule(resource);
|
|
47
|
+
const plugin = pluginModule?.[resourceKey];
|
|
48
|
+
if (plugin) return plugin;
|
|
46
49
|
}
|
|
47
|
-
|
|
48
|
-
const pluginModule = await loadPluginModule(resource);
|
|
49
|
-
// We currently assume that plugin modules will have named exports that match the kinds they handle
|
|
50
|
-
const plugin = pluginModule[name];
|
|
51
|
-
if (plugin === undefined) {
|
|
52
|
-
throw new Error(`The ${name} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`);
|
|
53
|
-
}
|
|
54
|
-
return plugin;
|
|
50
|
+
throw new Error(`A ${name} plugin for kind '${kind}' is not installed`);
|
|
55
51
|
}, [
|
|
56
52
|
getPluginIndexes,
|
|
57
53
|
loadPluginModule
|
|
@@ -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 { usePluginIndexes,
|
|
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 { usePluginIndexes, PluginCompoundKey } from './plugin-indexes';\nimport { resolvePluginKeys } from './getPluginSearchHelper';\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 const plugin = pluginModule?.[resourceKey];\n if (plugin) return plugin 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","usePluginIndexes","resolvePluginKeys","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","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;AAS9E,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,QAAQ,QAAQ,cAAc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;QAC5B,OAAOyB,YAAYC,OAAO,CAAC,CAACC,OAASb,cAAcc,oBAAoB,CAACrB,GAAG,CAACoB,SAAS,EAAE;IACzF,GACA;QAAC3B;KAAiB;IAGpB,iDAAiD;IACjD,MAAM6B,UAAUzC,QACd,IAAO,CAAA;YAAEwB;YAAWY;YAAoBzB;QAAmB,CAAA,GAC3D;QAACa;QAAWY;QAAoBzB;KAAmB;IAErD,qBAAO,KAACV,sBAAsByC,QAAQ;QAACC,OAAOF;kBAAU/B;;AAC1D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PluginType } from '../../model';
|
|
2
|
+
import { PluginCompoundKey } from './plugin-indexes';
|
|
3
|
+
export interface PluginLookupPrecedenceLogic {
|
|
4
|
+
registryOverVersion: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Returns an ordered list of candidate 4-part keys to try when resolving a plugin.
|
|
8
|
+
* If version/registry are specified, the exact-match key comes first.
|
|
9
|
+
* The best fallback key (highest version, tie-broken by precedence policy) follows.
|
|
10
|
+
*/
|
|
11
|
+
export declare const resolvePluginKeys: <T extends PluginType>(allKeys: Iterable<string>, query: PluginCompoundKey<T>, precedenceLogic?: PluginLookupPrecedenceLogic) => string[];
|
|
12
|
+
//# sourceMappingURL=getPluginSearchHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPluginSearchHelper.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/getPluginSearchHelper.ts"],"names":[],"mappings":"AAcA,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,kCACnB,SAAS,MAAM,CAAC,SAClB,kBAAkB,CAAC,CAAC,oBACV,2BAA2B,KAC3C,MAAM,EAkER,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { gt } from 'semver';
|
|
14
|
+
import { getPluginModuleCompoundKey } from '../../model';
|
|
15
|
+
const PLUGIN_LOOKUP_PRECEDENCE_LOGIC = {
|
|
16
|
+
registryOverVersion: false
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Returns an ordered list of candidate 4-part keys to try when resolving a plugin.
|
|
20
|
+
* If version/registry are specified, the exact-match key comes first.
|
|
21
|
+
* The best fallback key (highest version, tie-broken by precedence policy) follows.
|
|
22
|
+
*/ export const resolvePluginKeys = (allKeys, query, precedenceLogic = PLUGIN_LOOKUP_PRECEDENCE_LOGIC)=>{
|
|
23
|
+
const { kind, name, version, registry } = query;
|
|
24
|
+
const candidates = [];
|
|
25
|
+
// Exact match first when version or registry is specified
|
|
26
|
+
if (version || registry) {
|
|
27
|
+
candidates.push(getPluginModuleCompoundKey({
|
|
28
|
+
kind,
|
|
29
|
+
name,
|
|
30
|
+
registry,
|
|
31
|
+
version
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
const latestWithRegistry = {
|
|
35
|
+
key: '',
|
|
36
|
+
version: ''
|
|
37
|
+
};
|
|
38
|
+
const latestWithoutRegistry = {
|
|
39
|
+
key: '',
|
|
40
|
+
version: ''
|
|
41
|
+
};
|
|
42
|
+
const prefix = `${kind}:${name}:`;
|
|
43
|
+
for (const key of allKeys){
|
|
44
|
+
if (!key.startsWith(prefix)) continue;
|
|
45
|
+
const split = key.split(':');
|
|
46
|
+
if (split.length !== 4) {
|
|
47
|
+
console.warn(`An invalid Plugin Resource key detected during default plugin lookup: ${key}`);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const [, , reg, ver] = split;
|
|
51
|
+
if (!ver) {
|
|
52
|
+
console.warn(`An invalid Plugin Resource key detected during default plugin lookup: ${key}`);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (reg) {
|
|
56
|
+
if (!latestWithRegistry.key || gt(ver, latestWithRegistry.version)) {
|
|
57
|
+
latestWithRegistry.key = key;
|
|
58
|
+
latestWithRegistry.version = ver;
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
if (!latestWithoutRegistry.key || gt(ver, latestWithoutRegistry.version)) {
|
|
62
|
+
latestWithoutRegistry.key = key;
|
|
63
|
+
latestWithoutRegistry.version = ver;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// Determine the best fallback key from the two buckets
|
|
68
|
+
let fallbackKey;
|
|
69
|
+
if (latestWithRegistry.key && latestWithoutRegistry.key) {
|
|
70
|
+
const { registryOverVersion } = precedenceLogic;
|
|
71
|
+
if (gt(latestWithRegistry.version, latestWithoutRegistry.version)) {
|
|
72
|
+
fallbackKey = latestWithRegistry.key;
|
|
73
|
+
} else if (gt(latestWithoutRegistry.version, latestWithRegistry.version)) {
|
|
74
|
+
fallbackKey = latestWithoutRegistry.key;
|
|
75
|
+
} else {
|
|
76
|
+
// Versions are equal — use the tie-breaker
|
|
77
|
+
fallbackKey = registryOverVersion ? latestWithRegistry.key : latestWithoutRegistry.key;
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
fallbackKey = latestWithRegistry.key || latestWithoutRegistry.key || undefined;
|
|
81
|
+
}
|
|
82
|
+
if (fallbackKey && !candidates.includes(fallbackKey)) {
|
|
83
|
+
candidates.push(fallbackKey);
|
|
84
|
+
}
|
|
85
|
+
return candidates;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=getPluginSearchHelper.js.map
|
|
@@ -0,0 +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\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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,IAAIf,GAAGwB,KAAKR,sBAAsBN,OAAO,GAAG;gBACxEM,sBAAsBD,GAAG,GAAGA;gBAC5BC,sBAAsBN,OAAO,GAAGc;YAClC;QACF;IACF;IAEA,uDAAuD;IACvD,IAAIC;IAEJ,IAAIX,mBAAmBC,GAAG,IAAIC,sBAAsBD,GAAG,EAAE;QACvD,MAAM,EAAEZ,mBAAmB,EAAE,GAAGI;QAEhC,IAAIP,GAAGc,mBAAmBJ,OAAO,EAAEM,sBAAsBN,OAAO,GAAG;YACjEe,cAAcX,mBAAmBC,GAAG;QACtC,OAAO,IAAIf,GAAGgB,sBAAsBN,OAAO,EAAEI,mBAAmBJ,OAAO,GAAG;YACxEe,cAAcT,sBAAsBD,GAAG;QACzC,OAAO;YACL,2CAA2C;YAC3CU,cAActB,sBAAsBW,mBAAmBC,GAAG,GAAGC,sBAAsBD,GAAG;QACxF;IACF,OAAO;QACLU,cAAcX,mBAAmBC,GAAG,IAAIC,sBAAsBD,GAAG,IAAIW;IACvE;IAEA,IAAID,eAAe,CAACb,WAAWe,QAAQ,CAACF,cAAc;QACpDb,WAAWC,IAAI,CAACY;IAClB;IAEA,OAAOb;AACT,EAAE"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { PluginLoader, PluginMetadataWithModule, PluginModuleResource, PluginType } from '../../model';
|
|
1
|
+
import { PluginLoader, PluginMetadataWithModule, PluginModuleResource, PluginType, PluginCompoundKey, getPluginModuleCompoundKey } from '../../model';
|
|
2
|
+
export type { PluginCompoundKey };
|
|
3
|
+
export { getPluginModuleCompoundKey };
|
|
2
4
|
export interface PluginIndexes {
|
|
3
|
-
|
|
5
|
+
pluginResourcesByNameKindRegistryVersion: Map<string, PluginModuleResource>;
|
|
4
6
|
pluginMetadataByKind: Map<PluginType, PluginMetadataWithModule[]>;
|
|
5
7
|
}
|
|
6
8
|
/**
|
|
7
9
|
* Returns an async callback for getting indexes of the installed plugin data.
|
|
8
10
|
*/
|
|
9
11
|
export declare function usePluginIndexes(getInstalledPlugins: PluginLoader['getInstalledPlugins']): () => Promise<PluginIndexes>;
|
|
10
|
-
/**
|
|
11
|
-
* Gets a unique key for a plugin type/kind that can be used as a cache key.
|
|
12
|
-
*/
|
|
13
|
-
export declare function getTypeAndKindKey(kind: PluginType, name: string): string;
|
|
14
12
|
//# sourceMappingURL=plugin-indexes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-indexes.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/plugin-indexes.ts"],"names":[],"mappings":"AAcA,OAAO,
|
|
1
|
+
{"version":3,"file":"plugin-indexes.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/plugin-indexes.ts"],"names":[],"mappings":"AAcA,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"}
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { useCallback, useRef } from 'react';
|
|
14
|
+
import { getPluginModuleCompoundKey } from '../../model';
|
|
14
15
|
import { useEvent } from '../../utils';
|
|
16
|
+
export { getPluginModuleCompoundKey };
|
|
15
17
|
/**
|
|
16
18
|
* Returns an async callback for getting indexes of the installed plugin data.
|
|
17
19
|
*/ export function usePluginIndexes(getInstalledPlugins) {
|
|
@@ -20,17 +22,22 @@ import { useEvent } from '../../utils';
|
|
|
20
22
|
const createPluginIndexes = useEvent(async ()=>{
|
|
21
23
|
const installedPlugins = await getInstalledPlugins();
|
|
22
24
|
// Create the two indexes from the installed plugins
|
|
23
|
-
const
|
|
25
|
+
const pluginResourcesByNameKindRegistryVersion = new Map();
|
|
24
26
|
const pluginMetadataByKind = new Map();
|
|
25
27
|
for (const resource of installedPlugins){
|
|
28
|
+
const { metadata: { version, registry } } = resource;
|
|
26
29
|
for (const pluginMetadata of resource.spec.plugins){
|
|
27
30
|
const { kind, spec: { name } } = pluginMetadata;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
const key = getPluginModuleCompoundKey({
|
|
32
|
+
kind,
|
|
33
|
+
name,
|
|
34
|
+
registry,
|
|
35
|
+
version
|
|
36
|
+
});
|
|
37
|
+
if (pluginResourcesByNameKindRegistryVersion.has(key)) {
|
|
38
|
+
console.warn(`Got more than one ${kind} plugin for kind ${name}, registry '${registry || 'undefined'}', and version '${version || 'undefined'}'`);
|
|
32
39
|
}
|
|
33
|
-
|
|
40
|
+
pluginResourcesByNameKindRegistryVersion.set(key, resource);
|
|
34
41
|
// Index the metadata by plugin type
|
|
35
42
|
let list = pluginMetadataByKind.get(kind);
|
|
36
43
|
if (list === undefined) {
|
|
@@ -44,7 +51,7 @@ import { useEvent } from '../../utils';
|
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
53
|
return {
|
|
47
|
-
|
|
54
|
+
pluginResourcesByNameKindRegistryVersion,
|
|
48
55
|
pluginMetadataByKind
|
|
49
56
|
};
|
|
50
57
|
});
|
|
@@ -56,7 +63,7 @@ import { useEvent } from '../../utils';
|
|
|
56
63
|
request = createPluginIndexes();
|
|
57
64
|
pluginIndexesCache.current = request;
|
|
58
65
|
// Remove failed requests from the cache so they can potentially be retried
|
|
59
|
-
request.catch(()=>pluginIndexesCache.current
|
|
66
|
+
request.catch(()=>pluginIndexesCache.current = undefined);
|
|
60
67
|
}
|
|
61
68
|
return request;
|
|
62
69
|
}, [
|
|
@@ -64,10 +71,5 @@ import { useEvent } from '../../utils';
|
|
|
64
71
|
]);
|
|
65
72
|
return getPluginIndexes;
|
|
66
73
|
}
|
|
67
|
-
/**
|
|
68
|
-
* Gets a unique key for a plugin type/kind that can be used as a cache key.
|
|
69
|
-
*/ export function getTypeAndKindKey(kind, name) {
|
|
70
|
-
return `${kind}:${name}`;
|
|
71
|
-
}
|
|
72
74
|
|
|
73
75
|
//# sourceMappingURL=plugin-indexes.js.map
|
|
@@ -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 {
|
|
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']\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,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAAEC,MAAM,QAAQ,QAAQ;AAC5C,SAMEC,0BAA0B,QACrB,cAAc;AACrB,SAASC,QAAQ,QAAQ,cAAc;AAGvC,SAASD,0BAA0B,GAAG;AAStC;;CAEC,GACD,OAAO,SAASE,iBACdC,mBAAwD;IAExD,oHAAoH;IACpH,yDAAyD;IACzD,MAAMC,sBAAsBH,SAAS;QACnC,MAAMI,mBAAmB,MAAMF;QAE/B,oDAAoD;QACpD,MAAMG,2CAA2C,IAAIC;QACrD,MAAMC,uBAAuB,IAAID;QAEjC,KAAK,MAAME,YAAYJ,iBAAkB;YACvC,MAAM,EACJK,UAAU,EAAEC,OAAO,EAAEC,QAAQ,EAAE,EAChC,GAAGH;YACJ,KAAK,MAAMI,kBAAkBJ,SAASK,IAAI,CAACC,OAAO,CAAE;gBAClD,MAAM,EACJC,IAAI,EACJF,MAAM,EAAEG,IAAI,EAAE,EACf,GAAGJ;gBAEJ,MAAMK,MAAMlB,2BAA2B;oBAAEgB;oBAAMC;oBAAML;oBAAUD;gBAAQ;gBACvE,IAAIL,yCAAyCa,GAAG,CAACD,MAAM;oBACrDE,QAAQC,IAAI,CACV,CAAC,kBAAkB,EAAEL,KAAK,iBAAiB,EAAEC,KAAK,YAAY,EAAEL,YAAY,YAAY,gBAAgB,EAAED,WAAW,YAAY,CAAC,CAAC;gBAEvI;gBACAL,yCAAyCgB,GAAG,CAACJ,KAAKT;gBAElD,oCAAoC;gBACpC,IAAIc,OAAOf,qBAAqBgB,GAAG,CAACR;gBACpC,IAAIO,SAASE,WAAW;oBACtBF,OAAO,EAAE;oBACTf,qBAAqBc,GAAG,CAACN,MAAMO;gBACjC;gBACAA,KAAKG,IAAI,CAAC;oBAAE,GAAGb,cAAc;oBAAEc,QAAQlB,SAASC,QAAQ;gBAAC;YAC3D;QACF;QAEA,OAAO;YACLJ;YACAE;QACF;IACF;IAEA,2EAA2E;IAC3E,MAAMoB,qBAAqB7B,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginSpecEditor/PluginSpecEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB,CAAC,WAAW,CAAC;IAC5E,eAAe,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"PluginSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginSpecEditor/PluginSpecEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB,CAAC,WAAW,CAAC;IAC5E,eAAe,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,YAAY,GAAG,IAAI,CA4BlF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { ErrorAlert } from '@perses-dev/components';
|
|
15
15
|
import { CircularProgress, Stack } from '@mui/material';
|
|
16
16
|
import { usePlugin } from '../../runtime';
|
|
@@ -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 { CircularProgress, Stack } from '@mui/material';\nimport { OptionsEditorProps } from '../../model';\nimport { usePlugin } from '../../runtime';\nimport { PluginEditorSelection } from '../PluginEditor';\n\nexport interface PluginSpecEditorProps extends OptionsEditorProps<UnknownSpec> {\n pluginSelection: PluginEditorSelection;\n isEditor?: boolean;\n}\n\nexport function PluginSpecEditor(props: PluginSpecEditorProps): ReactElement | null {\n const {\n pluginSelection: { type: pluginType, kind: pluginKind },\n ...others\n } = props;\n const { data: plugin, isLoading, error } = usePlugin(pluginType, pluginKind);\n
|
|
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 { CircularProgress, Stack } from '@mui/material';\nimport { OptionsEditorProps } from '../../model';\nimport { usePlugin } from '../../runtime';\nimport { PluginEditorSelection } from '../PluginEditor';\n\nexport interface PluginSpecEditorProps extends OptionsEditorProps<UnknownSpec> {\n pluginSelection: PluginEditorSelection;\n isEditor?: boolean;\n}\n\nexport function PluginSpecEditor(props: PluginSpecEditorProps): ReactElement | null {\n const {\n pluginSelection: { type: pluginType, kind: pluginKind },\n ...others\n } = props;\n const { data: plugin, isLoading, error } = usePlugin(pluginType, pluginKind);\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 const { OptionsEditorComponent } = plugin;\n\n return OptionsEditorComponent ? <OptionsEditorComponent {...others} /> : null;\n}\n"],"names":["ErrorAlert","CircularProgress","Stack","usePlugin","PluginSpecEditor","props","pluginSelection","type","pluginType","kind","pluginKind","others","data","plugin","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,iCAAiC;AAEjC,SAASA,UAAU,QAAQ,yBAAyB;AAGpD,SAASC,gBAAgB,EAAEC,KAAK,QAAQ,gBAAgB;AAExD,SAASC,SAAS,QAAQ,gBAAgB;AAQ1C,OAAO,SAASC,iBAAiBC,KAA4B;IAC3D,MAAM,EACJC,iBAAiB,EAAEC,MAAMC,UAAU,EAAEC,MAAMC,UAAU,EAAE,EACvD,GAAGC,QACJ,GAAGN;IACJ,MAAM,EAAEO,MAAMC,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGZ,UAAUK,YAAYE;IACjE,IAAIK,OAAO;QACT,qBAAO,KAACf;YAAWe,OAAOA;;IAC5B;IAEA,IAAID,WAAW;QACb,qBACE,KAACZ;YAAMc,OAAM;YAAOC,IAAI;gBAAEC,YAAY;gBAAUC,gBAAgB;YAAS;sBACvE,cAAA,KAAClB;;IAGP;IAEA,IAAI,CAACY,QAAQ;QACX,MAAM,IAAIO,MAAM,CAAC,2BAA2B,EAAEZ,WAAW,mBAAmB,EAAEE,WAAW,CAAC,CAAC;IAC7F;IAEA,IAAIF,eAAe,SAAS;QAC1B,MAAM,IAAIY,MAAM;IAClB;IACA,MAAM,EAAEC,sBAAsB,EAAE,GAAGR;IAEnC,OAAOQ,uCAAyB,KAACA;QAAwB,GAAGV,MAAM;SAAO;AAC3E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
import { Switch } from '@mui/material';
|
|
15
15
|
import { OptionsEditorControl, OptionsEditorGroup } from '@perses-dev/components';
|
|
16
16
|
export function SelectionOptionsEditor({ value, onChange }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/SelectionOptionsEditor/SelectionOptionsEditor.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 { Switch, SwitchProps } from '@mui/material';\nimport { OptionsEditorControl, OptionsEditorGroup } from '@perses-dev/components';\nimport { ReactElement } from 'react';\n\nexport interface SelectionOptions {\n enabled?: boolean;\n}\n\nexport interface SelectionOptionsEditorProps {\n value?: SelectionOptions;\n onChange: (selection?: SelectionOptions) => void;\n}\n\nexport function SelectionOptionsEditor({ value, onChange }: SelectionOptionsEditorProps): ReactElement {\n const handleEnabledChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n onChange(checked ? { enabled: true } : undefined);\n };\n\n return (\n <OptionsEditorGroup title=\"Selection\">\n <OptionsEditorControl\n label=\"Enable Selection\"\n description=\"Allow selecting items to enable actions on selected data\"\n control={<Switch checked={value?.enabled ?? false} onChange={handleEnabledChange} />}\n />\n </OptionsEditorGroup>\n );\n}\n"],"names":["Switch","OptionsEditorControl","OptionsEditorGroup","SelectionOptionsEditor","value","onChange","handleEnabledChange","_","checked","enabled","undefined","title","label","description","control"],"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
|
|
1
|
+
{"version":3,"sources":["../../../src/components/SelectionOptionsEditor/SelectionOptionsEditor.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 { Switch, SwitchProps } from '@mui/material';\nimport { OptionsEditorControl, OptionsEditorGroup } from '@perses-dev/components';\nimport { ReactElement } from 'react';\n\nexport interface SelectionOptions {\n enabled?: boolean;\n}\n\nexport interface SelectionOptionsEditorProps {\n value?: SelectionOptions;\n onChange: (selection?: SelectionOptions) => void;\n}\n\nexport function SelectionOptionsEditor({ value, onChange }: SelectionOptionsEditorProps): ReactElement {\n const handleEnabledChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n onChange(checked ? { enabled: true } : undefined);\n };\n\n return (\n <OptionsEditorGroup title=\"Selection\">\n <OptionsEditorControl\n label=\"Enable Selection\"\n description=\"Allow selecting items to enable actions on selected data\"\n control={<Switch checked={value?.enabled ?? false} onChange={handleEnabledChange} />}\n />\n </OptionsEditorGroup>\n );\n}\n"],"names":["Switch","OptionsEditorControl","OptionsEditorGroup","SelectionOptionsEditor","value","onChange","handleEnabledChange","_","checked","enabled","undefined","title","label","description","control"],"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,MAAM,QAAqB,gBAAgB;AACpD,SAASC,oBAAoB,EAAEC,kBAAkB,QAAQ,yBAAyB;AAYlF,OAAO,SAASC,uBAAuB,EAAEC,KAAK,EAAEC,QAAQ,EAA+B;IACrF,MAAMC,sBAA+C,CAACC,GAAYC;QAChEH,SAASG,UAAU;YAAEC,SAAS;QAAK,IAAIC;IACzC;IAEA,qBACE,KAACR;QAAmBS,OAAM;kBACxB,cAAA,KAACV;YACCW,OAAM;YACNC,aAAY;YACZC,uBAAS,KAACd;gBAAOQ,SAASJ,OAAOK,WAAW;gBAAOJ,UAAUC;;;;AAIrE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import RefreshIcon from 'mdi-material-ui/Refresh';
|
|
15
15
|
// eslint-disable-next-line import/no-duplicates
|
|
16
16
|
import ZoomIn from 'mdi-material-ui/PlusCircleOutline';
|
|
@@ -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 { 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\n if (\n 'pastDuration' in timeRange &&\n !timePresetsValue.some((option) => option.value.pastDuration === timeRange['pastDuration'])\n ) {\n timePresetsValue.push(buildRelativeTimeOption(timeRange['pastDuration']));\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","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","push","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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AYzE,aAAasB,OAAO;oBAAEoD,SAASpD;oBAASqD,IAAI;wBAAE/C;oBAAO;8BAClF,cAAA,KAACxC;;;YAIN0B,qCACC,KAACrB;gBAAY8E,aAAavE,aAAauB,eAAe;0BACpD,cAAA,KAAC/B;oBACC4E,aAAa/D;oBACbC,OACE;;;;cAIA,GACAD,iCAAiCyB,IAAI,CAAC,CAAC+C,IAAMA,EAAEvE,KAAK,CAACC,YAAY,KAAKgB,mBAClEA,kBACAlB,iCAAiCyE,IAAI,CAAC,CAACD,IAAMA,EAAErE,OAAO,KAAKe,kBAAkBjB,MAAMC;oBAEzF8D,UAAUpC;oBACVL,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 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 { 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\n if (\n 'pastDuration' in timeRange &&\n !timePresetsValue.some((option) => option.value.pastDuration === timeRange['pastDuration'])\n ) {\n timePresetsValue.push(buildRelativeTimeOption(timeRange['pastDuration']));\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","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","push","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","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KAAC5B;oBAAkB+E,cAAYzE,aAAasB,OAAO;oBAAEoD,SAASpD;oBAASqD,IAAI;wBAAE/C;oBAAO;8BAClF,cAAA,KAACxC;;;YAIN0B,qCACC,KAACrB;gBAAY8E,aAAavE,aAAauB,eAAe;0BACpD,cAAA,KAAC/B;oBACC4E,aAAa/D;oBACbC,OACE;;;;cAIA,GACAD,iCAAiCyB,IAAI,CAAC,CAAC+C,IAAMA,EAAEvE,KAAK,CAACC,YAAY,KAAKgB,mBAClEA,kBACAlB,iCAAiCyE,IAAI,CAAC,CAACD,IAAMA,EAAErE,OAAO,KAAKe,kBAAkBjB,MAAMC;oBAEzF8D,UAAUpC;oBACVL,QAAQA;;;;;AAMpB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DispatchWithoutAction, ReactElement } from 'react';
|
|
2
2
|
import { VariableDefinition } from '@perses-dev/spec';
|
|
3
|
-
import { Action } from '@perses-dev/
|
|
3
|
+
import { Action } from '@perses-dev/client';
|
|
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":"AAaA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAEnF,OAAO,EAAE,kBAAkB,EAA0B,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"VariableEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Variables/VariableEditorForm/VariableEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAEnF,OAAO,EAAE,kBAAkB,EAA0B,MAAM,kBAAkB,CAAC;AAa9E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AA6V5C,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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
14
|
import { useCallback, useState } from 'react';
|
|
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';
|