@perses-dev/plugin-system 0.0.0-snapshot-color-palette-gen-test-0ebddd6 → 0.0.0-snapshot-tooltip-highlight-c995fc8
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/PanelSpecEditor/PanelSpecEditor.js +75 -0
- package/dist/cjs/components/PanelSpecEditor/index.js +28 -0
- package/dist/cjs/components/PluginEditor/PluginEditor.js +2 -2
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +27 -6
- package/dist/cjs/components/{PluginKindSelect.js → PluginKindSelect/PluginKindSelect.js} +1 -1
- package/dist/cjs/components/PluginKindSelect/index.js +28 -0
- package/dist/cjs/components/{PluginSpecEditor.js → PluginSpecEditor/PluginSpecEditor.js} +2 -30
- package/dist/cjs/components/PluginSpecEditor/index.js +28 -0
- package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +142 -0
- package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +94 -0
- package/dist/cjs/components/TimeSeriesQueryEditor/index.js +28 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +88 -0
- package/dist/cjs/runtime/DataQueriesProvider/index.js +29 -0
- package/dist/cjs/runtime/DataQueriesProvider/model.js +16 -0
- package/dist/cjs/runtime/index.js +1 -0
- package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +39 -0
- package/dist/cjs/stories/shared-utils/decorators/WithDatasourceStore.js +83 -0
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +94 -0
- package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +38 -0
- package/dist/cjs/stories/shared-utils/decorators/index.js +31 -0
- package/dist/cjs/stories/shared-utils/index.js +28 -0
- package/dist/cjs/test/render.js +4 -1
- package/dist/cjs/test/test-plugins/bert/index.js +27 -20
- package/dist/cjs/test/test-plugins/ernie/index.js +37 -4
- package/dist/cjs/test-utils/mock-plugin-registry.js +4 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +10 -0
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -0
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +69 -0
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -0
- package/dist/components/PanelSpecEditor/index.d.ts +2 -0
- package/dist/components/PanelSpecEditor/index.d.ts.map +1 -0
- package/dist/components/PanelSpecEditor/index.js +15 -0
- package/dist/components/PanelSpecEditor/index.js.map +1 -0
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +2 -2
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +4 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +27 -6
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/{PluginKindSelect.d.ts → PluginKindSelect/PluginKindSelect.d.ts} +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -0
- package/dist/components/{PluginKindSelect.js → PluginKindSelect/PluginKindSelect.js} +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -0
- package/dist/components/PluginKindSelect/index.d.ts +2 -0
- package/dist/components/PluginKindSelect/index.d.ts.map +1 -0
- package/dist/components/PluginKindSelect/index.js +15 -0
- package/dist/components/PluginKindSelect/index.js.map +1 -0
- package/dist/components/PluginRegistry/PluginRegistry.d.ts +2 -2
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/{PluginSpecEditor.d.ts → PluginSpecEditor/PluginSpecEditor.d.ts} +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -0
- package/dist/components/{PluginSpecEditor.js → PluginSpecEditor/PluginSpecEditor.js} +3 -31
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -0
- package/dist/components/PluginSpecEditor/index.d.ts +2 -0
- package/dist/components/PluginSpecEditor/index.d.ts.map +1 -0
- package/dist/components/PluginSpecEditor/index.js +15 -0
- package/dist/components/PluginSpecEditor/index.js.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +8 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +131 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +13 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +83 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/index.d.ts +2 -0
- package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/index.js +15 -0
- package/dist/components/TimeSeriesQueryEditor/index.js.map +1 -0
- 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/model/panels.d.ts +6 -5
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.d.ts +7 -0
- package/dist/model/plugin-base.d.ts.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugins.d.ts +3 -1
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +8 -0
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -0
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +74 -0
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -0
- package/dist/runtime/DataQueriesProvider/index.d.ts +3 -0
- package/dist/runtime/DataQueriesProvider/index.d.ts.map +1 -0
- package/dist/runtime/DataQueriesProvider/index.js +16 -0
- package/dist/runtime/DataQueriesProvider/index.js.map +1 -0
- package/dist/runtime/DataQueriesProvider/model.d.ts +27 -0
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -0
- package/dist/runtime/DataQueriesProvider/model.js +15 -0
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -0
- 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 +1 -1
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +8 -0
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/WithDataQueries.js +33 -0
- package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithDatasourceStore.d.ts +8 -0
- package/dist/stories/shared-utils/decorators/WithDatasourceStore.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/WithDatasourceStore.js +77 -0
- package/dist/stories/shared-utils/decorators/WithDatasourceStore.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +4 -0
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +49 -0
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +8 -0
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/WithTimeRange.js +32 -0
- package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -0
- package/dist/stories/shared-utils/decorators/index.d.ts +5 -0
- package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/index.js +18 -0
- package/dist/stories/shared-utils/decorators/index.js.map +1 -0
- package/dist/stories/shared-utils/index.d.ts +2 -0
- package/dist/stories/shared-utils/index.d.ts.map +1 -0
- package/dist/stories/shared-utils/index.js +15 -0
- package/dist/stories/shared-utils/index.js.map +1 -0
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +4 -1
- package/dist/test/render.js.map +1 -1
- package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
- package/dist/test/test-plugins/bert/index.js +27 -20
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.d.ts +4 -1
- package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +28 -1
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +4 -1
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/package.json +6 -3
- package/dist/cjs/components/TimeSeriesQueryEditor.js +0 -42
- package/dist/components/PluginKindSelect.d.ts.map +0 -1
- package/dist/components/PluginKindSelect.js.map +0 -1
- package/dist/components/PluginSpecEditor.d.ts.map +0 -1
- package/dist/components/PluginSpecEditor.js.map +0 -1
- package/dist/components/TimeSeriesQueryEditor.d.ts +0 -14
- package/dist/components/TimeSeriesQueryEditor.d.ts.map +0 -1
- package/dist/components/TimeSeriesQueryEditor.js +0 -38
- package/dist/components/TimeSeriesQueryEditor.js.map +0 -1
|
@@ -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
|
+
_exportStar(require("./DataQueriesProvider"), exports);
|
|
18
|
+
_exportStar(require("./model"), exports);
|
|
19
|
+
function _exportStar(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return from;
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
});
|
|
@@ -19,6 +19,7 @@ _exportStar(require("./plugin-registry"), exports);
|
|
|
19
19
|
_exportStar(require("./template-variables"), exports);
|
|
20
20
|
_exportStar(require("./TimeRangeProvider"), exports);
|
|
21
21
|
_exportStar(require("./time-series-queries"), exports);
|
|
22
|
+
_exportStar(require("./DataQueriesProvider"), exports);
|
|
22
23
|
function _exportStar(from, to) {
|
|
23
24
|
Object.keys(from).forEach(function(k) {
|
|
24
25
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
@@ -0,0 +1,39 @@
|
|
|
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, "WithDataQueries", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>WithDataQueries
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
23
|
+
// Type guard because storybook types parameters as `any`
|
|
24
|
+
function isWithDataQueriesParameter(parameter) {
|
|
25
|
+
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
26
|
+
}
|
|
27
|
+
const WithDataQueries = (Story, context)=>{
|
|
28
|
+
const initParameter = context.parameters.WithDataQueries;
|
|
29
|
+
const parameter = isWithDataQueriesParameter(initParameter) ? initParameter : {
|
|
30
|
+
props: {
|
|
31
|
+
definitions: []
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
35
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DataQueriesProvider, {
|
|
36
|
+
...props,
|
|
37
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
|
|
38
|
+
});
|
|
39
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
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, "WithDatasourceStore", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>WithDatasourceStore
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
23
|
+
const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
|
|
24
|
+
// Type guard because storybook types parameters as `any`
|
|
25
|
+
function isWithDatastoreStoreParameter(parameter) {
|
|
26
|
+
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
27
|
+
}
|
|
28
|
+
const WithDatasourceStore = (Story, context)=>{
|
|
29
|
+
const { getPlugin } = (0, _pluginSystem.usePluginRegistry)();
|
|
30
|
+
const initParameter = context.parameters.WithDataQueries;
|
|
31
|
+
// This currently provides a very simplified default to enable use in some
|
|
32
|
+
// basic stories. It likely will need expanding in the future.
|
|
33
|
+
// In general, `plugin-system` would probably benefit from a provider wrapper
|
|
34
|
+
// for `DatasourceStoreContext` that is more generic than the one available
|
|
35
|
+
// in in the `dashboard` package for non-dashboard use cases.
|
|
36
|
+
const defaultValue = {
|
|
37
|
+
getDatasource: (selector)=>{
|
|
38
|
+
if (selector.kind === 'PrometheusDatasource') {
|
|
39
|
+
return Promise.resolve({
|
|
40
|
+
default: true,
|
|
41
|
+
plugin: {
|
|
42
|
+
kind: 'PrometheusDatasource',
|
|
43
|
+
spec: {}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
|
|
48
|
+
},
|
|
49
|
+
getDatasourceClient: async (selector)=>{
|
|
50
|
+
if (selector.kind === 'PrometheusDatasource') {
|
|
51
|
+
const plugin = await getPlugin('Datasource', 'PrometheusDatasource');
|
|
52
|
+
const client = plugin.createClient({
|
|
53
|
+
direct_url: prometheusDemoUrl
|
|
54
|
+
}, {
|
|
55
|
+
proxyUrl: prometheusDemoUrl
|
|
56
|
+
});
|
|
57
|
+
return client;
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
|
|
60
|
+
},
|
|
61
|
+
listDatasourceMetadata: async (datasourcePluginKind)=>{
|
|
62
|
+
if (datasourcePluginKind === 'PrometheusDatasource') {
|
|
63
|
+
return Promise.resolve([
|
|
64
|
+
{
|
|
65
|
+
name: 'PrometheusDatasource',
|
|
66
|
+
selector: {
|
|
67
|
+
kind: 'PrometheusDatasource'
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginKind}`);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : {
|
|
76
|
+
props: defaultValue
|
|
77
|
+
};
|
|
78
|
+
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
79
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceStoreContext.Provider, {
|
|
80
|
+
value: props,
|
|
81
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
|
|
82
|
+
});
|
|
83
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
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, "WithPluginRegistry", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>WithPluginRegistry
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
23
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
24
|
+
if (typeof WeakMap !== "function") return null;
|
|
25
|
+
var cacheBabelInterop = new WeakMap();
|
|
26
|
+
var cacheNodeInterop = new WeakMap();
|
|
27
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
28
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
29
|
+
})(nodeInterop);
|
|
30
|
+
}
|
|
31
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
32
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
33
|
+
return obj;
|
|
34
|
+
}
|
|
35
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
36
|
+
return {
|
|
37
|
+
default: obj
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
41
|
+
if (cache && cache.has(obj)) {
|
|
42
|
+
return cache.get(obj);
|
|
43
|
+
}
|
|
44
|
+
var newObj = {};
|
|
45
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
46
|
+
for(var key in obj){
|
|
47
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
48
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
49
|
+
if (desc && (desc.get || desc.set)) {
|
|
50
|
+
Object.defineProperty(newObj, key, desc);
|
|
51
|
+
} else {
|
|
52
|
+
newObj[key] = obj[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
newObj.default = obj;
|
|
57
|
+
if (cache) {
|
|
58
|
+
cache.set(obj, newObj);
|
|
59
|
+
}
|
|
60
|
+
return newObj;
|
|
61
|
+
}
|
|
62
|
+
// NOTE: the aliases we use for components break these top level imports, so we
|
|
63
|
+
// import relatively.
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
65
|
+
const prometheusResource = require('../../../../../prometheus-plugin/plugin.json');
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
67
|
+
const panelsResource = require('../../../../../panels-plugin/plugin.json');
|
|
68
|
+
const bundledPluginLoader = (0, _pluginSystem.dynamicImportPluginLoader)([
|
|
69
|
+
{
|
|
70
|
+
resource: prometheusResource,
|
|
71
|
+
// This throws an error in CI (but not locally for some reason), likely because
|
|
72
|
+
// this package isn't a dependency for dashboards. We probably do not want to
|
|
73
|
+
// make it one solely for type-checking in storybook.
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("@perses-dev/prometheus-plugin")))
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
resource: panelsResource,
|
|
80
|
+
// Same comment as above.
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("@perses-dev/panels-plugin")))
|
|
84
|
+
}
|
|
85
|
+
]);
|
|
86
|
+
const WithPluginRegistry = (Story)=>{
|
|
87
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
|
|
88
|
+
pluginLoader: bundledPluginLoader,
|
|
89
|
+
defaultPluginKinds: {
|
|
90
|
+
TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
|
|
91
|
+
},
|
|
92
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
|
|
93
|
+
});
|
|
94
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
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, "WithTimeRange", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>WithTimeRange
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
23
|
+
// Type guard because storybook types parameters as `any`
|
|
24
|
+
function isWithTimeRangeParameter(parameter) {
|
|
25
|
+
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
26
|
+
}
|
|
27
|
+
const WithTimeRange = (Story, context)=>{
|
|
28
|
+
const initParameter = context.parameters.withTimeRange;
|
|
29
|
+
const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;
|
|
30
|
+
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
31
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TimeRangeProvider, {
|
|
32
|
+
initialTimeRange: {
|
|
33
|
+
pastDuration: '1h'
|
|
34
|
+
},
|
|
35
|
+
...props,
|
|
36
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
|
|
37
|
+
});
|
|
38
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
_exportStar(require("./WithDataQueries"), exports);
|
|
18
|
+
_exportStar(require("./WithDatasourceStore"), exports);
|
|
19
|
+
_exportStar(require("./WithPluginRegistry"), exports);
|
|
20
|
+
_exportStar(require("./WithTimeRange"), exports);
|
|
21
|
+
function _exportStar(from, to) {
|
|
22
|
+
Object.keys(from).forEach(function(k) {
|
|
23
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return from[k];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
return from;
|
|
31
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
_exportStar(require("./decorators"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
package/dist/cjs/test/render.js
CHANGED
|
@@ -41,11 +41,14 @@ function renderWithContext(ui, renderOptions, contextOptions) {
|
|
|
41
41
|
},
|
|
42
42
|
logger: testLogger
|
|
43
43
|
});
|
|
44
|
+
var ref;
|
|
44
45
|
return (0, _react.render)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_reactQuery.QueryClientProvider, {
|
|
45
46
|
client: queryClient,
|
|
46
47
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginRegistry.PluginRegistry, {
|
|
47
48
|
pluginLoader: _testPlugins.testPluginLoader,
|
|
48
|
-
defaultPluginKinds: contextOptions === null || contextOptions === void 0 ? void 0 : contextOptions.defaultPluginKinds
|
|
49
|
+
defaultPluginKinds: (ref = contextOptions === null || contextOptions === void 0 ? void 0 : contextOptions.defaultPluginKinds) !== null && ref !== void 0 ? ref : {
|
|
50
|
+
TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
|
|
51
|
+
},
|
|
49
52
|
children: ui
|
|
50
53
|
})
|
|
51
54
|
}), renderOptions);
|
|
@@ -25,27 +25,33 @@ _export(exports, {
|
|
|
25
25
|
BertPanel2: ()=>BertPanel2
|
|
26
26
|
});
|
|
27
27
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
28
|
+
function BertPanel1Editor({ value , onChange }) {
|
|
29
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
30
|
+
children: [
|
|
31
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("label", {
|
|
32
|
+
htmlFor: "editor-input",
|
|
33
|
+
children: "BertPanel1 editor"
|
|
34
|
+
}),
|
|
35
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("input", {
|
|
36
|
+
type: "text",
|
|
37
|
+
id: "editor-input",
|
|
38
|
+
value: value.option1,
|
|
39
|
+
onChange: (e)=>onChange({
|
|
40
|
+
...value,
|
|
41
|
+
option1: e.target.value
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
28
47
|
const BertPanel1 = {
|
|
29
48
|
PanelComponent: ()=>null,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}),
|
|
37
|
-
/*#__PURE__*/ (0, _jsxRuntime.jsx)("input", {
|
|
38
|
-
type: "text",
|
|
39
|
-
id: "editor-input",
|
|
40
|
-
value: value.option1,
|
|
41
|
-
onChange: (e)=>onChange({
|
|
42
|
-
...value,
|
|
43
|
-
option1: e.target.value
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
]
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
+
panelOptionsEditorComponents: [
|
|
50
|
+
{
|
|
51
|
+
label: 'Editor',
|
|
52
|
+
content: BertPanel1Editor
|
|
53
|
+
}
|
|
54
|
+
],
|
|
49
55
|
createInitialOptions: ()=>({
|
|
50
56
|
option1: ''
|
|
51
57
|
})
|
|
@@ -86,5 +92,6 @@ const BertPanel2 = {
|
|
|
86
92
|
],
|
|
87
93
|
createInitialOptions: ()=>({
|
|
88
94
|
option2: ''
|
|
89
|
-
})
|
|
95
|
+
}),
|
|
96
|
+
hideQueryEditor: true
|
|
90
97
|
};
|
|
@@ -14,9 +14,15 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
ErnieVariable1: ()=>ErnieVariable1,
|
|
25
|
+
ErnieVariable2: ()=>ErnieVariable2
|
|
20
26
|
});
|
|
21
27
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
28
|
const data = [
|
|
@@ -29,7 +35,7 @@ const data = [
|
|
|
29
35
|
value: 'Snuffleupagus'
|
|
30
36
|
}
|
|
31
37
|
];
|
|
32
|
-
const
|
|
38
|
+
const ErnieVariable1 = {
|
|
33
39
|
getVariableOptions: async ()=>({
|
|
34
40
|
data
|
|
35
41
|
}),
|
|
@@ -56,3 +62,30 @@ const ErnieVariable = {
|
|
|
56
62
|
variableOption: ''
|
|
57
63
|
})
|
|
58
64
|
};
|
|
65
|
+
const ErnieVariable2 = {
|
|
66
|
+
getVariableOptions: async ()=>({
|
|
67
|
+
data
|
|
68
|
+
}),
|
|
69
|
+
OptionsEditorComponent: function ErnieVariableEditor({ value , onChange }) {
|
|
70
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
|
|
71
|
+
children: [
|
|
72
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("label", {
|
|
73
|
+
htmlFor: "editor-input",
|
|
74
|
+
children: "ErnieVariable2 editor"
|
|
75
|
+
}),
|
|
76
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("input", {
|
|
77
|
+
type: "text",
|
|
78
|
+
id: "editor-input",
|
|
79
|
+
value: value.variableOption2,
|
|
80
|
+
onChange: (e)=>onChange({
|
|
81
|
+
...value,
|
|
82
|
+
variableOption2: e.target.value
|
|
83
|
+
})
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
createInitialOptions: ()=>({
|
|
89
|
+
variableOption2: ''
|
|
90
|
+
})
|
|
91
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PanelDefinition, QueryDefinition, UnknownSpec } from '@perses-dev/core';
|
|
3
|
+
export interface PanelSpecEditorProps {
|
|
4
|
+
panelDefinition: PanelDefinition;
|
|
5
|
+
onQueriesChange: (queries: QueryDefinition[]) => void;
|
|
6
|
+
onPluginSpecChange: (spec: UnknownSpec) => void;
|
|
7
|
+
onJSONChange: (panelDefinition: PanelDefinition) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function PanelSpecEditor(props: PanelSpecEditorProps): JSX.Element | null;
|
|
10
|
+
//# sourceMappingURL=PanelSpecEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PanelSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAMjF,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IACtD,kBAAkB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAChD,YAAY,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,IAAI,CAAC;CAC1D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,sBA0C1D"}
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { ErrorAlert, JSONEditor } from '@perses-dev/components';
|
|
15
|
+
import { usePlugin } from '../../runtime';
|
|
16
|
+
import { OptionsEditorTabs } from '../OptionsEditorTabs';
|
|
17
|
+
import { TimeSeriesQueryEditor } from '../TimeSeriesQueryEditor';
|
|
18
|
+
export function PanelSpecEditor(props) {
|
|
19
|
+
const { panelDefinition , onJSONChange , onQueriesChange , onPluginSpecChange } = props;
|
|
20
|
+
const { kind } = panelDefinition.spec.plugin;
|
|
21
|
+
const { data: plugin , isLoading , error } = usePlugin('Panel', kind);
|
|
22
|
+
if (error) {
|
|
23
|
+
return /*#__PURE__*/ _jsx(ErrorAlert, {
|
|
24
|
+
error: error
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
// TODO: Proper loading indicator
|
|
28
|
+
if (isLoading) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
if (plugin === undefined) {
|
|
32
|
+
throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);
|
|
33
|
+
}
|
|
34
|
+
const { panelOptionsEditorComponents , hideQueryEditor } = plugin;
|
|
35
|
+
let tabs = [];
|
|
36
|
+
if (!hideQueryEditor) {
|
|
37
|
+
var _queries;
|
|
38
|
+
// Since we only support TimeSeriesQuery for now, we will always show a TimeSeriesQueryEditor
|
|
39
|
+
tabs.push({
|
|
40
|
+
label: 'Query',
|
|
41
|
+
content: /*#__PURE__*/ _jsx(TimeSeriesQueryEditor, {
|
|
42
|
+
queries: (_queries = panelDefinition.spec.queries) !== null && _queries !== void 0 ? _queries : [],
|
|
43
|
+
onChange: onQueriesChange
|
|
44
|
+
})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (panelOptionsEditorComponents !== undefined) {
|
|
48
|
+
tabs = tabs.concat(panelOptionsEditorComponents.map(({ label , content: OptionsEditorComponent })=>({
|
|
49
|
+
label,
|
|
50
|
+
content: /*#__PURE__*/ _jsx(OptionsEditorComponent, {
|
|
51
|
+
value: panelDefinition.spec.plugin.spec,
|
|
52
|
+
onChange: onPluginSpecChange
|
|
53
|
+
})
|
|
54
|
+
})));
|
|
55
|
+
}
|
|
56
|
+
// always show json editor by default
|
|
57
|
+
tabs.push({
|
|
58
|
+
label: 'JSON',
|
|
59
|
+
content: /*#__PURE__*/ _jsx(JSONEditor, {
|
|
60
|
+
value: panelDefinition,
|
|
61
|
+
onChange: onJSONChange
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
return /*#__PURE__*/ _jsx(OptionsEditorTabs, {
|
|
65
|
+
tabs: tabs
|
|
66
|
+
}, tabs.length);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=PanelSpecEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.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 { ErrorAlert, JSONEditor } from '@perses-dev/components';\nimport { PanelDefinition, QueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { usePlugin } from '../../runtime';\nimport { PanelPlugin } from '../../model';\nimport { OptionsEditorTabsProps, OptionsEditorTabs } from '../OptionsEditorTabs';\nimport { TimeSeriesQueryEditor } from '../TimeSeriesQueryEditor';\n\nexport interface PanelSpecEditorProps {\n panelDefinition: PanelDefinition;\n onQueriesChange: (queries: QueryDefinition[]) => void;\n onPluginSpecChange: (spec: UnknownSpec) => void;\n onJSONChange: (panelDefinition: PanelDefinition) => void;\n}\n\nexport function PanelSpecEditor(props: PanelSpecEditorProps) {\n const { panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;\n const { kind } = panelDefinition.spec.plugin;\n const { data: plugin, isLoading, error } = usePlugin('Panel', kind);\n\n if (error) {\n return <ErrorAlert error={error} />;\n }\n\n // TODO: Proper loading indicator\n if (isLoading) {\n return null;\n }\n\n if (plugin === undefined) {\n throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);\n }\n\n const { panelOptionsEditorComponents, hideQueryEditor } = plugin as PanelPlugin;\n let tabs: OptionsEditorTabsProps['tabs'] = [];\n\n if (!hideQueryEditor) {\n // Since we only support TimeSeriesQuery for now, we will always show a TimeSeriesQueryEditor\n tabs.push({\n label: 'Query',\n content: <TimeSeriesQueryEditor queries={panelDefinition.spec.queries ?? []} onChange={onQueriesChange} />,\n });\n }\n\n if (panelOptionsEditorComponents !== undefined) {\n tabs = tabs.concat(\n panelOptionsEditorComponents.map(({ label, content: OptionsEditorComponent }) => ({\n label,\n content: <OptionsEditorComponent value={panelDefinition.spec.plugin.spec} onChange={onPluginSpecChange} />,\n }))\n );\n }\n\n // always show json editor by default\n tabs.push({ label: 'JSON', content: <JSONEditor value={panelDefinition} onChange={onJSONChange} /> });\n\n return <OptionsEditorTabs key={tabs.length} tabs={tabs} />;\n}\n"],"names":["ErrorAlert","JSONEditor","usePlugin","OptionsEditorTabs","TimeSeriesQueryEditor","PanelSpecEditor","props","panelDefinition","onJSONChange","onQueriesChange","onPluginSpecChange","kind","spec","plugin","data","isLoading","error","undefined","Error","panelOptionsEditorComponents","hideQueryEditor","tabs","push","label","content","queries","onChange","concat","map","OptionsEditorComponent","value","length"],"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;AAAA,SAASA,UAAU,EAAEC,UAAU,QAAQ,wBAAwB,CAAC;AAEhE,SAASC,SAAS,QAAQ,eAAe,CAAC;AAE1C,SAAiCC,iBAAiB,QAAQ,sBAAsB,CAAC;AACjF,SAASC,qBAAqB,QAAQ,0BAA0B,CAAC;AASjE,OAAO,SAASC,eAAe,CAACC,KAA2B,EAAE;IAC3D,MAAM,EAAEC,eAAe,CAAA,EAAEC,YAAY,CAAA,EAAEC,eAAe,CAAA,EAAEC,kBAAkB,CAAA,EAAE,GAAGJ,KAAK,AAAC;IACrF,MAAM,EAAEK,IAAI,CAAA,EAAE,GAAGJ,eAAe,CAACK,IAAI,CAACC,MAAM,AAAC;IAC7C,MAAM,EAAEC,IAAI,EAAED,MAAM,CAAA,EAAEE,SAAS,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGd,SAAS,CAAC,OAAO,EAAES,IAAI,CAAC,AAAC;IAEpE,IAAIK,KAAK,EAAE;QACT,qBAAO,KAAChB,UAAU;YAACgB,KAAK,EAAEA,KAAK;UAAI,CAAC;IACtC,CAAC;IAED,iCAAiC;IACjC,IAAID,SAAS,EAAE;QACb,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAIF,MAAM,KAAKI,SAAS,EAAE;QACxB,MAAM,IAAIC,KAAK,CAAC,CAAC,mDAAmD,EAAEP,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC;IAED,MAAM,EAAEQ,4BAA4B,CAAA,EAAEC,eAAe,CAAA,EAAE,GAAGP,MAAM,AAAe,AAAC;IAChF,IAAIQ,IAAI,GAAmC,EAAE,AAAC;IAE9C,IAAI,CAACD,eAAe,EAAE;YAIuBb,QAA4B;QAHvE,6FAA6F;QAC7Fc,IAAI,CAACC,IAAI,CAAC;YACRC,KAAK,EAAE,OAAO;YACdC,OAAO,gBAAE,KAACpB,qBAAqB;gBAACqB,OAAO,EAAElB,CAAAA,QAA4B,GAA5BA,eAAe,CAACK,IAAI,CAACa,OAAO,cAA5BlB,QAA4B,cAA5BA,QAA4B,GAAI,EAAE;gBAAEmB,QAAQ,EAAEjB,eAAe;cAAI;SAC3G,CAAC,CAAC;IACL,CAAC;IAED,IAAIU,4BAA4B,KAAKF,SAAS,EAAE;QAC9CI,IAAI,GAAGA,IAAI,CAACM,MAAM,CAChBR,4BAA4B,CAACS,GAAG,CAAC,CAAC,EAAEL,KAAK,CAAA,EAAEC,OAAO,EAAEK,sBAAsB,CAAA,EAAE,GAAM,CAAA;gBAChFN,KAAK;gBACLC,OAAO,gBAAE,KAACK,sBAAsB;oBAACC,KAAK,EAAEvB,eAAe,CAACK,IAAI,CAACC,MAAM,CAACD,IAAI;oBAAEc,QAAQ,EAAEhB,kBAAkB;kBAAI;aAC3G,CAAA,AAAC,CAAC,CACJ,CAAC;IACJ,CAAC;IAED,qCAAqC;IACrCW,IAAI,CAACC,IAAI,CAAC;QAAEC,KAAK,EAAE,MAAM;QAAEC,OAAO,gBAAE,KAACvB,UAAU;YAAC6B,KAAK,EAAEvB,eAAe;YAAEmB,QAAQ,EAAElB,YAAY;UAAI;KAAE,CAAC,CAAC;IAEtG,qBAAO,KAACL,iBAAiB;QAAmBkB,IAAI,EAAEA,IAAI;OAAvBA,IAAI,CAACU,MAAM,CAAgB,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PanelSpecEditor/index.tsx"],"names":[],"mappings":"AAaA,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
export * from './PanelSpecEditor';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelSpecEditor/index.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\nexport * from './PanelSpecEditor';\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,mBAAmB,CAAC"}
|