@perses-dev/plugin-system 0.0.0-snapshot-color-palette-gen-test-0ebddd6 → 0.0.0-snapshot-tooltip-highlight-c995fc8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +75 -0
  2. package/dist/cjs/components/PanelSpecEditor/index.js +28 -0
  3. package/dist/cjs/components/PluginEditor/PluginEditor.js +2 -2
  4. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +27 -6
  5. package/dist/cjs/components/{PluginKindSelect.js → PluginKindSelect/PluginKindSelect.js} +1 -1
  6. package/dist/cjs/components/PluginKindSelect/index.js +28 -0
  7. package/dist/cjs/components/{PluginSpecEditor.js → PluginSpecEditor/PluginSpecEditor.js} +2 -30
  8. package/dist/cjs/components/PluginSpecEditor/index.js +28 -0
  9. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +142 -0
  10. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +94 -0
  11. package/dist/cjs/components/TimeSeriesQueryEditor/index.js +28 -0
  12. package/dist/cjs/components/index.js +1 -0
  13. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +88 -0
  14. package/dist/cjs/runtime/DataQueriesProvider/index.js +29 -0
  15. package/dist/cjs/runtime/DataQueriesProvider/model.js +16 -0
  16. package/dist/cjs/runtime/index.js +1 -0
  17. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +39 -0
  18. package/dist/cjs/stories/shared-utils/decorators/WithDatasourceStore.js +83 -0
  19. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +94 -0
  20. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +38 -0
  21. package/dist/cjs/stories/shared-utils/decorators/index.js +31 -0
  22. package/dist/cjs/stories/shared-utils/index.js +28 -0
  23. package/dist/cjs/test/render.js +4 -1
  24. package/dist/cjs/test/test-plugins/bert/index.js +27 -20
  25. package/dist/cjs/test/test-plugins/ernie/index.js +37 -4
  26. package/dist/cjs/test-utils/mock-plugin-registry.js +4 -1
  27. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +10 -0
  28. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -0
  29. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +69 -0
  30. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -0
  31. package/dist/components/PanelSpecEditor/index.d.ts +2 -0
  32. package/dist/components/PanelSpecEditor/index.d.ts.map +1 -0
  33. package/dist/components/PanelSpecEditor/index.js +15 -0
  34. package/dist/components/PanelSpecEditor/index.js.map +1 -0
  35. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  36. package/dist/components/PluginEditor/PluginEditor.js +2 -2
  37. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  38. package/dist/components/PluginEditor/plugin-editor-api.d.ts +4 -1
  39. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  40. package/dist/components/PluginEditor/plugin-editor-api.js +27 -6
  41. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  42. package/dist/components/{PluginKindSelect.d.ts → PluginKindSelect/PluginKindSelect.d.ts} +1 -1
  43. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -0
  44. package/dist/components/{PluginKindSelect.js → PluginKindSelect/PluginKindSelect.js} +1 -1
  45. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -0
  46. package/dist/components/PluginKindSelect/index.d.ts +2 -0
  47. package/dist/components/PluginKindSelect/index.d.ts.map +1 -0
  48. package/dist/components/PluginKindSelect/index.js +15 -0
  49. package/dist/components/PluginKindSelect/index.js.map +1 -0
  50. package/dist/components/PluginRegistry/PluginRegistry.d.ts +2 -2
  51. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  52. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  53. package/dist/components/{PluginSpecEditor.d.ts → PluginSpecEditor/PluginSpecEditor.d.ts} +1 -1
  54. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -0
  55. package/dist/components/{PluginSpecEditor.js → PluginSpecEditor/PluginSpecEditor.js} +3 -31
  56. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -0
  57. package/dist/components/PluginSpecEditor/index.d.ts +2 -0
  58. package/dist/components/PluginSpecEditor/index.d.ts.map +1 -0
  59. package/dist/components/PluginSpecEditor/index.js +15 -0
  60. package/dist/components/PluginSpecEditor/index.js.map +1 -0
  61. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +8 -0
  62. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -0
  63. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +131 -0
  64. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -0
  65. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +13 -0
  66. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +1 -0
  67. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +83 -0
  68. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -0
  69. package/dist/components/TimeSeriesQueryEditor/index.d.ts +2 -0
  70. package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +1 -0
  71. package/dist/components/TimeSeriesQueryEditor/index.js +15 -0
  72. package/dist/components/TimeSeriesQueryEditor/index.js.map +1 -0
  73. package/dist/components/index.d.ts +1 -0
  74. package/dist/components/index.d.ts.map +1 -1
  75. package/dist/components/index.js +1 -0
  76. package/dist/components/index.js.map +1 -1
  77. package/dist/model/panels.d.ts +6 -5
  78. package/dist/model/panels.d.ts.map +1 -1
  79. package/dist/model/panels.js.map +1 -1
  80. package/dist/model/plugin-base.d.ts +7 -0
  81. package/dist/model/plugin-base.d.ts.map +1 -1
  82. package/dist/model/plugin-base.js.map +1 -1
  83. package/dist/model/plugins.d.ts +3 -1
  84. package/dist/model/plugins.d.ts.map +1 -1
  85. package/dist/model/plugins.js.map +1 -1
  86. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +8 -0
  87. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -0
  88. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +74 -0
  89. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -0
  90. package/dist/runtime/DataQueriesProvider/index.d.ts +3 -0
  91. package/dist/runtime/DataQueriesProvider/index.d.ts.map +1 -0
  92. package/dist/runtime/DataQueriesProvider/index.js +16 -0
  93. package/dist/runtime/DataQueriesProvider/index.js.map +1 -0
  94. package/dist/runtime/DataQueriesProvider/model.d.ts +27 -0
  95. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -0
  96. package/dist/runtime/DataQueriesProvider/model.js +15 -0
  97. package/dist/runtime/DataQueriesProvider/model.js.map +1 -0
  98. package/dist/runtime/index.d.ts +1 -0
  99. package/dist/runtime/index.d.ts.map +1 -1
  100. package/dist/runtime/index.js +1 -0
  101. package/dist/runtime/index.js.map +1 -1
  102. package/dist/runtime/plugin-registry.d.ts +1 -1
  103. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  104. package/dist/runtime/plugin-registry.js.map +1 -1
  105. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +8 -0
  106. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -0
  107. package/dist/stories/shared-utils/decorators/WithDataQueries.js +33 -0
  108. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -0
  109. package/dist/stories/shared-utils/decorators/WithDatasourceStore.d.ts +8 -0
  110. package/dist/stories/shared-utils/decorators/WithDatasourceStore.d.ts.map +1 -0
  111. package/dist/stories/shared-utils/decorators/WithDatasourceStore.js +77 -0
  112. package/dist/stories/shared-utils/decorators/WithDatasourceStore.js.map +1 -0
  113. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +4 -0
  114. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -0
  115. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +49 -0
  116. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -0
  117. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +8 -0
  118. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -0
  119. package/dist/stories/shared-utils/decorators/WithTimeRange.js +32 -0
  120. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -0
  121. package/dist/stories/shared-utils/decorators/index.d.ts +5 -0
  122. package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -0
  123. package/dist/stories/shared-utils/decorators/index.js +18 -0
  124. package/dist/stories/shared-utils/decorators/index.js.map +1 -0
  125. package/dist/stories/shared-utils/index.d.ts +2 -0
  126. package/dist/stories/shared-utils/index.d.ts.map +1 -0
  127. package/dist/stories/shared-utils/index.js +15 -0
  128. package/dist/stories/shared-utils/index.js.map +1 -0
  129. package/dist/test/render.d.ts.map +1 -1
  130. package/dist/test/render.js +4 -1
  131. package/dist/test/render.js.map +1 -1
  132. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  133. package/dist/test/test-plugins/bert/index.js +27 -20
  134. package/dist/test/test-plugins/bert/index.js.map +1 -1
  135. package/dist/test/test-plugins/ernie/index.d.ts +4 -1
  136. package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
  137. package/dist/test/test-plugins/ernie/index.js +28 -1
  138. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  139. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  140. package/dist/test-utils/mock-plugin-registry.js +4 -1
  141. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  142. package/package.json +6 -3
  143. package/dist/cjs/components/TimeSeriesQueryEditor.js +0 -42
  144. package/dist/components/PluginKindSelect.d.ts.map +0 -1
  145. package/dist/components/PluginKindSelect.js.map +0 -1
  146. package/dist/components/PluginSpecEditor.d.ts.map +0 -1
  147. package/dist/components/PluginSpecEditor.js.map +0 -1
  148. package/dist/components/TimeSeriesQueryEditor.d.ts +0 -14
  149. package/dist/components/TimeSeriesQueryEditor.d.ts.map +0 -1
  150. package/dist/components/TimeSeriesQueryEditor.js +0 -38
  151. package/dist/components/TimeSeriesQueryEditor.js.map +0 -1
@@ -0,0 +1,33 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { DataQueriesProvider } from '@perses-dev/plugin-system';
15
+ // Type guard because storybook types parameters as `any`
16
+ function isWithDataQueriesParameter(parameter) {
17
+ return !!parameter && typeof parameter === 'object' && 'props' in parameter;
18
+ }
19
+ export const WithDataQueries = (Story, context)=>{
20
+ const initParameter = context.parameters.WithDataQueries;
21
+ const parameter = isWithDataQueriesParameter(initParameter) ? initParameter : {
22
+ props: {
23
+ definitions: []
24
+ }
25
+ };
26
+ const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
27
+ return /*#__PURE__*/ _jsx(DataQueriesProvider, {
28
+ ...props,
29
+ children: /*#__PURE__*/ _jsx(Story, {})
30
+ });
31
+ };
32
+
33
+ //# sourceMappingURL=WithDataQueries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithDataQueries.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from '@perses-dev/core';\nimport { DataQueriesProvider, DataQueriesProviderProps } from '@perses-dev/plugin-system';\nimport { StoryFn, StoryContext } from '@storybook/react';\n\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"}
@@ -0,0 +1,8 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,77 @@
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
+ export const WithDatasourceStore = (Story, context)=>{
21
+ const { getPlugin } = usePluginRegistry();
22
+ const initParameter = context.parameters.WithDataQueries;
23
+ // This currently provides a very simplified default to enable use in some
24
+ // basic stories. It likely will need expanding in the future.
25
+ // In general, `plugin-system` would probably benefit from a provider wrapper
26
+ // for `DatasourceStoreContext` that is more generic than the one available
27
+ // in in the `dashboard` package for non-dashboard use cases.
28
+ const defaultValue = {
29
+ getDatasource: (selector)=>{
30
+ if (selector.kind === 'PrometheusDatasource') {
31
+ return Promise.resolve({
32
+ default: true,
33
+ plugin: {
34
+ kind: 'PrometheusDatasource',
35
+ spec: {}
36
+ }
37
+ });
38
+ }
39
+ throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
40
+ },
41
+ getDatasourceClient: async (selector)=>{
42
+ if (selector.kind === 'PrometheusDatasource') {
43
+ const plugin = await getPlugin('Datasource', 'PrometheusDatasource');
44
+ const client = plugin.createClient({
45
+ direct_url: prometheusDemoUrl
46
+ }, {
47
+ proxyUrl: prometheusDemoUrl
48
+ });
49
+ return client;
50
+ }
51
+ throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
52
+ },
53
+ listDatasourceMetadata: async (datasourcePluginKind)=>{
54
+ if (datasourcePluginKind === 'PrometheusDatasource') {
55
+ return Promise.resolve([
56
+ {
57
+ name: 'PrometheusDatasource',
58
+ selector: {
59
+ kind: 'PrometheusDatasource'
60
+ }
61
+ }
62
+ ]);
63
+ }
64
+ throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginKind}`);
65
+ }
66
+ };
67
+ const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : {
68
+ props: defaultValue
69
+ };
70
+ const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
71
+ return /*#__PURE__*/ _jsx(DatasourceStoreContext.Provider, {
72
+ value: props,
73
+ children: /*#__PURE__*/ _jsx(Story, {})
74
+ });
75
+ };
76
+
77
+ //# sourceMappingURL=WithDatasourceStore.js.map
@@ -0,0 +1 @@
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.WithDataQueries;\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","WithDataQueries","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,CAACC,eAAe,AAAC;IAEzD,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,4 @@
1
+ /// <reference types="react" />
2
+ import { StoryFn } from '@storybook/react';
3
+ export declare const WithPluginRegistry: (Story: StoryFn) => JSX.Element;
4
+ //# sourceMappingURL=WithPluginRegistry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithPluginRegistry.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithPluginRegistry.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAkC3C,eAAO,MAAM,kBAAkB,UAAW,OAAO,gBAShD,CAAC"}
@@ -0,0 +1,49 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { PluginRegistry, dynamicImportPluginLoader } from '@perses-dev/plugin-system';
15
+ // NOTE: the aliases we use for components break these top level imports, so we
16
+ // import relatively.
17
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
18
+ const prometheusResource = require('../../../../../prometheus-plugin/plugin.json');
19
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
20
+ const panelsResource = require('../../../../../panels-plugin/plugin.json');
21
+ const bundledPluginLoader = dynamicImportPluginLoader([
22
+ {
23
+ resource: prometheusResource,
24
+ // This throws an error in CI (but not locally for some reason), likely because
25
+ // this package isn't a dependency for dashboards. We probably do not want to
26
+ // make it one solely for type-checking in storybook.
27
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
28
+ // @ts-ignore
29
+ importPlugin: ()=>import('@perses-dev/prometheus-plugin')
30
+ },
31
+ {
32
+ resource: panelsResource,
33
+ // Same comment as above.
34
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
35
+ // @ts-ignore
36
+ importPlugin: ()=>import('@perses-dev/panels-plugin')
37
+ }
38
+ ]);
39
+ export const WithPluginRegistry = (Story)=>{
40
+ return /*#__PURE__*/ _jsx(PluginRegistry, {
41
+ pluginLoader: bundledPluginLoader,
42
+ defaultPluginKinds: {
43
+ TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
44
+ },
45
+ children: /*#__PURE__*/ _jsx(Story, {})
46
+ });
47
+ };
48
+
49
+ //# sourceMappingURL=WithPluginRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithPluginRegistry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StoryFn } from '@storybook/react';\nimport {\n PluginRegistry,\n PluginLoader,\n PluginModuleResource,\n dynamicImportPluginLoader,\n} from '@perses-dev/plugin-system';\n\n// NOTE: the aliases we use for components break these top level imports, so we\n// import relatively.\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst prometheusResource = require('../../../../../prometheus-plugin/plugin.json');\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst panelsResource = require('../../../../../panels-plugin/plugin.json');\n\nconst bundledPluginLoader: PluginLoader = dynamicImportPluginLoader([\n {\n resource: prometheusResource as PluginModuleResource,\n // This throws an error in CI (but not locally for some reason), likely because\n // this package isn't a dependency for dashboards. We probably do not want to\n // make it one solely for type-checking in storybook.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n importPlugin: () => import('@perses-dev/prometheus-plugin'),\n },\n {\n resource: panelsResource as PluginModuleResource,\n // Same comment as above.\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n importPlugin: () => import('@perses-dev/panels-plugin'),\n },\n]);\n\nexport const WithPluginRegistry = (Story: StoryFn) => {\n return (\n <PluginRegistry\n pluginLoader={bundledPluginLoader}\n defaultPluginKinds={{ TimeSeriesQuery: 'PrometheusTimeSeriesQuery' }}\n >\n <Story />\n </PluginRegistry>\n );\n};\n"],"names":["PluginRegistry","dynamicImportPluginLoader","prometheusResource","require","panelsResource","bundledPluginLoader","resource","importPlugin","WithPluginRegistry","Story","pluginLoader","defaultPluginKinds","TimeSeriesQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AACA,SACEA,cAAc,EAGdC,yBAAyB,QACpB,2BAA2B,CAAC;AAEnC,+EAA+E;AAC/E,qBAAqB;AACrB,8DAA8D;AAC9D,MAAMC,kBAAkB,GAAGC,OAAO,CAAC,8CAA8C,CAAC,AAAC;AACnF,8DAA8D;AAC9D,MAAMC,cAAc,GAAGD,OAAO,CAAC,0CAA0C,CAAC,AAAC;AAE3E,MAAME,mBAAmB,GAAiBJ,yBAAyB,CAAC;IAClE;QACEK,QAAQ,EAAEJ,kBAAkB;QAC5B,+EAA+E;QAC/E,6EAA6E;QAC7E,qDAAqD;QACrD,6DAA6D;QAC7D,aAAa;QACbK,YAAY,EAAE,IAAM,MAAM,CAAC,+BAA+B,CAAC;KAC5D;IACD;QACED,QAAQ,EAAEF,cAAc;QACxB,yBAAyB;QACzB,6DAA6D;QAC7D,aAAa;QACbG,YAAY,EAAE,IAAM,MAAM,CAAC,2BAA2B,CAAC;KACxD;CACF,CAAC,AAAC;AAEH,OAAO,MAAMC,kBAAkB,GAAG,CAACC,KAAc,GAAK;IACpD,qBACE,KAACT,cAAc;QACbU,YAAY,EAAEL,mBAAmB;QACjCM,kBAAkB,EAAE;YAAEC,eAAe,EAAE,2BAA2B;SAAE;kBAEpE,cAAA,KAACH,KAAK,KAAG;MACM,CACjB;AACJ,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { StoryFn, StoryContext } from '@storybook/react';
3
+ import { TimeRangeProviderProps } from '@perses-dev/plugin-system';
4
+ export declare type WithTimeRangeParameter = {
5
+ props: Partial<TimeRangeProviderProps>;
6
+ };
7
+ export declare const WithTimeRange: (Story: StoryFn, context: StoryContext<unknown>) => JSX.Element;
8
+ //# sourceMappingURL=WithTimeRange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WithTimeRange.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/WithTimeRange.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAqB,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEtF,oBAAY,sBAAsB,GAAG;IACnC,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACxC,CAAC;AAOF,eAAO,MAAM,aAAa,UAAW,OAAO,WAAW,aAAa,OAAO,CAAC,gBAU3E,CAAC"}
@@ -0,0 +1,32 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { TimeRangeProvider } from '@perses-dev/plugin-system';
15
+ // Type guard because storybook types parameters as `any`
16
+ function isWithTimeRangeParameter(parameter) {
17
+ return !!parameter && typeof parameter === 'object' && 'props' in parameter;
18
+ }
19
+ export const WithTimeRange = (Story, context)=>{
20
+ const initParameter = context.parameters.withTimeRange;
21
+ const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;
22
+ const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
23
+ return /*#__PURE__*/ _jsx(TimeRangeProvider, {
24
+ initialTimeRange: {
25
+ pastDuration: '1h'
26
+ },
27
+ ...props,
28
+ children: /*#__PURE__*/ _jsx(Story, {})
29
+ });
30
+ };
31
+
32
+ //# sourceMappingURL=WithTimeRange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/WithTimeRange.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { StoryFn, StoryContext } from '@storybook/react';\nimport { TimeRangeProvider, TimeRangeProviderProps } from '@perses-dev/plugin-system';\n\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"}
@@ -0,0 +1,5 @@
1
+ export * from './WithDataQueries';
2
+ export * from './WithDatasourceStore';
3
+ export * from './WithPluginRegistry';
4
+ export * from './WithTimeRange';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/stories/shared-utils/decorators/index.ts"],"names":[],"mappings":"AAaA,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,18 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './WithDataQueries';
14
+ export * from './WithDatasourceStore';
15
+ export * from './WithPluginRegistry';
16
+ export * from './WithTimeRange';
17
+
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/stories/shared-utils/decorators/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './WithDataQueries';\nexport * from './WithDatasourceStore';\nexport * from './WithPluginRegistry';\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,iBAAiB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './decorators';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stories/shared-utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ export * from './decorators';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/stories/shared-utils/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './decorators';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAW9C,aAAK,cAAc,GAAG;IACpB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,KAAK,CAAC,SAAS,EACnB,aAAa,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAC9C,cAAc,CAAC,EAAE,cAAc,gIAehC"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAW9C,aAAK,cAAc,GAAG;IACpB,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,KAAK,CAAC,SAAS,EACnB,aAAa,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EAC9C,cAAc,CAAC,EAAE,cAAc,gIAsBhC"}
@@ -36,11 +36,14 @@ const testLogger = {
36
36
  },
37
37
  logger: testLogger
38
38
  });
39
+ var ref;
39
40
  return render(/*#__PURE__*/ _jsx(QueryClientProvider, {
40
41
  client: queryClient,
41
42
  children: /*#__PURE__*/ _jsx(PluginRegistry, {
42
43
  pluginLoader: testPluginLoader,
43
- defaultPluginKinds: contextOptions === null || contextOptions === void 0 ? void 0 : contextOptions.defaultPluginKinds,
44
+ defaultPluginKinds: (ref = contextOptions === null || contextOptions === void 0 ? void 0 : contextOptions.defaultPluginKinds) !== null && ref !== void 0 ? ref : {
45
+ TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
46
+ },
44
47
  children: ui
45
48
  })
46
49
  }), renderOptions);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/render.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 { render, RenderOptions } from '@testing-library/react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { PluginRegistry } from '../components/PluginRegistry';\nimport { DefaultPluginKinds } from '../model';\nimport { testPluginLoader } from './test-plugins';\n\nconst testLogger = {\n log: console.log,\n warn: console.warn,\n error: () => {\n // Don't log network errors in tests to the console\n },\n};\n\ntype ContextOptions = {\n defaultPluginKinds?: DefaultPluginKinds;\n};\n\n/**\n * Test helper to render a React component with some common app-level providers, as well as the PluginRegistry\n * wrapped around it.\n */\nexport function renderWithContext(\n ui: React.ReactNode,\n renderOptions?: Omit<RenderOptions, 'queries'>,\n contextOptions?: ContextOptions\n) {\n // Create a new QueryClient for each test to avoid caching issues\n const queryClient = new QueryClient({\n defaultOptions: { queries: { refetchOnWindowFocus: false, retry: false } },\n logger: testLogger,\n });\n return render(\n <QueryClientProvider client={queryClient}>\n <PluginRegistry pluginLoader={testPluginLoader} defaultPluginKinds={contextOptions?.defaultPluginKinds}>\n {ui}\n </PluginRegistry>\n </QueryClientProvider>,\n renderOptions\n );\n}\n"],"names":["render","QueryClient","QueryClientProvider","PluginRegistry","testPluginLoader","testLogger","log","console","warn","error","renderWithContext","ui","renderOptions","contextOptions","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","logger","client","pluginLoader","defaultPluginKinds"],"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,MAAM,QAAuB,wBAAwB,CAAC;AAC/D,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,uBAAuB,CAAC;AACzE,SAASC,cAAc,QAAQ,8BAA8B,CAAC;AAE9D,SAASC,gBAAgB,QAAQ,gBAAgB,CAAC;AAElD,MAAMC,UAAU,GAAG;IACjBC,GAAG,EAAEC,OAAO,CAACD,GAAG;IAChBE,IAAI,EAAED,OAAO,CAACC,IAAI;IAClBC,KAAK,EAAE,IAAM;IACX,mDAAmD;IACrD,CAAC;CACF,AAAC;AAMF;;;CAGC,GACD,OAAO,SAASC,iBAAiB,CAC/BC,EAAmB,EACnBC,aAA8C,EAC9CC,cAA+B,EAC/B;IACA,iEAAiE;IACjE,MAAMC,WAAW,GAAG,IAAIb,WAAW,CAAC;QAClCc,cAAc,EAAE;YAAEC,OAAO,EAAE;gBAAEC,oBAAoB,EAAE,KAAK;gBAAEC,KAAK,EAAE,KAAK;aAAE;SAAE;QAC1EC,MAAM,EAAEd,UAAU;KACnB,CAAC,AAAC;IACH,OAAOL,MAAM,eACX,KAACE,mBAAmB;QAACkB,MAAM,EAAEN,WAAW;kBACtC,cAAA,KAACX,cAAc;YAACkB,YAAY,EAAEjB,gBAAgB;YAAEkB,kBAAkB,EAAET,cAAc,aAAdA,cAAc,WAAoB,GAAlCA,KAAAA,CAAkC,GAAlCA,cAAc,CAAES,kBAAkB;sBACnGX,EAAE;UACY;MACG,EACtBC,aAAa,CACd,CAAC;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/test/render.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 { render, RenderOptions } from '@testing-library/react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { PluginRegistry } from '../components/PluginRegistry';\nimport { DefaultPluginKinds } from '../model';\nimport { testPluginLoader } from './test-plugins';\n\nconst testLogger = {\n log: console.log,\n warn: console.warn,\n error: () => {\n // Don't log network errors in tests to the console\n },\n};\n\ntype ContextOptions = {\n defaultPluginKinds?: DefaultPluginKinds;\n};\n\n/**\n * Test helper to render a React component with some common app-level providers, as well as the PluginRegistry\n * wrapped around it.\n */\nexport function renderWithContext(\n ui: React.ReactNode,\n renderOptions?: Omit<RenderOptions, 'queries'>,\n contextOptions?: ContextOptions\n) {\n // Create a new QueryClient for each test to avoid caching issues\n const queryClient = new QueryClient({\n defaultOptions: { queries: { refetchOnWindowFocus: false, retry: false } },\n logger: testLogger,\n });\n return render(\n <QueryClientProvider client={queryClient}>\n <PluginRegistry\n pluginLoader={testPluginLoader}\n defaultPluginKinds={\n contextOptions?.defaultPluginKinds ?? {\n TimeSeriesQuery: 'PrometheusTimeSeriesQuery',\n }\n }\n >\n {ui}\n </PluginRegistry>\n </QueryClientProvider>,\n renderOptions\n );\n}\n"],"names":["render","QueryClient","QueryClientProvider","PluginRegistry","testPluginLoader","testLogger","log","console","warn","error","renderWithContext","ui","renderOptions","contextOptions","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","logger","client","pluginLoader","defaultPluginKinds","TimeSeriesQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,MAAM,QAAuB,wBAAwB,CAAC;AAC/D,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,uBAAuB,CAAC;AACzE,SAASC,cAAc,QAAQ,8BAA8B,CAAC;AAE9D,SAASC,gBAAgB,QAAQ,gBAAgB,CAAC;AAElD,MAAMC,UAAU,GAAG;IACjBC,GAAG,EAAEC,OAAO,CAACD,GAAG;IAChBE,IAAI,EAAED,OAAO,CAACC,IAAI;IAClBC,KAAK,EAAE,IAAM;IACX,mDAAmD;IACrD,CAAC;CACF,AAAC;AAMF;;;CAGC,GACD,OAAO,SAASC,iBAAiB,CAC/BC,EAAmB,EACnBC,aAA8C,EAC9CC,cAA+B,EAC/B;IACA,iEAAiE;IACjE,MAAMC,WAAW,GAAG,IAAIb,WAAW,CAAC;QAClCc,cAAc,EAAE;YAAEC,OAAO,EAAE;gBAAEC,oBAAoB,EAAE,KAAK;gBAAEC,KAAK,EAAE,KAAK;aAAE;SAAE;QAC1EC,MAAM,EAAEd,UAAU;KACnB,CAAC,AAAC;QAMKQ,GAAkC;IAL1C,OAAOb,MAAM,eACX,KAACE,mBAAmB;QAACkB,MAAM,EAAEN,WAAW;kBACtC,cAAA,KAACX,cAAc;YACbkB,YAAY,EAAEjB,gBAAgB;YAC9BkB,kBAAkB,EAChBT,CAAAA,GAAkC,GAAlCA,cAAc,aAAdA,cAAc,WAAoB,GAAlCA,KAAAA,CAAkC,GAAlCA,cAAc,CAAES,kBAAkB,cAAlCT,GAAkC,cAAlCA,GAAkC,GAAI;gBACpCU,eAAe,EAAE,2BAA2B;aAC7C;sBAGFZ,EAAE;UACY;MACG,EACtBC,aAAa,CACd,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/test/test-plugins/bert/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAgBvD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CA2BvD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/test/test-plugins/bert/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAsB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAiBjE,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CASvD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CA4BvD,CAAC"}
@@ -11,28 +11,34 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ function BertPanel1Editor({ value , onChange }) {
15
+ return /*#__PURE__*/ _jsxs("div", {
16
+ children: [
17
+ /*#__PURE__*/ _jsx("label", {
18
+ htmlFor: "editor-input",
19
+ children: "BertPanel1 editor"
20
+ }),
21
+ /*#__PURE__*/ _jsx("input", {
22
+ type: "text",
23
+ id: "editor-input",
24
+ value: value.option1,
25
+ onChange: (e)=>onChange({
26
+ ...value,
27
+ option1: e.target.value
28
+ })
29
+ })
30
+ ]
31
+ });
32
+ }
14
33
  // Dummy plugins to test loading
15
34
  export const BertPanel1 = {
16
35
  PanelComponent: ()=>null,
17
- PanelQueryEditorComponent: function BertPanel1Editor({ value , onChange }) {
18
- return /*#__PURE__*/ _jsxs("div", {
19
- children: [
20
- /*#__PURE__*/ _jsx("label", {
21
- htmlFor: "editor-input",
22
- children: "BertPanel1 editor"
23
- }),
24
- /*#__PURE__*/ _jsx("input", {
25
- type: "text",
26
- id: "editor-input",
27
- value: value.option1,
28
- onChange: (e)=>onChange({
29
- ...value,
30
- option1: e.target.value
31
- })
32
- })
33
- ]
34
- });
35
- },
36
+ panelOptionsEditorComponents: [
37
+ {
38
+ label: 'Editor',
39
+ content: BertPanel1Editor
40
+ }
41
+ ],
36
42
  createInitialOptions: ()=>({
37
43
  option1: ''
38
44
  })
@@ -73,7 +79,8 @@ export const BertPanel2 = {
73
79
  ],
74
80
  createInitialOptions: ()=>({
75
81
  option2: ''
76
- })
82
+ }),
83
+ hideQueryEditor: true
77
84
  };
78
85
 
79
86
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/test/test-plugins/bert/index.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PanelPlugin } from '../../../model';\n\n// Dummy plugins to test loading\nexport const BertPanel1: PanelPlugin<{ option1: string }> = {\n PanelComponent: () => null,\n PanelQueryEditorComponent: function BertPanel1Editor({ value, onChange }) {\n return (\n <div>\n <label htmlFor=\"editor-input\">BertPanel1 editor</label>\n <input\n type=\"text\"\n id=\"editor-input\"\n value={value.option1}\n onChange={(e) => onChange({ ...value, option1: e.target.value })}\n />\n </div>\n );\n },\n createInitialOptions: () => ({ option1: '' }),\n};\n\nexport const BertPanel2: PanelPlugin<{ option2: string }> = {\n PanelComponent: () => null,\n panelOptionsEditorComponents: [\n {\n label: 'Settings',\n content: function BertPanel2Editor({ value, onChange }) {\n return (\n <div>\n <label htmlFor=\"editor-input\">BertPanel2 editor</label>\n <input\n type=\"text\"\n id=\"editor-input\"\n value={value.option2}\n onChange={(e) => onChange({ ...value, option2: e.target.value })}\n />\n </div>\n );\n },\n },\n {\n label: 'Custom Tab',\n content: function Editor() {\n return <div>custom content</div>;\n },\n },\n ],\n createInitialOptions: () => ({ option2: '' }),\n};\n"],"names":["BertPanel1","PanelComponent","PanelQueryEditorComponent","BertPanel1Editor","value","onChange","div","label","htmlFor","input","type","id","option1","e","target","createInitialOptions","BertPanel2","panelOptionsEditorComponents","content","BertPanel2Editor","option2","Editor"],"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;AAEA,gCAAgC;AAChC,OAAO,MAAMA,UAAU,GAAqC;IAC1DC,cAAc,EAAE,IAAM,IAAI;IAC1BC,yBAAyB,EAAE,SAASC,gBAAgB,CAAC,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAE,EAAE;QACxE,qBACE,MAACC,KAAG;;8BACF,KAACC,OAAK;oBAACC,OAAO,EAAC,cAAc;8BAAC,mBAAiB;kBAAQ;8BACvD,KAACC,OAAK;oBACJC,IAAI,EAAC,MAAM;oBACXC,EAAE,EAAC,cAAc;oBACjBP,KAAK,EAAEA,KAAK,CAACQ,OAAO;oBACpBP,QAAQ,EAAE,CAACQ,CAAC,GAAKR,QAAQ,CAAC;4BAAE,GAAGD,KAAK;4BAAEQ,OAAO,EAAEC,CAAC,CAACC,MAAM,CAACV,KAAK;yBAAE,CAAC;kBAChE;;UACE,CACN;IACJ,CAAC;IACDW,oBAAoB,EAAE,IAAO,CAAA;YAAEH,OAAO,EAAE,EAAE;SAAE,CAAA,AAAC;CAC9C,CAAC;AAEF,OAAO,MAAMI,UAAU,GAAqC;IAC1Df,cAAc,EAAE,IAAM,IAAI;IAC1BgB,4BAA4B,EAAE;QAC5B;YACEV,KAAK,EAAE,UAAU;YACjBW,OAAO,EAAE,SAASC,gBAAgB,CAAC,EAAEf,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAE,EAAE;gBACtD,qBACE,MAACC,KAAG;;sCACF,KAACC,OAAK;4BAACC,OAAO,EAAC,cAAc;sCAAC,mBAAiB;0BAAQ;sCACvD,KAACC,OAAK;4BACJC,IAAI,EAAC,MAAM;4BACXC,EAAE,EAAC,cAAc;4BACjBP,KAAK,EAAEA,KAAK,CAACgB,OAAO;4BACpBf,QAAQ,EAAE,CAACQ,CAAC,GAAKR,QAAQ,CAAC;oCAAE,GAAGD,KAAK;oCAAEgB,OAAO,EAAEP,CAAC,CAACC,MAAM,CAACV,KAAK;iCAAE,CAAC;0BAChE;;kBACE,CACN;YACJ,CAAC;SACF;QACD;YACEG,KAAK,EAAE,YAAY;YACnBW,OAAO,EAAE,SAASG,MAAM,GAAG;gBACzB,qBAAO,KAACf,KAAG;8BAAC,gBAAc;kBAAM,CAAC;YACnC,CAAC;SACF;KACF;IACDS,oBAAoB,EAAE,IAAO,CAAA;YAAEK,OAAO,EAAE,EAAE;SAAE,CAAA,AAAC;CAC9C,CAAC"}
1
+ {"version":3,"sources":["../../../../src/test/test-plugins/bert/index.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { OptionsEditorProps, PanelPlugin } from '../../../model';\n\nfunction BertPanel1Editor({ value, onChange }: OptionsEditorProps<{ option1: string }>) {\n return (\n <div>\n <label htmlFor=\"editor-input\">BertPanel1 editor</label>\n <input\n type=\"text\"\n id=\"editor-input\"\n value={value.option1}\n onChange={(e) => onChange({ ...value, option1: e.target.value })}\n />\n </div>\n );\n}\n\n// Dummy plugins to test loading\nexport const BertPanel1: PanelPlugin<{ option1: string }> = {\n PanelComponent: () => null,\n panelOptionsEditorComponents: [\n {\n label: 'Editor',\n content: BertPanel1Editor,\n },\n ],\n createInitialOptions: () => ({ option1: '' }),\n};\n\nexport const BertPanel2: PanelPlugin<{ option2: string }> = {\n PanelComponent: () => null,\n panelOptionsEditorComponents: [\n {\n label: 'Settings',\n content: function BertPanel2Editor({ value, onChange }) {\n return (\n <div>\n <label htmlFor=\"editor-input\">BertPanel2 editor</label>\n <input\n type=\"text\"\n id=\"editor-input\"\n value={value.option2}\n onChange={(e) => onChange({ ...value, option2: e.target.value })}\n />\n </div>\n );\n },\n },\n {\n label: 'Custom Tab',\n content: function Editor() {\n return <div>custom content</div>;\n },\n },\n ],\n createInitialOptions: () => ({ option2: '' }),\n hideQueryEditor: true,\n};\n"],"names":["BertPanel1Editor","value","onChange","div","label","htmlFor","input","type","id","option1","e","target","BertPanel1","PanelComponent","panelOptionsEditorComponents","content","createInitialOptions","BertPanel2","BertPanel2Editor","option2","Editor","hideQueryEditor"],"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;AAEA,SAASA,gBAAgB,CAAC,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAA2C,EAAE;IACtF,qBACE,MAACC,KAAG;;0BACF,KAACC,OAAK;gBAACC,OAAO,EAAC,cAAc;0BAAC,mBAAiB;cAAQ;0BACvD,KAACC,OAAK;gBACJC,IAAI,EAAC,MAAM;gBACXC,EAAE,EAAC,cAAc;gBACjBP,KAAK,EAAEA,KAAK,CAACQ,OAAO;gBACpBP,QAAQ,EAAE,CAACQ,CAAC,GAAKR,QAAQ,CAAC;wBAAE,GAAGD,KAAK;wBAAEQ,OAAO,EAAEC,CAAC,CAACC,MAAM,CAACV,KAAK;qBAAE,CAAC;cAChE;;MACE,CACN;AACJ,CAAC;AAED,gCAAgC;AAChC,OAAO,MAAMW,UAAU,GAAqC;IAC1DC,cAAc,EAAE,IAAM,IAAI;IAC1BC,4BAA4B,EAAE;QAC5B;YACEV,KAAK,EAAE,QAAQ;YACfW,OAAO,EAAEf,gBAAgB;SAC1B;KACF;IACDgB,oBAAoB,EAAE,IAAO,CAAA;YAAEP,OAAO,EAAE,EAAE;SAAE,CAAA,AAAC;CAC9C,CAAC;AAEF,OAAO,MAAMQ,UAAU,GAAqC;IAC1DJ,cAAc,EAAE,IAAM,IAAI;IAC1BC,4BAA4B,EAAE;QAC5B;YACEV,KAAK,EAAE,UAAU;YACjBW,OAAO,EAAE,SAASG,gBAAgB,CAAC,EAAEjB,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAE,EAAE;gBACtD,qBACE,MAACC,KAAG;;sCACF,KAACC,OAAK;4BAACC,OAAO,EAAC,cAAc;sCAAC,mBAAiB;0BAAQ;sCACvD,KAACC,OAAK;4BACJC,IAAI,EAAC,MAAM;4BACXC,EAAE,EAAC,cAAc;4BACjBP,KAAK,EAAEA,KAAK,CAACkB,OAAO;4BACpBjB,QAAQ,EAAE,CAACQ,CAAC,GAAKR,QAAQ,CAAC;oCAAE,GAAGD,KAAK;oCAAEkB,OAAO,EAAET,CAAC,CAACC,MAAM,CAACV,KAAK;iCAAE,CAAC;0BAChE;;kBACE,CACN;YACJ,CAAC;SACF;QACD;YACEG,KAAK,EAAE,YAAY;YACnBW,OAAO,EAAE,SAASK,MAAM,GAAG;gBACzB,qBAAO,KAACjB,KAAG;8BAAC,gBAAc;kBAAM,CAAC;YACnC,CAAC;SACF;KACF;IACDa,oBAAoB,EAAE,IAAO,CAAA;YAAEG,OAAO,EAAE,EAAE;SAAE,CAAA,AAAC;IAC7CE,eAAe,EAAE,IAAI;CACtB,CAAC"}
@@ -1,5 +1,8 @@
1
1
  import { VariablePlugin } from '../../../model';
2
- export declare const ErnieVariable: VariablePlugin<{
2
+ export declare const ErnieVariable1: VariablePlugin<{
3
3
  variableOption: string;
4
4
  }>;
5
+ export declare const ErnieVariable2: VariablePlugin<{
6
+ variableOption2: string;
7
+ }>;
5
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/test/test-plugins/ernie/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAkB,MAAM,gBAAgB,CAAC;AAQhE,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,CAgBpE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/test/test-plugins/ernie/index.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAkB,MAAM,gBAAgB,CAAC;AAQhE,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,CAgBrE,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,CAgBtE,CAAC"}
@@ -22,7 +22,7 @@ const data = [
22
22
  }
23
23
  ];
24
24
  // Dummy plugin to test loading
25
- export const ErnieVariable = {
25
+ export const ErnieVariable1 = {
26
26
  getVariableOptions: async ()=>({
27
27
  data
28
28
  }),
@@ -49,5 +49,32 @@ export const ErnieVariable = {
49
49
  variableOption: ''
50
50
  })
51
51
  };
52
+ export const ErnieVariable2 = {
53
+ getVariableOptions: async ()=>({
54
+ data
55
+ }),
56
+ OptionsEditorComponent: function ErnieVariableEditor({ value , onChange }) {
57
+ return /*#__PURE__*/ _jsxs("div", {
58
+ children: [
59
+ /*#__PURE__*/ _jsx("label", {
60
+ htmlFor: "editor-input",
61
+ children: "ErnieVariable2 editor"
62
+ }),
63
+ /*#__PURE__*/ _jsx("input", {
64
+ type: "text",
65
+ id: "editor-input",
66
+ value: value.variableOption2,
67
+ onChange: (e)=>onChange({
68
+ ...value,
69
+ variableOption2: e.target.value
70
+ })
71
+ })
72
+ ]
73
+ });
74
+ },
75
+ createInitialOptions: ()=>({
76
+ variableOption2: ''
77
+ })
78
+ };
52
79
 
53
80
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/test/test-plugins/ernie/index.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { VariablePlugin, VariableOption } from '../../../model';\n\nconst data: VariableOption[] = [\n { label: 'Grover', value: 'Grover' },\n { label: 'Snuffleupagus', value: 'Snuffleupagus' },\n];\n\n// Dummy plugin to test loading\nexport const ErnieVariable: VariablePlugin<{ variableOption: string }> = {\n getVariableOptions: async () => ({ data }),\n OptionsEditorComponent: function ErnieVariableEditor({ value, onChange }) {\n return (\n <div>\n <label htmlFor=\"editor-input\">ErnieVariable editor</label>\n <input\n type=\"text\"\n id=\"editor-input\"\n value={value.variableOption}\n onChange={(e) => onChange({ ...value, variableOption: e.target.value })}\n />\n </div>\n );\n },\n createInitialOptions: () => ({ variableOption: '' }),\n};\n"],"names":["data","label","value","ErnieVariable","getVariableOptions","OptionsEditorComponent","ErnieVariableEditor","onChange","div","htmlFor","input","type","id","variableOption","e","target","createInitialOptions"],"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;AAEA,MAAMA,IAAI,GAAqB;IAC7B;QAAEC,KAAK,EAAE,QAAQ;QAAEC,KAAK,EAAE,QAAQ;KAAE;IACpC;QAAED,KAAK,EAAE,eAAe;QAAEC,KAAK,EAAE,eAAe;KAAE;CACnD,AAAC;AAEF,+BAA+B;AAC/B,OAAO,MAAMC,aAAa,GAA+C;IACvEC,kBAAkB,EAAE,UAAa,CAAA;YAAEJ,IAAI;SAAE,CAAA,AAAC;IAC1CK,sBAAsB,EAAE,SAASC,mBAAmB,CAAC,EAAEJ,KAAK,CAAA,EAAEK,QAAQ,CAAA,EAAE,EAAE;QACxE,qBACE,MAACC,KAAG;;8BACF,KAACP,OAAK;oBAACQ,OAAO,EAAC,cAAc;8BAAC,sBAAoB;kBAAQ;8BAC1D,KAACC,OAAK;oBACJC,IAAI,EAAC,MAAM;oBACXC,EAAE,EAAC,cAAc;oBACjBV,KAAK,EAAEA,KAAK,CAACW,cAAc;oBAC3BN,QAAQ,EAAE,CAACO,CAAC,GAAKP,QAAQ,CAAC;4BAAE,GAAGL,KAAK;4BAAEW,cAAc,EAAEC,CAAC,CAACC,MAAM,CAACb,KAAK;yBAAE,CAAC;kBACvE;;UACE,CACN;IACJ,CAAC;IACDc,oBAAoB,EAAE,IAAO,CAAA;YAAEH,cAAc,EAAE,EAAE;SAAE,CAAA,AAAC;CACrD,CAAC"}
1
+ {"version":3,"sources":["../../../../src/test/test-plugins/ernie/index.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { VariablePlugin, VariableOption } from '../../../model';\n\nconst data: VariableOption[] = [\n { label: 'Grover', value: 'Grover' },\n { label: 'Snuffleupagus', value: 'Snuffleupagus' },\n];\n\n// Dummy plugin to test loading\nexport const ErnieVariable1: VariablePlugin<{ variableOption: string }> = {\n getVariableOptions: async () => ({ data }),\n OptionsEditorComponent: function ErnieVariableEditor({ value, onChange }) {\n return (\n <div>\n <label htmlFor=\"editor-input\">ErnieVariable editor</label>\n <input\n type=\"text\"\n id=\"editor-input\"\n value={value.variableOption}\n onChange={(e) => onChange({ ...value, variableOption: e.target.value })}\n />\n </div>\n );\n },\n createInitialOptions: () => ({ variableOption: '' }),\n};\n\nexport const ErnieVariable2: VariablePlugin<{ variableOption2: string }> = {\n getVariableOptions: async () => ({ data }),\n OptionsEditorComponent: function ErnieVariableEditor({ value, onChange }) {\n return (\n <div>\n <label htmlFor=\"editor-input\">ErnieVariable2 editor</label>\n <input\n type=\"text\"\n id=\"editor-input\"\n value={value.variableOption2}\n onChange={(e) => onChange({ ...value, variableOption2: e.target.value })}\n />\n </div>\n );\n },\n createInitialOptions: () => ({ variableOption2: '' }),\n};\n"],"names":["data","label","value","ErnieVariable1","getVariableOptions","OptionsEditorComponent","ErnieVariableEditor","onChange","div","htmlFor","input","type","id","variableOption","e","target","createInitialOptions","ErnieVariable2","variableOption2"],"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;AAEA,MAAMA,IAAI,GAAqB;IAC7B;QAAEC,KAAK,EAAE,QAAQ;QAAEC,KAAK,EAAE,QAAQ;KAAE;IACpC;QAAED,KAAK,EAAE,eAAe;QAAEC,KAAK,EAAE,eAAe;KAAE;CACnD,AAAC;AAEF,+BAA+B;AAC/B,OAAO,MAAMC,cAAc,GAA+C;IACxEC,kBAAkB,EAAE,UAAa,CAAA;YAAEJ,IAAI;SAAE,CAAA,AAAC;IAC1CK,sBAAsB,EAAE,SAASC,mBAAmB,CAAC,EAAEJ,KAAK,CAAA,EAAEK,QAAQ,CAAA,EAAE,EAAE;QACxE,qBACE,MAACC,KAAG;;8BACF,KAACP,OAAK;oBAACQ,OAAO,EAAC,cAAc;8BAAC,sBAAoB;kBAAQ;8BAC1D,KAACC,OAAK;oBACJC,IAAI,EAAC,MAAM;oBACXC,EAAE,EAAC,cAAc;oBACjBV,KAAK,EAAEA,KAAK,CAACW,cAAc;oBAC3BN,QAAQ,EAAE,CAACO,CAAC,GAAKP,QAAQ,CAAC;4BAAE,GAAGL,KAAK;4BAAEW,cAAc,EAAEC,CAAC,CAACC,MAAM,CAACb,KAAK;yBAAE,CAAC;kBACvE;;UACE,CACN;IACJ,CAAC;IACDc,oBAAoB,EAAE,IAAO,CAAA;YAAEH,cAAc,EAAE,EAAE;SAAE,CAAA,AAAC;CACrD,CAAC;AAEF,OAAO,MAAMI,cAAc,GAAgD;IACzEb,kBAAkB,EAAE,UAAa,CAAA;YAAEJ,IAAI;SAAE,CAAA,AAAC;IAC1CK,sBAAsB,EAAE,SAASC,mBAAmB,CAAC,EAAEJ,KAAK,CAAA,EAAEK,QAAQ,CAAA,EAAE,EAAE;QACxE,qBACE,MAACC,KAAG;;8BACF,KAACP,OAAK;oBAACQ,OAAO,EAAC,cAAc;8BAAC,uBAAqB;kBAAQ;8BAC3D,KAACC,OAAK;oBACJC,IAAI,EAAC,MAAM;oBACXC,EAAE,EAAC,cAAc;oBACjBV,KAAK,EAAEA,KAAK,CAACgB,eAAe;oBAC5BX,QAAQ,EAAE,CAACO,CAAC,GAAKP,QAAQ,CAAC;4BAAE,GAAGL,KAAK;4BAAEgB,eAAe,EAAEJ,CAAC,CAACC,MAAM,CAACb,KAAK;yBAAE,CAAC;kBACxE;;UACE,CACN;IACJ,CAAC;IACDc,oBAAoB,EAAE,IAAO,CAAA;YAAEE,eAAe,EAAE,EAAE;SAAE,CAAA,AAAC;CACtD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mock-plugin-registry.d.ts","sourceRoot":"","sources":["../../src/test-utils/mock-plugin-registry.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAA8C,oBAAoB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAExG,oBAAY,UAAU,GAAG;KACtB,CAAC,IAAI,UAAU,GAAG;QACjB,UAAU,EAAE,CAAC,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;KACjC;CACF,CAAC,UAAU,CAAC,CAAC;AAEd;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAuCtG;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAErE"}
1
+ {"version":3,"file":"mock-plugin-registry.d.ts","sourceRoot":"","sources":["../../src/test-utils/mock-plugin-registry.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAA8C,oBAAoB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAExG,oBAAY,UAAU,GAAG;KACtB,CAAC,IAAI,UAAU,GAAG;QACjB,UAAU,EAAE,CAAC,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;KACjC;CACF,CAAC,UAAU,CAAC,CAAC;AAEd;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,CA0CtG;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAErE"}
@@ -49,7 +49,10 @@
49
49
  }
50
50
  };
51
51
  return {
52
- pluginLoader
52
+ pluginLoader,
53
+ defaultPluginKinds: {
54
+ TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
55
+ }
53
56
  };
54
57
  }
55
58
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test-utils/mock-plugin-registry.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 { UnknownSpec } from '@perses-dev/core';\nimport { PluginRegistryProps } from '../components';\nimport { PluginModuleResource, Plugin, PluginLoader, PluginImplementation, PluginType } from '../model';\n\nexport type MockPlugin = {\n [T in PluginType]: {\n pluginType: T;\n kind: string;\n plugin: PluginImplementation<T>;\n };\n}[PluginType];\n\n/**\n * Helper for mocking `PluginRegistry` data during tests. Returns props that can be spread on the `PluginRegistry`\n * component so that it will load the mock plugins you provide.\n */\nexport function mockPluginRegistry(...mockPlugins: MockPlugin[]): Omit<PluginRegistryProps, 'children'> {\n const mockPluginResource: PluginModuleResource = {\n kind: 'PluginModule',\n metadata: {\n name: 'Fake Plugin Module for Tests',\n created_at: '',\n updated_at: '',\n version: 0,\n },\n spec: {\n // Add metadata for all mock plugins\n plugins: mockPlugins.map(({ pluginType, kind }) => ({\n pluginType,\n kind,\n display: {\n name: getMockPluginName(pluginType, kind),\n },\n })),\n },\n };\n\n const mockPluginModule: Record<string, Plugin<UnknownSpec>> = {};\n for (const mockPlugin of mockPlugins) {\n // \"Export\" on the module under the same name as the kind the plugin handles\n mockPluginModule[mockPlugin.kind] = mockPlugin.plugin;\n }\n\n const pluginLoader: PluginLoader = {\n getInstalledPlugins() {\n return Promise.resolve([mockPluginResource]);\n },\n importPluginModule(/* resource */) {\n return Promise.resolve(mockPluginModule);\n },\n };\n\n return {\n pluginLoader,\n };\n}\n\n/**\n * The function that's used to generate the display name of mocked plugins in mockPluginRegistry. Can be useful if you\n * need to interact with some UI component that's displaying it.\n */\nexport function getMockPluginName(pluginType: PluginType, kind: string) {\n return `${pluginType} Plugin for ${kind}`;\n}\n"],"names":["mockPluginRegistry","mockPlugins","mockPluginResource","kind","metadata","name","created_at","updated_at","version","spec","plugins","map","pluginType","display","getMockPluginName","mockPluginModule","mockPlugin","plugin","pluginLoader","getInstalledPlugins","Promise","resolve","importPluginModule"],"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;AAcjC;;;CAGC,GACD,OAAO,SAASA,kBAAkB,CAAC,GAAGC,WAAW,AAAc,EAAyC;IACtG,MAAMC,kBAAkB,GAAyB;QAC/CC,IAAI,EAAE,cAAc;QACpBC,QAAQ,EAAE;YACRC,IAAI,EAAE,8BAA8B;YACpCC,UAAU,EAAE,EAAE;YACdC,UAAU,EAAE,EAAE;YACdC,OAAO,EAAE,CAAC;SACX;QACDC,IAAI,EAAE;YACJ,oCAAoC;YACpCC,OAAO,EAAET,WAAW,CAACU,GAAG,CAAC,CAAC,EAAEC,UAAU,CAAA,EAAET,IAAI,CAAA,EAAE,GAAM,CAAA;oBAClDS,UAAU;oBACVT,IAAI;oBACJU,OAAO,EAAE;wBACPR,IAAI,EAAES,iBAAiB,CAACF,UAAU,EAAET,IAAI,CAAC;qBAC1C;iBACF,CAAA,AAAC,CAAC;SACJ;KACF,AAAC;IAEF,MAAMY,gBAAgB,GAAwC,EAAE,AAAC;IACjE,KAAK,MAAMC,UAAU,IAAIf,WAAW,CAAE;QACpC,4EAA4E;QAC5Ec,gBAAgB,CAACC,UAAU,CAACb,IAAI,CAAC,GAAGa,UAAU,CAACC,MAAM,CAAC;IACxD,CAAC;IAED,MAAMC,YAAY,GAAiB;QACjCC,mBAAmB,IAAG;YACpB,OAAOC,OAAO,CAACC,OAAO,CAAC;gBAACnB,kBAAkB;aAAC,CAAC,CAAC;QAC/C,CAAC;QACDoB,kBAAkB,IAAiB;YACjC,OAAOF,OAAO,CAACC,OAAO,CAACN,gBAAgB,CAAC,CAAC;QAC3C,CAAC;KACF,AAAC;IAEF,OAAO;QACLG,YAAY;KACb,CAAC;AACJ,CAAC;AAED;;;CAGC,GACD,OAAO,SAASJ,iBAAiB,CAACF,UAAsB,EAAET,IAAY,EAAE;IACtE,OAAO,CAAC,EAAES,UAAU,CAAC,YAAY,EAAET,IAAI,CAAC,CAAC,CAAC;AAC5C,CAAC"}
1
+ {"version":3,"sources":["../../src/test-utils/mock-plugin-registry.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 { UnknownSpec } from '@perses-dev/core';\nimport { PluginRegistryProps } from '../components';\nimport { PluginModuleResource, Plugin, PluginLoader, PluginImplementation, PluginType } from '../model';\n\nexport type MockPlugin = {\n [T in PluginType]: {\n pluginType: T;\n kind: string;\n plugin: PluginImplementation<T>;\n };\n}[PluginType];\n\n/**\n * Helper for mocking `PluginRegistry` data during tests. Returns props that can be spread on the `PluginRegistry`\n * component so that it will load the mock plugins you provide.\n */\nexport function mockPluginRegistry(...mockPlugins: MockPlugin[]): Omit<PluginRegistryProps, 'children'> {\n const mockPluginResource: PluginModuleResource = {\n kind: 'PluginModule',\n metadata: {\n name: 'Fake Plugin Module for Tests',\n created_at: '',\n updated_at: '',\n version: 0,\n },\n spec: {\n // Add metadata for all mock plugins\n plugins: mockPlugins.map(({ pluginType, kind }) => ({\n pluginType,\n kind,\n display: {\n name: getMockPluginName(pluginType, kind),\n },\n })),\n },\n };\n\n const mockPluginModule: Record<string, Plugin<UnknownSpec>> = {};\n for (const mockPlugin of mockPlugins) {\n // \"Export\" on the module under the same name as the kind the plugin handles\n mockPluginModule[mockPlugin.kind] = mockPlugin.plugin;\n }\n\n const pluginLoader: PluginLoader = {\n getInstalledPlugins() {\n return Promise.resolve([mockPluginResource]);\n },\n importPluginModule(/* resource */) {\n return Promise.resolve(mockPluginModule);\n },\n };\n\n return {\n pluginLoader,\n defaultPluginKinds: {\n TimeSeriesQuery: 'PrometheusTimeSeriesQuery',\n },\n };\n}\n\n/**\n * The function that's used to generate the display name of mocked plugins in mockPluginRegistry. Can be useful if you\n * need to interact with some UI component that's displaying it.\n */\nexport function getMockPluginName(pluginType: PluginType, kind: string) {\n return `${pluginType} Plugin for ${kind}`;\n}\n"],"names":["mockPluginRegistry","mockPlugins","mockPluginResource","kind","metadata","name","created_at","updated_at","version","spec","plugins","map","pluginType","display","getMockPluginName","mockPluginModule","mockPlugin","plugin","pluginLoader","getInstalledPlugins","Promise","resolve","importPluginModule","defaultPluginKinds","TimeSeriesQuery"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAcjC;;;CAGC,GACD,OAAO,SAASA,kBAAkB,CAAC,GAAGC,WAAW,AAAc,EAAyC;IACtG,MAAMC,kBAAkB,GAAyB;QAC/CC,IAAI,EAAE,cAAc;QACpBC,QAAQ,EAAE;YACRC,IAAI,EAAE,8BAA8B;YACpCC,UAAU,EAAE,EAAE;YACdC,UAAU,EAAE,EAAE;YACdC,OAAO,EAAE,CAAC;SACX;QACDC,IAAI,EAAE;YACJ,oCAAoC;YACpCC,OAAO,EAAET,WAAW,CAACU,GAAG,CAAC,CAAC,EAAEC,UAAU,CAAA,EAAET,IAAI,CAAA,EAAE,GAAM,CAAA;oBAClDS,UAAU;oBACVT,IAAI;oBACJU,OAAO,EAAE;wBACPR,IAAI,EAAES,iBAAiB,CAACF,UAAU,EAAET,IAAI,CAAC;qBAC1C;iBACF,CAAA,AAAC,CAAC;SACJ;KACF,AAAC;IAEF,MAAMY,gBAAgB,GAAwC,EAAE,AAAC;IACjE,KAAK,MAAMC,UAAU,IAAIf,WAAW,CAAE;QACpC,4EAA4E;QAC5Ec,gBAAgB,CAACC,UAAU,CAACb,IAAI,CAAC,GAAGa,UAAU,CAACC,MAAM,CAAC;IACxD,CAAC;IAED,MAAMC,YAAY,GAAiB;QACjCC,mBAAmB,IAAG;YACpB,OAAOC,OAAO,CAACC,OAAO,CAAC;gBAACnB,kBAAkB;aAAC,CAAC,CAAC;QAC/C,CAAC;QACDoB,kBAAkB,IAAiB;YACjC,OAAOF,OAAO,CAACC,OAAO,CAACN,gBAAgB,CAAC,CAAC;QAC3C,CAAC;KACF,AAAC;IAEF,OAAO;QACLG,YAAY;QACZK,kBAAkB,EAAE;YAClBC,eAAe,EAAE,2BAA2B;SAC7C;KACF,CAAC;AACJ,CAAC;AAED;;;CAGC,GACD,OAAO,SAASV,iBAAiB,CAACF,UAAsB,EAAET,IAAY,EAAE;IACtE,OAAO,CAAC,EAAES,UAAU,CAAC,YAAY,EAAET,IAAI,CAAC,CAAC,CAAC;AAC5C,CAAC"}