@perses-dev/plugin-system 0.38.0 → 0.40.0
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/CalculationSelector/CalculationSelector.js +6 -4
- package/dist/cjs/components/CalculationSelector/index.js +10 -8
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +380 -0
- package/dist/cjs/components/DatasourceEditorForm/index.js +30 -0
- package/dist/cjs/components/DatasourceSelect.js +119 -21
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +18 -16
- package/dist/cjs/components/LegendOptionsEditor/index.js +10 -8
- package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +69 -0
- package/dist/cjs/components/OptionsEditorRadios/index.js +30 -0
- package/dist/cjs/components/{OptionsEditorTabs/TabPanel.js → OptionsEditorTabPanel/OptionsEditorTabPanel.js} +8 -6
- package/dist/cjs/components/OptionsEditorTabPanel/index.js +30 -0
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +10 -8
- package/dist/cjs/components/OptionsEditorTabs/index.js +10 -8
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +13 -11
- package/dist/cjs/components/PanelSpecEditor/index.js +10 -8
- package/dist/cjs/components/PluginEditor/PluginEditor.js +24 -31
- package/dist/cjs/components/PluginEditor/index.js +11 -9
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +5 -3
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +23 -12
- package/dist/cjs/components/PluginKindSelect/index.js +10 -8
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -9
- package/dist/cjs/components/PluginRegistry/index.js +10 -8
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +6 -2
- package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +6 -4
- package/dist/cjs/components/PluginSpecEditor/index.js +10 -8
- package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +15 -13
- package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +21 -19
- package/dist/cjs/components/TimeSeriesQueryEditor/index.js +10 -8
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +256 -166
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +32 -28
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +11 -9
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +28 -32
- package/dist/cjs/components/Variables/index.js +11 -9
- package/dist/cjs/components/Variables/variable-model.js +17 -9
- package/dist/cjs/components/index.js +22 -18
- package/dist/cjs/constants/index.js +10 -8
- package/dist/cjs/constants/user-interface-text.js +3 -1
- package/dist/cjs/index.js +16 -13
- package/dist/cjs/model/index.js +17 -15
- package/dist/cjs/model/legend.js +32 -20
- package/dist/cjs/model/panels.js +2 -2
- package/dist/cjs/model/plugin-base.js +2 -2
- package/dist/cjs/model/plugin-loading.js +3 -1
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +55 -35
- package/dist/cjs/runtime/DataQueriesProvider/index.js +11 -9
- package/dist/cjs/runtime/DataQueriesProvider/model.js +61 -0
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +19 -11
- package/dist/cjs/runtime/TimeRangeProvider/index.js +11 -9
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +36 -18
- package/dist/cjs/runtime/builtin-variables.js +81 -0
- package/dist/cjs/runtime/datasources.js +29 -11
- package/dist/cjs/runtime/index.js +16 -13
- package/dist/cjs/runtime/plugin-registry.js +41 -11
- package/dist/cjs/runtime/template-variables.js +96 -4
- package/dist/cjs/runtime/time-series-queries.js +39 -27
- package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +7 -5
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +16 -14
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +42 -0
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +19 -13
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js +6 -4
- package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +7 -5
- package/dist/cjs/stories/shared-utils/decorators/index.js +15 -12
- package/dist/cjs/stories/shared-utils/index.js +10 -8
- package/dist/cjs/test/index.js +11 -8
- package/dist/cjs/test/mock-data.js +57 -0
- package/dist/cjs/test/render.js +13 -11
- package/dist/cjs/test/test-plugins/bert/index.js +14 -10
- package/dist/cjs/test/test-plugins/ernie/index.js +13 -9
- package/dist/cjs/test/test-plugins/index.js +11 -9
- package/dist/cjs/test-utils/index.js +10 -8
- package/dist/cjs/test-utils/mock-plugin-registry.js +8 -4
- package/dist/cjs/utils/action.js +43 -0
- package/dist/cjs/utils/index.js +11 -8
- package/dist/cjs/utils/variables.js +26 -8
- package/dist/cjs/validation/datasource.js +30 -0
- package/dist/cjs/validation/index.js +32 -0
- package/dist/cjs/validation/resource.js +24 -0
- package/dist/cjs/validation/variable.js +29 -0
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/CalculationSelector/index.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +15 -0
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -0
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +333 -0
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -0
- package/dist/components/DatasourceEditorForm/index.d.ts +2 -0
- package/dist/components/DatasourceEditorForm/index.d.ts.map +1 -0
- package/dist/components/DatasourceEditorForm/index.js +15 -0
- package/dist/components/DatasourceEditorForm/index.js.map +1 -0
- package/dist/components/DatasourceSelect.d.ts +5 -0
- package/dist/components/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect.js +102 -19
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +2 -2
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/LegendOptionsEditor/index.js.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +16 -0
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -0
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +61 -0
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -0
- package/dist/components/OptionsEditorRadios/index.d.ts +2 -0
- package/dist/components/OptionsEditorRadios/index.d.ts.map +1 -0
- package/dist/components/OptionsEditorRadios/index.js +15 -0
- package/dist/components/OptionsEditorRadios/index.js.map +1 -0
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +9 -0
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -0
- package/dist/components/{OptionsEditorTabs/TabPanel.js → OptionsEditorTabPanel/OptionsEditorTabPanel.js} +2 -2
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -0
- package/dist/components/OptionsEditorTabPanel/index.d.ts +2 -0
- package/dist/components/OptionsEditorTabPanel/index.d.ts.map +1 -0
- package/dist/components/OptionsEditorTabPanel/index.js +15 -0
- package/dist/components/OptionsEditorTabPanel/index.js.map +1 -0
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +2 -2
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/OptionsEditorTabs/index.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +2 -2
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PanelSpecEditor/index.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +15 -24
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/index.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +2 -2
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +3 -3
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +21 -12
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginKindSelect/index.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +3 -3
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/index.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/PluginSpecEditor/index.js.map +1 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +4 -4
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +1 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -1
- package/dist/components/TimeSeriesQueryEditor/index.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +10 -7
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +200 -112
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +5 -4
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +22 -30
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/components/Variables/variable-model.js +3 -3
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/datasource.d.ts +2 -1
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/legend.d.ts +1 -1
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +14 -14
- package/dist/model/legend.js.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +5 -5
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +40 -28
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/index.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +17 -12
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +47 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/builtin-variables.d.ts +11 -0
- package/dist/runtime/builtin-variables.d.ts.map +1 -0
- package/dist/runtime/builtin-variables.js +59 -0
- package/dist/runtime/builtin-variables.js.map +1 -0
- package/dist/runtime/datasources.d.ts +14 -6
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js +13 -6
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +2 -0
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +19 -2
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/template-variables.d.ts +62 -2
- package/dist/runtime/template-variables.d.ts.map +1 -1
- package/dist/runtime/template-variables.js +83 -1
- package/dist/runtime/template-variables.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts +3 -3
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +14 -12
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +13 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +39 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +11 -7
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
- package/dist/stories/shared-utils/decorators/index.d.ts +1 -0
- package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/index.js +1 -0
- package/dist/stories/shared-utils/decorators/index.js.map +1 -1
- package/dist/stories/shared-utils/index.js.map +1 -1
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +1 -0
- package/dist/test/index.js.map +1 -1
- package/dist/test/mock-data.d.ts +3 -0
- package/dist/test/mock-data.d.ts.map +1 -0
- package/dist/test/mock-data.js +49 -0
- package/dist/test/mock-data.js.map +1 -0
- package/dist/test/render.js +2 -2
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test/test-plugins/index.js.map +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +2 -2
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/dist/utils/action.d.ts +4 -0
- package/dist/utils/action.d.ts.map +1 -0
- package/dist/utils/action.js +27 -0
- package/dist/utils/action.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/variables.d.ts.map +1 -1
- package/dist/utils/variables.js +17 -5
- package/dist/utils/variables.js.map +1 -1
- package/dist/validation/datasource.d.ts +19 -0
- package/dist/validation/datasource.d.ts.map +1 -0
- package/dist/validation/datasource.js +22 -0
- package/dist/validation/datasource.js.map +1 -0
- package/dist/validation/index.d.ts +4 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +17 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/resource.d.ts +3 -0
- package/dist/validation/resource.d.ts.map +1 -0
- package/dist/validation/resource.js +16 -0
- package/dist/validation/resource.js.map +1 -0
- package/dist/validation/variable.d.ts +19 -0
- package/dist/validation/variable.d.ts.map +1 -0
- package/dist/validation/variable.js +21 -0
- package/dist/validation/variable.js.map +1 -0
- package/package.json +8 -6
- package/dist/components/OptionsEditorTabs/TabPanel.d.ts +0 -9
- package/dist/components/OptionsEditorTabs/TabPanel.d.ts.map +0 -1
- package/dist/components/OptionsEditorTabs/TabPanel.js.map +0 -1
|
@@ -21,14 +21,27 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
PluginRegistryContext: ()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
PluginRegistryContext: function() {
|
|
25
|
+
return PluginRegistryContext;
|
|
26
|
+
},
|
|
27
|
+
usePluginRegistry: function() {
|
|
28
|
+
return usePluginRegistry;
|
|
29
|
+
},
|
|
30
|
+
usePlugin: function() {
|
|
31
|
+
return usePlugin;
|
|
32
|
+
},
|
|
33
|
+
usePlugins: function() {
|
|
34
|
+
return usePlugins;
|
|
35
|
+
},
|
|
36
|
+
useListPluginMetadata: function() {
|
|
37
|
+
return useListPluginMetadata;
|
|
38
|
+
},
|
|
39
|
+
usePluginBuiltinVariableDefinitions: function() {
|
|
40
|
+
return usePluginBuiltinVariableDefinitions;
|
|
41
|
+
}
|
|
29
42
|
});
|
|
30
43
|
const _react = require("react");
|
|
31
|
-
const
|
|
44
|
+
const _reactquery = require("@tanstack/react-query");
|
|
32
45
|
const PluginRegistryContext = (0, _react.createContext)(undefined);
|
|
33
46
|
function usePluginRegistry() {
|
|
34
47
|
const ctx = (0, _react.useContext)(PluginRegistryContext);
|
|
@@ -38,14 +51,14 @@ function usePluginRegistry() {
|
|
|
38
51
|
return ctx;
|
|
39
52
|
}
|
|
40
53
|
function usePlugin(pluginType, kind, options) {
|
|
41
|
-
var
|
|
54
|
+
var _options_enabled;
|
|
42
55
|
// We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically
|
|
43
56
|
options = {
|
|
44
57
|
...options,
|
|
45
|
-
enabled: ((
|
|
58
|
+
enabled: ((_options_enabled = options === null || options === void 0 ? void 0 : options.enabled) !== null && _options_enabled !== void 0 ? _options_enabled : true) && kind !== ''
|
|
46
59
|
};
|
|
47
60
|
const { getPlugin } = usePluginRegistry();
|
|
48
|
-
return (0,
|
|
61
|
+
return (0, _reactquery.useQuery)([
|
|
49
62
|
'getPlugin',
|
|
50
63
|
pluginType,
|
|
51
64
|
kind
|
|
@@ -53,7 +66,7 @@ function usePlugin(pluginType, kind, options) {
|
|
|
53
66
|
}
|
|
54
67
|
function usePlugins(pluginType, plugins) {
|
|
55
68
|
const { getPlugin } = usePluginRegistry();
|
|
56
|
-
return (0,
|
|
69
|
+
return (0, _reactquery.useQueries)({
|
|
57
70
|
queries: plugins.map((p)=>{
|
|
58
71
|
return {
|
|
59
72
|
queryKey: [
|
|
@@ -68,8 +81,25 @@ function usePlugins(pluginType, plugins) {
|
|
|
68
81
|
}
|
|
69
82
|
function useListPluginMetadata(pluginType, options) {
|
|
70
83
|
const { listPluginMetadata } = usePluginRegistry();
|
|
71
|
-
return (0,
|
|
84
|
+
return (0, _reactquery.useQuery)([
|
|
72
85
|
'listPluginMetadata',
|
|
73
86
|
pluginType
|
|
74
87
|
], ()=>listPluginMetadata(pluginType), options);
|
|
75
88
|
}
|
|
89
|
+
function usePluginBuiltinVariableDefinitions() {
|
|
90
|
+
const { getPlugin , listPluginMetadata } = usePluginRegistry();
|
|
91
|
+
return (0, _reactquery.useQuery)([
|
|
92
|
+
'usePluginBuiltinVariableDefinitions'
|
|
93
|
+
], async ()=>{
|
|
94
|
+
const datasources = await listPluginMetadata('Datasource');
|
|
95
|
+
const datasourceKinds = new Set(datasources.map((datasource)=>datasource.kind));
|
|
96
|
+
const result = [];
|
|
97
|
+
for (const kind of datasourceKinds){
|
|
98
|
+
const plugin = await getPlugin('Datasource', kind);
|
|
99
|
+
if (plugin.getBuiltinVariableDefinitions) {
|
|
100
|
+
plugin.getBuiltinVariableDefinitions().forEach((definition)=>result.push(definition));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
@@ -21,12 +21,99 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
VariableStoreStateMap: function() {
|
|
25
|
+
return VariableStoreStateMap;
|
|
26
|
+
},
|
|
27
|
+
TemplateVariableContext: function() {
|
|
28
|
+
return TemplateVariableContext;
|
|
29
|
+
},
|
|
30
|
+
useTemplateVariableValues: function() {
|
|
31
|
+
return useTemplateVariableValues;
|
|
32
|
+
},
|
|
33
|
+
useVariableValues: function() {
|
|
34
|
+
return useVariableValues;
|
|
35
|
+
},
|
|
36
|
+
useReplaceVariablesInString: function() {
|
|
37
|
+
return useReplaceVariablesInString;
|
|
38
|
+
}
|
|
27
39
|
});
|
|
28
40
|
const _react = require("react");
|
|
41
|
+
const _immer = require("immer");
|
|
29
42
|
const _utils = require("../utils");
|
|
43
|
+
const _builtinvariables = require("./builtin-variables");
|
|
44
|
+
function _define_property(obj, key, value) {
|
|
45
|
+
if (key in obj) {
|
|
46
|
+
Object.defineProperty(obj, key, {
|
|
47
|
+
value: value,
|
|
48
|
+
enumerable: true,
|
|
49
|
+
configurable: true,
|
|
50
|
+
writable: true
|
|
51
|
+
});
|
|
52
|
+
} else {
|
|
53
|
+
obj[key] = value;
|
|
54
|
+
}
|
|
55
|
+
return obj;
|
|
56
|
+
}
|
|
57
|
+
let _immerable = _immer.immerable;
|
|
58
|
+
class VariableStoreStateMap {
|
|
59
|
+
/**
|
|
60
|
+
* Get variable state by key.
|
|
61
|
+
* @param key
|
|
62
|
+
*/ get(key) {
|
|
63
|
+
return this._sourceStatesOrEmpty(key.source)[key.name];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Set variable state by key.
|
|
67
|
+
* @param key
|
|
68
|
+
* @param value
|
|
69
|
+
*/ set(key, value) {
|
|
70
|
+
const sourceName = this._sourceName(key.source);
|
|
71
|
+
if (!this._state[sourceName]) {
|
|
72
|
+
this._state[sourceName] = {};
|
|
73
|
+
}
|
|
74
|
+
this._sourceStatesOrEmpty(key.source)[key.name] = value;
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Check presence of variable state by key.
|
|
79
|
+
* @param key
|
|
80
|
+
*/ has(key) {
|
|
81
|
+
return this._sourceStatesOrEmpty(key.source)[key.name] !== undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Delete variable state by key.
|
|
85
|
+
* @param key
|
|
86
|
+
*/ delete(key) {
|
|
87
|
+
var _Object_keys;
|
|
88
|
+
const result = this.has(key);
|
|
89
|
+
const sourceName = this._sourceName(key.source);
|
|
90
|
+
const sourceStates = this._state[sourceName];
|
|
91
|
+
// Delete var from source state
|
|
92
|
+
if (sourceStates) {
|
|
93
|
+
delete sourceStates[key.name];
|
|
94
|
+
}
|
|
95
|
+
// Delete source state from state if empty
|
|
96
|
+
if (((_Object_keys = Object.keys(sourceStates !== null && sourceStates !== void 0 ? sourceStates : {})) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length) === 0) {
|
|
97
|
+
delete this._state[sourceName];
|
|
98
|
+
}
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
_sourceName(source) {
|
|
102
|
+
return source !== null && source !== void 0 ? source : this.DEFAULT_LOCAL_SOURCE_NAME;
|
|
103
|
+
}
|
|
104
|
+
_sourceStatesOrEmpty(source) {
|
|
105
|
+
var _this__state_this__sourceName;
|
|
106
|
+
return (_this__state_this__sourceName = this._state[this._sourceName(source)]) !== null && _this__state_this__sourceName !== void 0 ? _this__state_this__sourceName : {};
|
|
107
|
+
}
|
|
108
|
+
constructor(){
|
|
109
|
+
/**
|
|
110
|
+
* "Immerable" is mandatory to be able to use this class in an immer context.
|
|
111
|
+
* Ref: https://docs.pmnd.rs/zustand/integrations/immer-middleware#gotchas
|
|
112
|
+
*/ _define_property(this, _immerable, true);
|
|
113
|
+
_define_property(this, "DEFAULT_LOCAL_SOURCE_NAME", '');
|
|
114
|
+
_define_property(this, "_state", {});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
30
117
|
const TemplateVariableContext = (0, _react.createContext)(undefined);
|
|
31
118
|
function useTemplateVariableContext() {
|
|
32
119
|
const ctx = (0, _react.useContext)(TemplateVariableContext);
|
|
@@ -55,9 +142,14 @@ function useTemplateVariableValues(names) {
|
|
|
55
142
|
}
|
|
56
143
|
return values;
|
|
57
144
|
}
|
|
145
|
+
function useVariableValues(names) {
|
|
146
|
+
const templateVariableValues = useTemplateVariableValues(names);
|
|
147
|
+
const builtinVariableValues = (0, _builtinvariables.useBuiltinVariableValues)(names);
|
|
148
|
+
return Object.assign(templateVariableValues, builtinVariableValues);
|
|
149
|
+
}
|
|
58
150
|
function useReplaceVariablesInString(str) {
|
|
59
151
|
const variablesInString = str ? (0, _utils.parseTemplateVariables)(str) : [];
|
|
60
|
-
const variableValues =
|
|
152
|
+
const variableValues = useVariableValues(variablesInString);
|
|
61
153
|
if (!str) return undefined;
|
|
62
154
|
return (0, _utils.replaceTemplateVariables)(str, variableValues);
|
|
63
155
|
}
|
|
@@ -21,17 +21,27 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
TIME_SERIES_QUERY_KEY: ()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
TIME_SERIES_QUERY_KEY: function() {
|
|
25
|
+
return TIME_SERIES_QUERY_KEY;
|
|
26
|
+
},
|
|
27
|
+
useTimeSeriesQuery: function() {
|
|
28
|
+
return useTimeSeriesQuery;
|
|
29
|
+
},
|
|
30
|
+
useTimeSeriesQueries: function() {
|
|
31
|
+
return useTimeSeriesQueries;
|
|
32
|
+
},
|
|
33
|
+
useActiveTimeSeriesQueries: function() {
|
|
34
|
+
return useActiveTimeSeriesQueries;
|
|
35
|
+
},
|
|
36
|
+
getActiveTimeSeriesQueries: function() {
|
|
37
|
+
return getActiveTimeSeriesQueries;
|
|
38
|
+
}
|
|
29
39
|
});
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
40
|
+
const _reactquery = require("@tanstack/react-query");
|
|
41
|
+
const _templatevariables = require("./template-variables");
|
|
42
|
+
const _TimeRangeProvider = require("./TimeRangeProvider");
|
|
33
43
|
const _datasources = require("./datasources");
|
|
34
|
-
const
|
|
44
|
+
const _pluginregistry = require("./plugin-registry");
|
|
35
45
|
const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';
|
|
36
46
|
/**
|
|
37
47
|
* Returns a serialized string of the current state of variable values.
|
|
@@ -63,8 +73,8 @@ function getQueryOptions({ plugin , definition , context }) {
|
|
|
63
73
|
let waitToLoad = false;
|
|
64
74
|
if (variableDependencies) {
|
|
65
75
|
waitToLoad = variableDependencies.some((v)=>{
|
|
66
|
-
var
|
|
67
|
-
return (
|
|
76
|
+
var _variableState_v;
|
|
77
|
+
return (_variableState_v = variableState[v]) === null || _variableState_v === void 0 ? void 0 : _variableState_v.loading;
|
|
68
78
|
});
|
|
69
79
|
}
|
|
70
80
|
const queryEnabled = plugin !== undefined && !waitToLoad;
|
|
@@ -73,16 +83,17 @@ function getQueryOptions({ plugin , definition , context }) {
|
|
|
73
83
|
queryEnabled
|
|
74
84
|
};
|
|
75
85
|
}
|
|
76
|
-
const useTimeSeriesQuery = (definition, options)=>{
|
|
77
|
-
const { data: plugin } = (0,
|
|
86
|
+
const useTimeSeriesQuery = (definition, options, queryOptions)=>{
|
|
87
|
+
const { data: plugin } = (0, _pluginregistry.usePlugin)(TIME_SERIES_QUERY_KEY, definition.spec.plugin.kind);
|
|
78
88
|
const context = useTimeSeriesQueryContext();
|
|
79
89
|
const { queryEnabled , queryKey } = getQueryOptions({
|
|
80
90
|
plugin,
|
|
81
91
|
definition,
|
|
82
92
|
context
|
|
83
93
|
});
|
|
84
|
-
|
|
85
|
-
|
|
94
|
+
var _queryOptions_enabled;
|
|
95
|
+
return (0, _reactquery.useQuery)({
|
|
96
|
+
enabled: ((_queryOptions_enabled = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.enabled) !== null && _queryOptions_enabled !== void 0 ? _queryOptions_enabled : true) || queryEnabled,
|
|
86
97
|
queryKey: queryKey,
|
|
87
98
|
refetchInterval: context.refreshIntervalInMs > 0 ? context.refreshIntervalInMs : false,
|
|
88
99
|
queryFn: ()=>{
|
|
@@ -99,23 +110,24 @@ const useTimeSeriesQuery = (definition, options)=>{
|
|
|
99
110
|
}
|
|
100
111
|
});
|
|
101
112
|
};
|
|
102
|
-
function useTimeSeriesQueries(definitions, options) {
|
|
103
|
-
const { getPlugin } = (0,
|
|
113
|
+
function useTimeSeriesQueries(definitions, options, queryOptions) {
|
|
114
|
+
const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
|
|
104
115
|
const context = useTimeSeriesQueryContext();
|
|
105
|
-
const pluginLoaderResponse = (0,
|
|
116
|
+
const pluginLoaderResponse = (0, _pluginregistry.usePlugins)(TIME_SERIES_QUERY_KEY, definitions.map((d)=>({
|
|
106
117
|
kind: d.spec.plugin.kind
|
|
107
118
|
})));
|
|
108
|
-
return (0,
|
|
119
|
+
return (0, _reactquery.useQueries)({
|
|
109
120
|
queries: definitions.map((definition, idx)=>{
|
|
110
|
-
var
|
|
111
|
-
const plugin = (
|
|
121
|
+
var _pluginLoaderResponse_idx;
|
|
122
|
+
const plugin = (_pluginLoaderResponse_idx = pluginLoaderResponse[idx]) === null || _pluginLoaderResponse_idx === void 0 ? void 0 : _pluginLoaderResponse_idx.data;
|
|
112
123
|
const { queryEnabled , queryKey } = getQueryOptions({
|
|
113
124
|
plugin,
|
|
114
125
|
definition,
|
|
115
126
|
context
|
|
116
127
|
});
|
|
128
|
+
var _queryOptions_enabled;
|
|
117
129
|
return {
|
|
118
|
-
enabled: queryEnabled,
|
|
130
|
+
enabled: ((_queryOptions_enabled = queryOptions === null || queryOptions === void 0 ? void 0 : queryOptions.enabled) !== null && _queryOptions_enabled !== void 0 ? _queryOptions_enabled : true) && queryEnabled,
|
|
119
131
|
queryKey: queryKey,
|
|
120
132
|
refetchInterval: context.refreshIntervalInMs > 0 ? context.refreshIntervalInMs : undefined,
|
|
121
133
|
queryFn: async ()=>{
|
|
@@ -135,8 +147,8 @@ function useTimeSeriesQueries(definitions, options) {
|
|
|
135
147
|
/**
|
|
136
148
|
* Build the time series query context object from data available at runtime
|
|
137
149
|
*/ function useTimeSeriesQueryContext() {
|
|
138
|
-
const { absoluteTimeRange , refreshKey , refreshIntervalInMs } = (0,
|
|
139
|
-
const variableState = (0,
|
|
150
|
+
const { absoluteTimeRange , refreshKey , refreshIntervalInMs } = (0, _TimeRangeProvider.useTimeRange)();
|
|
151
|
+
const variableState = (0, _templatevariables.useVariableValues)();
|
|
140
152
|
const datasourceStore = (0, _datasources.useDatasourceStore)();
|
|
141
153
|
return {
|
|
142
154
|
timeRange: absoluteTimeRange,
|
|
@@ -147,7 +159,7 @@ function useTimeSeriesQueries(definitions, options) {
|
|
|
147
159
|
};
|
|
148
160
|
}
|
|
149
161
|
function useActiveTimeSeriesQueries() {
|
|
150
|
-
const queryClient = (0,
|
|
162
|
+
const queryClient = (0, _reactquery.useQueryClient)();
|
|
151
163
|
const queryCache = queryClient.getQueryCache();
|
|
152
164
|
return getActiveTimeSeriesQueries(queryCache);
|
|
153
165
|
}
|
|
@@ -156,8 +168,8 @@ function getActiveTimeSeriesQueries(cache) {
|
|
|
156
168
|
for (const query of cache.findAll({
|
|
157
169
|
type: 'active'
|
|
158
170
|
})){
|
|
159
|
-
var
|
|
160
|
-
const firstPart = (
|
|
171
|
+
var _query_queryKey;
|
|
172
|
+
const firstPart = (_query_queryKey = query.queryKey) === null || _query_queryKey === void 0 ? void 0 : _query_queryKey[0];
|
|
161
173
|
if ((firstPart === null || firstPart === void 0 ? void 0 : firstPart.kind) && firstPart.kind.startsWith(TIME_SERIES_QUERY_KEY)) {
|
|
162
174
|
queries.push(query);
|
|
163
175
|
}
|
|
@@ -16,10 +16,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "WithDataQueries", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return WithDataQueries;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
23
25
|
// Type guard because storybook types parameters as `any`
|
|
24
26
|
function isWithDataQueriesParameter(parameter) {
|
|
25
27
|
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
@@ -32,8 +34,8 @@ const WithDataQueries = (Story, context)=>{
|
|
|
32
34
|
}
|
|
33
35
|
};
|
|
34
36
|
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
35
|
-
return /*#__PURE__*/ (0,
|
|
37
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DataQueriesProvider, {
|
|
36
38
|
...props,
|
|
37
|
-
children: /*#__PURE__*/ (0,
|
|
39
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
38
40
|
});
|
|
39
41
|
};
|
|
@@ -16,13 +16,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "WithPluginRegistry", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return WithPluginRegistry;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
function
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
|
+
const _pluginjson = /*#__PURE__*/ _interop_require_default(require("@perses-dev/prometheus-plugin/plugin.json"));
|
|
26
|
+
const _pluginjson1 = /*#__PURE__*/ _interop_require_default(require("@perses-dev/panels-plugin/plugin.json"));
|
|
27
|
+
function _interop_require_default(obj) {
|
|
26
28
|
return obj && obj.__esModule ? obj : {
|
|
27
29
|
default: obj
|
|
28
30
|
};
|
|
@@ -35,7 +37,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
35
37
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
36
38
|
})(nodeInterop);
|
|
37
39
|
}
|
|
38
|
-
function
|
|
40
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
39
41
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
40
42
|
return obj;
|
|
41
43
|
}
|
|
@@ -66,30 +68,30 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
66
68
|
}
|
|
67
69
|
return newObj;
|
|
68
70
|
}
|
|
69
|
-
const bundledPluginLoader = (0,
|
|
71
|
+
const bundledPluginLoader = (0, _pluginsystem.dynamicImportPluginLoader)([
|
|
70
72
|
{
|
|
71
|
-
resource:
|
|
73
|
+
resource: _pluginjson.default,
|
|
72
74
|
// This throws an error in CI (but not locally for some reason), likely because
|
|
73
75
|
// this package isn't a dependency for dashboards. We probably do not want to
|
|
74
76
|
// make it one solely for type-checking in storybook.
|
|
75
77
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
76
78
|
// @ts-ignore
|
|
77
|
-
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/
|
|
79
|
+
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("@perses-dev/prometheus-plugin")))
|
|
78
80
|
},
|
|
79
81
|
{
|
|
80
|
-
resource:
|
|
82
|
+
resource: _pluginjson1.default,
|
|
81
83
|
// Same comment as above.
|
|
82
84
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
83
85
|
// @ts-ignore
|
|
84
|
-
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/
|
|
86
|
+
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("@perses-dev/panels-plugin")))
|
|
85
87
|
}
|
|
86
88
|
]);
|
|
87
89
|
const WithPluginRegistry = (Story)=>{
|
|
88
|
-
return /*#__PURE__*/ (0,
|
|
90
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PluginRegistry, {
|
|
89
91
|
pluginLoader: bundledPluginLoader,
|
|
90
92
|
defaultPluginKinds: {
|
|
91
93
|
TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
|
|
92
94
|
},
|
|
93
|
-
children: /*#__PURE__*/ (0,
|
|
95
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
94
96
|
});
|
|
95
97
|
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "WithPluginSystemBuiltinVariables", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return WithPluginSystemBuiltinVariables;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _runtime = require("../../../runtime");
|
|
25
|
+
// Type guard because storybook types parameters as `any`
|
|
26
|
+
function isWithBuiltinVariableParameter(parameter) {
|
|
27
|
+
return !!parameter && Array.isArray(parameter);
|
|
28
|
+
}
|
|
29
|
+
const WithPluginSystemBuiltinVariables = (Story, context)=>{
|
|
30
|
+
const initParameter = context.parameters.withPluginSystemBuiltinVariables;
|
|
31
|
+
const defaultValue = {
|
|
32
|
+
variables: []
|
|
33
|
+
};
|
|
34
|
+
const parameter = isWithBuiltinVariableParameter(initParameter) ? initParameter : {
|
|
35
|
+
props: defaultValue
|
|
36
|
+
};
|
|
37
|
+
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
38
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.BuiltinVariableContext.Provider, {
|
|
39
|
+
value: props,
|
|
40
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
41
|
+
});
|
|
42
|
+
};
|
|
@@ -16,23 +16,25 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "WithPluginSystemDatasourceStore", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return WithPluginSystemDatasourceStore;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
23
25
|
const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
|
|
24
26
|
// Type guard because storybook types parameters as `any`
|
|
25
27
|
function isWithDatastoreStoreParameter(parameter) {
|
|
26
28
|
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
27
29
|
}
|
|
28
30
|
const WithPluginSystemDatasourceStore = (Story, context)=>{
|
|
29
|
-
const { getPlugin } = (0,
|
|
31
|
+
const { getPlugin } = (0, _pluginsystem.usePluginRegistry)();
|
|
30
32
|
const initParameter = context.parameters.withPluginSystemDatasourceStore;
|
|
31
33
|
// This currently provides a very simplified default to enable use in some
|
|
32
34
|
// basic stories. It likely will need expanding in the future.
|
|
33
35
|
// In general, `plugin-system` would probably benefit from a provider wrapper
|
|
34
36
|
// for `DatasourceStoreContext` that is more generic than the one available
|
|
35
|
-
// in
|
|
37
|
+
// in the `dashboard` package for non-dashboard use cases.
|
|
36
38
|
const defaultValue = {
|
|
37
39
|
getDatasource: (selector)=>{
|
|
38
40
|
if (selector.kind === 'PrometheusDatasource') {
|
|
@@ -50,7 +52,7 @@ const WithPluginSystemDatasourceStore = (Story, context)=>{
|
|
|
50
52
|
if (selector.kind === 'PrometheusDatasource') {
|
|
51
53
|
const plugin = await getPlugin('Datasource', 'PrometheusDatasource');
|
|
52
54
|
const client = plugin.createClient({
|
|
53
|
-
|
|
55
|
+
directUrl: prometheusDemoUrl
|
|
54
56
|
}, {
|
|
55
57
|
proxyUrl: prometheusDemoUrl
|
|
56
58
|
});
|
|
@@ -58,14 +60,18 @@ const WithPluginSystemDatasourceStore = (Story, context)=>{
|
|
|
58
60
|
}
|
|
59
61
|
throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
|
|
60
62
|
},
|
|
61
|
-
|
|
63
|
+
listDatasourceSelectItems: async (datasourcePluginKind)=>{
|
|
62
64
|
if (datasourcePluginKind === 'PrometheusDatasource') {
|
|
63
65
|
return Promise.resolve([
|
|
64
66
|
{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
items: [
|
|
68
|
+
{
|
|
69
|
+
name: 'PrometheusDatasource',
|
|
70
|
+
selector: {
|
|
71
|
+
kind: 'PrometheusDatasource'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
]
|
|
69
75
|
}
|
|
70
76
|
]);
|
|
71
77
|
}
|
|
@@ -76,8 +82,8 @@ const WithPluginSystemDatasourceStore = (Story, context)=>{
|
|
|
76
82
|
props: defaultValue
|
|
77
83
|
};
|
|
78
84
|
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
79
|
-
return /*#__PURE__*/ (0,
|
|
85
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceStoreContext.Provider, {
|
|
80
86
|
value: props,
|
|
81
|
-
children: /*#__PURE__*/ (0,
|
|
87
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
82
88
|
});
|
|
83
89
|
};
|
|
@@ -16,9 +16,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "WithPluginSystemTemplateVariables", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return WithPluginSystemTemplateVariables;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
|
-
const
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
22
24
|
const _runtime = require("../../../runtime");
|
|
23
25
|
// Type guard because storybook types parameters as `any`
|
|
24
26
|
function isWithTemplateVariableParameter(parameter) {
|
|
@@ -33,8 +35,8 @@ const WithPluginSystemTemplateVariables = (Story, context)=>{
|
|
|
33
35
|
props: defaultValue
|
|
34
36
|
};
|
|
35
37
|
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
36
|
-
return /*#__PURE__*/ (0,
|
|
38
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.TemplateVariableContext.Provider, {
|
|
37
39
|
value: props,
|
|
38
|
-
children: /*#__PURE__*/ (0,
|
|
40
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
39
41
|
});
|
|
40
42
|
};
|
|
@@ -16,10 +16,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "WithTimeRange", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return WithTimeRange;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
23
25
|
// Type guard because storybook types parameters as `any`
|
|
24
26
|
function isWithTimeRangeParameter(parameter) {
|
|
25
27
|
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
@@ -28,12 +30,12 @@ const WithTimeRange = (Story, context)=>{
|
|
|
28
30
|
const initParameter = context.parameters.withTimeRange;
|
|
29
31
|
const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;
|
|
30
32
|
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
31
|
-
return /*#__PURE__*/ (0,
|
|
33
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TimeRangeProvider, {
|
|
32
34
|
initialRefreshInterval: "0s",
|
|
33
35
|
initialTimeRange: {
|
|
34
36
|
pastDuration: '1h'
|
|
35
37
|
},
|
|
36
38
|
...props,
|
|
37
|
-
children: /*#__PURE__*/ (0,
|
|
39
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
38
40
|
});
|
|
39
41
|
};
|
|
@@ -14,19 +14,22 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
_export_star(require("./WithDataQueries"), exports);
|
|
18
|
+
_export_star(require("./WithPluginRegistry"), exports);
|
|
19
|
+
_export_star(require("./WithPluginSystemBuiltinVariables"), exports);
|
|
20
|
+
_export_star(require("./WithPluginSystemDatasourceStore"), exports);
|
|
21
|
+
_export_star(require("./WithPluginSystemTemplateVariables"), exports);
|
|
22
|
+
_export_star(require("./WithTimeRange"), exports);
|
|
23
|
+
function _export_star(from, to) {
|
|
23
24
|
Object.keys(from).forEach(function(k) {
|
|
24
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k))
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
26
|
+
Object.defineProperty(to, k, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function() {
|
|
29
|
+
return from[k];
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
30
33
|
});
|
|
31
34
|
return from;
|
|
32
35
|
}
|