@perses-dev/plugin-system 0.29.1 → 0.31.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/PluginEditor/PluginEditor.js +2 -2
- package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +39 -0
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +95 -0
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +83 -0
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js +40 -0
- package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +38 -0
- package/dist/cjs/stories/shared-utils/decorators/index.js +32 -0
- package/dist/cjs/stories/shared-utils/index.js +28 -0
- package/dist/components/PluginEditor/PluginEditor.js +2 -2
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +13 -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/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 +45 -0
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +13 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +79 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +13 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js +39 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +13 -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 +6 -0
- package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/index.js +19 -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/package.json +6 -3
|
@@ -20,8 +20,8 @@ Object.defineProperty(exports, "PluginEditor", {
|
|
|
20
20
|
});
|
|
21
21
|
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
const _material = require("@mui/material");
|
|
23
|
-
const _pluginKindSelect = require("../PluginKindSelect
|
|
24
|
-
const _pluginSpecEditor = require("../PluginSpecEditor
|
|
23
|
+
const _pluginKindSelect = require("../PluginKindSelect");
|
|
24
|
+
const _pluginSpecEditor = require("../PluginSpecEditor");
|
|
25
25
|
const _pluginEditorApi = require("./plugin-editor-api");
|
|
26
26
|
function PluginEditor(props) {
|
|
27
27
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -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,95 @@
|
|
|
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
|
+
const _pluginJson = /*#__PURE__*/ _interopRequireDefault(require("@perses-dev/prometheus-plugin/plugin.json"));
|
|
24
|
+
const _pluginJson1 = /*#__PURE__*/ _interopRequireDefault(require("@perses-dev/panels-plugin/plugin.json"));
|
|
25
|
+
function _interopRequireDefault(obj) {
|
|
26
|
+
return obj && obj.__esModule ? obj : {
|
|
27
|
+
default: obj
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
31
|
+
if (typeof WeakMap !== "function") return null;
|
|
32
|
+
var cacheBabelInterop = new WeakMap();
|
|
33
|
+
var cacheNodeInterop = new WeakMap();
|
|
34
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
35
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
36
|
+
})(nodeInterop);
|
|
37
|
+
}
|
|
38
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
39
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
43
|
+
return {
|
|
44
|
+
default: obj
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
48
|
+
if (cache && cache.has(obj)) {
|
|
49
|
+
return cache.get(obj);
|
|
50
|
+
}
|
|
51
|
+
var newObj = {};
|
|
52
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
53
|
+
for(var key in obj){
|
|
54
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
55
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
56
|
+
if (desc && (desc.get || desc.set)) {
|
|
57
|
+
Object.defineProperty(newObj, key, desc);
|
|
58
|
+
} else {
|
|
59
|
+
newObj[key] = obj[key];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
newObj.default = obj;
|
|
64
|
+
if (cache) {
|
|
65
|
+
cache.set(obj, newObj);
|
|
66
|
+
}
|
|
67
|
+
return newObj;
|
|
68
|
+
}
|
|
69
|
+
const bundledPluginLoader = (0, _pluginSystem.dynamicImportPluginLoader)([
|
|
70
|
+
{
|
|
71
|
+
resource: _pluginJson.default,
|
|
72
|
+
// This throws an error in CI (but not locally for some reason), likely because
|
|
73
|
+
// this package isn't a dependency for dashboards. We probably do not want to
|
|
74
|
+
// make it one solely for type-checking in storybook.
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("@perses-dev/prometheus-plugin")))
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
resource: _pluginJson1.default,
|
|
81
|
+
// Same comment as above.
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("@perses-dev/panels-plugin")))
|
|
85
|
+
}
|
|
86
|
+
]);
|
|
87
|
+
const WithPluginRegistry = (Story)=>{
|
|
88
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
|
|
89
|
+
pluginLoader: bundledPluginLoader,
|
|
90
|
+
defaultPluginKinds: {
|
|
91
|
+
TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
|
|
92
|
+
},
|
|
93
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
|
|
94
|
+
});
|
|
95
|
+
};
|
|
@@ -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, "WithPluginSystemDatasourceStore", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>WithPluginSystemDatasourceStore
|
|
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 WithPluginSystemDatasourceStore = (Story, context)=>{
|
|
29
|
+
const { getPlugin } = (0, _pluginSystem.usePluginRegistry)();
|
|
30
|
+
const initParameter = context.parameters.withPluginSystemDatasourceStore;
|
|
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,40 @@
|
|
|
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, "WithPluginSystemTemplateVariables", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>WithPluginSystemTemplateVariables
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _runtime = require("../../../runtime");
|
|
23
|
+
// Type guard because storybook types parameters as `any`
|
|
24
|
+
function isWithTemplateVariableParameter(parameter) {
|
|
25
|
+
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
26
|
+
}
|
|
27
|
+
const WithPluginSystemTemplateVariables = (Story, context)=>{
|
|
28
|
+
const initParameter = context.parameters.withPluginSystemTemplateVariables;
|
|
29
|
+
const defaultValue = {
|
|
30
|
+
state: {}
|
|
31
|
+
};
|
|
32
|
+
const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : {
|
|
33
|
+
props: defaultValue
|
|
34
|
+
};
|
|
35
|
+
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
36
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_runtime.TemplateVariableContext.Provider, {
|
|
37
|
+
value: props,
|
|
38
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
|
|
39
|
+
});
|
|
40
|
+
};
|
|
@@ -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,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
|
+
_exportStar(require("./WithDataQueries"), exports);
|
|
18
|
+
_exportStar(require("./WithPluginRegistry"), exports);
|
|
19
|
+
_exportStar(require("./WithPluginSystemDatasourceStore"), exports);
|
|
20
|
+
_exportStar(require("./WithPluginSystemTemplateVariables"), exports);
|
|
21
|
+
_exportStar(require("./WithTimeRange"), exports);
|
|
22
|
+
function _exportStar(from, to) {
|
|
23
|
+
Object.keys(from).forEach(function(k) {
|
|
24
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function() {
|
|
27
|
+
return from[k];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
return from;
|
|
32
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { Box, FormControl, FormHelperText, InputLabel } from '@mui/material';
|
|
15
|
-
import { PluginKindSelect } from '../PluginKindSelect
|
|
16
|
-
import { PluginSpecEditor } from '../PluginSpecEditor
|
|
15
|
+
import { PluginKindSelect } from '../PluginKindSelect';
|
|
16
|
+
import { PluginSpecEditor } from '../PluginSpecEditor';
|
|
17
17
|
import { usePluginEditor } from './plugin-editor-api';
|
|
18
18
|
/**
|
|
19
19
|
* A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PluginEditor/PluginEditor.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 { Box, FormControl, FormHelperText, InputLabel } from '@mui/material';\nimport { PluginKindSelect } from '../PluginKindSelect
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PluginEditor/PluginEditor.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 { Box, FormControl, FormHelperText, InputLabel } from '@mui/material';\nimport { PluginKindSelect } from '../PluginKindSelect';\nimport { PluginSpecEditor } from '../PluginSpecEditor';\nimport { PluginEditorProps, usePluginEditor } from './plugin-editor-api';\n\n/**\n * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property\n * that's common in our JSON specs where a user selects a plugin `kind` and then edits the `spec` via that plugin's\n * editor component. It takes care of transitioning from one plugin kind to another \"all at once\" so that when the\n * plugin's kind changes, the spec is also changed at the same time so those options editor components don't see a\n * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the\n * `usePluginEditor` hook that powers this component.\n */\nexport function PluginEditor(props: PluginEditorProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { value, pluginType, pluginKindLabel, onChange: _, ...others } = props;\n const { pendingKind, isLoading, error, onKindChange, onSpecChange } = usePluginEditor(props);\n return (\n <Box {...others}>\n <FormControl margin=\"dense\" fullWidth={false} disabled={isLoading} error={error !== null} sx={{ mb: 1 }}>\n {/* TODO: How to ensure ids are unique? */}\n <InputLabel id=\"plugin-kind-label\">{pluginKindLabel}</InputLabel>\n <PluginKindSelect\n labelId=\"plugin-kind-label\"\n label={pluginKindLabel}\n pluginType={pluginType}\n value={pendingKind !== '' ? pendingKind : value.kind}\n onChange={onKindChange}\n />\n <FormHelperText>{error?.message ?? ''}</FormHelperText>\n </FormControl>\n <PluginSpecEditor pluginType={pluginType} pluginKind={value.kind} value={value.spec} onChange={onSpecChange} />\n </Box>\n );\n}\n"],"names":["Box","FormControl","FormHelperText","InputLabel","PluginKindSelect","PluginSpecEditor","usePluginEditor","PluginEditor","props","value","pluginType","pluginKindLabel","onChange","_","others","pendingKind","isLoading","error","onKindChange","onSpecChange","margin","fullWidth","disabled","sx","mb","id","labelId","label","kind","message","pluginKind","spec"],"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,GAAG,EAAEC,WAAW,EAAEC,cAAc,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC7E,SAASC,gBAAgB,QAAQ,qBAAqB,CAAC;AACvD,SAASC,gBAAgB,QAAQ,qBAAqB,CAAC;AACvD,SAA4BC,eAAe,QAAQ,qBAAqB,CAAC;AAEzE;;;;;;;CAOC,GACD,OAAO,SAASC,YAAY,CAACC,KAAwB,EAAE;IACrD,6DAA6D;IAC7D,MAAM,EAAEC,KAAK,CAAA,EAAEC,UAAU,CAAA,EAAEC,eAAe,CAAA,EAAEC,QAAQ,EAAEC,CAAC,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGN,KAAK,AAAC;IAC7E,MAAM,EAAEO,WAAW,CAAA,EAAEC,SAAS,CAAA,EAAEC,KAAK,CAAA,EAAEC,YAAY,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGb,eAAe,CAACE,KAAK,CAAC,AAAC;QAatES,GAAc;IAZrC,qBACE,MAACjB,GAAG;QAAE,GAAGc,MAAM;;0BACb,MAACb,WAAW;gBAACmB,MAAM,EAAC,OAAO;gBAACC,SAAS,EAAE,KAAK;gBAAEC,QAAQ,EAAEN,SAAS;gBAAEC,KAAK,EAAEA,KAAK,KAAK,IAAI;gBAAEM,EAAE,EAAE;oBAAEC,EAAE,EAAE,CAAC;iBAAE;;kCAErG,KAACrB,UAAU;wBAACsB,EAAE,EAAC,mBAAmB;kCAAEd,eAAe;sBAAc;kCACjE,KAACP,gBAAgB;wBACfsB,OAAO,EAAC,mBAAmB;wBAC3BC,KAAK,EAAEhB,eAAe;wBACtBD,UAAU,EAAEA,UAAU;wBACtBD,KAAK,EAAEM,WAAW,KAAK,EAAE,GAAGA,WAAW,GAAGN,KAAK,CAACmB,IAAI;wBACpDhB,QAAQ,EAAEM,YAAY;sBACtB;kCACF,KAAChB,cAAc;kCAAEe,CAAAA,GAAc,GAAdA,KAAK,aAALA,KAAK,WAAS,GAAdA,KAAAA,CAAc,GAAdA,KAAK,CAAEY,OAAO,cAAdZ,GAAc,cAAdA,GAAc,GAAI,EAAE;sBAAkB;;cAC3C;0BACd,KAACZ,gBAAgB;gBAACK,UAAU,EAAEA,UAAU;gBAAEoB,UAAU,EAAErB,KAAK,CAACmB,IAAI;gBAAEnB,KAAK,EAAEA,KAAK,CAACsB,IAAI;gBAAEnB,QAAQ,EAAEO,YAAY;cAAI;;MAC3G,CACN;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DataQueriesProviderProps } from '@perses-dev/plugin-system';
|
|
3
|
+
import { StoryFn, StoryContext } from '@storybook/react';
|
|
4
|
+
declare module '@storybook/react' {
|
|
5
|
+
interface Parameters {
|
|
6
|
+
withDataQueries?: WithDataQueriesProvideParameter;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare type WithDataQueriesProvideParameter = {
|
|
10
|
+
props: DataQueriesProviderProps;
|
|
11
|
+
};
|
|
12
|
+
export declare const WithDataQueries: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
|
|
13
|
+
//# sourceMappingURL=WithDataQueries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithDataQueries.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAuB,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,eAAe,CAAC,EAAE,+BAA+B,CAAC;KACnD;CACF;AAED,oBAAY,+BAA+B,GAAG;IAC5C,KAAK,EAAE,wBAAwB,CAAC;CACjC,CAAC;AASF,eAAO,MAAM,eAAe,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAY7E,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 { DataQueriesProvider } from '@perses-dev/plugin-system';
|
|
15
|
+
// Type guard because storybook types parameters as `any`
|
|
16
|
+
function isWithDataQueriesParameter(parameter) {
|
|
17
|
+
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
18
|
+
}
|
|
19
|
+
export const WithDataQueries = (Story, context)=>{
|
|
20
|
+
const initParameter = context.parameters.withDataQueries;
|
|
21
|
+
const parameter = isWithDataQueriesParameter(initParameter) ? initParameter : {
|
|
22
|
+
props: {
|
|
23
|
+
definitions: []
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
27
|
+
return /*#__PURE__*/ _jsx(DataQueriesProvider, {
|
|
28
|
+
...props,
|
|
29
|
+
children: /*#__PURE__*/ _jsx(Story, {})
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=WithDataQueries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.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 { Definition, UnknownSpec } from '@perses-dev/core';\nimport { DataQueriesProvider, DataQueriesProviderProps } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDataQueries?: WithDataQueriesProvideParameter;\n }\n}\n\nexport type WithDataQueriesProvideParameter = {\n props: DataQueriesProviderProps;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDataQueriesParameter(\n parameter: unknown | WithDataQueriesProvideParameter\n): parameter is WithDataQueriesProvideParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDataQueries = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDataQueries;\n const parameter = isWithDataQueriesParameter(initParameter)\n ? initParameter\n : { props: { definitions: [] as Array<Definition<UnknownSpec>> } };\n const props = parameter?.props;\n\n return (\n <DataQueriesProvider {...props}>\n <Story />\n </DataQueriesProvider>\n );\n};\n"],"names":["DataQueriesProvider","isWithDataQueriesParameter","parameter","WithDataQueries","Story","context","initParameter","parameters","withDataQueries","props","definitions"],"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;AACA,SAASA,mBAAmB,QAAkC,2BAA2B,CAAC;AAa1F,yDAAyD;AACzD,SAASC,0BAA0B,CACjCC,SAAoD,EACN;IAC9C,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,eAAe,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACjF,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,eAAe,AAAC;IACzD,MAAMN,SAAS,GAAGD,0BAA0B,CAACK,aAAa,CAAC,GACvDA,aAAa,GACb;QAAEG,KAAK,EAAE;YAAEC,WAAW,EAAE,EAAE;SAAoC;KAAE,AAAC;IACrE,MAAMD,KAAK,GAAGP,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEO,KAAK,AAAC;IAE/B,qBACE,KAACT,mBAAmB;QAAE,GAAGS,KAAK;kBAC5B,cAAA,KAACL,KAAK,KAAG;MACW,CACtB;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithPluginRegistry.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginRegistry.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AA8B3C,eAAO,MAAM,kBAAkB,UAAW,OAAO,gBAShD,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 { PluginRegistry, dynamicImportPluginLoader } from '@perses-dev/plugin-system';
|
|
15
|
+
import prometheusResource from '@perses-dev/prometheus-plugin/plugin.json';
|
|
16
|
+
import panelsResource from '@perses-dev/panels-plugin/plugin.json';
|
|
17
|
+
const bundledPluginLoader = dynamicImportPluginLoader([
|
|
18
|
+
{
|
|
19
|
+
resource: prometheusResource,
|
|
20
|
+
// This throws an error in CI (but not locally for some reason), likely because
|
|
21
|
+
// this package isn't a dependency for dashboards. We probably do not want to
|
|
22
|
+
// make it one solely for type-checking in storybook.
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
importPlugin: ()=>import('@perses-dev/prometheus-plugin')
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
resource: panelsResource,
|
|
29
|
+
// Same comment as above.
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
importPlugin: ()=>import('@perses-dev/panels-plugin')
|
|
33
|
+
}
|
|
34
|
+
]);
|
|
35
|
+
export const WithPluginRegistry = (Story)=>{
|
|
36
|
+
return /*#__PURE__*/ _jsx(PluginRegistry, {
|
|
37
|
+
pluginLoader: bundledPluginLoader,
|
|
38
|
+
defaultPluginKinds: {
|
|
39
|
+
TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
|
|
40
|
+
},
|
|
41
|
+
children: /*#__PURE__*/ _jsx(Story, {})
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=WithPluginRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginRegistry.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 { StoryFn } from '@storybook/react';\nimport {\n PluginRegistry,\n PluginLoader,\n PluginModuleResource,\n dynamicImportPluginLoader,\n} from '@perses-dev/plugin-system';\n\nimport prometheusResource from '@perses-dev/prometheus-plugin/plugin.json';\nimport panelsResource from '@perses-dev/panels-plugin/plugin.json';\n\nconst bundledPluginLoader: PluginLoader = dynamicImportPluginLoader([\n {\n resource: prometheusResource as PluginModuleResource,\n // This throws an error in CI (but not locally for some reason), likely because\n // this package isn't a dependency for dashboards. We probably do not want to\n // make it one solely for type-checking in storybook.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n importPlugin: () => import('@perses-dev/prometheus-plugin'),\n },\n {\n resource: panelsResource as PluginModuleResource,\n // Same comment as above.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n importPlugin: () => import('@perses-dev/panels-plugin'),\n },\n]);\n\nexport const WithPluginRegistry = (Story: StoryFn) => {\n return (\n <PluginRegistry\n pluginLoader={bundledPluginLoader}\n defaultPluginKinds={{ TimeSeriesQuery: 'PrometheusTimeSeriesQuery' }}\n >\n <Story />\n </PluginRegistry>\n );\n};\n"],"names":["PluginRegistry","dynamicImportPluginLoader","prometheusResource","panelsResource","bundledPluginLoader","resource","importPlugin","WithPluginRegistry","Story","pluginLoader","defaultPluginKinds","TimeSeriesQuery"],"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;AACA,SACEA,cAAc,EAGdC,yBAAyB,QACpB,2BAA2B,CAAC;AAEnC,OAAOC,kBAAkB,MAAM,2CAA2C,CAAC;AAC3E,OAAOC,cAAc,MAAM,uCAAuC,CAAC;AAEnE,MAAMC,mBAAmB,GAAiBH,yBAAyB,CAAC;IAClE;QACEI,QAAQ,EAAEH,kBAAkB;QAC5B,+EAA+E;QAC/E,6EAA6E;QAC7E,qDAAqD;QACrD,6DAA6D;QAC7D,aAAa;QACbI,YAAY,EAAE,IAAM,MAAM,CAAC,+BAA+B,CAAC;KAC5D;IACD;QACED,QAAQ,EAAEF,cAAc;QACxB,yBAAyB;QACzB,6DAA6D;QAC7D,aAAa;QACbG,YAAY,EAAE,IAAM,MAAM,CAAC,2BAA2B,CAAC;KACxD;CACF,CAAC,AAAC;AAEH,OAAO,MAAMC,kBAAkB,GAAG,CAACC,KAAc,GAAK;IACpD,qBACE,KAACR,cAAc;QACbS,YAAY,EAAEL,mBAAmB;QACjCM,kBAAkB,EAAE;YAAEC,eAAe,EAAE,2BAA2B;SAAE;kBAEpE,cAAA,KAACH,KAAK,KAAG;MACM,CACjB;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DatasourceStore } from '@perses-dev/plugin-system';
|
|
3
|
+
import { StoryFn, StoryContext } from '@storybook/react';
|
|
4
|
+
declare module '@storybook/react' {
|
|
5
|
+
interface Parameters {
|
|
6
|
+
withPluginSystemDatasourceStore?: WithPluginSystemDatasourceStoreParameter;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare type WithPluginSystemDatasourceStoreParameter = {
|
|
10
|
+
props: DatasourceStore;
|
|
11
|
+
};
|
|
12
|
+
export declare const WithPluginSystemDatasourceStore: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
|
|
13
|
+
//# sourceMappingURL=WithPluginSystemDatasourceStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithPluginSystemDatasourceStore.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.tsx"],"names":[],"mappings":";AAcA,OAAO,EAA0B,eAAe,EAAqB,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,+BAA+B,CAAC,EAAE,wCAAwC,CAAC;KAC5E;CACF;AAED,oBAAY,wCAAwC,GAAG;IACrD,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAaF,eAAO,MAAM,+BAA+B,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAuD7F,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
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 { DatasourceStoreContext, usePluginRegistry } from '@perses-dev/plugin-system';
|
|
15
|
+
const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
|
|
16
|
+
// Type guard because storybook types parameters as `any`
|
|
17
|
+
function isWithDatastoreStoreParameter(parameter) {
|
|
18
|
+
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
19
|
+
}
|
|
20
|
+
// This decorator includes "PluginSystem" in the name to differentiate it from
|
|
21
|
+
// the datasource store decorator in the `dashboards` package.
|
|
22
|
+
export const WithPluginSystemDatasourceStore = (Story, context)=>{
|
|
23
|
+
const { getPlugin } = usePluginRegistry();
|
|
24
|
+
const initParameter = context.parameters.withPluginSystemDatasourceStore;
|
|
25
|
+
// This currently provides a very simplified default to enable use in some
|
|
26
|
+
// basic stories. It likely will need expanding in the future.
|
|
27
|
+
// In general, `plugin-system` would probably benefit from a provider wrapper
|
|
28
|
+
// for `DatasourceStoreContext` that is more generic than the one available
|
|
29
|
+
// in in the `dashboard` package for non-dashboard use cases.
|
|
30
|
+
const defaultValue = {
|
|
31
|
+
getDatasource: (selector)=>{
|
|
32
|
+
if (selector.kind === 'PrometheusDatasource') {
|
|
33
|
+
return Promise.resolve({
|
|
34
|
+
default: true,
|
|
35
|
+
plugin: {
|
|
36
|
+
kind: 'PrometheusDatasource',
|
|
37
|
+
spec: {}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
|
|
42
|
+
},
|
|
43
|
+
getDatasourceClient: async (selector)=>{
|
|
44
|
+
if (selector.kind === 'PrometheusDatasource') {
|
|
45
|
+
const plugin = await getPlugin('Datasource', 'PrometheusDatasource');
|
|
46
|
+
const client = plugin.createClient({
|
|
47
|
+
direct_url: prometheusDemoUrl
|
|
48
|
+
}, {
|
|
49
|
+
proxyUrl: prometheusDemoUrl
|
|
50
|
+
});
|
|
51
|
+
return client;
|
|
52
|
+
}
|
|
53
|
+
throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
|
|
54
|
+
},
|
|
55
|
+
listDatasourceMetadata: async (datasourcePluginKind)=>{
|
|
56
|
+
if (datasourcePluginKind === 'PrometheusDatasource') {
|
|
57
|
+
return Promise.resolve([
|
|
58
|
+
{
|
|
59
|
+
name: 'PrometheusDatasource',
|
|
60
|
+
selector: {
|
|
61
|
+
kind: 'PrometheusDatasource'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginKind}`);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : {
|
|
70
|
+
props: defaultValue
|
|
71
|
+
};
|
|
72
|
+
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
73
|
+
return /*#__PURE__*/ _jsx(DatasourceStoreContext.Provider, {
|
|
74
|
+
value: props,
|
|
75
|
+
children: /*#__PURE__*/ _jsx(Story, {})
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=WithPluginSystemDatasourceStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.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 { DatasourceSelector } from '@perses-dev/core';\nimport { DatasourceStoreContext, DatasourceStore, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withPluginSystemDatasourceStore?: WithPluginSystemDatasourceStoreParameter;\n }\n}\n\nexport type WithPluginSystemDatasourceStoreParameter = {\n props: DatasourceStore;\n};\n\nconst prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDatastoreStoreParameter(\n parameter: unknown | WithPluginSystemDatasourceStoreParameter\n): parameter is WithPluginSystemDatasourceStoreParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\n// This decorator includes \"PluginSystem\" in the name to differentiate it from\n// the datasource store decorator in the `dashboards` package.\nexport const WithPluginSystemDatasourceStore = (Story: StoryFn, context: StoryContext<unknown>) => {\n const { getPlugin } = usePluginRegistry();\n\n const initParameter = context.parameters.withPluginSystemDatasourceStore;\n\n // This currently provides a very simplified default to enable use in some\n // basic stories. It likely will need expanding in the future.\n // In general, `plugin-system` would probably benefit from a provider wrapper\n // for `DatasourceStoreContext` that is more generic than the one available\n // in in the `dashboard` package for non-dashboard use cases.\n const defaultValue: DatasourceStore = {\n getDatasource: (selector) => {\n if (selector.kind === 'PrometheusDatasource') {\n return Promise.resolve({\n default: true,\n plugin: {\n kind: 'PrometheusDatasource',\n spec: {},\n },\n });\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);\n },\n getDatasourceClient: async <Client,>(selector: DatasourceSelector) => {\n if (selector.kind === 'PrometheusDatasource') {\n const plugin = await getPlugin('Datasource', 'PrometheusDatasource');\n const client = plugin.createClient(\n { direct_url: prometheusDemoUrl },\n { proxyUrl: prometheusDemoUrl }\n ) as Client;\n return client;\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);\n },\n listDatasourceMetadata: async (datasourcePluginKind) => {\n if (datasourcePluginKind === 'PrometheusDatasource') {\n return Promise.resolve([\n {\n name: 'PrometheusDatasource',\n selector: { kind: 'PrometheusDatasource' },\n },\n ]);\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginKind}`);\n },\n };\n\n const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : { props: defaultValue };\n const props = parameter?.props;\n\n return (\n <DatasourceStoreContext.Provider value={props}>\n <Story />\n </DatasourceStoreContext.Provider>\n );\n};\n"],"names":["DatasourceStoreContext","usePluginRegistry","prometheusDemoUrl","isWithDatastoreStoreParameter","parameter","WithPluginSystemDatasourceStore","Story","context","getPlugin","initParameter","parameters","withPluginSystemDatasourceStore","defaultValue","getDatasource","selector","kind","Promise","resolve","default","plugin","spec","Error","getDatasourceClient","client","createClient","direct_url","proxyUrl","listDatasourceMetadata","datasourcePluginKind","name","props","Provider","value"],"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;AACA,SAASA,sBAAsB,EAAmBC,iBAAiB,QAAQ,2BAA2B,CAAC;AAavG,MAAMC,iBAAiB,GAAG,0CAA0C,AAAC;AAErE,yDAAyD;AACzD,SAASC,6BAA6B,CACpCC,SAA6D,EACN;IACvD,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,8EAA8E;AAC9E,8DAA8D;AAC9D,OAAO,MAAMC,+BAA+B,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACjG,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGP,iBAAiB,EAAE,AAAC;IAE1C,MAAMQ,aAAa,GAAGF,OAAO,CAACG,UAAU,CAACC,+BAA+B,AAAC;IAEzE,0EAA0E;IAC1E,8DAA8D;IAC9D,6EAA6E;IAC7E,2EAA2E;IAC3E,6DAA6D;IAC7D,MAAMC,YAAY,GAAoB;QACpCC,aAAa,EAAE,CAACC,QAAQ,GAAK;YAC3B,IAAIA,QAAQ,CAACC,IAAI,KAAK,sBAAsB,EAAE;gBAC5C,OAAOC,OAAO,CAACC,OAAO,CAAC;oBACrBC,OAAO,EAAE,IAAI;oBACbC,MAAM,EAAE;wBACNJ,IAAI,EAAE,sBAAsB;wBAC5BK,IAAI,EAAE,EAAE;qBACT;iBACF,CAAC,CAAC;YACL,CAAC;YACD,MAAM,IAAIC,KAAK,CAAC,CAAC,uDAAuD,EAAEP,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7F,CAAC;QACDO,mBAAmB,EAAE,OAAgBR,QAA4B,GAAK;YACpE,IAAIA,QAAQ,CAACC,IAAI,KAAK,sBAAsB,EAAE;gBAC5C,MAAMI,MAAM,GAAG,MAAMX,SAAS,CAAC,YAAY,EAAE,sBAAsB,CAAC,AAAC;gBACrE,MAAMe,MAAM,GAAGJ,MAAM,CAACK,YAAY,CAChC;oBAAEC,UAAU,EAAEvB,iBAAiB;iBAAE,EACjC;oBAAEwB,QAAQ,EAAExB,iBAAiB;iBAAE,CAChC,AAAU,AAAC;gBACZ,OAAOqB,MAAM,CAAC;YAChB,CAAC;YACD,MAAM,IAAIF,KAAK,CAAC,CAAC,uDAAuD,EAAEP,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7F,CAAC;QACDY,sBAAsB,EAAE,OAAOC,oBAAoB,GAAK;YACtD,IAAIA,oBAAoB,KAAK,sBAAsB,EAAE;gBACnD,OAAOZ,OAAO,CAACC,OAAO,CAAC;oBACrB;wBACEY,IAAI,EAAE,sBAAsB;wBAC5Bf,QAAQ,EAAE;4BAAEC,IAAI,EAAE,sBAAsB;yBAAE;qBAC3C;iBACF,CAAC,CAAC;YACL,CAAC;YACD,MAAM,IAAIM,KAAK,CAAC,CAAC,uDAAuD,EAAEO,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACpG,CAAC;KACF,AAAC;IAEF,MAAMxB,SAAS,GAAGD,6BAA6B,CAACM,aAAa,CAAC,GAAGA,aAAa,GAAG;QAAEqB,KAAK,EAAElB,YAAY;KAAE,AAAC;IACzG,MAAMkB,KAAK,GAAG1B,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAE0B,KAAK,AAAC;IAE/B,qBACE,KAAC9B,sBAAsB,CAAC+B,QAAQ;QAACC,KAAK,EAAEF,KAAK;kBAC3C,cAAA,KAACxB,KAAK,KAAG;MACuB,CAClC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StoryFn, StoryContext } from '@storybook/react';
|
|
3
|
+
import { TemplateVariableSrv } from '../../../runtime';
|
|
4
|
+
declare module '@storybook/react' {
|
|
5
|
+
interface Parameters {
|
|
6
|
+
withPluginSystemTemplateVariables?: WithPluginSystemTemplateVariableParameter;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare type WithPluginSystemTemplateVariableParameter = {
|
|
10
|
+
props: TemplateVariableSrv;
|
|
11
|
+
};
|
|
12
|
+
export declare const WithPluginSystemTemplateVariables: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
|
|
13
|
+
//# sourceMappingURL=WithPluginSystemTemplateVariables.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithPluginSystemTemplateVariables.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAA2B,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,iCAAiC,CAAC,EAAE,yCAAyC,CAAC;KAC/E;CACF;AAED,oBAAY,yCAAyC,GAAG;IACtD,KAAK,EAAE,mBAAmB,CAAC;CAC5B,CAAC;AAcF,eAAO,MAAM,iCAAiC,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAc/F,CAAC"}
|
|
@@ -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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { TemplateVariableContext } from '../../../runtime';
|
|
15
|
+
// Type guard because storybook types parameters as `any`
|
|
16
|
+
function isWithTemplateVariableParameter(parameter) {
|
|
17
|
+
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
18
|
+
}
|
|
19
|
+
// This decorator is used for non-dashboards package template variable needs.
|
|
20
|
+
// Use the more specific decorator in the dashboards package when working with
|
|
21
|
+
// dashboards.
|
|
22
|
+
// This decorator includes "PluginSystem" in the name to differentiate it from
|
|
23
|
+
// the datasource store decorator in the `dashboards` package.
|
|
24
|
+
export const WithPluginSystemTemplateVariables = (Story, context)=>{
|
|
25
|
+
const initParameter = context.parameters.withPluginSystemTemplateVariables;
|
|
26
|
+
const defaultValue = {
|
|
27
|
+
state: {}
|
|
28
|
+
};
|
|
29
|
+
const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : {
|
|
30
|
+
props: defaultValue
|
|
31
|
+
};
|
|
32
|
+
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
33
|
+
return /*#__PURE__*/ _jsx(TemplateVariableContext.Provider, {
|
|
34
|
+
value: props,
|
|
35
|
+
children: /*#__PURE__*/ _jsx(Story, {})
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=WithPluginSystemTemplateVariables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { TemplateVariableContext, TemplateVariableSrv } from '../../../runtime';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withPluginSystemTemplateVariables?: WithPluginSystemTemplateVariableParameter;\n }\n}\n\nexport type WithPluginSystemTemplateVariableParameter = {\n props: TemplateVariableSrv;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTemplateVariableParameter(\n parameter: unknown | WithPluginSystemTemplateVariableParameter\n): parameter is WithPluginSystemTemplateVariableParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\n// This decorator is used for non-dashboards package template variable needs.\n// Use the more specific decorator in the dashboards package when working with\n// dashboards.\n// This decorator includes \"PluginSystem\" in the name to differentiate it from\n// the datasource store decorator in the `dashboards` package.\nexport const WithPluginSystemTemplateVariables = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withPluginSystemTemplateVariables;\n const defaultValue: TemplateVariableSrv = {\n state: {},\n };\n const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : { props: defaultValue };\n\n const props = parameter?.props;\n\n return (\n <TemplateVariableContext.Provider value={props}>\n <Story />\n </TemplateVariableContext.Provider>\n );\n};\n"],"names":["TemplateVariableContext","isWithTemplateVariableParameter","parameter","WithPluginSystemTemplateVariables","Story","context","initParameter","parameters","withPluginSystemTemplateVariables","defaultValue","state","props","Provider","value"],"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;AACA,SAASA,uBAAuB,QAA6B,kBAAkB,CAAC;AAYhF,yDAAyD;AACzD,SAASC,+BAA+B,CACtCC,SAA8D,EACN;IACxD,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,6EAA6E;AAC7E,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAC9E,8DAA8D;AAC9D,OAAO,MAAMC,iCAAiC,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACnG,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,iCAAiC,AAAC;IAC3E,MAAMC,YAAY,GAAwB;QACxCC,KAAK,EAAE,EAAE;KACV,AAAC;IACF,MAAMR,SAAS,GAAGD,+BAA+B,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAG;QAAEK,KAAK,EAAEF,YAAY;KAAE,AAAC;IAE3G,MAAME,KAAK,GAAGT,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAES,KAAK,AAAC;IAE/B,qBACE,KAACX,uBAAuB,CAACY,QAAQ;QAACC,KAAK,EAAEF,KAAK;kBAC5C,cAAA,KAACP,KAAK,KAAG;MACwB,CACnC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { StoryFn, StoryContext } from '@storybook/react';
|
|
3
|
+
import { TimeRangeProviderProps } from '@perses-dev/plugin-system';
|
|
4
|
+
declare module '@storybook/react' {
|
|
5
|
+
interface Parameters {
|
|
6
|
+
withTimeRange?: WithTimeRangeParameter;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare type WithTimeRangeParameter = {
|
|
10
|
+
props: Partial<TimeRangeProviderProps>;
|
|
11
|
+
};
|
|
12
|
+
export declare const WithTimeRange: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
|
|
13
|
+
//# sourceMappingURL=WithTimeRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WithTimeRange.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithTimeRange.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEtF,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,aAAa,CAAC,EAAE,sBAAsB,CAAC;KACxC;CACF;AAED,oBAAY,sBAAsB,GAAG;IACnC,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACxC,CAAC;AAOF,eAAO,MAAM,aAAa,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAU3E,CAAC"}
|
|
@@ -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
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { TimeRangeProvider } from '@perses-dev/plugin-system';
|
|
15
|
+
// Type guard because storybook types parameters as `any`
|
|
16
|
+
function isWithTimeRangeParameter(parameter) {
|
|
17
|
+
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
18
|
+
}
|
|
19
|
+
export const WithTimeRange = (Story, context)=>{
|
|
20
|
+
const initParameter = context.parameters.withTimeRange;
|
|
21
|
+
const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;
|
|
22
|
+
const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
|
|
23
|
+
return /*#__PURE__*/ _jsx(TimeRangeProvider, {
|
|
24
|
+
initialTimeRange: {
|
|
25
|
+
pastDuration: '1h'
|
|
26
|
+
},
|
|
27
|
+
...props,
|
|
28
|
+
children: /*#__PURE__*/ _jsx(Story, {})
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=WithTimeRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithTimeRange.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 { StoryFn, StoryContext } from '@storybook/react';\nimport { TimeRangeProvider, TimeRangeProviderProps } from '@perses-dev/plugin-system';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withTimeRange?: WithTimeRangeParameter;\n }\n}\n\nexport type WithTimeRangeParameter = {\n props: Partial<TimeRangeProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTimeRangeParameter(parameter: unknown | WithTimeRangeParameter): parameter is WithTimeRangeParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithTimeRange = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withTimeRange;\n const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <TimeRangeProvider initialTimeRange={{ pastDuration: '1h' }} {...props}>\n <Story />\n </TimeRangeProvider>\n );\n};\n"],"names":["TimeRangeProvider","isWithTimeRangeParameter","parameter","WithTimeRange","Story","context","initParameter","parameters","withTimeRange","undefined","props","initialTimeRange","pastDuration"],"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;AACA,SAASA,iBAAiB,QAAgC,2BAA2B,CAAC;AAYtF,yDAAyD;AACzD,SAASC,wBAAwB,CAACC,SAA2C,EAAuC;IAClH,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IAC/E,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,aAAa,AAAC;IACvD,MAAMN,SAAS,GAAGD,wBAAwB,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAGG,SAAS,AAAC;IACtF,MAAMC,KAAK,GAAGR,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEQ,KAAK,AAAC;IAE/B,qBACE,KAACV,iBAAiB;QAACW,gBAAgB,EAAE;YAAEC,YAAY,EAAE,IAAI;SAAE;QAAG,GAAGF,KAAK;kBACpE,cAAA,KAACN,KAAK,KAAG;MACS,CACpB;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/index.ts"],"names":[],"mappings":"AAaA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 './WithDataQueries';
|
|
14
|
+
export * from './WithPluginRegistry';
|
|
15
|
+
export * from './WithPluginSystemDatasourceStore';
|
|
16
|
+
export * from './WithPluginSystemTemplateVariables';
|
|
17
|
+
export * from './WithTimeRange';
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/stories/shared-utils/decorators/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 './WithDataQueries';\nexport * from './WithPluginRegistry';\nexport * from './WithPluginSystemDatasourceStore';\nexport * from './WithPluginSystemTemplateVariables';\nexport * from './WithTimeRange';\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;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stories/shared-utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,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 './decorators';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/stories/shared-utils/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 './decorators';\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,cAAc,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/plugin-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "The plugin feature in Pereses",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -28,12 +28,15 @@
|
|
|
28
28
|
"lint:fix": "eslint --fix src --ext .ts,.tsx"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@perses-dev/components": "0.
|
|
32
|
-
"@perses-dev/core": "0.
|
|
31
|
+
"@perses-dev/components": "0.31.0",
|
|
32
|
+
"@perses-dev/core": "0.31.0",
|
|
33
33
|
"immer": "^9.0.15",
|
|
34
34
|
"use-immer": "^0.7.0",
|
|
35
35
|
"use-query-params": "^2.1.2"
|
|
36
36
|
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@perses-dev/storybook": "0.31.0"
|
|
39
|
+
},
|
|
37
40
|
"peerDependencies": {
|
|
38
41
|
"@mui/material": "^5.10.0",
|
|
39
42
|
"@tanstack/react-query": "^4.7.1",
|