@perses-dev/plugin-system 0.39.0 → 0.40.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/CalculationSelector/CalculationSelector.js +6 -4
- package/dist/cjs/components/CalculationSelector/index.js +10 -8
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +381 -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 +23 -28
- package/dist/cjs/components/OptionsEditorRadios/index.js +10 -8
- package/dist/cjs/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +6 -4
- package/dist/cjs/components/OptionsEditorTabPanel/index.js +10 -8
- 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 +257 -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 -19
- 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 +19 -11
- package/dist/cjs/runtime/DataQueriesProvider/index.js +11 -9
- package/dist/cjs/runtime/DataQueriesProvider/model.js +12 -8
- 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 +42 -12
- 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 -9
- package/dist/cjs/test/mock-data.js +3 -1
- 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 +334 -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 +2 -2
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +16 -23
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
- package/dist/components/OptionsEditorRadios/index.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/index.js.map +1 -1
- 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 +201 -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 +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/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.js +4 -4
- 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 +3 -2
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +4 -4
- 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 +2 -1
- package/dist/runtime/template-variables.d.ts.map +1 -1
- package/dist/runtime/template-variables.js +27 -8
- 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.js.map +1 -1
- package/dist/test/mock-data.js.map +1 -1
- 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/cjs/test/render.js
CHANGED
|
@@ -16,13 +16,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "renderWithContext", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return renderWithContext;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
|
-
const
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
22
24
|
const _react = require("@testing-library/react");
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
25
|
+
const _reactquery = require("@tanstack/react-query");
|
|
26
|
+
const _PluginRegistry = require("../components/PluginRegistry");
|
|
27
|
+
const _testplugins = require("./test-plugins");
|
|
26
28
|
const testLogger = {
|
|
27
29
|
log: console.log,
|
|
28
30
|
warn: console.warn,
|
|
@@ -32,7 +34,7 @@ const testLogger = {
|
|
|
32
34
|
};
|
|
33
35
|
function renderWithContext(ui, renderOptions, contextOptions) {
|
|
34
36
|
// Create a new QueryClient for each test to avoid caching issues
|
|
35
|
-
const queryClient = new
|
|
37
|
+
const queryClient = new _reactquery.QueryClient({
|
|
36
38
|
defaultOptions: {
|
|
37
39
|
queries: {
|
|
38
40
|
refetchOnWindowFocus: false,
|
|
@@ -41,12 +43,12 @@ function renderWithContext(ui, renderOptions, contextOptions) {
|
|
|
41
43
|
},
|
|
42
44
|
logger: testLogger
|
|
43
45
|
});
|
|
44
|
-
var
|
|
45
|
-
return (0, _react.render)(/*#__PURE__*/ (0,
|
|
46
|
+
var _contextOptions_defaultPluginKinds;
|
|
47
|
+
return (0, _react.render)(/*#__PURE__*/ (0, _jsxruntime.jsx)(_reactquery.QueryClientProvider, {
|
|
46
48
|
client: queryClient,
|
|
47
|
-
children: /*#__PURE__*/ (0,
|
|
48
|
-
pluginLoader:
|
|
49
|
-
defaultPluginKinds: (
|
|
49
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PluginRegistry.PluginRegistry, {
|
|
50
|
+
pluginLoader: _testplugins.testPluginLoader,
|
|
51
|
+
defaultPluginKinds: (_contextOptions_defaultPluginKinds = contextOptions === null || contextOptions === void 0 ? void 0 : contextOptions.defaultPluginKinds) !== null && _contextOptions_defaultPluginKinds !== void 0 ? _contextOptions_defaultPluginKinds : {
|
|
50
52
|
TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
|
|
51
53
|
},
|
|
52
54
|
children: ui
|
|
@@ -21,18 +21,22 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
BertPanel1: ()
|
|
25
|
-
|
|
24
|
+
BertPanel1: function() {
|
|
25
|
+
return BertPanel1;
|
|
26
|
+
},
|
|
27
|
+
BertPanel2: function() {
|
|
28
|
+
return BertPanel2;
|
|
29
|
+
}
|
|
26
30
|
});
|
|
27
|
-
const
|
|
31
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
28
32
|
function BertPanel1Editor({ value , onChange }) {
|
|
29
|
-
return /*#__PURE__*/ (0,
|
|
33
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
30
34
|
children: [
|
|
31
|
-
/*#__PURE__*/ (0,
|
|
35
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("label", {
|
|
32
36
|
htmlFor: "editor-input",
|
|
33
37
|
children: "BertPanel1 editor"
|
|
34
38
|
}),
|
|
35
|
-
/*#__PURE__*/ (0,
|
|
39
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
36
40
|
type: "text",
|
|
37
41
|
id: "editor-input",
|
|
38
42
|
value: value.option1,
|
|
@@ -62,13 +66,13 @@ const BertPanel2 = {
|
|
|
62
66
|
{
|
|
63
67
|
label: 'Settings',
|
|
64
68
|
content: function BertPanel2Editor({ value , onChange }) {
|
|
65
|
-
return /*#__PURE__*/ (0,
|
|
69
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
66
70
|
children: [
|
|
67
|
-
/*#__PURE__*/ (0,
|
|
71
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("label", {
|
|
68
72
|
htmlFor: "editor-input",
|
|
69
73
|
children: "BertPanel2 editor"
|
|
70
74
|
}),
|
|
71
|
-
/*#__PURE__*/ (0,
|
|
75
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
72
76
|
type: "text",
|
|
73
77
|
id: "editor-input",
|
|
74
78
|
value: value.option2,
|
|
@@ -84,7 +88,7 @@ const BertPanel2 = {
|
|
|
84
88
|
{
|
|
85
89
|
label: 'Custom Tab',
|
|
86
90
|
content: function Editor() {
|
|
87
|
-
return /*#__PURE__*/ (0,
|
|
91
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
88
92
|
children: "custom content"
|
|
89
93
|
});
|
|
90
94
|
}
|
|
@@ -21,10 +21,14 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
ErnieVariable1: ()
|
|
25
|
-
|
|
24
|
+
ErnieVariable1: function() {
|
|
25
|
+
return ErnieVariable1;
|
|
26
|
+
},
|
|
27
|
+
ErnieVariable2: function() {
|
|
28
|
+
return ErnieVariable2;
|
|
29
|
+
}
|
|
26
30
|
});
|
|
27
|
-
const
|
|
31
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
28
32
|
const data = [
|
|
29
33
|
{
|
|
30
34
|
label: 'Grover',
|
|
@@ -40,13 +44,13 @@ const ErnieVariable1 = {
|
|
|
40
44
|
data
|
|
41
45
|
}),
|
|
42
46
|
OptionsEditorComponent: function ErnieVariableEditor({ value , onChange }) {
|
|
43
|
-
return /*#__PURE__*/ (0,
|
|
47
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
44
48
|
children: [
|
|
45
|
-
/*#__PURE__*/ (0,
|
|
49
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("label", {
|
|
46
50
|
htmlFor: "editor-input",
|
|
47
51
|
children: "ErnieVariable editor"
|
|
48
52
|
}),
|
|
49
|
-
/*#__PURE__*/ (0,
|
|
53
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
50
54
|
type: "text",
|
|
51
55
|
id: "editor-input",
|
|
52
56
|
value: value.variableOption,
|
|
@@ -67,13 +71,13 @@ const ErnieVariable2 = {
|
|
|
67
71
|
data
|
|
68
72
|
}),
|
|
69
73
|
OptionsEditorComponent: function ErnieVariableEditor({ value , onChange }) {
|
|
70
|
-
return /*#__PURE__*/ (0,
|
|
74
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
|
|
71
75
|
children: [
|
|
72
|
-
/*#__PURE__*/ (0,
|
|
76
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("label", {
|
|
73
77
|
htmlFor: "editor-input",
|
|
74
78
|
children: "ErnieVariable2 editor"
|
|
75
79
|
}),
|
|
76
|
-
/*#__PURE__*/ (0,
|
|
80
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
|
|
77
81
|
type: "text",
|
|
78
82
|
id: "editor-input",
|
|
79
83
|
value: value.variableOption2,
|
|
@@ -16,12 +16,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "testPluginLoader", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return testPluginLoader;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
23
|
const _model = require("../../model");
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
function
|
|
24
|
+
const _pluginjson = /*#__PURE__*/ _interop_require_default(require("./bert/plugin.json"));
|
|
25
|
+
const _pluginjson1 = /*#__PURE__*/ _interop_require_default(require("./ernie/plugin.json"));
|
|
26
|
+
function _interop_require_default(obj) {
|
|
25
27
|
return obj && obj.__esModule ? obj : {
|
|
26
28
|
default: obj
|
|
27
29
|
};
|
|
@@ -34,7 +36,7 @@ function _getRequireWildcardCache(nodeInterop) {
|
|
|
34
36
|
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
35
37
|
})(nodeInterop);
|
|
36
38
|
}
|
|
37
|
-
function
|
|
39
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
38
40
|
if (!nodeInterop && obj && obj.__esModule) {
|
|
39
41
|
return obj;
|
|
40
42
|
}
|
|
@@ -67,11 +69,11 @@ function _interopRequireWildcard(obj, nodeInterop) {
|
|
|
67
69
|
}
|
|
68
70
|
const testPluginLoader = (0, _model.dynamicImportPluginLoader)([
|
|
69
71
|
{
|
|
70
|
-
resource:
|
|
71
|
-
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/
|
|
72
|
+
resource: _pluginjson.default,
|
|
73
|
+
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bert")))
|
|
72
74
|
},
|
|
73
75
|
{
|
|
74
|
-
resource:
|
|
75
|
-
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/
|
|
76
|
+
resource: _pluginjson1.default,
|
|
77
|
+
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./ernie")))
|
|
76
78
|
}
|
|
77
79
|
]);
|
|
@@ -14,15 +14,17 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
function
|
|
17
|
+
_export_star(require("./mock-plugin-registry"), exports);
|
|
18
|
+
function _export_star(from, to) {
|
|
19
19
|
Object.keys(from).forEach(function(k) {
|
|
20
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
21
|
+
Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
26
28
|
});
|
|
27
29
|
return from;
|
|
28
30
|
}
|
|
@@ -21,16 +21,20 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
mockPluginRegistry: ()
|
|
25
|
-
|
|
24
|
+
mockPluginRegistry: function() {
|
|
25
|
+
return mockPluginRegistry;
|
|
26
|
+
},
|
|
27
|
+
getMockPluginName: function() {
|
|
28
|
+
return getMockPluginName;
|
|
29
|
+
}
|
|
26
30
|
});
|
|
27
31
|
function mockPluginRegistry(...mockPlugins) {
|
|
28
32
|
const mockPluginResource = {
|
|
29
33
|
kind: 'PluginModule',
|
|
30
34
|
metadata: {
|
|
31
35
|
name: 'Fake Plugin Module for Tests',
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
createdAt: '',
|
|
37
|
+
updatedAt: '',
|
|
34
38
|
version: 0
|
|
35
39
|
},
|
|
36
40
|
spec: {
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
getTitleAction: function() {
|
|
25
|
+
return getTitleAction;
|
|
26
|
+
},
|
|
27
|
+
getSubmitText: function() {
|
|
28
|
+
return getSubmitText;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
function getTitleAction(action, isDraft) {
|
|
32
|
+
if (action === 'read') return 'View';
|
|
33
|
+
if (isDraft && action === 'create') return 'Add';
|
|
34
|
+
if (!isDraft && action === 'create') return 'Create';
|
|
35
|
+
if (action === 'update') return 'Edit';
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
function getSubmitText(action, isDraft) {
|
|
39
|
+
if (isDraft && action === 'create') return 'Add';
|
|
40
|
+
if (isDraft && action === 'update') return 'Apply';
|
|
41
|
+
if (!isDraft) return 'Save';
|
|
42
|
+
return '';
|
|
43
|
+
}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -14,15 +14,18 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
_export_star(require("./action"), exports);
|
|
18
|
+
_export_star(require("./variables"), exports);
|
|
19
|
+
function _export_star(from, to) {
|
|
19
20
|
Object.keys(from).forEach(function(k) {
|
|
20
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
22
|
+
Object.defineProperty(to, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function() {
|
|
25
|
+
return from[k];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
26
29
|
});
|
|
27
30
|
return from;
|
|
28
31
|
}
|
|
@@ -21,14 +21,23 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
replaceTemplateVariables: ()
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
replaceTemplateVariables: function() {
|
|
25
|
+
return replaceTemplateVariables;
|
|
26
|
+
},
|
|
27
|
+
replaceTemplateVariable: function() {
|
|
28
|
+
return replaceTemplateVariable;
|
|
29
|
+
},
|
|
30
|
+
parseTemplateVariables: function() {
|
|
31
|
+
return parseTemplateVariables;
|
|
32
|
+
}
|
|
27
33
|
});
|
|
28
34
|
function replaceTemplateVariables(text, variableState) {
|
|
29
35
|
const variables = parseTemplateVariables(text);
|
|
30
36
|
let finalText = text;
|
|
31
|
-
variables.
|
|
37
|
+
variables// Sorting variables by their length.
|
|
38
|
+
// In order to not have a variable name have contained in another variable name.
|
|
39
|
+
// i.e.: $__range replacing $__range_ms => '3600_ms' instead of '3600000'
|
|
40
|
+
.sort((a, b)=>b.length - a.length).forEach((v)=>{
|
|
32
41
|
const variable = variableState[v];
|
|
33
42
|
if (variable && (variable === null || variable === void 0 ? void 0 : variable.value)) {
|
|
34
43
|
finalText = replaceTemplateVariable(finalText, v, variable === null || variable === void 0 ? void 0 : variable.value);
|
|
@@ -38,6 +47,7 @@ function replaceTemplateVariables(text, variableState) {
|
|
|
38
47
|
}
|
|
39
48
|
function replaceTemplateVariable(text, varName, templateVariableValue) {
|
|
40
49
|
const variableTemplate = '$' + varName;
|
|
50
|
+
const bracketsVariableTemplate = '${' + varName + '}';
|
|
41
51
|
let replaceString = '';
|
|
42
52
|
if (Array.isArray(templateVariableValue)) {
|
|
43
53
|
replaceString = `(${templateVariableValue.join('|')})`; // regex style
|
|
@@ -45,12 +55,14 @@ function replaceTemplateVariable(text, varName, templateVariableValue) {
|
|
|
45
55
|
if (typeof templateVariableValue === 'string') {
|
|
46
56
|
replaceString = templateVariableValue;
|
|
47
57
|
}
|
|
48
|
-
|
|
58
|
+
text = text.replaceAll(variableTemplate, replaceString);
|
|
59
|
+
return text.replaceAll(bracketsVariableTemplate, replaceString);
|
|
49
60
|
}
|
|
50
61
|
// This regular expression is designed to identify variable references in a template string.
|
|
51
62
|
// It supports two formats for referencing variables:
|
|
52
63
|
// 1. $variableName - This is a simpler format, and the regular expression captures the variable name (\w+ matches one or more word characters).
|
|
53
|
-
// 2.
|
|
64
|
+
// 2. ${variableName} - This is a more complex format and the regular expression captures the variable name (\w+ matches one or more word characters) in the curly braces.
|
|
65
|
+
// 3. [COMING SOON] ${variableName:value} - This is a more complex format that allows specifying a format function as well.
|
|
54
66
|
// TODO: Fix this lint error
|
|
55
67
|
// eslint-disable-next-line no-useless-escape
|
|
56
68
|
const TEMPLATE_VARIABLE_REGEX = /\$(\w+)|\${(\w+)(?:\.([^:^\}]+))?(?::([^\}]+))?}/gm;
|
|
@@ -59,8 +71,14 @@ const parseTemplateVariables = (text)=>{
|
|
|
59
71
|
const matches = new Set();
|
|
60
72
|
let match;
|
|
61
73
|
while((match = regex.exec(text)) !== null){
|
|
62
|
-
if (match
|
|
63
|
-
|
|
74
|
+
if (match) {
|
|
75
|
+
if (match[1]) {
|
|
76
|
+
// \$(\w+)\
|
|
77
|
+
matches.add(match[1]);
|
|
78
|
+
} else if (match[2]) {
|
|
79
|
+
// \${(\w+)}\
|
|
80
|
+
matches.add(match[2]);
|
|
81
|
+
}
|
|
64
82
|
}
|
|
65
83
|
}
|
|
66
84
|
// return unique matches
|
|
@@ -0,0 +1,30 @@
|
|
|
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, "datasourceEditValidationSchema", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return datasourceEditValidationSchema;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _zod = require("zod");
|
|
24
|
+
const _resource = require("./resource");
|
|
25
|
+
const datasourceEditValidationSchema = _zod.z.object({
|
|
26
|
+
name: _resource.resourceIdValidationSchema,
|
|
27
|
+
title: _zod.z.string().optional(),
|
|
28
|
+
description: _zod.z.string().optional(),
|
|
29
|
+
default: _zod.z.boolean()
|
|
30
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
_export_star(require("./datasource"), exports);
|
|
18
|
+
_export_star(require("./resource"), exports);
|
|
19
|
+
_export_star(require("./variable"), exports);
|
|
20
|
+
function _export_star(from, to) {
|
|
21
|
+
Object.keys(from).forEach(function(k) {
|
|
22
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
23
|
+
Object.defineProperty(to, k, {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return from[k];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return from;
|
|
32
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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, "resourceIdValidationSchema", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return resourceIdValidationSchema;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _zod = require("zod");
|
|
24
|
+
const resourceIdValidationSchema = _zod.z.string().nonempty('Required').max(75, 'Must be 75 or fewer characters long').regex(/^[a-zA-Z0-9_.-]+$/, 'Must only contains alphanumerical characters and special characters _ . -');
|
|
@@ -0,0 +1,29 @@
|
|
|
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, "variableEditValidationSchema", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return variableEditValidationSchema;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _zod = require("zod");
|
|
24
|
+
const variableEditValidationSchema = _zod.z.object({
|
|
25
|
+
name: _zod.z.string().nonempty('Required').regex(/^\w+$/, 'Must only contains alphanumerical characters and underscores').refine((val)=>!val.startsWith('__'), '__ prefix is reserved to builtin variables'),
|
|
26
|
+
title: _zod.z.string().optional(),
|
|
27
|
+
description: _zod.z.string().optional(),
|
|
28
|
+
kind: _zod.z.string().nonempty('Required')
|
|
29
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { OptionsEditorControl, SettingsAutocomplete } from '@perses-dev/components';\nimport { CALCULATIONS_CONFIG, CalculationConfig, CalculationType } from '@perses-dev/core';\n\ntype AutocompleteCalculationOption = CalculationConfig & { id: CalculationType };\nconst CALC_OPTIONS: AutocompleteCalculationOption[] = Object.entries(CALCULATIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as CalculationType,\n ...config,\n };\n});\n\nexport interface CalculationSelectorProps {\n value: CalculationType;\n onChange: (unit: CalculationType) => void;\n}\n\nexport function CalculationSelector({ value, onChange }: CalculationSelectorProps) {\n const handleCalculationChange = (_: unknown, newValue: AutocompleteCalculationOption) => {\n onChange(newValue.id);\n };\n\n const calcConfig = CALCULATIONS_CONFIG[value];\n\n return (\n <OptionsEditorControl\n label=\"Calculation\"\n control={\n <SettingsAutocomplete\n value={{\n ...calcConfig,\n id: value,\n }}\n options={CALC_OPTIONS}\n onChange={handleCalculationChange}\n disableClearable\n ></SettingsAutocomplete>\n }\n />\n );\n}\n"],"names":["OptionsEditorControl","SettingsAutocomplete","CALCULATIONS_CONFIG","CALC_OPTIONS","Object","entries","map","id","config","CalculationSelector","value","onChange","handleCalculationChange","_","newValue","calcConfig","label","control","options","disableClearable"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC
|
|
1
|
+
{"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { OptionsEditorControl, SettingsAutocomplete } from '@perses-dev/components';\nimport { CALCULATIONS_CONFIG, CalculationConfig, CalculationType } from '@perses-dev/core';\n\ntype AutocompleteCalculationOption = CalculationConfig & { id: CalculationType };\nconst CALC_OPTIONS: AutocompleteCalculationOption[] = Object.entries(CALCULATIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as CalculationType,\n ...config,\n };\n});\n\nexport interface CalculationSelectorProps {\n value: CalculationType;\n onChange: (unit: CalculationType) => void;\n}\n\nexport function CalculationSelector({ value, onChange }: CalculationSelectorProps) {\n const handleCalculationChange = (_: unknown, newValue: AutocompleteCalculationOption) => {\n onChange(newValue.id);\n };\n\n const calcConfig = CALCULATIONS_CONFIG[value];\n\n return (\n <OptionsEditorControl\n label=\"Calculation\"\n control={\n <SettingsAutocomplete\n value={{\n ...calcConfig,\n id: value,\n }}\n options={CALC_OPTIONS}\n onChange={handleCalculationChange}\n disableClearable\n ></SettingsAutocomplete>\n }\n />\n );\n}\n"],"names":["OptionsEditorControl","SettingsAutocomplete","CALCULATIONS_CONFIG","CALC_OPTIONS","Object","entries","map","id","config","CalculationSelector","value","onChange","handleCalculationChange","_","newValue","calcConfig","label","control","options","disableClearable"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,oBAAoB,EAAEC,oBAAoB,QAAQ,yBAAyB;AACpF,SAASC,mBAAmB,QAA4C,mBAAmB;AAG3F,MAAMC,eAAgDC,OAAOC,QAAQH,qBAAqBI,IAAI,CAAC,CAACC,IAAIC,OAAO;IACzG,OAAO;QACLD,IAAIA;QACJ,GAAGC,MAAM;IACX;AACF;AAOA,OAAO,SAASC,oBAAoB,EAAEC,MAAK,EAAEC,SAAQ,EAA4B;IAC/E,MAAMC,0BAA0B,CAACC,GAAYC;QAC3CH,SAASG,SAASP;IACpB;IAEA,MAAMQ,aAAab,mBAAmB,CAACQ,MAAM;IAE7C,qBACE,KAACV;QACCgB,OAAM;QACNC,uBACE,KAAChB;YACCS,OAAO;gBACL,GAAGK,UAAU;gBACbR,IAAIG;YACN;YACAQ,SAASf;YACTQ,UAAUC;YACVO,gBAAgB;;;AAK1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/CalculationSelector/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './CalculationSelector';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,
|
|
1
|
+
{"version":3,"sources":["../../../src/components/CalculationSelector/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './CalculationSelector';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,wBAAwB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Datasource } from '@perses-dev/core';
|
|
2
|
+
import { Dispatch, DispatchWithoutAction } from 'react';
|
|
3
|
+
import { Action } from '../../utils';
|
|
4
|
+
interface DatasourceEditorFormProps<T extends Datasource> {
|
|
5
|
+
initialDatasource: T;
|
|
6
|
+
initialAction: Action;
|
|
7
|
+
isDraft: boolean;
|
|
8
|
+
isReadonly?: boolean;
|
|
9
|
+
onSave: Dispatch<T>;
|
|
10
|
+
onClose: DispatchWithoutAction;
|
|
11
|
+
onDelete?: DispatchWithoutAction;
|
|
12
|
+
}
|
|
13
|
+
export declare function DatasourceEditorForm<T extends Datasource>(props: DatasourceEditorFormProps<T>): JSX.Element;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=DatasourceEditorForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatasourceEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/DatasourceEditorForm/DatasourceEditorForm.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAW,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAc,EAAE,QAAQ,EAAE,qBAAqB,EAAyB,MAAM,OAAO,CAAC;AAKtF,OAAO,EAAE,MAAM,EAAiC,MAAM,aAAa,CAAC;AAsBpE,UAAU,yBAAyB,CAAC,CAAC,SAAS,UAAU;IACtD,iBAAiB,EAAE,CAAC,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IACpB,OAAO,EAAE,qBAAqB,CAAC;IAC/B,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,UAAU,EAAE,KAAK,EAAE,yBAAyB,CAAC,CAAC,CAAC,eAiO7F"}
|