@perses-dev/plugin-system 0.50.3 → 0.51.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +17 -71
- package/dist/cjs/components/DatasourceSelect.js +8 -13
- package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +534 -0
- package/dist/cjs/{stories/shared-utils → components/HTTPSettingsEditor}/index.js +2 -2
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -4
- package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +1 -1
- package/dist/cjs/components/MetricLabelInput/index.js +1 -1
- package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +15 -14
- package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +2 -2
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +7 -11
- package/dist/cjs/components/PluginEditor/PluginEditor.js +10 -6
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +4 -5
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +7 -8
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +7 -10
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +17 -14
- package/dist/cjs/components/ProjectSelect.js +2 -3
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +46 -92
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +6 -6
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
- package/dist/cjs/components/Variables/variable-model.js +4 -7
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/{stories/shared-utils/index.js → cjs/model/explore.js} +4 -3
- package/dist/cjs/remote/PersesPlugin.types.js +16 -0
- package/dist/cjs/remote/PluginLoaderComponent.js +75 -0
- package/dist/cjs/remote/PluginRuntime.js +267 -0
- package/dist/cjs/{stories/shared-utils/decorators → remote}/index.js +3 -7
- package/dist/cjs/remote/remotePluginLoader.js +61 -0
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +4 -10
- package/dist/cjs/runtime/DataQueriesProvider/model.js +4 -7
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +2 -2
- package/dist/cjs/runtime/builtin-variables.js +1 -1
- package/dist/cjs/runtime/datasources.js +3 -3
- package/dist/cjs/runtime/plugin-registry.js +5 -6
- package/dist/cjs/runtime/time-series-queries.js +11 -18
- package/dist/cjs/runtime/trace-queries.js +1 -2
- package/dist/cjs/runtime/variables.js +10 -28
- package/dist/cjs/test/render.js +1 -2
- package/dist/cjs/test-utils/mock-plugin-registry.js +10 -10
- package/dist/cjs/utils/variables.js +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +17 -30
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect.d.ts +2 -2
- package/dist/components/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect.js +8 -13
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +11 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +480 -0
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -0
- package/dist/components/HTTPSettingsEditor/index.d.ts +2 -0
- package/dist/components/HTTPSettingsEditor/index.d.ts.map +1 -0
- package/dist/{stories/shared-utils/decorators → components/HTTPSettingsEditor}/index.js +1 -6
- package/dist/components/HTTPSettingsEditor/index.js.map +1 -0
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +4 -4
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js +1 -1
- package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -1
- package/dist/components/MetricLabelInput/index.js +1 -1
- package/dist/components/MetricLabelInput/index.js.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
- package/dist/components/MultiQueryEditor/MultiQueryEditor.js +15 -14
- package/dist/components/MultiQueryEditor/MultiQueryEditor.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/PanelSpecEditor/PanelSpecEditor.js +7 -11
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +10 -6
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +4 -5
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +7 -8
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +7 -10
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -4
- package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +17 -14
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/ProjectSelect.js +2 -3
- package/dist/components/ProjectSelect.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +46 -92
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +6 -6
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +6 -11
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.js +4 -7
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/explore.d.ts +13 -0
- package/dist/model/explore.d.ts.map +1 -0
- package/dist/model/explore.js +17 -0
- package/dist/model/explore.js.map +1 -0
- package/dist/model/panels.d.ts +13 -3
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugins.d.ts +31 -17
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/remote/PersesPlugin.types.d.ts +7 -0
- package/dist/remote/PersesPlugin.types.d.ts.map +1 -0
- package/dist/remote/PersesPlugin.types.js +15 -0
- package/dist/remote/PersesPlugin.types.js.map +1 -0
- package/dist/remote/PluginLoaderComponent.d.ts +10 -0
- package/dist/remote/PluginLoaderComponent.d.ts.map +1 -0
- package/dist/remote/PluginLoaderComponent.js +67 -0
- package/dist/remote/PluginLoaderComponent.js.map +1 -0
- package/dist/remote/PluginRuntime.d.ts +11 -0
- package/dist/remote/PluginRuntime.d.ts.map +1 -0
- package/dist/remote/PluginRuntime.js +202 -0
- package/dist/remote/PluginRuntime.js.map +1 -0
- package/dist/remote/index.d.ts +3 -0
- package/dist/remote/index.d.ts.map +1 -0
- package/dist/remote/index.js +16 -0
- package/dist/remote/index.js.map +1 -0
- package/dist/remote/remotePluginLoader.d.ts +3 -0
- package/dist/remote/remotePluginLoader.d.ts.map +1 -0
- package/dist/remote/remotePluginLoader.js +53 -0
- package/dist/remote/remotePluginLoader.js.map +1 -0
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +4 -10
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +4 -7
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +2 -2
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/builtin-variables.js +1 -1
- package/dist/runtime/builtin-variables.js.map +1 -1
- package/dist/runtime/datasources.d.ts +2 -2
- package/dist/runtime/datasources.js +3 -3
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +6 -6
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +5 -6
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/time-series-queries.js +11 -18
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.js +1 -2
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/runtime/variables.js +10 -28
- package/dist/runtime/variables.js.map +1 -1
- package/dist/test/render.js +1 -2
- package/dist/test/render.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts +5 -3
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +10 -10
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/dist/utils/variables.js +1 -1
- package/dist/utils/variables.js.map +1 -1
- package/package.json +9 -10
- package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +0 -41
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +0 -100
- 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/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 -46
- 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.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,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 === null || parameter === void 0 ? void 0 : 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,sBAAAA,gCAAAA,UAAWW,KAAK;IAE9B,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 (datasourcePluginKind)=>{
|
|
56
|
-
if (datasourcePluginKind === '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: ${datasourcePluginKind}`);
|
|
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 === null || parameter === void 0 ? void 0 : 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 (datasourcePluginKind): Promise<DatasourceSelectItemGroup[]> => {\n if (datasourcePluginKind === '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: ${datasourcePluginKind}`);\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","datasourcePluginKind","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,sBAAAA,gCAAAA,UAAWgC,KAAK;IAE9B,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 === null || parameter === void 0 ? void 0 : 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,sBAAAA,gCAAAA,UAAWS,KAAK;IAE9B,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"}
|
|
@@ -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 { 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
|
-
refreshInterval: "0s",
|
|
25
|
-
timeRange: {
|
|
26
|
-
pastDuration: '1h'
|
|
27
|
-
},
|
|
28
|
-
...props,
|
|
29
|
-
children: /*#__PURE__*/ _jsx(Story, {})
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
//# sourceMappingURL=WithTimeRange.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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, TimeRangeFromQueryProps } from '@perses-dev/plugin-system';\nimport { ReactElement } from 'react';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withTimeRange?: WithTimeRangeParameter;\n }\n}\n\nexport type WithTimeRangeParameter = {\n props: Partial<TimeRangeFromQueryProps>;\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>): ReactElement => {\n const initParameter = context.parameters.withTimeRange;\n const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <TimeRangeProvider refreshInterval=\"0s\" timeRange={{ pastDuration: '1h' }} {...props}>\n <Story />\n </TimeRangeProvider>\n );\n};\n"],"names":["TimeRangeProvider","isWithTimeRangeParameter","parameter","WithTimeRange","Story","context","initParameter","parameters","withTimeRange","undefined","props","refreshInterval","timeRange","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;;AAGjC,SAASA,iBAAiB,QAAiC,4BAA4B;AAavF,yDAAyD;AACzD,SAASC,yBAAyBC,SAA2C;IAC3E,OAAO,CAAC,CAACA,aAAa,OAAOA,cAAc,YAAY,WAAWA;AACpE;AAEA,OAAO,MAAMC,gBAAgB,CAACC,OAAgBC;IAC5C,MAAMC,gBAAgBD,QAAQE,UAAU,CAACC,aAAa;IACtD,MAAMN,YAAYD,yBAAyBK,iBAAiBA,gBAAgBG;IAC5E,MAAMC,QAAQR,sBAAAA,gCAAAA,UAAWQ,KAAK;IAE9B,qBACE,KAACV;QAAkBW,iBAAgB;QAAKC,WAAW;YAAEC,cAAc;QAAK;QAAI,GAAGH,KAAK;kBAClF,cAAA,KAACN;;AAGP,EAAE"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './WithDataQueries';
|
|
2
|
-
export * from './WithPluginRegistry';
|
|
3
|
-
export * from './WithPluginSystemBuiltinVariables';
|
|
4
|
-
export * from './WithPluginSystemDatasourceStore';
|
|
5
|
-
export * from './WithPluginSystemVariables';
|
|
6
|
-
export * from './WithTimeRange';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/stories/shared-utils/decorators/index.ts"],"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\nexport * from './WithDataQueries';\nexport * from './WithPluginRegistry';\nexport * from './WithPluginSystemBuiltinVariables';\nexport * from './WithPluginSystemDatasourceStore';\nexport * from './WithPluginSystemVariables';\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,oBAAoB;AAClC,cAAc,uBAAuB;AACrC,cAAc,qCAAqC;AACnD,cAAc,oCAAoC;AAClD,cAAc,8BAA8B;AAC5C,cAAc,kBAAkB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stories/shared-utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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,eAAe"}
|