@perses-dev/plugin-system 0.30.0 → 0.32.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.
Files changed (33) hide show
  1. package/dist/cjs/components/PluginEditor/PluginEditor.js +2 -2
  2. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  3. package/dist/cjs/stories/shared-utils/decorators/{WithDatasourceStore.js → WithPluginSystemDatasourceStore.js} +4 -4
  4. package/dist/cjs/stories/shared-utils/decorators/{WithTemplateVariables.js → WithPluginSystemTemplateVariables.js} +4 -4
  5. package/dist/cjs/stories/shared-utils/decorators/index.js +2 -2
  6. package/dist/components/PluginEditor/PluginEditor.js +2 -2
  7. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  8. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +5 -0
  9. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -1
  10. package/dist/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  11. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  12. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +13 -0
  13. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -0
  14. package/dist/stories/shared-utils/decorators/{WithDatasourceStore.js → WithPluginSystemDatasourceStore.js} +5 -3
  15. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -0
  16. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +13 -0
  17. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +1 -0
  18. package/dist/stories/shared-utils/decorators/{WithTemplateVariables.js → WithPluginSystemTemplateVariables.js} +5 -3
  19. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +1 -0
  20. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +5 -0
  21. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
  22. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  23. package/dist/stories/shared-utils/decorators/index.d.ts +2 -2
  24. package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
  25. package/dist/stories/shared-utils/decorators/index.js +2 -2
  26. package/dist/stories/shared-utils/decorators/index.js.map +1 -1
  27. package/package.json +4 -4
  28. package/dist/stories/shared-utils/decorators/WithDatasourceStore.d.ts +0 -8
  29. package/dist/stories/shared-utils/decorators/WithDatasourceStore.d.ts.map +0 -1
  30. package/dist/stories/shared-utils/decorators/WithDatasourceStore.js.map +0 -1
  31. package/dist/stories/shared-utils/decorators/WithTemplateVariables.d.ts +0 -8
  32. package/dist/stories/shared-utils/decorators/WithTemplateVariables.d.ts.map +0 -1
  33. package/dist/stories/shared-utils/decorators/WithTemplateVariables.js.map +0 -1
@@ -20,8 +20,8 @@ Object.defineProperty(exports, "PluginEditor", {
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _material = require("@mui/material");
23
- const _pluginKindSelect = require("../PluginKindSelect/PluginKindSelect");
24
- const _pluginSpecEditor = require("../PluginSpecEditor/PluginSpecEditor");
23
+ const _pluginKindSelect = require("../PluginKindSelect");
24
+ const _pluginSpecEditor = require("../PluginSpecEditor");
25
25
  const _pluginEditorApi = require("./plugin-editor-api");
26
26
  function PluginEditor(props) {
27
27
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -25,7 +25,7 @@ function isWithDataQueriesParameter(parameter) {
25
25
  return !!parameter && typeof parameter === 'object' && 'props' in parameter;
26
26
  }
27
27
  const WithDataQueries = (Story, context)=>{
28
- const initParameter = context.parameters.WithDataQueries;
28
+ const initParameter = context.parameters.withDataQueries;
29
29
  const parameter = isWithDataQueriesParameter(initParameter) ? initParameter : {
30
30
  props: {
31
31
  definitions: []
@@ -14,9 +14,9 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "WithDatasourceStore", {
17
+ Object.defineProperty(exports, "WithPluginSystemDatasourceStore", {
18
18
  enumerable: true,
19
- get: ()=>WithDatasourceStore
19
+ get: ()=>WithPluginSystemDatasourceStore
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _pluginSystem = require("@perses-dev/plugin-system");
@@ -25,9 +25,9 @@ const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
25
25
  function isWithDatastoreStoreParameter(parameter) {
26
26
  return !!parameter && typeof parameter === 'object' && 'props' in parameter;
27
27
  }
28
- const WithDatasourceStore = (Story, context)=>{
28
+ const WithPluginSystemDatasourceStore = (Story, context)=>{
29
29
  const { getPlugin } = (0, _pluginSystem.usePluginRegistry)();
30
- const initParameter = context.parameters.WithDatasourceStore;
30
+ const initParameter = context.parameters.withPluginSystemDatasourceStore;
31
31
  // This currently provides a very simplified default to enable use in some
32
32
  // basic stories. It likely will need expanding in the future.
33
33
  // In general, `plugin-system` would probably benefit from a provider wrapper
@@ -14,9 +14,9 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "WithTemplateVariables", {
17
+ Object.defineProperty(exports, "WithPluginSystemTemplateVariables", {
18
18
  enumerable: true,
19
- get: ()=>WithTemplateVariables
19
+ get: ()=>WithPluginSystemTemplateVariables
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _runtime = require("../../../runtime");
@@ -24,8 +24,8 @@ const _runtime = require("../../../runtime");
24
24
  function isWithTemplateVariableParameter(parameter) {
25
25
  return !!parameter && typeof parameter === 'object' && 'props' in parameter;
26
26
  }
27
- const WithTemplateVariables = (Story, context)=>{
28
- const initParameter = context.parameters.withTemplateVariables;
27
+ const WithPluginSystemTemplateVariables = (Story, context)=>{
28
+ const initParameter = context.parameters.withPluginSystemTemplateVariables;
29
29
  const defaultValue = {
30
30
  state: {}
31
31
  };
@@ -15,9 +15,9 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _exportStar(require("./WithDataQueries"), exports);
18
- _exportStar(require("./WithDatasourceStore"), exports);
19
18
  _exportStar(require("./WithPluginRegistry"), exports);
20
- _exportStar(require("./WithTemplateVariables"), exports);
19
+ _exportStar(require("./WithPluginSystemDatasourceStore"), exports);
20
+ _exportStar(require("./WithPluginSystemTemplateVariables"), exports);
21
21
  _exportStar(require("./WithTimeRange"), exports);
22
22
  function _exportStar(from, to) {
23
23
  Object.keys(from).forEach(function(k) {
@@ -12,8 +12,8 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Box, FormControl, FormHelperText, InputLabel } from '@mui/material';
15
- import { PluginKindSelect } from '../PluginKindSelect/PluginKindSelect';
16
- import { PluginSpecEditor } from '../PluginSpecEditor/PluginSpecEditor';
15
+ import { PluginKindSelect } from '../PluginKindSelect';
16
+ import { PluginSpecEditor } from '../PluginSpecEditor';
17
17
  import { usePluginEditor } from './plugin-editor-api';
18
18
  /**
19
19
  * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, FormControl, FormHelperText, InputLabel } from '@mui/material';\nimport { PluginKindSelect } from '../PluginKindSelect/PluginKindSelect';\nimport { PluginSpecEditor } from '../PluginSpecEditor/PluginSpecEditor';\nimport { PluginEditorProps, usePluginEditor } from './plugin-editor-api';\n\n/**\n * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property\n * that's common in our JSON specs where a user selects a plugin `kind` and then edits the `spec` via that plugin's\n * editor component. It takes care of transitioning from one plugin kind to another \"all at once\" so that when the\n * plugin's kind changes, the spec is also changed at the same time so those options editor components don't see a\n * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the\n * `usePluginEditor` hook that powers this component.\n */\nexport function PluginEditor(props: PluginEditorProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { value, pluginType, pluginKindLabel, onChange: _, ...others } = props;\n const { pendingKind, isLoading, error, onKindChange, onSpecChange } = usePluginEditor(props);\n return (\n <Box {...others}>\n <FormControl margin=\"dense\" fullWidth={false} disabled={isLoading} error={error !== null} sx={{ mb: 1 }}>\n {/* TODO: How to ensure ids are unique? */}\n <InputLabel id=\"plugin-kind-label\">{pluginKindLabel}</InputLabel>\n <PluginKindSelect\n labelId=\"plugin-kind-label\"\n label={pluginKindLabel}\n pluginType={pluginType}\n value={pendingKind !== '' ? pendingKind : value.kind}\n onChange={onKindChange}\n />\n <FormHelperText>{error?.message ?? ''}</FormHelperText>\n </FormControl>\n <PluginSpecEditor pluginType={pluginType} pluginKind={value.kind} value={value.spec} onChange={onSpecChange} />\n </Box>\n );\n}\n"],"names":["Box","FormControl","FormHelperText","InputLabel","PluginKindSelect","PluginSpecEditor","usePluginEditor","PluginEditor","props","value","pluginType","pluginKindLabel","onChange","_","others","pendingKind","isLoading","error","onKindChange","onSpecChange","margin","fullWidth","disabled","sx","mb","id","labelId","label","kind","message","pluginKind","spec"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,EAAEC,WAAW,EAAEC,cAAc,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC7E,SAASC,gBAAgB,QAAQ,sCAAsC,CAAC;AACxE,SAASC,gBAAgB,QAAQ,sCAAsC,CAAC;AACxE,SAA4BC,eAAe,QAAQ,qBAAqB,CAAC;AAEzE;;;;;;;CAOC,GACD,OAAO,SAASC,YAAY,CAACC,KAAwB,EAAE;IACrD,6DAA6D;IAC7D,MAAM,EAAEC,KAAK,CAAA,EAAEC,UAAU,CAAA,EAAEC,eAAe,CAAA,EAAEC,QAAQ,EAAEC,CAAC,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGN,KAAK,AAAC;IAC7E,MAAM,EAAEO,WAAW,CAAA,EAAEC,SAAS,CAAA,EAAEC,KAAK,CAAA,EAAEC,YAAY,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGb,eAAe,CAACE,KAAK,CAAC,AAAC;QAatES,GAAc;IAZrC,qBACE,MAACjB,GAAG;QAAE,GAAGc,MAAM;;0BACb,MAACb,WAAW;gBAACmB,MAAM,EAAC,OAAO;gBAACC,SAAS,EAAE,KAAK;gBAAEC,QAAQ,EAAEN,SAAS;gBAAEC,KAAK,EAAEA,KAAK,KAAK,IAAI;gBAAEM,EAAE,EAAE;oBAAEC,EAAE,EAAE,CAAC;iBAAE;;kCAErG,KAACrB,UAAU;wBAACsB,EAAE,EAAC,mBAAmB;kCAAEd,eAAe;sBAAc;kCACjE,KAACP,gBAAgB;wBACfsB,OAAO,EAAC,mBAAmB;wBAC3BC,KAAK,EAAEhB,eAAe;wBACtBD,UAAU,EAAEA,UAAU;wBACtBD,KAAK,EAAEM,WAAW,KAAK,EAAE,GAAGA,WAAW,GAAGN,KAAK,CAACmB,IAAI;wBACpDhB,QAAQ,EAAEM,YAAY;sBACtB;kCACF,KAAChB,cAAc;kCAAEe,CAAAA,GAAc,GAAdA,KAAK,aAALA,KAAK,WAAS,GAAdA,KAAAA,CAAc,GAAdA,KAAK,CAAEY,OAAO,cAAdZ,GAAc,cAAdA,GAAc,GAAI,EAAE;sBAAkB;;cAC3C;0BACd,KAACZ,gBAAgB;gBAACK,UAAU,EAAEA,UAAU;gBAAEoB,UAAU,EAAErB,KAAK,CAACmB,IAAI;gBAAEnB,KAAK,EAAEA,KAAK,CAACsB,IAAI;gBAAEnB,QAAQ,EAAEO,YAAY;cAAI;;MAC3G,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, FormControl, FormHelperText, InputLabel } from '@mui/material';\nimport { PluginKindSelect } from '../PluginKindSelect';\nimport { PluginSpecEditor } from '../PluginSpecEditor';\nimport { PluginEditorProps, usePluginEditor } from './plugin-editor-api';\n\n/**\n * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property\n * that's common in our JSON specs where a user selects a plugin `kind` and then edits the `spec` via that plugin's\n * editor component. It takes care of transitioning from one plugin kind to another \"all at once\" so that when the\n * plugin's kind changes, the spec is also changed at the same time so those options editor components don't see a\n * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the\n * `usePluginEditor` hook that powers this component.\n */\nexport function PluginEditor(props: PluginEditorProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { value, pluginType, pluginKindLabel, onChange: _, ...others } = props;\n const { pendingKind, isLoading, error, onKindChange, onSpecChange } = usePluginEditor(props);\n return (\n <Box {...others}>\n <FormControl margin=\"dense\" fullWidth={false} disabled={isLoading} error={error !== null} sx={{ mb: 1 }}>\n {/* TODO: How to ensure ids are unique? */}\n <InputLabel id=\"plugin-kind-label\">{pluginKindLabel}</InputLabel>\n <PluginKindSelect\n labelId=\"plugin-kind-label\"\n label={pluginKindLabel}\n pluginType={pluginType}\n value={pendingKind !== '' ? pendingKind : value.kind}\n onChange={onKindChange}\n />\n <FormHelperText>{error?.message ?? ''}</FormHelperText>\n </FormControl>\n <PluginSpecEditor pluginType={pluginType} pluginKind={value.kind} value={value.spec} onChange={onSpecChange} />\n </Box>\n );\n}\n"],"names":["Box","FormControl","FormHelperText","InputLabel","PluginKindSelect","PluginSpecEditor","usePluginEditor","PluginEditor","props","value","pluginType","pluginKindLabel","onChange","_","others","pendingKind","isLoading","error","onKindChange","onSpecChange","margin","fullWidth","disabled","sx","mb","id","labelId","label","kind","message","pluginKind","spec"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,EAAEC,WAAW,EAAEC,cAAc,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC7E,SAASC,gBAAgB,QAAQ,qBAAqB,CAAC;AACvD,SAASC,gBAAgB,QAAQ,qBAAqB,CAAC;AACvD,SAA4BC,eAAe,QAAQ,qBAAqB,CAAC;AAEzE;;;;;;;CAOC,GACD,OAAO,SAASC,YAAY,CAACC,KAAwB,EAAE;IACrD,6DAA6D;IAC7D,MAAM,EAAEC,KAAK,CAAA,EAAEC,UAAU,CAAA,EAAEC,eAAe,CAAA,EAAEC,QAAQ,EAAEC,CAAC,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGN,KAAK,AAAC;IAC7E,MAAM,EAAEO,WAAW,CAAA,EAAEC,SAAS,CAAA,EAAEC,KAAK,CAAA,EAAEC,YAAY,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGb,eAAe,CAACE,KAAK,CAAC,AAAC;QAatES,GAAc;IAZrC,qBACE,MAACjB,GAAG;QAAE,GAAGc,MAAM;;0BACb,MAACb,WAAW;gBAACmB,MAAM,EAAC,OAAO;gBAACC,SAAS,EAAE,KAAK;gBAAEC,QAAQ,EAAEN,SAAS;gBAAEC,KAAK,EAAEA,KAAK,KAAK,IAAI;gBAAEM,EAAE,EAAE;oBAAEC,EAAE,EAAE,CAAC;iBAAE;;kCAErG,KAACrB,UAAU;wBAACsB,EAAE,EAAC,mBAAmB;kCAAEd,eAAe;sBAAc;kCACjE,KAACP,gBAAgB;wBACfsB,OAAO,EAAC,mBAAmB;wBAC3BC,KAAK,EAAEhB,eAAe;wBACtBD,UAAU,EAAEA,UAAU;wBACtBD,KAAK,EAAEM,WAAW,KAAK,EAAE,GAAGA,WAAW,GAAGN,KAAK,CAACmB,IAAI;wBACpDhB,QAAQ,EAAEM,YAAY;sBACtB;kCACF,KAAChB,cAAc;kCAAEe,CAAAA,GAAc,GAAdA,KAAK,aAALA,KAAK,WAAS,GAAdA,KAAAA,CAAc,GAAdA,KAAK,CAAEY,OAAO,cAAdZ,GAAc,cAAdA,GAAc,GAAI,EAAE;sBAAkB;;cAC3C;0BACd,KAACZ,gBAAgB;gBAACK,UAAU,EAAEA,UAAU;gBAAEoB,UAAU,EAAErB,KAAK,CAACmB,IAAI;gBAAEnB,KAAK,EAAEA,KAAK,CAACsB,IAAI;gBAAEnB,QAAQ,EAAEO,YAAY;cAAI;;MAC3G,CACN;AACJ,CAAC"}
@@ -1,6 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { DataQueriesProviderProps } from '@perses-dev/plugin-system';
3
3
  import { StoryFn, StoryContext } from '@storybook/react';
4
+ declare module '@storybook/react' {
5
+ interface Parameters {
6
+ withDataQueries?: WithDataQueriesProvideParameter;
7
+ }
8
+ }
4
9
  export declare type WithDataQueriesProvideParameter = {
5
10
  props: DataQueriesProviderProps;
6
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"WithDataQueries.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAuB,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzD,oBAAY,+BAA+B,GAAG;IAC5C,KAAK,EAAE,wBAAwB,CAAC;CACjC,CAAC;AASF,eAAO,MAAM,eAAe,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAY7E,CAAC"}
1
+ {"version":3,"file":"WithDataQueries.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAuB,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,eAAe,CAAC,EAAE,+BAA+B,CAAC;KACnD;CACF;AAED,oBAAY,+BAA+B,GAAG;IAC5C,KAAK,EAAE,wBAAwB,CAAC;CACjC,CAAC;AASF,eAAO,MAAM,eAAe,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAY7E,CAAC"}
@@ -17,7 +17,7 @@ function isWithDataQueriesParameter(parameter) {
17
17
  return !!parameter && typeof parameter === 'object' && 'props' in parameter;
18
18
  }
19
19
  export const WithDataQueries = (Story, context)=>{
20
- const initParameter = context.parameters.WithDataQueries;
20
+ const initParameter = context.parameters.withDataQueries;
21
21
  const parameter = isWithDataQueriesParameter(initParameter) ? initParameter : {
22
22
  props: {
23
23
  definitions: []
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from '@perses-dev/core';\nimport { DataQueriesProvider, DataQueriesProviderProps } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\nexport type WithDataQueriesProvideParameter = {\n props: DataQueriesProviderProps;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDataQueriesParameter(\n parameter: unknown | WithDataQueriesProvideParameter\n): parameter is WithDataQueriesProvideParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDataQueries = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.WithDataQueries;\n const parameter = isWithDataQueriesParameter(initParameter)\n ? initParameter\n : { props: { definitions: [] as Array<Definition<UnknownSpec>> } };\n const props = parameter?.props;\n\n return (\n <DataQueriesProvider {...props}>\n <Story />\n </DataQueriesProvider>\n );\n};\n"],"names":["DataQueriesProvider","isWithDataQueriesParameter","parameter","WithDataQueries","Story","context","initParameter","parameters","props","definitions"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,mBAAmB,QAAkC,2BAA2B,CAAC;AAO1F,yDAAyD;AACzD,SAASC,0BAA0B,CACjCC,SAAoD,EACN;IAC9C,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,eAAe,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACjF,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACJ,eAAe,AAAC;IACzD,MAAMD,SAAS,GAAGD,0BAA0B,CAACK,aAAa,CAAC,GACvDA,aAAa,GACb;QAAEE,KAAK,EAAE;YAAEC,WAAW,EAAE,EAAE;SAAoC;KAAE,AAAC;IACrE,MAAMD,KAAK,GAAGN,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEM,KAAK,AAAC;IAE/B,qBACE,KAACR,mBAAmB;QAAE,GAAGQ,KAAK;kBAC5B,cAAA,KAACJ,KAAK,KAAG;MACW,CACtB;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from '@perses-dev/core';\nimport { DataQueriesProvider, DataQueriesProviderProps } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withDataQueries?: WithDataQueriesProvideParameter;\n }\n}\n\nexport type WithDataQueriesProvideParameter = {\n props: DataQueriesProviderProps;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDataQueriesParameter(\n parameter: unknown | WithDataQueriesProvideParameter\n): parameter is WithDataQueriesProvideParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDataQueries = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withDataQueries;\n const parameter = isWithDataQueriesParameter(initParameter)\n ? initParameter\n : { props: { definitions: [] as Array<Definition<UnknownSpec>> } };\n const props = parameter?.props;\n\n return (\n <DataQueriesProvider {...props}>\n <Story />\n </DataQueriesProvider>\n );\n};\n"],"names":["DataQueriesProvider","isWithDataQueriesParameter","parameter","WithDataQueries","Story","context","initParameter","parameters","withDataQueries","props","definitions"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,mBAAmB,QAAkC,2BAA2B,CAAC;AAa1F,yDAAyD;AACzD,SAASC,0BAA0B,CACjCC,SAAoD,EACN;IAC9C,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,eAAe,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACjF,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,eAAe,AAAC;IACzD,MAAMN,SAAS,GAAGD,0BAA0B,CAACK,aAAa,CAAC,GACvDA,aAAa,GACb;QAAEG,KAAK,EAAE;YAAEC,WAAW,EAAE,EAAE;SAAoC;KAAE,AAAC;IACrE,MAAMD,KAAK,GAAGP,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEO,KAAK,AAAC;IAE/B,qBACE,KAACT,mBAAmB;QAAE,GAAGS,KAAK;kBAC5B,cAAA,KAACL,KAAK,KAAG;MACW,CACtB;AACJ,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { DatasourceStore } from '@perses-dev/plugin-system';
3
+ import { StoryFn, StoryContext } from '@storybook/react';
4
+ declare module '@storybook/react' {
5
+ interface Parameters {
6
+ withPluginSystemDatasourceStore?: WithPluginSystemDatasourceStoreParameter;
7
+ }
8
+ }
9
+ export declare type WithPluginSystemDatasourceStoreParameter = {
10
+ props: DatasourceStore;
11
+ };
12
+ export declare const WithPluginSystemDatasourceStore: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
13
+ //# sourceMappingURL=WithPluginSystemDatasourceStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithPluginSystemDatasourceStore.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.tsx"],"names":[],"mappings":";AAcA,OAAO,EAA0B,eAAe,EAAqB,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,+BAA+B,CAAC,EAAE,wCAAwC,CAAC;KAC5E;CACF;AAED,oBAAY,wCAAwC,GAAG;IACrD,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAaF,eAAO,MAAM,+BAA+B,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAuD7F,CAAC"}
@@ -17,9 +17,11 @@ const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
17
17
  function isWithDatastoreStoreParameter(parameter) {
18
18
  return !!parameter && typeof parameter === 'object' && 'props' in parameter;
19
19
  }
20
- export const WithDatasourceStore = (Story, context)=>{
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)=>{
21
23
  const { getPlugin } = usePluginRegistry();
22
- const initParameter = context.parameters.WithDatasourceStore;
24
+ const initParameter = context.parameters.withPluginSystemDatasourceStore;
23
25
  // This currently provides a very simplified default to enable use in some
24
26
  // basic stories. It likely will need expanding in the future.
25
27
  // In general, `plugin-system` would probably benefit from a provider wrapper
@@ -74,4 +76,4 @@ export const WithDatasourceStore = (Story, context)=>{
74
76
  });
75
77
  };
76
78
 
77
- //# sourceMappingURL=WithDatasourceStore.js.map
79
+ //# sourceMappingURL=WithPluginSystemDatasourceStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { DatasourceStoreContext, DatasourceStore, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withPluginSystemDatasourceStore?: WithPluginSystemDatasourceStoreParameter;\n }\n}\n\nexport type WithPluginSystemDatasourceStoreParameter = {\n props: DatasourceStore;\n};\n\nconst prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';\n\n// Type guard because storybook types parameters as `any`\nfunction isWithDatastoreStoreParameter(\n parameter: unknown | WithPluginSystemDatasourceStoreParameter\n): parameter is WithPluginSystemDatasourceStoreParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\n// This decorator includes \"PluginSystem\" in the name to differentiate it from\n// the datasource store decorator in the `dashboards` package.\nexport const WithPluginSystemDatasourceStore = (Story: StoryFn, context: StoryContext<unknown>) => {\n const { getPlugin } = usePluginRegistry();\n\n const initParameter = context.parameters.withPluginSystemDatasourceStore;\n\n // This currently provides a very simplified default to enable use in some\n // basic stories. It likely will need expanding in the future.\n // In general, `plugin-system` would probably benefit from a provider wrapper\n // for `DatasourceStoreContext` that is more generic than the one available\n // in in the `dashboard` package for non-dashboard use cases.\n const defaultValue: DatasourceStore = {\n getDatasource: (selector) => {\n if (selector.kind === 'PrometheusDatasource') {\n return Promise.resolve({\n default: true,\n plugin: {\n kind: 'PrometheusDatasource',\n spec: {},\n },\n });\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);\n },\n getDatasourceClient: async <Client,>(selector: DatasourceSelector) => {\n if (selector.kind === 'PrometheusDatasource') {\n const plugin = await getPlugin('Datasource', 'PrometheusDatasource');\n const client = plugin.createClient(\n { direct_url: prometheusDemoUrl },\n { proxyUrl: prometheusDemoUrl }\n ) as Client;\n return client;\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);\n },\n listDatasourceMetadata: async (datasourcePluginKind) => {\n if (datasourcePluginKind === 'PrometheusDatasource') {\n return Promise.resolve([\n {\n name: 'PrometheusDatasource',\n selector: { kind: 'PrometheusDatasource' },\n },\n ]);\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginKind}`);\n },\n };\n\n const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : { props: defaultValue };\n const props = parameter?.props;\n\n return (\n <DatasourceStoreContext.Provider value={props}>\n <Story />\n </DatasourceStoreContext.Provider>\n );\n};\n"],"names":["DatasourceStoreContext","usePluginRegistry","prometheusDemoUrl","isWithDatastoreStoreParameter","parameter","WithPluginSystemDatasourceStore","Story","context","getPlugin","initParameter","parameters","withPluginSystemDatasourceStore","defaultValue","getDatasource","selector","kind","Promise","resolve","default","plugin","spec","Error","getDatasourceClient","client","createClient","direct_url","proxyUrl","listDatasourceMetadata","datasourcePluginKind","name","props","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,sBAAsB,EAAmBC,iBAAiB,QAAQ,2BAA2B,CAAC;AAavG,MAAMC,iBAAiB,GAAG,0CAA0C,AAAC;AAErE,yDAAyD;AACzD,SAASC,6BAA6B,CACpCC,SAA6D,EACN;IACvD,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,8EAA8E;AAC9E,8DAA8D;AAC9D,OAAO,MAAMC,+BAA+B,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACjG,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGP,iBAAiB,EAAE,AAAC;IAE1C,MAAMQ,aAAa,GAAGF,OAAO,CAACG,UAAU,CAACC,+BAA+B,AAAC;IAEzE,0EAA0E;IAC1E,8DAA8D;IAC9D,6EAA6E;IAC7E,2EAA2E;IAC3E,6DAA6D;IAC7D,MAAMC,YAAY,GAAoB;QACpCC,aAAa,EAAE,CAACC,QAAQ,GAAK;YAC3B,IAAIA,QAAQ,CAACC,IAAI,KAAK,sBAAsB,EAAE;gBAC5C,OAAOC,OAAO,CAACC,OAAO,CAAC;oBACrBC,OAAO,EAAE,IAAI;oBACbC,MAAM,EAAE;wBACNJ,IAAI,EAAE,sBAAsB;wBAC5BK,IAAI,EAAE,EAAE;qBACT;iBACF,CAAC,CAAC;YACL,CAAC;YACD,MAAM,IAAIC,KAAK,CAAC,CAAC,uDAAuD,EAAEP,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7F,CAAC;QACDO,mBAAmB,EAAE,OAAgBR,QAA4B,GAAK;YACpE,IAAIA,QAAQ,CAACC,IAAI,KAAK,sBAAsB,EAAE;gBAC5C,MAAMI,MAAM,GAAG,MAAMX,SAAS,CAAC,YAAY,EAAE,sBAAsB,CAAC,AAAC;gBACrE,MAAMe,MAAM,GAAGJ,MAAM,CAACK,YAAY,CAChC;oBAAEC,UAAU,EAAEvB,iBAAiB;iBAAE,EACjC;oBAAEwB,QAAQ,EAAExB,iBAAiB;iBAAE,CAChC,AAAU,AAAC;gBACZ,OAAOqB,MAAM,CAAC;YAChB,CAAC;YACD,MAAM,IAAIF,KAAK,CAAC,CAAC,uDAAuD,EAAEP,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7F,CAAC;QACDY,sBAAsB,EAAE,OAAOC,oBAAoB,GAAK;YACtD,IAAIA,oBAAoB,KAAK,sBAAsB,EAAE;gBACnD,OAAOZ,OAAO,CAACC,OAAO,CAAC;oBACrB;wBACEY,IAAI,EAAE,sBAAsB;wBAC5Bf,QAAQ,EAAE;4BAAEC,IAAI,EAAE,sBAAsB;yBAAE;qBAC3C;iBACF,CAAC,CAAC;YACL,CAAC;YACD,MAAM,IAAIM,KAAK,CAAC,CAAC,uDAAuD,EAAEO,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACpG,CAAC;KACF,AAAC;IAEF,MAAMxB,SAAS,GAAGD,6BAA6B,CAACM,aAAa,CAAC,GAAGA,aAAa,GAAG;QAAEqB,KAAK,EAAElB,YAAY;KAAE,AAAC;IACzG,MAAMkB,KAAK,GAAG1B,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAE0B,KAAK,AAAC;IAE/B,qBACE,KAAC9B,sBAAsB,CAAC+B,QAAQ;QAACC,KAAK,EAAEF,KAAK;kBAC3C,cAAA,KAACxB,KAAK,KAAG;MACuB,CAClC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { StoryFn, StoryContext } from '@storybook/react';
3
+ import { TemplateVariableSrv } from '../../../runtime';
4
+ declare module '@storybook/react' {
5
+ interface Parameters {
6
+ withPluginSystemTemplateVariables?: WithPluginSystemTemplateVariableParameter;
7
+ }
8
+ }
9
+ export declare type WithPluginSystemTemplateVariableParameter = {
10
+ props: TemplateVariableSrv;
11
+ };
12
+ export declare const WithPluginSystemTemplateVariables: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
13
+ //# sourceMappingURL=WithPluginSystemTemplateVariables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithPluginSystemTemplateVariables.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAA2B,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,iCAAiC,CAAC,EAAE,yCAAyC,CAAC;KAC/E;CACF;AAED,oBAAY,yCAAyC,GAAG;IACtD,KAAK,EAAE,mBAAmB,CAAC;CAC5B,CAAC;AAcF,eAAO,MAAM,iCAAiC,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAc/F,CAAC"}
@@ -19,8 +19,10 @@ function isWithTemplateVariableParameter(parameter) {
19
19
  // This decorator is used for non-dashboards package template variable needs.
20
20
  // Use the more specific decorator in the dashboards package when working with
21
21
  // dashboards.
22
- export const WithTemplateVariables = (Story, context)=>{
23
- const initParameter = context.parameters.withTemplateVariables;
22
+ // This decorator includes "PluginSystem" in the name to differentiate it from
23
+ // the datasource store decorator in the `dashboards` package.
24
+ export const WithPluginSystemTemplateVariables = (Story, context)=>{
25
+ const initParameter = context.parameters.withPluginSystemTemplateVariables;
24
26
  const defaultValue = {
25
27
  state: {}
26
28
  };
@@ -34,4 +36,4 @@ export const WithTemplateVariables = (Story, context)=>{
34
36
  });
35
37
  };
36
38
 
37
- //# sourceMappingURL=WithTemplateVariables.js.map
39
+ //# sourceMappingURL=WithPluginSystemTemplateVariables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StoryFn, StoryContext } from '@storybook/react';\nimport { TemplateVariableContext, TemplateVariableSrv } from '../../../runtime';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withPluginSystemTemplateVariables?: WithPluginSystemTemplateVariableParameter;\n }\n}\n\nexport type WithPluginSystemTemplateVariableParameter = {\n props: TemplateVariableSrv;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTemplateVariableParameter(\n parameter: unknown | WithPluginSystemTemplateVariableParameter\n): parameter is WithPluginSystemTemplateVariableParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\n// This decorator is used for non-dashboards package template variable needs.\n// Use the more specific decorator in the dashboards package when working with\n// dashboards.\n// This decorator includes \"PluginSystem\" in the name to differentiate it from\n// the datasource store decorator in the `dashboards` package.\nexport const WithPluginSystemTemplateVariables = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withPluginSystemTemplateVariables;\n const defaultValue: TemplateVariableSrv = {\n state: {},\n };\n const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : { props: defaultValue };\n\n const props = parameter?.props;\n\n return (\n <TemplateVariableContext.Provider value={props}>\n <Story />\n </TemplateVariableContext.Provider>\n );\n};\n"],"names":["TemplateVariableContext","isWithTemplateVariableParameter","parameter","WithPluginSystemTemplateVariables","Story","context","initParameter","parameters","withPluginSystemTemplateVariables","defaultValue","state","props","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,uBAAuB,QAA6B,kBAAkB,CAAC;AAYhF,yDAAyD;AACzD,SAASC,+BAA+B,CACtCC,SAA8D,EACN;IACxD,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,6EAA6E;AAC7E,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAC9E,8DAA8D;AAC9D,OAAO,MAAMC,iCAAiC,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACnG,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,iCAAiC,AAAC;IAC3E,MAAMC,YAAY,GAAwB;QACxCC,KAAK,EAAE,EAAE;KACV,AAAC;IACF,MAAMR,SAAS,GAAGD,+BAA+B,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAG;QAAEK,KAAK,EAAEF,YAAY;KAAE,AAAC;IAE3G,MAAME,KAAK,GAAGT,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAES,KAAK,AAAC;IAE/B,qBACE,KAACX,uBAAuB,CAACY,QAAQ;QAACC,KAAK,EAAEF,KAAK;kBAC5C,cAAA,KAACP,KAAK,KAAG;MACwB,CACnC;AACJ,CAAC,CAAC"}
@@ -1,6 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { StoryFn, StoryContext } from '@storybook/react';
3
3
  import { TimeRangeProviderProps } from '@perses-dev/plugin-system';
4
+ declare module '@storybook/react' {
5
+ interface Parameters {
6
+ withTimeRange?: WithTimeRangeParameter;
7
+ }
8
+ }
4
9
  export declare type WithTimeRangeParameter = {
5
10
  props: Partial<TimeRangeProviderProps>;
6
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"WithTimeRange.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithTimeRange.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEtF,oBAAY,sBAAsB,GAAG;IACnC,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACxC,CAAC;AAOF,eAAO,MAAM,aAAa,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAU3E,CAAC"}
1
+ {"version":3,"file":"WithTimeRange.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithTimeRange.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEtF,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,UAAU;QAClB,aAAa,CAAC,EAAE,sBAAsB,CAAC;KACxC;CACF;AAED,oBAAY,sBAAsB,GAAG;IACnC,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACxC,CAAC;AAOF,eAAO,MAAM,aAAa,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAU3E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithTimeRange.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StoryFn, StoryContext } from '@storybook/react';\nimport { TimeRangeProvider, TimeRangeProviderProps } from '@perses-dev/plugin-system';\n\nexport type WithTimeRangeParameter = {\n props: Partial<TimeRangeProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTimeRangeParameter(parameter: unknown | WithTimeRangeParameter): parameter is WithTimeRangeParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithTimeRange = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withTimeRange;\n const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <TimeRangeProvider initialTimeRange={{ pastDuration: '1h' }} {...props}>\n <Story />\n </TimeRangeProvider>\n );\n};\n"],"names":["TimeRangeProvider","isWithTimeRangeParameter","parameter","WithTimeRange","Story","context","initParameter","parameters","withTimeRange","undefined","props","initialTimeRange","pastDuration"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,iBAAiB,QAAgC,2BAA2B,CAAC;AAMtF,yDAAyD;AACzD,SAASC,wBAAwB,CAACC,SAA2C,EAAuC;IAClH,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IAC/E,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,aAAa,AAAC;IACvD,MAAMN,SAAS,GAAGD,wBAAwB,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAGG,SAAS,AAAC;IACtF,MAAMC,KAAK,GAAGR,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEQ,KAAK,AAAC;IAE/B,qBACE,KAACV,iBAAiB;QAACW,gBAAgB,EAAE;YAAEC,YAAY,EAAE,IAAI;SAAE;QAAG,GAAGF,KAAK;kBACpE,cAAA,KAACN,KAAK,KAAG;MACS,CACpB;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithTimeRange.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StoryFn, StoryContext } from '@storybook/react';\nimport { TimeRangeProvider, TimeRangeProviderProps } from '@perses-dev/plugin-system';\n\ndeclare module '@storybook/react' {\n interface Parameters {\n withTimeRange?: WithTimeRangeParameter;\n }\n}\n\nexport type WithTimeRangeParameter = {\n props: Partial<TimeRangeProviderProps>;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTimeRangeParameter(parameter: unknown | WithTimeRangeParameter): parameter is WithTimeRangeParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithTimeRange = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withTimeRange;\n const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;\n const props = parameter?.props;\n\n return (\n <TimeRangeProvider initialTimeRange={{ pastDuration: '1h' }} {...props}>\n <Story />\n </TimeRangeProvider>\n );\n};\n"],"names":["TimeRangeProvider","isWithTimeRangeParameter","parameter","WithTimeRange","Story","context","initParameter","parameters","withTimeRange","undefined","props","initialTimeRange","pastDuration"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,iBAAiB,QAAgC,2BAA2B,CAAC;AAYtF,yDAAyD;AACzD,SAASC,wBAAwB,CAACC,SAA2C,EAAuC;IAClH,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,aAAa,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IAC/E,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,aAAa,AAAC;IACvD,MAAMN,SAAS,GAAGD,wBAAwB,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAGG,SAAS,AAAC;IACtF,MAAMC,KAAK,GAAGR,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEQ,KAAK,AAAC;IAE/B,qBACE,KAACV,iBAAiB;QAACW,gBAAgB,EAAE;YAAEC,YAAY,EAAE,IAAI;SAAE;QAAG,GAAGF,KAAK;kBACpE,cAAA,KAACN,KAAK,KAAG;MACS,CACpB;AACJ,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export * from './WithDataQueries';
2
- export * from './WithDatasourceStore';
3
2
  export * from './WithPluginRegistry';
4
- export * from './WithTemplateVariables';
3
+ export * from './WithPluginSystemDatasourceStore';
4
+ export * from './WithPluginSystemTemplateVariables';
5
5
  export * from './WithTimeRange';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/index.ts"],"names":[],"mappings":"AAaA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/index.ts"],"names":[],"mappings":"AAaA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iBAAiB,CAAC"}
@@ -11,9 +11,9 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  export * from './WithDataQueries';
14
- export * from './WithDatasourceStore';
15
14
  export * from './WithPluginRegistry';
16
- export * from './WithTemplateVariables';
15
+ export * from './WithPluginSystemDatasourceStore';
16
+ export * from './WithPluginSystemTemplateVariables';
17
17
  export * from './WithTimeRange';
18
18
 
19
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './WithDataQueries';\nexport * from './WithDatasourceStore';\nexport * from './WithPluginRegistry';\nexport * from './WithTemplateVariables';\nexport * from './WithTimeRange';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './WithDataQueries';\nexport * from './WithPluginRegistry';\nexport * from './WithPluginSystemDatasourceStore';\nexport * from './WithPluginSystemTemplateVariables';\nexport * from './WithTimeRange';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/plugin-system",
3
- "version": "0.30.0",
3
+ "version": "0.32.0",
4
4
  "description": "The plugin feature in Pereses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -28,14 +28,14 @@
28
28
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
29
29
  },
30
30
  "dependencies": {
31
- "@perses-dev/components": "0.30.0",
32
- "@perses-dev/core": "0.30.0",
31
+ "@perses-dev/components": "0.32.0",
32
+ "@perses-dev/core": "0.32.0",
33
33
  "immer": "^9.0.15",
34
34
  "use-immer": "^0.7.0",
35
35
  "use-query-params": "^2.1.2"
36
36
  },
37
37
  "devDependencies": {
38
- "@perses-dev/storybook": "0.30.0"
38
+ "@perses-dev/storybook": "0.32.0"
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@mui/material": "^5.10.0",
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import { DatasourceStore } from '@perses-dev/plugin-system';
3
- import { StoryFn, StoryContext } from '@storybook/react';
4
- export declare type WithDatasourceStoreParameter = {
5
- props: DatasourceStore;
6
- };
7
- export declare const WithDatasourceStore: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
8
- //# sourceMappingURL=WithDatasourceStore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WithDatasourceStore.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithDatasourceStore.tsx"],"names":[],"mappings":";AAcA,OAAO,EAA0B,eAAe,EAAqB,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzD,oBAAY,4BAA4B,GAAG;IACzC,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAWF,eAAO,MAAM,mBAAmB,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAuDjF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithDatasourceStore.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { DatasourceStoreContext, DatasourceStore, usePluginRegistry } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\nexport type WithDatasourceStoreParameter = {\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 | WithDatasourceStoreParameter\n): parameter is WithDatasourceStoreParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\nexport const WithDatasourceStore = (Story: StoryFn, context: StoryContext<unknown>) => {\n const { getPlugin } = usePluginRegistry();\n\n const initParameter = context.parameters.WithDatasourceStore;\n\n // This currently provides a very simplified default to enable use in some\n // basic stories. It likely will need expanding in the future.\n // In general, `plugin-system` would probably benefit from a provider wrapper\n // for `DatasourceStoreContext` that is more generic than the one available\n // in in the `dashboard` package for non-dashboard use cases.\n const defaultValue: DatasourceStore = {\n getDatasource: (selector) => {\n if (selector.kind === 'PrometheusDatasource') {\n return Promise.resolve({\n default: true,\n plugin: {\n kind: 'PrometheusDatasource',\n spec: {},\n },\n });\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);\n },\n getDatasourceClient: async <Client,>(selector: DatasourceSelector) => {\n if (selector.kind === 'PrometheusDatasource') {\n const plugin = await getPlugin('Datasource', 'PrometheusDatasource');\n const client = plugin.createClient(\n { direct_url: prometheusDemoUrl },\n { proxyUrl: prometheusDemoUrl }\n ) as Client;\n return client;\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);\n },\n listDatasourceMetadata: async (datasourcePluginKind) => {\n if (datasourcePluginKind === 'PrometheusDatasource') {\n return Promise.resolve([\n {\n name: 'PrometheusDatasource',\n selector: { kind: 'PrometheusDatasource' },\n },\n ]);\n }\n throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginKind}`);\n },\n };\n\n const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : { props: defaultValue };\n const props = parameter?.props;\n\n return (\n <DatasourceStoreContext.Provider value={props}>\n <Story />\n </DatasourceStoreContext.Provider>\n );\n};\n"],"names":["DatasourceStoreContext","usePluginRegistry","prometheusDemoUrl","isWithDatastoreStoreParameter","parameter","WithDatasourceStore","Story","context","getPlugin","initParameter","parameters","defaultValue","getDatasource","selector","kind","Promise","resolve","default","plugin","spec","Error","getDatasourceClient","client","createClient","direct_url","proxyUrl","listDatasourceMetadata","datasourcePluginKind","name","props","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,sBAAsB,EAAmBC,iBAAiB,QAAQ,2BAA2B,CAAC;AAOvG,MAAMC,iBAAiB,GAAG,0CAA0C,AAAC;AAErE,yDAAyD;AACzD,SAASC,6BAA6B,CACpCC,SAAiD,EACN;IAC3C,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,OAAO,MAAMC,mBAAmB,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACrF,MAAM,EAAEC,SAAS,CAAA,EAAE,GAAGP,iBAAiB,EAAE,AAAC;IAE1C,MAAMQ,aAAa,GAAGF,OAAO,CAACG,UAAU,CAACL,mBAAmB,AAAC;IAE7D,0EAA0E;IAC1E,8DAA8D;IAC9D,6EAA6E;IAC7E,2EAA2E;IAC3E,6DAA6D;IAC7D,MAAMM,YAAY,GAAoB;QACpCC,aAAa,EAAE,CAACC,QAAQ,GAAK;YAC3B,IAAIA,QAAQ,CAACC,IAAI,KAAK,sBAAsB,EAAE;gBAC5C,OAAOC,OAAO,CAACC,OAAO,CAAC;oBACrBC,OAAO,EAAE,IAAI;oBACbC,MAAM,EAAE;wBACNJ,IAAI,EAAE,sBAAsB;wBAC5BK,IAAI,EAAE,EAAE;qBACT;iBACF,CAAC,CAAC;YACL,CAAC;YACD,MAAM,IAAIC,KAAK,CAAC,CAAC,uDAAuD,EAAEP,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7F,CAAC;QACDO,mBAAmB,EAAE,OAAgBR,QAA4B,GAAK;YACpE,IAAIA,QAAQ,CAACC,IAAI,KAAK,sBAAsB,EAAE;gBAC5C,MAAMI,MAAM,GAAG,MAAMV,SAAS,CAAC,YAAY,EAAE,sBAAsB,CAAC,AAAC;gBACrE,MAAMc,MAAM,GAAGJ,MAAM,CAACK,YAAY,CAChC;oBAAEC,UAAU,EAAEtB,iBAAiB;iBAAE,EACjC;oBAAEuB,QAAQ,EAAEvB,iBAAiB;iBAAE,CAChC,AAAU,AAAC;gBACZ,OAAOoB,MAAM,CAAC;YAChB,CAAC;YACD,MAAM,IAAIF,KAAK,CAAC,CAAC,uDAAuD,EAAEP,QAAQ,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7F,CAAC;QACDY,sBAAsB,EAAE,OAAOC,oBAAoB,GAAK;YACtD,IAAIA,oBAAoB,KAAK,sBAAsB,EAAE;gBACnD,OAAOZ,OAAO,CAACC,OAAO,CAAC;oBACrB;wBACEY,IAAI,EAAE,sBAAsB;wBAC5Bf,QAAQ,EAAE;4BAAEC,IAAI,EAAE,sBAAsB;yBAAE;qBAC3C;iBACF,CAAC,CAAC;YACL,CAAC;YACD,MAAM,IAAIM,KAAK,CAAC,CAAC,uDAAuD,EAAEO,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACpG,CAAC;KACF,AAAC;IAEF,MAAMvB,SAAS,GAAGD,6BAA6B,CAACM,aAAa,CAAC,GAAGA,aAAa,GAAG;QAAEoB,KAAK,EAAElB,YAAY;KAAE,AAAC;IACzG,MAAMkB,KAAK,GAAGzB,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAEyB,KAAK,AAAC;IAE/B,qBACE,KAAC7B,sBAAsB,CAAC8B,QAAQ;QAACC,KAAK,EAAEF,KAAK;kBAC3C,cAAA,KAACvB,KAAK,KAAG;MACuB,CAClC;AACJ,CAAC,CAAC"}
@@ -1,8 +0,0 @@
1
- /// <reference types="react" />
2
- import { StoryFn, StoryContext } from '@storybook/react';
3
- import { TemplateVariableSrv } from '../../../runtime';
4
- export declare type WithTemplateVariableParameter = {
5
- props: TemplateVariableSrv;
6
- };
7
- export declare const WithTemplateVariables: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
8
- //# sourceMappingURL=WithTemplateVariables.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WithTemplateVariables.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithTemplateVariables.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAA2B,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEhF,oBAAY,6BAA6B,GAAG;IAC1C,KAAK,EAAE,mBAAmB,CAAC;CAC5B,CAAC;AAYF,eAAO,MAAM,qBAAqB,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAcnF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithTemplateVariables.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StoryFn, StoryContext } from '@storybook/react';\nimport { TemplateVariableContext, TemplateVariableSrv } from '../../../runtime';\n\nexport type WithTemplateVariableParameter = {\n props: TemplateVariableSrv;\n};\n\n// Type guard because storybook types parameters as `any`\nfunction isWithTemplateVariableParameter(\n parameter: unknown | WithTemplateVariableParameter\n): parameter is WithTemplateVariableParameter {\n return !!parameter && typeof parameter === 'object' && 'props' in parameter;\n}\n\n// This decorator is used for non-dashboards package template variable needs.\n// Use the more specific decorator in the dashboards package when working with\n// dashboards.\nexport const WithTemplateVariables = (Story: StoryFn, context: StoryContext<unknown>) => {\n const initParameter = context.parameters.withTemplateVariables;\n const defaultValue: TemplateVariableSrv = {\n state: {},\n };\n const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : { props: defaultValue };\n\n const props = parameter?.props;\n\n return (\n <TemplateVariableContext.Provider value={props}>\n <Story />\n </TemplateVariableContext.Provider>\n );\n};\n"],"names":["TemplateVariableContext","isWithTemplateVariableParameter","parameter","WithTemplateVariables","Story","context","initParameter","parameters","withTemplateVariables","defaultValue","state","props","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SAASA,uBAAuB,QAA6B,kBAAkB,CAAC;AAMhF,yDAAyD;AACzD,SAASC,+BAA+B,CACtCC,SAAkD,EACN;IAC5C,OAAO,CAAC,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,OAAO,IAAIA,SAAS,CAAC;AAC9E,CAAC;AAED,6EAA6E;AAC7E,8EAA8E;AAC9E,cAAc;AACd,OAAO,MAAMC,qBAAqB,GAAG,CAACC,KAAc,EAAEC,OAA8B,GAAK;IACvF,MAAMC,aAAa,GAAGD,OAAO,CAACE,UAAU,CAACC,qBAAqB,AAAC;IAC/D,MAAMC,YAAY,GAAwB;QACxCC,KAAK,EAAE,EAAE;KACV,AAAC;IACF,MAAMR,SAAS,GAAGD,+BAA+B,CAACK,aAAa,CAAC,GAAGA,aAAa,GAAG;QAAEK,KAAK,EAAEF,YAAY;KAAE,AAAC;IAE3G,MAAME,KAAK,GAAGT,SAAS,aAATA,SAAS,WAAO,GAAhBA,KAAAA,CAAgB,GAAhBA,SAAS,CAAES,KAAK,AAAC;IAE/B,qBACE,KAACX,uBAAuB,CAACY,QAAQ;QAACC,KAAK,EAAEF,KAAK;kBAC5C,cAAA,KAACP,KAAK,KAAG;MACwB,CACnC;AACJ,CAAC,CAAC"}