@perses-dev/plugin-system 0.54.0-beta.0 → 0.54.0-beta.10
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/CalculationSelector/CalculationSelector.js +3 -3
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -5
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +97 -12
- package/dist/cjs/components/MultiQueryEditor/index.js +1 -0
- package/dist/cjs/{utils/action.js → components/MultiQueryEditor/utils.js} +8 -15
- 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/VariableEditorForm/VariableEditorForm.js +2 -3
- 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/calculations.js +178 -0
- package/dist/cjs/model/index.js +4 -0
- package/dist/cjs/model/legend.js +6 -5
- 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/model/time-series-queries.js +10 -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.js +2 -2
- package/dist/cjs/test-utils/mock-plugin-registry.js +8 -2
- package/dist/cjs/utils/index.js +0 -1
- 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.d.ts +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js +2 -2
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +2 -3
- 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.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +2 -3
- 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.d.ts +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/{utils/action.js → components/MultiQueryEditor/utils.js} +8 -12
- 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 +2 -3
- 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/calculations.d.ts +45 -0
- package/dist/model/calculations.d.ts.map +1 -0
- package/dist/model/calculations.js +165 -0
- package/dist/model/calculations.js.map +1 -0
- package/dist/model/index.d.ts +4 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +4 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/legend.d.ts +3 -2
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +2 -1
- package/dist/model/legend.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/time-series-queries.d.ts +11 -1
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js +4 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/trace-queries.d.ts +2 -3
- package/dist/model/trace-queries.d.ts.map +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/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.d.ts.map +1 -1
- package/dist/test/utils.js +2 -2
- 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/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/index.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
- package/dist/utils/action.d.ts +0 -4
- package/dist/utils/action.d.ts.map +0 -1
- package/dist/utils/action.js.map +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
get SILENCES_QUERY_KEY () {
|
|
25
|
+
return SILENCES_QUERY_KEY;
|
|
26
|
+
},
|
|
27
|
+
get useSilencesQueries () {
|
|
28
|
+
return useSilencesQueries;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const _reactquery = require("@tanstack/react-query");
|
|
32
|
+
const _datasources = require("./datasources");
|
|
33
|
+
const _pluginregistry = require("./plugin-registry");
|
|
34
|
+
const _variables = require("./variables");
|
|
35
|
+
const _utils = require("./utils");
|
|
36
|
+
const SILENCES_QUERY_KEY = 'SilencesQuery';
|
|
37
|
+
function useSilencesQueries(definitions) {
|
|
38
|
+
const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
|
|
39
|
+
const context = useSilencesQueryContext();
|
|
40
|
+
const pluginLoaderResponse = (0, _pluginregistry.usePlugins)('SilencesQuery', definitions.map((d)=>({
|
|
41
|
+
kind: d.spec.plugin.kind
|
|
42
|
+
})));
|
|
43
|
+
return (0, _reactquery.useQueries)({
|
|
44
|
+
queries: definitions.map((definition, idx)=>{
|
|
45
|
+
const plugin = pluginLoaderResponse[idx]?.data;
|
|
46
|
+
const { queryEnabled, queryKey } = getQueryOptions({
|
|
47
|
+
context,
|
|
48
|
+
definition,
|
|
49
|
+
plugin
|
|
50
|
+
});
|
|
51
|
+
const silencesQueryKind = definition?.spec?.plugin?.kind;
|
|
52
|
+
return {
|
|
53
|
+
enabled: queryEnabled,
|
|
54
|
+
queryKey: queryKey,
|
|
55
|
+
refetchOnMount: false,
|
|
56
|
+
refetchOnWindowFocus: false,
|
|
57
|
+
refetchOnReconnect: false,
|
|
58
|
+
staleTime: 60_000,
|
|
59
|
+
queryFn: async ({ signal })=>{
|
|
60
|
+
const plugin = await getPlugin({
|
|
61
|
+
kind: SILENCES_QUERY_KEY,
|
|
62
|
+
name: silencesQueryKind
|
|
63
|
+
});
|
|
64
|
+
const data = await plugin.getSilencesData(definition.spec.plugin.spec, context, signal);
|
|
65
|
+
return data;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function getQueryOptions({ plugin, definition, context }) {
|
|
72
|
+
const { variableState } = context;
|
|
73
|
+
const dependencies = plugin?.dependsOn ? plugin.dependsOn(definition.spec.plugin.spec, context) : {};
|
|
74
|
+
const variableDependencies = dependencies?.variables;
|
|
75
|
+
const filteredVariabledState = (0, _utils.filterVariableStateMap)(variableState, variableDependencies);
|
|
76
|
+
const variablesValueKey = (0, _utils.getVariableValuesKey)(filteredVariabledState);
|
|
77
|
+
// Note: no absoluteTimeRange in query key since silences are current state
|
|
78
|
+
const queryKey = [
|
|
79
|
+
'query',
|
|
80
|
+
SILENCES_QUERY_KEY,
|
|
81
|
+
definition,
|
|
82
|
+
variablesValueKey
|
|
83
|
+
];
|
|
84
|
+
let waitToLoad = false;
|
|
85
|
+
if (variableDependencies) {
|
|
86
|
+
waitToLoad = variableDependencies.some((v)=>variableState[v]?.loading);
|
|
87
|
+
}
|
|
88
|
+
const queryEnabled = plugin !== undefined && !waitToLoad;
|
|
89
|
+
return {
|
|
90
|
+
queryKey,
|
|
91
|
+
queryEnabled
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function useSilencesQueryContext() {
|
|
95
|
+
const variableState = (0, _variables.useAllVariableValues)();
|
|
96
|
+
const datasourceStore = (0, _datasources.useDatasourceStore)();
|
|
97
|
+
return {
|
|
98
|
+
variableState,
|
|
99
|
+
datasourceStore
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -123,7 +123,10 @@ function useTimeSeriesQueries(definitions, options, queryOptions) {
|
|
|
123
123
|
staleTime: Infinity,
|
|
124
124
|
queryKey: queryKey,
|
|
125
125
|
queryFn: async ({ signal })=>{
|
|
126
|
-
const plugin = await getPlugin(
|
|
126
|
+
const plugin = await getPlugin({
|
|
127
|
+
kind: TIME_SERIES_QUERY_KEY,
|
|
128
|
+
name: definition.spec.plugin.kind
|
|
129
|
+
});
|
|
127
130
|
const data = await plugin.getTimeSeriesData(definition.spec.plugin.spec, context, signal);
|
|
128
131
|
return data;
|
|
129
132
|
}
|
|
@@ -60,7 +60,10 @@ function useTraceQueries(definitions) {
|
|
|
60
60
|
refetchOnReconnect: false,
|
|
61
61
|
staleTime: Infinity,
|
|
62
62
|
queryFn: async ({ signal })=>{
|
|
63
|
-
const plugin = await getPlugin(
|
|
63
|
+
const plugin = await getPlugin({
|
|
64
|
+
kind: TRACE_QUERY_KEY,
|
|
65
|
+
name: traceQueryKind
|
|
66
|
+
});
|
|
64
67
|
const data = await plugin.getTraceData(definition.spec.plugin.spec, context, signal);
|
|
65
68
|
return data;
|
|
66
69
|
}
|
|
@@ -21,6 +21,9 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
get MOCK_ALERTS_DATA () {
|
|
25
|
+
return MOCK_ALERTS_DATA;
|
|
26
|
+
},
|
|
24
27
|
get MOCK_EMPTY_PLUGIN_MODULE () {
|
|
25
28
|
return MOCK_EMPTY_PLUGIN_MODULE;
|
|
26
29
|
},
|
|
@@ -45,6 +48,9 @@ _export(exports, {
|
|
|
45
48
|
get MOCK_REMOTE_PLUGIN_MODULE () {
|
|
46
49
|
return MOCK_REMOTE_PLUGIN_MODULE;
|
|
47
50
|
},
|
|
51
|
+
get MOCK_SILENCES_DATA () {
|
|
52
|
+
return MOCK_SILENCES_DATA;
|
|
53
|
+
},
|
|
48
54
|
get MOCK_TIME_SERIES_DATA () {
|
|
49
55
|
return MOCK_TIME_SERIES_DATA;
|
|
50
56
|
},
|
|
@@ -170,6 +176,51 @@ const MOCK_PROFILE_DATA = {
|
|
|
170
176
|
name: 'cpu'
|
|
171
177
|
}
|
|
172
178
|
};
|
|
179
|
+
const MOCK_ALERTS_DATA = {
|
|
180
|
+
alerts: [
|
|
181
|
+
{
|
|
182
|
+
id: 'abc123',
|
|
183
|
+
name: 'HighErrorRate',
|
|
184
|
+
state: 'firing',
|
|
185
|
+
labels: {
|
|
186
|
+
alertname: 'HighErrorRate',
|
|
187
|
+
severity: 'critical',
|
|
188
|
+
service: 'backend'
|
|
189
|
+
},
|
|
190
|
+
annotations: {
|
|
191
|
+
summary: 'High error rate detected'
|
|
192
|
+
},
|
|
193
|
+
severity: 'critical',
|
|
194
|
+
startsAt: '2024-01-01T00:00:00Z',
|
|
195
|
+
endsAt: '2024-01-02T00:00:00Z',
|
|
196
|
+
updatedAt: '2024-01-01T12:00:00Z',
|
|
197
|
+
receivers: [
|
|
198
|
+
'cluster-01'
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
};
|
|
203
|
+
const MOCK_SILENCES_DATA = {
|
|
204
|
+
silences: [
|
|
205
|
+
{
|
|
206
|
+
id: 'silence-1',
|
|
207
|
+
state: 'active',
|
|
208
|
+
matchers: [
|
|
209
|
+
{
|
|
210
|
+
name: 'alertname',
|
|
211
|
+
value: 'HighErrorRate',
|
|
212
|
+
isRegex: false,
|
|
213
|
+
isEqual: true
|
|
214
|
+
}
|
|
215
|
+
],
|
|
216
|
+
startsAt: '2024-01-01T00:00:00Z',
|
|
217
|
+
endsAt: '2024-01-02T00:00:00Z',
|
|
218
|
+
createdBy: 'admin',
|
|
219
|
+
comment: 'Maintenance window',
|
|
220
|
+
updatedAt: '2024-01-01T00:00:00Z'
|
|
221
|
+
}
|
|
222
|
+
]
|
|
223
|
+
};
|
|
173
224
|
const MOCK_VALID_PLUGIN_METADATA = {
|
|
174
225
|
kind: 'Panel',
|
|
175
226
|
spec: {
|
|
@@ -14,18 +14,10 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
get BertPanel1 () {
|
|
25
|
-
return BertPanel1;
|
|
26
|
-
},
|
|
27
|
-
get BertPanel2 () {
|
|
28
|
-
return BertPanel2;
|
|
17
|
+
Object.defineProperty(exports, "plugins", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return plugins;
|
|
29
21
|
}
|
|
30
22
|
});
|
|
31
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
@@ -48,6 +40,7 @@ function BertPanel1Editor({ value, onChange }) {
|
|
|
48
40
|
]
|
|
49
41
|
});
|
|
50
42
|
}
|
|
43
|
+
// Dummy plugins to test loading
|
|
51
44
|
const BertPanel1 = {
|
|
52
45
|
PanelComponent: ()=>null,
|
|
53
46
|
panelOptionsEditorComponents: [
|
|
@@ -100,3 +93,7 @@ const BertPanel2 = {
|
|
|
100
93
|
}),
|
|
101
94
|
hideQueryEditor: true
|
|
102
95
|
};
|
|
96
|
+
const plugins = {
|
|
97
|
+
'Panel:BertPanel1::1.0.0': BertPanel1,
|
|
98
|
+
'Panel:BertPanel2::1.0.0': BertPanel2
|
|
99
|
+
};
|
|
@@ -14,18 +14,10 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
get ErnieVariable1 () {
|
|
25
|
-
return ErnieVariable1;
|
|
26
|
-
},
|
|
27
|
-
get ErnieVariable2 () {
|
|
28
|
-
return ErnieVariable2;
|
|
17
|
+
Object.defineProperty(exports, "plugins", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return plugins;
|
|
29
21
|
}
|
|
30
22
|
});
|
|
31
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
@@ -39,6 +31,7 @@ const data = [
|
|
|
39
31
|
value: 'Snuffleupagus'
|
|
40
32
|
}
|
|
41
33
|
];
|
|
34
|
+
// Dummy plugin to test loading
|
|
42
35
|
const ErnieVariable1 = {
|
|
43
36
|
getVariableOptions: async ()=>({
|
|
44
37
|
data
|
|
@@ -93,3 +86,7 @@ const ErnieVariable2 = {
|
|
|
93
86
|
variableOption2: ''
|
|
94
87
|
})
|
|
95
88
|
};
|
|
89
|
+
const plugins = {
|
|
90
|
+
'Variable:ErnieVariable1::1.0.0': ErnieVariable1,
|
|
91
|
+
'Variable:ErnieVariable2::1.0.0': ErnieVariable2
|
|
92
|
+
};
|
|
@@ -72,10 +72,10 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
72
72
|
const testPluginLoader = (0, _model.dynamicImportPluginLoader)([
|
|
73
73
|
{
|
|
74
74
|
resource: _pluginjson.default,
|
|
75
|
-
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bert")))
|
|
75
|
+
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bert"))).then((m)=>m.plugins)
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
78
|
resource: _pluginjson1.default,
|
|
79
|
-
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./ernie")))
|
|
79
|
+
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./ernie"))).then((m)=>m.plugins)
|
|
80
80
|
}
|
|
81
81
|
]);
|
package/dist/cjs/test/utils.js
CHANGED
|
@@ -22,7 +22,6 @@ Object.defineProperty(exports, "getTestContextWrapper", {
|
|
|
22
22
|
});
|
|
23
23
|
const _jsxruntime = require("react/jsx-runtime");
|
|
24
24
|
const _reactquery = require("@tanstack/react-query");
|
|
25
|
-
const _core = require("@perses-dev/core");
|
|
26
25
|
const _components = require("../components");
|
|
27
26
|
const _runtime = require("../runtime");
|
|
28
27
|
const _testplugins = require("./test-plugins");
|
|
@@ -36,8 +35,9 @@ function getTestContextWrapper(contextOptions) {
|
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
});
|
|
38
|
+
const DEFAULT_DASHBOARD_DURATION = '1h';
|
|
39
39
|
const timeRange = {
|
|
40
|
-
start: new Date(Date.now() - Number(
|
|
40
|
+
start: new Date(Date.now() - Number(DEFAULT_DASHBOARD_DURATION)),
|
|
41
41
|
end: new Date()
|
|
42
42
|
};
|
|
43
43
|
return function Wrapper({ children }) {
|
|
@@ -28,12 +28,13 @@ _export(exports, {
|
|
|
28
28
|
return mockPluginRegistry;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
+
const _model = require("../model");
|
|
31
32
|
function mockPluginRegistry(...mockPlugins) {
|
|
32
33
|
const mockPluginResource = {
|
|
33
34
|
kind: 'PluginModule',
|
|
34
35
|
metadata: {
|
|
35
36
|
name: 'Fake Plugin Module for Tests',
|
|
36
|
-
version: '0'
|
|
37
|
+
version: '1.0.0'
|
|
37
38
|
},
|
|
38
39
|
spec: {
|
|
39
40
|
// Add metadata for all mock plugins
|
|
@@ -51,7 +52,12 @@ function mockPluginRegistry(...mockPlugins) {
|
|
|
51
52
|
const mockPluginModule = {};
|
|
52
53
|
for (const mockPlugin of mockPlugins){
|
|
53
54
|
// "Export" on the module under the same name as the kind the plugin handles
|
|
54
|
-
mockPluginModule[
|
|
55
|
+
mockPluginModule[(0, _model.getPluginModuleCompoundKey)({
|
|
56
|
+
kind: mockPlugin.kind,
|
|
57
|
+
name: mockPlugin.spec.name,
|
|
58
|
+
registry: mockPluginResource.metadata.registry,
|
|
59
|
+
version: mockPluginResource.metadata.version
|
|
60
|
+
})] = mockPlugin.plugin;
|
|
55
61
|
}
|
|
56
62
|
const pluginLoader = {
|
|
57
63
|
getInstalledPlugins () {
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
_export_star(require("./action"), exports);
|
|
18
17
|
_export_star(require("./event"), exports);
|
|
19
18
|
_export_star(require("./variables"), exports);
|
|
20
19
|
_export_star(require("./csv-export"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DispatchWithoutAction, ReactElement } from 'react';
|
|
2
|
+
import { AnnotationSpec } from '@perses-dev/spec';
|
|
3
|
+
import { Action } from '@perses-dev/client';
|
|
4
|
+
interface AnnotationEditorFormProps {
|
|
5
|
+
initialAnnotationSpec: AnnotationSpec;
|
|
6
|
+
action: Action;
|
|
7
|
+
isDraft: boolean;
|
|
8
|
+
isReadonly?: boolean;
|
|
9
|
+
onActionChange?: (action: Action) => void;
|
|
10
|
+
onSave: (def: AnnotationSpec) => void;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
onDelete?: DispatchWithoutAction;
|
|
13
|
+
}
|
|
14
|
+
export declare function AnnotationEditorForm({ initialAnnotationSpec, action, isDraft, isReadonly, onActionChange, onSave, onClose, onDelete, }: AnnotationEditorFormProps): ReactElement;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=AnnotationEditorForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnnotationEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAclD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmD5C,UAAU,yBAAyB;IACjC,qBAAqB,EAAE,cAAc,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;IACtC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,EACnC,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,UAAU,EACV,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,yBAAyB,GAAG,YAAY,CAuK1C"}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 { useCallback, useState } from 'react';
|
|
15
|
+
import { Box, Typography, TextField, Grid, Divider, Stack, IconButton } from '@mui/material';
|
|
16
|
+
import { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary, FormActions, OptionsColorPicker, getSubmitText, getTitleAction } from '@perses-dev/components';
|
|
17
|
+
import { Controller, FormProvider, useForm, useWatch } from 'react-hook-form';
|
|
18
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
19
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
20
|
+
import InvertColorsIcon from 'mdi-material-ui/InvertColors';
|
|
21
|
+
import { PluginEditor } from '../../PluginEditor';
|
|
22
|
+
import { useValidationSchemas } from '../../../context';
|
|
23
|
+
import { DEFAULT_ANNOTATION_COLOR } from '../constants';
|
|
24
|
+
import { AnnotationPreview } from './AnnotationPreview';
|
|
25
|
+
function FallbackPreview() {
|
|
26
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
27
|
+
children: "Error previewing annotations"
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function AnnotationPluginControl({ action, control, onRunQuery }) {
|
|
31
|
+
const plugin = useWatch({
|
|
32
|
+
control,
|
|
33
|
+
name: 'plugin'
|
|
34
|
+
});
|
|
35
|
+
const kind = plugin?.kind;
|
|
36
|
+
const pluginSpec = plugin?.spec;
|
|
37
|
+
return /*#__PURE__*/ _jsx(Controller, {
|
|
38
|
+
control: control,
|
|
39
|
+
name: "plugin",
|
|
40
|
+
render: ({ field })=>{
|
|
41
|
+
return /*#__PURE__*/ _jsx(PluginEditor, {
|
|
42
|
+
withRunQueryButton: true,
|
|
43
|
+
width: "100%",
|
|
44
|
+
pluginTypes: [
|
|
45
|
+
'Annotation'
|
|
46
|
+
],
|
|
47
|
+
pluginKindLabel: "Source",
|
|
48
|
+
value: {
|
|
49
|
+
selection: {
|
|
50
|
+
type: 'Annotation',
|
|
51
|
+
kind: kind ?? 'StaticListAnnotation'
|
|
52
|
+
},
|
|
53
|
+
spec: pluginSpec ?? {}
|
|
54
|
+
},
|
|
55
|
+
isReadonly: action === 'read',
|
|
56
|
+
onChange: (v)=>{
|
|
57
|
+
field.onChange({
|
|
58
|
+
kind: v.selection.kind,
|
|
59
|
+
spec: v.spec
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
onRunQuery: onRunQuery
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export function AnnotationEditorForm({ initialAnnotationSpec, action, isDraft, isReadonly, onActionChange, onSave, onClose, onDelete }) {
|
|
68
|
+
const queryClient = useQueryClient();
|
|
69
|
+
const [isDiscardDialogOpened, setDiscardDialogOpened] = useState(false);
|
|
70
|
+
const titleAction = getTitleAction(action, isDraft);
|
|
71
|
+
const submitText = getSubmitText(action, isDraft);
|
|
72
|
+
const { annotationEditorSchema } = useValidationSchemas();
|
|
73
|
+
const form = useForm({
|
|
74
|
+
resolver: zodResolver(annotationEditorSchema),
|
|
75
|
+
mode: 'onBlur',
|
|
76
|
+
defaultValues: initialAnnotationSpec
|
|
77
|
+
});
|
|
78
|
+
/* We use `previewDefinition` to explicitly update the spec
|
|
79
|
+
* that will be used for preview when running query. The reason why we do this is to avoid
|
|
80
|
+
* having to re-fetch the values when the user is still editing the spec.
|
|
81
|
+
* Using structuredClone to not have reference issues with nested objects.
|
|
82
|
+
*/ const [previewSpec, setPreviewSpec] = useState(structuredClone(form.getValues()));
|
|
83
|
+
const handleRunQuery = useCallback(async ()=>{
|
|
84
|
+
const values = form.getValues();
|
|
85
|
+
if (JSON.stringify(previewSpec) === JSON.stringify(values)) {
|
|
86
|
+
await queryClient.invalidateQueries({
|
|
87
|
+
queryKey: [
|
|
88
|
+
'annotation',
|
|
89
|
+
previewSpec
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
setPreviewSpec(structuredClone(values));
|
|
94
|
+
}
|
|
95
|
+
}, [
|
|
96
|
+
form,
|
|
97
|
+
previewSpec,
|
|
98
|
+
queryClient
|
|
99
|
+
]);
|
|
100
|
+
const processForm = (data)=>{
|
|
101
|
+
// reset display attributes to undefined when empty, because we don't want to save empty strings
|
|
102
|
+
onSave(data);
|
|
103
|
+
};
|
|
104
|
+
function handleCancel() {
|
|
105
|
+
if (JSON.stringify(initialAnnotationSpec) !== JSON.stringify(form.getValues())) {
|
|
106
|
+
setDiscardDialogOpened(true);
|
|
107
|
+
} else {
|
|
108
|
+
onClose();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return /*#__PURE__*/ _jsxs(FormProvider, {
|
|
112
|
+
...form,
|
|
113
|
+
children: [
|
|
114
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
115
|
+
sx: {
|
|
116
|
+
display: 'flex',
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
padding: (theme)=>theme.spacing(1, 2),
|
|
119
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
120
|
+
},
|
|
121
|
+
children: [
|
|
122
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
123
|
+
variant: "h2",
|
|
124
|
+
children: [
|
|
125
|
+
titleAction,
|
|
126
|
+
" Annotation"
|
|
127
|
+
]
|
|
128
|
+
}),
|
|
129
|
+
/*#__PURE__*/ _jsx(FormActions, {
|
|
130
|
+
action: action,
|
|
131
|
+
submitText: submitText,
|
|
132
|
+
isReadonly: isReadonly,
|
|
133
|
+
isValid: form.formState.isValid,
|
|
134
|
+
onActionChange: onActionChange,
|
|
135
|
+
onSubmit: form.handleSubmit(processForm),
|
|
136
|
+
onDelete: onDelete,
|
|
137
|
+
onCancel: handleCancel
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
}),
|
|
141
|
+
/*#__PURE__*/ _jsxs(Box, {
|
|
142
|
+
padding: 2,
|
|
143
|
+
sx: {
|
|
144
|
+
overflowY: 'scroll'
|
|
145
|
+
},
|
|
146
|
+
children: [
|
|
147
|
+
/*#__PURE__*/ _jsxs(Grid, {
|
|
148
|
+
container: true,
|
|
149
|
+
spacing: 2,
|
|
150
|
+
mb: 2,
|
|
151
|
+
children: [
|
|
152
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
153
|
+
item: true,
|
|
154
|
+
xs: 12,
|
|
155
|
+
children: /*#__PURE__*/ _jsx(Controller, {
|
|
156
|
+
control: form.control,
|
|
157
|
+
name: "display.name",
|
|
158
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
|
|
159
|
+
...field,
|
|
160
|
+
required: true,
|
|
161
|
+
fullWidth: true,
|
|
162
|
+
label: "Name",
|
|
163
|
+
InputLabelProps: {
|
|
164
|
+
shrink: action === 'read' ? true : undefined
|
|
165
|
+
},
|
|
166
|
+
InputProps: {
|
|
167
|
+
disabled: action === 'update' && !isDraft,
|
|
168
|
+
readOnly: action === 'read'
|
|
169
|
+
},
|
|
170
|
+
error: !!fieldState.error,
|
|
171
|
+
helperText: fieldState.error?.message,
|
|
172
|
+
value: field.value ?? '',
|
|
173
|
+
onChange: (event)=>{
|
|
174
|
+
field.onChange(event);
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
})
|
|
178
|
+
}),
|
|
179
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
180
|
+
item: true,
|
|
181
|
+
xs: 12,
|
|
182
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
183
|
+
direction: "row",
|
|
184
|
+
gap: 1,
|
|
185
|
+
children: [
|
|
186
|
+
/*#__PURE__*/ _jsx(Controller, {
|
|
187
|
+
control: form.control,
|
|
188
|
+
name: "display.color",
|
|
189
|
+
render: ({ field })=>{
|
|
190
|
+
const isEnabled = field.value !== undefined;
|
|
191
|
+
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
192
|
+
children: isEnabled ? /*#__PURE__*/ _jsx(OptionsColorPicker, {
|
|
193
|
+
size: "medium",
|
|
194
|
+
label: "annotation",
|
|
195
|
+
color: field.value ?? DEFAULT_ANNOTATION_COLOR,
|
|
196
|
+
onColorChange: (color)=>field.onChange(color),
|
|
197
|
+
onClear: ()=>field.onChange(undefined)
|
|
198
|
+
}) : /*#__PURE__*/ _jsx(IconButton, {
|
|
199
|
+
size: "medium",
|
|
200
|
+
onClick: ()=>field.onChange(DEFAULT_ANNOTATION_COLOR),
|
|
201
|
+
children: /*#__PURE__*/ _jsx(InvertColorsIcon, {})
|
|
202
|
+
})
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}),
|
|
206
|
+
/*#__PURE__*/ _jsx(Controller, {
|
|
207
|
+
control: form.control,
|
|
208
|
+
name: "display.description",
|
|
209
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
|
|
210
|
+
...field,
|
|
211
|
+
fullWidth: true,
|
|
212
|
+
label: "Description",
|
|
213
|
+
InputLabelProps: {
|
|
214
|
+
shrink: action === 'read' ? true : undefined
|
|
215
|
+
},
|
|
216
|
+
InputProps: {
|
|
217
|
+
readOnly: action === 'read'
|
|
218
|
+
},
|
|
219
|
+
error: !!fieldState.error,
|
|
220
|
+
helperText: fieldState.error?.message,
|
|
221
|
+
value: field.value ?? '',
|
|
222
|
+
onChange: (event)=>{
|
|
223
|
+
field.onChange(event);
|
|
224
|
+
}
|
|
225
|
+
})
|
|
226
|
+
})
|
|
227
|
+
]
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
]
|
|
231
|
+
}),
|
|
232
|
+
/*#__PURE__*/ _jsx(Divider, {}),
|
|
233
|
+
/*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
234
|
+
FallbackComponent: FallbackPreview,
|
|
235
|
+
resetKeys: [
|
|
236
|
+
previewSpec
|
|
237
|
+
],
|
|
238
|
+
children: /*#__PURE__*/ _jsx(AnnotationPreview, {
|
|
239
|
+
spec: previewSpec,
|
|
240
|
+
sx: {
|
|
241
|
+
marginY: 2
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
}),
|
|
245
|
+
/*#__PURE__*/ _jsx(ErrorBoundary, {
|
|
246
|
+
FallbackComponent: ErrorAlert,
|
|
247
|
+
children: /*#__PURE__*/ _jsx(AnnotationPluginControl, {
|
|
248
|
+
action: action,
|
|
249
|
+
control: form.control,
|
|
250
|
+
onRunQuery: handleRunQuery
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
]
|
|
254
|
+
}),
|
|
255
|
+
/*#__PURE__*/ _jsx(DiscardChangesConfirmationDialog, {
|
|
256
|
+
description: "Are you sure you want to discard these changes? Changes cannot be recovered.",
|
|
257
|
+
isOpen: isDiscardDialogOpened,
|
|
258
|
+
onCancel: ()=>{
|
|
259
|
+
setDiscardDialogOpened(false);
|
|
260
|
+
},
|
|
261
|
+
onDiscardChanges: ()=>{
|
|
262
|
+
setDiscardDialogOpened(false);
|
|
263
|
+
onClose();
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
]
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
//# sourceMappingURL=AnnotationEditorForm.js.map
|