@perses-dev/plugin-system 0.51.0-beta.0 → 0.51.0-rc.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/DatasourceSelect.js +155 -71
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +2 -2
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +91 -1
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +11 -7
- package/dist/cjs/constants/user-interface-text.js +3 -1
- package/dist/cjs/remote/PluginRuntime.js +168 -162
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +13 -0
- package/dist/cjs/runtime/plugin-registry.js +13 -4
- package/dist/cjs/runtime/time-series-queries.js +3 -13
- package/dist/cjs/runtime/trace-queries.js +46 -16
- package/dist/cjs/{stories/shared-utils/index.js → runtime/utils.js} +21 -12
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect.d.ts +8 -3
- package/dist/components/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect.js +148 -72
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +2 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +94 -2
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +11 -7
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +2 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +3 -1
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/model/trace-queries.d.ts +13 -1
- package/dist/model/trace-queries.d.ts.map +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/remote/PluginLoaderComponent.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts +0 -1
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +169 -160
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/remote/remotePluginLoader.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +7 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +13 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +2 -2
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +13 -4
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +1 -11
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts.map +1 -1
- package/dist/runtime/trace-queries.js +47 -17
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/utils.d.ts +7 -0
- package/dist/runtime/utils.d.ts.map +1 -0
- package/dist/{stories/shared-utils/index.js → runtime/utils.js} +12 -2
- package/dist/runtime/utils.js.map +1 -0
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/package.json +7 -9
- package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +0 -41
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +0 -34
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -42
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -101
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemVariables.js +0 -42
- package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +0 -41
- package/dist/cjs/stories/shared-utils/decorators/index.js +0 -35
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.js +0 -33
- package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +0 -4
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +0 -26
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +0 -39
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +0 -95
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js +0 -39
- package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +0 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +0 -13
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.js +0 -33
- package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +0 -1
- package/dist/stories/shared-utils/decorators/index.d.ts +0 -7
- package/dist/stories/shared-utils/decorators/index.d.ts.map +0 -1
- package/dist/stories/shared-utils/decorators/index.js +0 -20
- package/dist/stories/shared-utils/decorators/index.js.map +0 -1
- package/dist/stories/shared-utils/index.d.ts +0 -2
- package/dist/stories/shared-utils/index.d.ts.map +0 -1
- package/dist/stories/shared-utils/index.js.map +0 -1
|
@@ -1,101 +0,0 @@
|
|
|
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: function() {
|
|
20
|
-
return WithPluginSystemDatasourceStore;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
|
-
const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
|
|
26
|
-
// Type guard because storybook types parameters as `any`
|
|
27
|
-
function isWithDatastoreStoreParameter(parameter) {
|
|
28
|
-
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
29
|
-
}
|
|
30
|
-
const WithPluginSystemDatasourceStore = (Story, context)=>{
|
|
31
|
-
const { getPlugin } = (0, _pluginsystem.usePluginRegistry)();
|
|
32
|
-
const initParameter = context.parameters.withPluginSystemDatasourceStore;
|
|
33
|
-
// This currently provides a very simplified default to enable use in some
|
|
34
|
-
// basic stories. It likely will need expanding in the future.
|
|
35
|
-
// In general, `plugin-system` would probably benefit from a provider wrapper
|
|
36
|
-
// for `DatasourceStoreContext` that is more generic than the one available
|
|
37
|
-
// in the `dashboard` package for non-dashboard use cases.
|
|
38
|
-
const defaultValue = {
|
|
39
|
-
getDatasource: (selector)=>{
|
|
40
|
-
if (selector.kind === 'PrometheusDatasource') {
|
|
41
|
-
return Promise.resolve({
|
|
42
|
-
default: true,
|
|
43
|
-
plugin: {
|
|
44
|
-
kind: 'PrometheusDatasource',
|
|
45
|
-
spec: {}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
|
|
50
|
-
},
|
|
51
|
-
getDatasourceClient: async (selector)=>{
|
|
52
|
-
if (selector.kind === 'PrometheusDatasource') {
|
|
53
|
-
const plugin = await getPlugin('Datasource', 'PrometheusDatasource');
|
|
54
|
-
const client = plugin.createClient({
|
|
55
|
-
directUrl: prometheusDemoUrl
|
|
56
|
-
}, {
|
|
57
|
-
proxyUrl: prometheusDemoUrl
|
|
58
|
-
});
|
|
59
|
-
return client;
|
|
60
|
-
}
|
|
61
|
-
throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
|
|
62
|
-
},
|
|
63
|
-
listDatasourceSelectItems: async (datasourcePluginName)=>{
|
|
64
|
-
if (datasourcePluginName === 'PrometheusDatasource') {
|
|
65
|
-
return Promise.resolve([
|
|
66
|
-
{
|
|
67
|
-
items: [
|
|
68
|
-
{
|
|
69
|
-
name: 'PrometheusDatasource',
|
|
70
|
-
selector: {
|
|
71
|
-
kind: 'PrometheusDatasource'
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
]
|
|
75
|
-
}
|
|
76
|
-
]);
|
|
77
|
-
}
|
|
78
|
-
throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginName}`);
|
|
79
|
-
},
|
|
80
|
-
getSavedDatasources: ()=>{
|
|
81
|
-
return {};
|
|
82
|
-
},
|
|
83
|
-
setSavedDatasources: (datasources)=>{
|
|
84
|
-
return datasources;
|
|
85
|
-
},
|
|
86
|
-
getLocalDatasources: ()=>{
|
|
87
|
-
return {};
|
|
88
|
-
},
|
|
89
|
-
setLocalDatasources: (datasources)=>{
|
|
90
|
-
return datasources;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : {
|
|
94
|
-
props: defaultValue
|
|
95
|
-
};
|
|
96
|
-
const props = parameter?.props;
|
|
97
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceStoreContext.Provider, {
|
|
98
|
-
value: props,
|
|
99
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
100
|
-
});
|
|
101
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 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, "WithPluginSystemVariables", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return WithPluginSystemVariables;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _runtime = require("../../../runtime");
|
|
25
|
-
// Type guard because storybook types parameters as `any`
|
|
26
|
-
function isWithVariableParameter(parameter) {
|
|
27
|
-
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
28
|
-
}
|
|
29
|
-
const WithPluginSystemVariables = (Story, context)=>{
|
|
30
|
-
const initParameter = context.parameters.withPluginSystemVariables;
|
|
31
|
-
const defaultValue = {
|
|
32
|
-
state: {}
|
|
33
|
-
};
|
|
34
|
-
const parameter = isWithVariableParameter(initParameter) ? initParameter : {
|
|
35
|
-
props: defaultValue
|
|
36
|
-
};
|
|
37
|
-
const props = parameter?.props;
|
|
38
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_runtime.VariableContext.Provider, {
|
|
39
|
-
value: props,
|
|
40
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
41
|
-
});
|
|
42
|
-
};
|
|
@@ -1,41 +0,0 @@
|
|
|
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: function() {
|
|
20
|
-
return WithTimeRange;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
|
-
// Type guard because storybook types parameters as `any`
|
|
26
|
-
function isWithTimeRangeParameter(parameter) {
|
|
27
|
-
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
28
|
-
}
|
|
29
|
-
const WithTimeRange = (Story, context)=>{
|
|
30
|
-
const initParameter = context.parameters.withTimeRange;
|
|
31
|
-
const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;
|
|
32
|
-
const props = parameter?.props;
|
|
33
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.TimeRangeProvider, {
|
|
34
|
-
refreshInterval: "0s",
|
|
35
|
-
timeRange: {
|
|
36
|
-
pastDuration: '1h'
|
|
37
|
-
},
|
|
38
|
-
...props,
|
|
39
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(Story, {})
|
|
40
|
-
});
|
|
41
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
_export_star(require("./WithDataQueries"), exports);
|
|
18
|
-
_export_star(require("./WithPluginRegistry"), exports);
|
|
19
|
-
_export_star(require("./WithPluginSystemBuiltinVariables"), exports);
|
|
20
|
-
_export_star(require("./WithPluginSystemDatasourceStore"), exports);
|
|
21
|
-
_export_star(require("./WithPluginSystemVariables"), exports);
|
|
22
|
-
_export_star(require("./WithTimeRange"), exports);
|
|
23
|
-
function _export_star(from, to) {
|
|
24
|
-
Object.keys(from).forEach(function(k) {
|
|
25
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
26
|
-
Object.defineProperty(to, k, {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function() {
|
|
29
|
-
return from[k];
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return from;
|
|
35
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DataQueriesProviderProps } from '@perses-dev/plugin-system';
|
|
2
|
-
import { StoryFn, StoryContext } from '@storybook/react';
|
|
3
|
-
import { ReactElement } from 'react';
|
|
4
|
-
declare module '@storybook/react' {
|
|
5
|
-
interface Parameters {
|
|
6
|
-
withDataQueries?: WithDataQueriesProvideParameter;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export type WithDataQueriesProvideParameter = {
|
|
10
|
-
props: DataQueriesProviderProps;
|
|
11
|
-
};
|
|
12
|
-
export declare const WithDataQueries: (Story: StoryFn, context: StoryContext<unknown>) => ReactElement;
|
|
13
|
-
//# sourceMappingURL=WithDataQueries.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,eAAe,CAAC,EAAE,+BAA+B,CAAC;KACnD;CACF;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,KAAK,EAAE,wBAAwB,CAAC;CACjC,CAAC;AASF,eAAO,MAAM,eAAe,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,KAAG,YAYhF,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
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?.props;
|
|
27
|
-
return /*#__PURE__*/ _jsx(DataQueriesProvider, {
|
|
28
|
-
...props,
|
|
29
|
-
children: /*#__PURE__*/ _jsx(Story, {})
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=WithDataQueries.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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';\nimport { ReactElement } from '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>): ReactElement => {\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;;AAGjC,SAASA,mBAAmB,QAAkC,4BAA4B;AAc1F,yDAAyD;AACzD,SAASC,2BACPC,SAAoD;IAEpD,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,OAAO,MAAMC,kBAAkB,CAACC,OAAgBC;IAC9C,MAAMC,gBAAgBD,QAAQE,UAAU,CAACC,eAAe;IACxD,MAAMN,YAAYD,2BAA2BK,iBACzCA,gBACA;QAAEG,OAAO;YAAEC,aAAa,EAAE;QAAmC;IAAE;IACnE,MAAMD,QAAQP,WAAWO;IAEzB,qBACE,KAACT;QAAqB,GAAGS,KAAK;kBAC5B,cAAA,KAACL;;AAGP,EAAE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WithPluginRegistry.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginRegistry.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,eAAO,MAAM,kBAAkB,UAAW,OAAO,KAAG,YAYnD,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
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, remotePluginLoader } from '@perses-dev/plugin-system';
|
|
15
|
-
export const WithPluginRegistry = (Story)=>{
|
|
16
|
-
return /*#__PURE__*/ _jsx(PluginRegistry, {
|
|
17
|
-
pluginLoader: remotePluginLoader(),
|
|
18
|
-
defaultPluginKinds: {
|
|
19
|
-
TimeSeriesQuery: 'PrometheusTimeSeriesQuery',
|
|
20
|
-
TraceQuery: 'TempoTraceQuery'
|
|
21
|
-
},
|
|
22
|
-
children: /*#__PURE__*/ _jsx(Story, {})
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=WithPluginRegistry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 { PluginRegistry, remotePluginLoader } from '@perses-dev/plugin-system';\nimport { StoryFn } from '@storybook/react';\n\nimport { ReactElement } from 'react';\n\nexport const WithPluginRegistry = (Story: StoryFn): ReactElement => {\n return (\n <PluginRegistry\n pluginLoader={remotePluginLoader()}\n defaultPluginKinds={{\n TimeSeriesQuery: 'PrometheusTimeSeriesQuery',\n TraceQuery: 'TempoTraceQuery',\n }}\n >\n <Story />\n </PluginRegistry>\n );\n};\n"],"names":["PluginRegistry","remotePluginLoader","WithPluginRegistry","Story","pluginLoader","defaultPluginKinds","TimeSeriesQuery","TraceQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,cAAc,EAAEC,kBAAkB,QAAQ,4BAA4B;AAK/E,OAAO,MAAMC,qBAAqB,CAACC;IACjC,qBACE,KAACH;QACCI,cAAcH;QACdI,oBAAoB;YAClBC,iBAAiB;YACjBC,YAAY;QACd;kBAEA,cAAA,KAACJ;;AAGP,EAAE"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { StoryFn, StoryContext } from '@storybook/react';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { BuiltinVariableSrv } from '../../../runtime';
|
|
4
|
-
declare module '@storybook/react' {
|
|
5
|
-
interface Parameters {
|
|
6
|
-
withPluginSystemBuiltinVariables?: WithPluginSystemBuiltinVariableParameter;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export type WithPluginSystemBuiltinVariableParameter = {
|
|
10
|
-
props: BuiltinVariableSrv;
|
|
11
|
-
};
|
|
12
|
-
export declare const WithPluginSystemBuiltinVariables: (Story: StoryFn, context: StoryContext<unknown>) => ReactElement;
|
|
13
|
-
//# sourceMappingURL=WithPluginSystemBuiltinVariables.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WithPluginSystemBuiltinVariables.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAA0B,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,gCAAgC,CAAC,EAAE,wCAAwC,CAAC;KAC7E;CACF;AAED,MAAM,MAAM,wCAAwC,GAAG;IACrD,KAAK,EAAE,kBAAkB,CAAC;CAC3B,CAAC;AAcF,eAAO,MAAM,gCAAgC,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,KAAG,YAcjG,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
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 { BuiltinVariableContext } from '../../../runtime';
|
|
15
|
-
// Type guard because storybook types parameters as `any`
|
|
16
|
-
function isWithBuiltinVariableParameter(parameter) {
|
|
17
|
-
return !!parameter && Array.isArray(parameter);
|
|
18
|
-
}
|
|
19
|
-
// This decorator is used for non-dashboards package Builtin 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 WithPluginSystemBuiltinVariables = (Story, context)=>{
|
|
25
|
-
const initParameter = context.parameters.withPluginSystemBuiltinVariables;
|
|
26
|
-
const defaultValue = {
|
|
27
|
-
variables: []
|
|
28
|
-
};
|
|
29
|
-
const parameter = isWithBuiltinVariableParameter(initParameter) ? initParameter : {
|
|
30
|
-
props: defaultValue
|
|
31
|
-
};
|
|
32
|
-
const props = parameter?.props;
|
|
33
|
-
return /*#__PURE__*/ _jsx(BuiltinVariableContext.Provider, {
|
|
34
|
-
value: props,
|
|
35
|
-
children: /*#__PURE__*/ _jsx(Story, {})
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
//# sourceMappingURL=WithPluginSystemBuiltinVariables.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.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 { ReactElement } from 'react';\nimport { BuiltinVariableContext, BuiltinVariableSrv } from '../../../runtime';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withPluginSystemBuiltinVariables?: WithPluginSystemBuiltinVariableParameter;\n }\n}\n\nexport type WithPluginSystemBuiltinVariableParameter = {\n props: BuiltinVariableSrv;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithBuiltinVariableParameter(\n parameter: unknown | WithPluginSystemBuiltinVariableParameter\n): parameter is WithPluginSystemBuiltinVariableParameter {\n return !!parameter && Array.isArray(parameter);\n}\n\n// This decorator is used for non-dashboards package Builtin 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 WithPluginSystemBuiltinVariables = (Story: StoryFn, context: StoryContext<unknown>): ReactElement => {\n const initParameter = context.parameters.withPluginSystemBuiltinVariables;\n const defaultValue: BuiltinVariableSrv = {\n variables: [],\n };\n const parameter = isWithBuiltinVariableParameter(initParameter) ? initParameter : { props: defaultValue };\n\n const props = parameter?.props;\n\n return (\n <BuiltinVariableContext.Provider value={props}>\n <Story />\n </BuiltinVariableContext.Provider>\n );\n};\n"],"names":["BuiltinVariableContext","isWithBuiltinVariableParameter","parameter","Array","isArray","WithPluginSystemBuiltinVariables","Story","context","initParameter","parameters","withPluginSystemBuiltinVariables","defaultValue","variables","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;;AAIjC,SAASA,sBAAsB,QAA4B,mBAAmB;AAY9E,yDAAyD;AACzD,SAASC,+BACPC,SAA6D;IAE7D,OAAO,CAAC,CAACA,aAAaC,MAAMC,OAAO,CAACF;AACtC;AAEA,4EAA4E;AAC5E,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAC9E,8DAA8D;AAC9D,OAAO,MAAMG,mCAAmC,CAACC,OAAgBC;IAC/D,MAAMC,gBAAgBD,QAAQE,UAAU,CAACC,gCAAgC;IACzE,MAAMC,eAAmC;QACvCC,WAAW,EAAE;IACf;IACA,MAAMV,YAAYD,+BAA+BO,iBAAiBA,gBAAgB;QAAEK,OAAOF;IAAa;IAExG,MAAME,QAAQX,WAAWW;IAEzB,qBACE,KAACb,uBAAuBc,QAAQ;QAACC,OAAOF;kBACtC,cAAA,KAACP;;AAGP,EAAE"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { DatasourceStore } from '@perses-dev/plugin-system';
|
|
2
|
-
import { StoryFn, StoryContext } from '@storybook/react';
|
|
3
|
-
import { ReactElement } from 'react';
|
|
4
|
-
declare module '@storybook/react' {
|
|
5
|
-
interface Parameters {
|
|
6
|
-
withPluginSystemDatasourceStore?: WithPluginSystemDatasourceStoreParameter;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export type WithPluginSystemDatasourceStoreParameter = {
|
|
10
|
-
props: DatasourceStore;
|
|
11
|
-
};
|
|
12
|
-
export declare const WithPluginSystemDatasourceStore: (Story: StoryFn, context: StoryContext<unknown>) => ReactElement;
|
|
13
|
-
//# sourceMappingURL=WithPluginSystemDatasourceStore.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WithPluginSystemDatasourceStore.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.tsx"],"names":[],"mappings":"AAcA,OAAO,EAEL,eAAe,EAGhB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,+BAA+B,CAAC,EAAE,wCAAwC,CAAC;KAC5E;CACF;AAED,MAAM,MAAM,wCAAwC,GAAG;IACrD,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAaF,eAAO,MAAM,+BAA+B,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,KAAG,YAoEhG,CAAC"}
|
|
@@ -1,95 +0,0 @@
|
|
|
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 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
|
-
directUrl: 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
|
-
listDatasourceSelectItems: async (datasourcePluginName)=>{
|
|
56
|
-
if (datasourcePluginName === 'PrometheusDatasource') {
|
|
57
|
-
return Promise.resolve([
|
|
58
|
-
{
|
|
59
|
-
items: [
|
|
60
|
-
{
|
|
61
|
-
name: 'PrometheusDatasource',
|
|
62
|
-
selector: {
|
|
63
|
-
kind: 'PrometheusDatasource'
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
|
-
]);
|
|
69
|
-
}
|
|
70
|
-
throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginName}`);
|
|
71
|
-
},
|
|
72
|
-
getSavedDatasources: ()=>{
|
|
73
|
-
return {};
|
|
74
|
-
},
|
|
75
|
-
setSavedDatasources: (datasources)=>{
|
|
76
|
-
return datasources;
|
|
77
|
-
},
|
|
78
|
-
getLocalDatasources: ()=>{
|
|
79
|
-
return {};
|
|
80
|
-
},
|
|
81
|
-
setLocalDatasources: (datasources)=>{
|
|
82
|
-
return datasources;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : {
|
|
86
|
-
props: defaultValue
|
|
87
|
-
};
|
|
88
|
-
const props = parameter?.props;
|
|
89
|
-
return /*#__PURE__*/ _jsx(DatasourceStoreContext.Provider, {
|
|
90
|
-
value: props,
|
|
91
|
-
children: /*#__PURE__*/ _jsx(Story, {})
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
//# sourceMappingURL=WithPluginSystemDatasourceStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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, DatasourceSpec } from '@perses-dev/core';\nimport {\n DatasourceStoreContext,\n DatasourceStore,\n usePluginRegistry,\n DatasourceSelectItemGroup,\n} from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\nimport { ReactElement } from '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>): ReactElement => {\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 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({ directUrl: prometheusDemoUrl }, { proxyUrl: prometheusDemoUrl }) as Client;\n return client;\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);\n },\n listDatasourceSelectItems: async (datasourcePluginName): Promise<DatasourceSelectItemGroup[]> => {\n if (datasourcePluginName === 'PrometheusDatasource') {\n return Promise.resolve([\n {\n items: [\n {\n name: 'PrometheusDatasource',\n selector: { kind: 'PrometheusDatasource' },\n },\n ],\n },\n ]);\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginName}`);\n },\n getSavedDatasources: (): Record<string, DatasourceSpec> => {\n return {};\n },\n setSavedDatasources: (datasources: Record<string, DatasourceSpec>) => {\n return datasources;\n },\n getLocalDatasources: (): Record<string, DatasourceSpec> => {\n return {};\n },\n setLocalDatasources: (datasources: Record<string, DatasourceSpec>) => {\n return datasources;\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","directUrl","proxyUrl","listDatasourceSelectItems","datasourcePluginName","items","name","getSavedDatasources","setSavedDatasources","datasources","getLocalDatasources","setLocalDatasources","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;;AAGjC,SACEA,sBAAsB,EAEtBC,iBAAiB,QAEZ,4BAA4B;AAcnC,MAAMC,oBAAoB;AAE1B,yDAAyD;AACzD,SAASC,8BACPC,SAA6D;IAE7D,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,8EAA8E;AAC9E,8DAA8D;AAC9D,OAAO,MAAMC,kCAAkC,CAACC,OAAgBC;IAC9D,MAAM,EAAEC,SAAS,EAAE,GAAGP;IAEtB,MAAMQ,gBAAgBF,QAAQG,UAAU,CAACC,+BAA+B;IAExE,0EAA0E;IAC1E,8DAA8D;IAC9D,6EAA6E;IAC7E,2EAA2E;IAC3E,0DAA0D;IAC1D,MAAMC,eAAgC;QACpCC,eAAe,CAACC;YACd,IAAIA,SAASC,IAAI,KAAK,wBAAwB;gBAC5C,OAAOC,QAAQC,OAAO,CAAC;oBACrBC,SAAS;oBACTC,QAAQ;wBACNJ,MAAM;wBACNK,MAAM,CAAC;oBACT;gBACF;YACF;YACA,MAAM,IAAIC,MAAM,CAAC,uDAAuD,EAAEP,SAASC,IAAI,CAAC,CAAC;QAC3F;QACAO,qBAAqB,OAAgBR;YACnC,IAAIA,SAASC,IAAI,KAAK,wBAAwB;gBAC5C,MAAMI,SAAS,MAAMX,UAAU,cAAc;gBAC7C,MAAMe,SAASJ,OAAOK,YAAY,CAAC;oBAAEC,WAAWvB;gBAAkB,GAAG;oBAAEwB,UAAUxB;gBAAkB;gBACnG,OAAOqB;YACT;YACA,MAAM,IAAIF,MAAM,CAAC,uDAAuD,EAAEP,SAASC,IAAI,CAAC,CAAC;QAC3F;QACAY,2BAA2B,OAAOC;YAChC,IAAIA,yBAAyB,wBAAwB;gBACnD,OAAOZ,QAAQC,OAAO,CAAC;oBACrB;wBACEY,OAAO;4BACL;gCACEC,MAAM;gCACNhB,UAAU;oCAAEC,MAAM;gCAAuB;4BAC3C;yBACD;oBACH;iBACD;YACH;YACA,MAAM,IAAIM,MAAM,CAAC,uDAAuD,EAAEO,qBAAqB,CAAC;QAClG;QACAG,qBAAqB;YACnB,OAAO,CAAC;QACV;QACAC,qBAAqB,CAACC;YACpB,OAAOA;QACT;QACAC,qBAAqB;YACnB,OAAO,CAAC;QACV;QACAC,qBAAqB,CAACF;YACpB,OAAOA;QACT;IACF;IAEA,MAAM7B,YAAYD,8BAA8BM,iBAAiBA,gBAAgB;QAAE2B,OAAOxB;IAAa;IACvG,MAAMwB,QAAQhC,WAAWgC;IAEzB,qBACE,KAACpC,uBAAuBqC,QAAQ;QAACC,OAAOF;kBACtC,cAAA,KAAC9B;;AAGP,EAAE"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { StoryFn, StoryContext } from '@storybook/react';
|
|
2
|
-
import { ReactElement } from 'react';
|
|
3
|
-
import { VariableSrv } from '../../../runtime';
|
|
4
|
-
declare module '@storybook/react' {
|
|
5
|
-
interface Parameters {
|
|
6
|
-
withPluginSystemVariables?: WithPluginSystemVariableParameter;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export type WithPluginSystemVariableParameter = {
|
|
10
|
-
props: VariableSrv;
|
|
11
|
-
};
|
|
12
|
-
export declare const WithPluginSystemVariables: (Story: StoryFn, context: StoryContext<unknown>) => ReactElement;
|
|
13
|
-
//# sourceMappingURL=WithPluginSystemVariables.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WithPluginSystemVariables.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemVariables.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,EAAmB,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,yBAAyB,CAAC,EAAE,iCAAiC,CAAC;KAC/D;CACF;AAED,MAAM,MAAM,iCAAiC,GAAG;IAC9C,KAAK,EAAE,WAAW,CAAC;CACpB,CAAC;AAcF,eAAO,MAAM,yBAAyB,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,KAAG,YAc1F,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 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 { VariableContext } from '../../../runtime';
|
|
15
|
-
// Type guard because storybook types parameters as `any`
|
|
16
|
-
function isWithVariableParameter(parameter) {
|
|
17
|
-
return !!parameter && typeof parameter === 'object' && 'props' in parameter;
|
|
18
|
-
}
|
|
19
|
-
// This decorator is used for non-dashboards package 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 WithPluginSystemVariables = (Story, context)=>{
|
|
25
|
-
const initParameter = context.parameters.withPluginSystemVariables;
|
|
26
|
-
const defaultValue = {
|
|
27
|
-
state: {}
|
|
28
|
-
};
|
|
29
|
-
const parameter = isWithVariableParameter(initParameter) ? initParameter : {
|
|
30
|
-
props: defaultValue
|
|
31
|
-
};
|
|
32
|
-
const props = parameter?.props;
|
|
33
|
-
return /*#__PURE__*/ _jsx(VariableContext.Provider, {
|
|
34
|
-
value: props,
|
|
35
|
-
children: /*#__PURE__*/ _jsx(Story, {})
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
//# sourceMappingURL=WithPluginSystemVariables.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemVariables.tsx"],"sourcesContent":["// Copyright 2024 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 { ReactElement } from 'react';\nimport { VariableContext, VariableSrv } from '../../../runtime';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withPluginSystemVariables?: WithPluginSystemVariableParameter;\n }\n}\n\nexport type WithPluginSystemVariableParameter = {\n props: VariableSrv;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithVariableParameter(\n parameter: unknown | WithPluginSystemVariableParameter\n): parameter is WithPluginSystemVariableParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\n// This decorator is used for non-dashboards package 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 WithPluginSystemVariables = (Story: StoryFn, context: StoryContext<unknown>): ReactElement => {\n const initParameter = context.parameters.withPluginSystemVariables;\n const defaultValue: VariableSrv = {\n state: {},\n };\n const parameter = isWithVariableParameter(initParameter) ? initParameter : { props: defaultValue };\n\n const props = parameter?.props;\n\n return (\n <VariableContext.Provider value={props}>\n <Story />\n </VariableContext.Provider>\n );\n};\n"],"names":["VariableContext","isWithVariableParameter","parameter","WithPluginSystemVariables","Story","context","initParameter","parameters","withPluginSystemVariables","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;;AAIjC,SAASA,eAAe,QAAqB,mBAAmB;AAYhE,yDAAyD;AACzD,SAASC,wBACPC,SAAsD;IAEtD,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,oEAAoE;AACpE,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAC9E,8DAA8D;AAC9D,OAAO,MAAMC,4BAA4B,CAACC,OAAgBC;IACxD,MAAMC,gBAAgBD,QAAQE,UAAU,CAACC,yBAAyB;IAClE,MAAMC,eAA4B;QAChCC,OAAO,CAAC;IACV;IACA,MAAMR,YAAYD,wBAAwBK,iBAAiBA,gBAAgB;QAAEK,OAAOF;IAAa;IAEjG,MAAME,QAAQT,WAAWS;IAEzB,qBACE,KAACX,gBAAgBY,QAAQ;QAACC,OAAOF;kBAC/B,cAAA,KAACP;;AAGP,EAAE"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { StoryFn, StoryContext } from '@storybook/react';
|
|
2
|
-
import { TimeRangeFromQueryProps } from '@perses-dev/plugin-system';
|
|
3
|
-
import { ReactElement } from 'react';
|
|
4
|
-
declare module '@storybook/react' {
|
|
5
|
-
interface Parameters {
|
|
6
|
-
withTimeRange?: WithTimeRangeParameter;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export type WithTimeRangeParameter = {
|
|
10
|
-
props: Partial<TimeRangeFromQueryProps>;
|
|
11
|
-
};
|
|
12
|
-
export declare const WithTimeRange: (Story: StoryFn, context: StoryContext<unknown>) => ReactElement;
|
|
13
|
-
//# sourceMappingURL=WithTimeRange.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,aAAa,CAAC,EAAE,sBAAsB,CAAC;KACxC;CACF;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACzC,CAAC;AAOF,eAAO,MAAM,aAAa,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,KAAG,YAU9E,CAAC"}
|