@perses-dev/plugin-system 0.0.0-snapshot-color-palette-gen-test-0ebddd6 → 0.0.0-snapshot-saving-defaults-refinements-1b25cec

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 (154) 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/plugin-editor-api.js +27 -6
  4. package/dist/cjs/components/{PluginKindSelect.js → PluginKindSelect/PluginKindSelect.js} +1 -1
  5. package/dist/cjs/components/PluginKindSelect/index.js +28 -0
  6. package/dist/cjs/components/{PluginSpecEditor.js → PluginSpecEditor/PluginSpecEditor.js} +2 -30
  7. package/dist/cjs/components/PluginSpecEditor/index.js +28 -0
  8. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +142 -0
  9. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +94 -0
  10. package/dist/cjs/components/TimeSeriesQueryEditor/index.js +28 -0
  11. package/dist/cjs/components/index.js +1 -0
  12. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +88 -0
  13. package/dist/cjs/runtime/DataQueriesProvider/index.js +29 -0
  14. package/dist/cjs/runtime/DataQueriesProvider/model.js +16 -0
  15. package/dist/cjs/runtime/index.js +1 -0
  16. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +39 -0
  17. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +95 -0
  18. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +83 -0
  19. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js +40 -0
  20. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +38 -0
  21. package/dist/cjs/stories/shared-utils/decorators/index.js +32 -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.map +1 -1
  37. package/dist/components/PluginEditor/plugin-editor-api.d.ts +4 -1
  38. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  39. package/dist/components/PluginEditor/plugin-editor-api.js +27 -6
  40. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  41. package/dist/components/{PluginKindSelect.d.ts → PluginKindSelect/PluginKindSelect.d.ts} +1 -1
  42. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -0
  43. package/dist/components/{PluginKindSelect.js → PluginKindSelect/PluginKindSelect.js} +1 -1
  44. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -0
  45. package/dist/components/PluginKindSelect/index.d.ts +2 -0
  46. package/dist/components/PluginKindSelect/index.d.ts.map +1 -0
  47. package/dist/components/PluginKindSelect/index.js +15 -0
  48. package/dist/components/PluginKindSelect/index.js.map +1 -0
  49. package/dist/components/PluginRegistry/PluginRegistry.d.ts +2 -2
  50. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  51. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  52. package/dist/components/{PluginSpecEditor.d.ts → PluginSpecEditor/PluginSpecEditor.d.ts} +1 -1
  53. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -0
  54. package/dist/components/{PluginSpecEditor.js → PluginSpecEditor/PluginSpecEditor.js} +3 -31
  55. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -0
  56. package/dist/components/PluginSpecEditor/index.d.ts +2 -0
  57. package/dist/components/PluginSpecEditor/index.d.ts.map +1 -0
  58. package/dist/components/PluginSpecEditor/index.js +15 -0
  59. package/dist/components/PluginSpecEditor/index.js.map +1 -0
  60. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +8 -0
  61. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -0
  62. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +131 -0
  63. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -0
  64. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +13 -0
  65. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +1 -0
  66. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +83 -0
  67. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -0
  68. package/dist/components/TimeSeriesQueryEditor/index.d.ts +2 -0
  69. package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +1 -0
  70. package/dist/components/TimeSeriesQueryEditor/index.js +15 -0
  71. package/dist/components/TimeSeriesQueryEditor/index.js.map +1 -0
  72. package/dist/components/index.d.ts +1 -0
  73. package/dist/components/index.d.ts.map +1 -1
  74. package/dist/components/index.js +1 -0
  75. package/dist/components/index.js.map +1 -1
  76. package/dist/model/panels.d.ts +6 -5
  77. package/dist/model/panels.d.ts.map +1 -1
  78. package/dist/model/panels.js.map +1 -1
  79. package/dist/model/plugin-base.d.ts +7 -0
  80. package/dist/model/plugin-base.d.ts.map +1 -1
  81. package/dist/model/plugin-base.js.map +1 -1
  82. package/dist/model/plugins.d.ts +3 -1
  83. package/dist/model/plugins.d.ts.map +1 -1
  84. package/dist/model/plugins.js.map +1 -1
  85. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +8 -0
  86. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -0
  87. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +74 -0
  88. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -0
  89. package/dist/runtime/DataQueriesProvider/index.d.ts +3 -0
  90. package/dist/runtime/DataQueriesProvider/index.d.ts.map +1 -0
  91. package/dist/runtime/DataQueriesProvider/index.js +16 -0
  92. package/dist/runtime/DataQueriesProvider/index.js.map +1 -0
  93. package/dist/runtime/DataQueriesProvider/model.d.ts +27 -0
  94. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -0
  95. package/dist/runtime/DataQueriesProvider/model.js +15 -0
  96. package/dist/runtime/DataQueriesProvider/model.js.map +1 -0
  97. package/dist/runtime/index.d.ts +1 -0
  98. package/dist/runtime/index.d.ts.map +1 -1
  99. package/dist/runtime/index.js +1 -0
  100. package/dist/runtime/index.js.map +1 -1
  101. package/dist/runtime/plugin-registry.d.ts +1 -1
  102. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  103. package/dist/runtime/plugin-registry.js.map +1 -1
  104. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +13 -0
  105. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -0
  106. package/dist/stories/shared-utils/decorators/WithDataQueries.js +33 -0
  107. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -0
  108. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +4 -0
  109. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -0
  110. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +45 -0
  111. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -0
  112. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +13 -0
  113. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -0
  114. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +79 -0
  115. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -0
  116. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +13 -0
  117. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +1 -0
  118. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js +39 -0
  119. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +1 -0
  120. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +13 -0
  121. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -0
  122. package/dist/stories/shared-utils/decorators/WithTimeRange.js +32 -0
  123. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -0
  124. package/dist/stories/shared-utils/decorators/index.d.ts +6 -0
  125. package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -0
  126. package/dist/stories/shared-utils/decorators/index.js +19 -0
  127. package/dist/stories/shared-utils/decorators/index.js.map +1 -0
  128. package/dist/stories/shared-utils/index.d.ts +2 -0
  129. package/dist/stories/shared-utils/index.d.ts.map +1 -0
  130. package/dist/stories/shared-utils/index.js +15 -0
  131. package/dist/stories/shared-utils/index.js.map +1 -0
  132. package/dist/test/render.d.ts.map +1 -1
  133. package/dist/test/render.js +4 -1
  134. package/dist/test/render.js.map +1 -1
  135. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  136. package/dist/test/test-plugins/bert/index.js +27 -20
  137. package/dist/test/test-plugins/bert/index.js.map +1 -1
  138. package/dist/test/test-plugins/ernie/index.d.ts +4 -1
  139. package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
  140. package/dist/test/test-plugins/ernie/index.js +28 -1
  141. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  142. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  143. package/dist/test-utils/mock-plugin-registry.js +4 -1
  144. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  145. package/package.json +6 -3
  146. package/dist/cjs/components/TimeSeriesQueryEditor.js +0 -42
  147. package/dist/components/PluginKindSelect.d.ts.map +0 -1
  148. package/dist/components/PluginKindSelect.js.map +0 -1
  149. package/dist/components/PluginSpecEditor.d.ts.map +0 -1
  150. package/dist/components/PluginSpecEditor.js.map +0 -1
  151. package/dist/components/TimeSeriesQueryEditor.d.ts +0 -14
  152. package/dist/components/TimeSeriesQueryEditor.d.ts.map +0 -1
  153. package/dist/components/TimeSeriesQueryEditor.js +0 -38
  154. package/dist/components/TimeSeriesQueryEditor.js.map +0 -1
@@ -0,0 +1,29 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./DataQueriesProvider"), exports);
18
+ _exportStar(require("./model"), exports);
19
+ function _exportStar(from, to) {
20
+ Object.keys(from).forEach(function(k) {
21
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ });
28
+ return from;
29
+ }
@@ -0,0 +1,16 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
@@ -19,6 +19,7 @@ _exportStar(require("./plugin-registry"), exports);
19
19
  _exportStar(require("./template-variables"), exports);
20
20
  _exportStar(require("./TimeRangeProvider"), exports);
21
21
  _exportStar(require("./time-series-queries"), exports);
22
+ _exportStar(require("./DataQueriesProvider"), exports);
22
23
  function _exportStar(from, to) {
23
24
  Object.keys(from).forEach(function(k) {
24
25
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
@@ -0,0 +1,39 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "WithDataQueries", {
18
+ enumerable: true,
19
+ get: ()=>WithDataQueries
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _pluginSystem = require("@perses-dev/plugin-system");
23
+ // Type guard because storybook types parameters as `any`
24
+ function isWithDataQueriesParameter(parameter) {
25
+ return !!parameter && typeof parameter === 'object' && 'props' in parameter;
26
+ }
27
+ const WithDataQueries = (Story, context)=>{
28
+ const initParameter = context.parameters.withDataQueries;
29
+ const parameter = isWithDataQueriesParameter(initParameter) ? initParameter : {
30
+ props: {
31
+ definitions: []
32
+ }
33
+ };
34
+ const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
35
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DataQueriesProvider, {
36
+ ...props,
37
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
38
+ });
39
+ };
@@ -0,0 +1,95 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "WithPluginRegistry", {
18
+ enumerable: true,
19
+ get: ()=>WithPluginRegistry
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _pluginSystem = require("@perses-dev/plugin-system");
23
+ const _pluginJson = /*#__PURE__*/ _interopRequireDefault(require("@perses-dev/prometheus-plugin/plugin.json"));
24
+ const _pluginJson1 = /*#__PURE__*/ _interopRequireDefault(require("@perses-dev/panels-plugin/plugin.json"));
25
+ function _interopRequireDefault(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
30
+ function _getRequireWildcardCache(nodeInterop) {
31
+ if (typeof WeakMap !== "function") return null;
32
+ var cacheBabelInterop = new WeakMap();
33
+ var cacheNodeInterop = new WeakMap();
34
+ return (_getRequireWildcardCache = function(nodeInterop) {
35
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
36
+ })(nodeInterop);
37
+ }
38
+ function _interopRequireWildcard(obj, nodeInterop) {
39
+ if (!nodeInterop && obj && obj.__esModule) {
40
+ return obj;
41
+ }
42
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
43
+ return {
44
+ default: obj
45
+ };
46
+ }
47
+ var cache = _getRequireWildcardCache(nodeInterop);
48
+ if (cache && cache.has(obj)) {
49
+ return cache.get(obj);
50
+ }
51
+ var newObj = {};
52
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
53
+ for(var key in obj){
54
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
55
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
56
+ if (desc && (desc.get || desc.set)) {
57
+ Object.defineProperty(newObj, key, desc);
58
+ } else {
59
+ newObj[key] = obj[key];
60
+ }
61
+ }
62
+ }
63
+ newObj.default = obj;
64
+ if (cache) {
65
+ cache.set(obj, newObj);
66
+ }
67
+ return newObj;
68
+ }
69
+ const bundledPluginLoader = (0, _pluginSystem.dynamicImportPluginLoader)([
70
+ {
71
+ resource: _pluginJson.default,
72
+ // This throws an error in CI (but not locally for some reason), likely because
73
+ // this package isn't a dependency for dashboards. We probably do not want to
74
+ // make it one solely for type-checking in storybook.
75
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
76
+ // @ts-ignore
77
+ importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("@perses-dev/prometheus-plugin")))
78
+ },
79
+ {
80
+ resource: _pluginJson1.default,
81
+ // Same comment as above.
82
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
83
+ // @ts-ignore
84
+ importPlugin: ()=>Promise.resolve().then(()=>/*#__PURE__*/ _interopRequireWildcard(require("@perses-dev/panels-plugin")))
85
+ }
86
+ ]);
87
+ const WithPluginRegistry = (Story)=>{
88
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.PluginRegistry, {
89
+ pluginLoader: bundledPluginLoader,
90
+ defaultPluginKinds: {
91
+ TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
92
+ },
93
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
94
+ });
95
+ };
@@ -0,0 +1,83 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "WithPluginSystemDatasourceStore", {
18
+ enumerable: true,
19
+ get: ()=>WithPluginSystemDatasourceStore
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _pluginSystem = require("@perses-dev/plugin-system");
23
+ const prometheusDemoUrl = 'https://prometheus.demo.do.prometheus.io';
24
+ // Type guard because storybook types parameters as `any`
25
+ function isWithDatastoreStoreParameter(parameter) {
26
+ return !!parameter && typeof parameter === 'object' && 'props' in parameter;
27
+ }
28
+ const WithPluginSystemDatasourceStore = (Story, context)=>{
29
+ const { getPlugin } = (0, _pluginSystem.usePluginRegistry)();
30
+ const initParameter = context.parameters.withPluginSystemDatasourceStore;
31
+ // This currently provides a very simplified default to enable use in some
32
+ // basic stories. It likely will need expanding in the future.
33
+ // In general, `plugin-system` would probably benefit from a provider wrapper
34
+ // for `DatasourceStoreContext` that is more generic than the one available
35
+ // in in the `dashboard` package for non-dashboard use cases.
36
+ const defaultValue = {
37
+ getDatasource: (selector)=>{
38
+ if (selector.kind === 'PrometheusDatasource') {
39
+ return Promise.resolve({
40
+ default: true,
41
+ plugin: {
42
+ kind: 'PrometheusDatasource',
43
+ spec: {}
44
+ }
45
+ });
46
+ }
47
+ throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
48
+ },
49
+ getDatasourceClient: async (selector)=>{
50
+ if (selector.kind === 'PrometheusDatasource') {
51
+ const plugin = await getPlugin('Datasource', 'PrometheusDatasource');
52
+ const client = plugin.createClient({
53
+ direct_url: prometheusDemoUrl
54
+ }, {
55
+ proxyUrl: prometheusDemoUrl
56
+ });
57
+ return client;
58
+ }
59
+ throw new Error(`WithDatasourceStore is not configured to support kind: ${selector.kind}`);
60
+ },
61
+ listDatasourceMetadata: async (datasourcePluginKind)=>{
62
+ if (datasourcePluginKind === 'PrometheusDatasource') {
63
+ return Promise.resolve([
64
+ {
65
+ name: 'PrometheusDatasource',
66
+ selector: {
67
+ kind: 'PrometheusDatasource'
68
+ }
69
+ }
70
+ ]);
71
+ }
72
+ throw new Error(`WithDatasourceStore is not configured to support kind: ${datasourcePluginKind}`);
73
+ }
74
+ };
75
+ const parameter = isWithDatastoreStoreParameter(initParameter) ? initParameter : {
76
+ props: defaultValue
77
+ };
78
+ const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
79
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceStoreContext.Provider, {
80
+ value: props,
81
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
82
+ });
83
+ };
@@ -0,0 +1,40 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "WithPluginSystemTemplateVariables", {
18
+ enumerable: true,
19
+ get: ()=>WithPluginSystemTemplateVariables
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _runtime = require("../../../runtime");
23
+ // Type guard because storybook types parameters as `any`
24
+ function isWithTemplateVariableParameter(parameter) {
25
+ return !!parameter && typeof parameter === 'object' && 'props' in parameter;
26
+ }
27
+ const WithPluginSystemTemplateVariables = (Story, context)=>{
28
+ const initParameter = context.parameters.withPluginSystemTemplateVariables;
29
+ const defaultValue = {
30
+ state: {}
31
+ };
32
+ const parameter = isWithTemplateVariableParameter(initParameter) ? initParameter : {
33
+ props: defaultValue
34
+ };
35
+ const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
36
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_runtime.TemplateVariableContext.Provider, {
37
+ value: props,
38
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
39
+ });
40
+ };
@@ -0,0 +1,38 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "WithTimeRange", {
18
+ enumerable: true,
19
+ get: ()=>WithTimeRange
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _pluginSystem = require("@perses-dev/plugin-system");
23
+ // Type guard because storybook types parameters as `any`
24
+ function isWithTimeRangeParameter(parameter) {
25
+ return !!parameter && typeof parameter === 'object' && 'props' in parameter;
26
+ }
27
+ const WithTimeRange = (Story, context)=>{
28
+ const initParameter = context.parameters.withTimeRange;
29
+ const parameter = isWithTimeRangeParameter(initParameter) ? initParameter : undefined;
30
+ const props = parameter === null || parameter === void 0 ? void 0 : parameter.props;
31
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.TimeRangeProvider, {
32
+ initialTimeRange: {
33
+ pastDuration: '1h'
34
+ },
35
+ ...props,
36
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(Story, {})
37
+ });
38
+ };
@@ -0,0 +1,32 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./WithDataQueries"), exports);
18
+ _exportStar(require("./WithPluginRegistry"), exports);
19
+ _exportStar(require("./WithPluginSystemDatasourceStore"), exports);
20
+ _exportStar(require("./WithPluginSystemTemplateVariables"), exports);
21
+ _exportStar(require("./WithTimeRange"), exports);
22
+ function _exportStar(from, to) {
23
+ Object.keys(from).forEach(function(k) {
24
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
25
+ enumerable: true,
26
+ get: function() {
27
+ return from[k];
28
+ }
29
+ });
30
+ });
31
+ return from;
32
+ }
@@ -0,0 +1,28 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./decorators"), exports);
18
+ function _exportStar(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ });
27
+ return from;
28
+ }
@@ -41,11 +41,14 @@ function renderWithContext(ui, renderOptions, contextOptions) {
41
41
  },
42
42
  logger: testLogger
43
43
  });
44
+ var ref;
44
45
  return (0, _react.render)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_reactQuery.QueryClientProvider, {
45
46
  client: queryClient,
46
47
  children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginRegistry.PluginRegistry, {
47
48
  pluginLoader: _testPlugins.testPluginLoader,
48
- defaultPluginKinds: contextOptions === null || contextOptions === void 0 ? void 0 : contextOptions.defaultPluginKinds,
49
+ defaultPluginKinds: (ref = contextOptions === null || contextOptions === void 0 ? void 0 : contextOptions.defaultPluginKinds) !== null && ref !== void 0 ? ref : {
50
+ TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
51
+ },
49
52
  children: ui
50
53
  })
51
54
  }), renderOptions);
@@ -25,27 +25,33 @@ _export(exports, {
25
25
  BertPanel2: ()=>BertPanel2
26
26
  });
27
27
  const _jsxRuntime = require("react/jsx-runtime");
28
+ function BertPanel1Editor({ value , onChange }) {
29
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
30
+ children: [
31
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)("label", {
32
+ htmlFor: "editor-input",
33
+ children: "BertPanel1 editor"
34
+ }),
35
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)("input", {
36
+ type: "text",
37
+ id: "editor-input",
38
+ value: value.option1,
39
+ onChange: (e)=>onChange({
40
+ ...value,
41
+ option1: e.target.value
42
+ })
43
+ })
44
+ ]
45
+ });
46
+ }
28
47
  const BertPanel1 = {
29
48
  PanelComponent: ()=>null,
30
- PanelQueryEditorComponent: function BertPanel1Editor({ value , onChange }) {
31
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
32
- children: [
33
- /*#__PURE__*/ (0, _jsxRuntime.jsx)("label", {
34
- htmlFor: "editor-input",
35
- children: "BertPanel1 editor"
36
- }),
37
- /*#__PURE__*/ (0, _jsxRuntime.jsx)("input", {
38
- type: "text",
39
- id: "editor-input",
40
- value: value.option1,
41
- onChange: (e)=>onChange({
42
- ...value,
43
- option1: e.target.value
44
- })
45
- })
46
- ]
47
- });
48
- },
49
+ panelOptionsEditorComponents: [
50
+ {
51
+ label: 'Editor',
52
+ content: BertPanel1Editor
53
+ }
54
+ ],
49
55
  createInitialOptions: ()=>({
50
56
  option1: ''
51
57
  })
@@ -86,5 +92,6 @@ const BertPanel2 = {
86
92
  ],
87
93
  createInitialOptions: ()=>({
88
94
  option2: ''
89
- })
95
+ }),
96
+ hideQueryEditor: true
90
97
  };
@@ -14,9 +14,15 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "ErnieVariable", {
18
- enumerable: true,
19
- get: ()=>ErnieVariable
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ ErnieVariable1: ()=>ErnieVariable1,
25
+ ErnieVariable2: ()=>ErnieVariable2
20
26
  });
21
27
  const _jsxRuntime = require("react/jsx-runtime");
22
28
  const data = [
@@ -29,7 +35,7 @@ const data = [
29
35
  value: 'Snuffleupagus'
30
36
  }
31
37
  ];
32
- const ErnieVariable = {
38
+ const ErnieVariable1 = {
33
39
  getVariableOptions: async ()=>({
34
40
  data
35
41
  }),
@@ -56,3 +62,30 @@ const ErnieVariable = {
56
62
  variableOption: ''
57
63
  })
58
64
  };
65
+ const ErnieVariable2 = {
66
+ getVariableOptions: async ()=>({
67
+ data
68
+ }),
69
+ OptionsEditorComponent: function ErnieVariableEditor({ value , onChange }) {
70
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)("div", {
71
+ children: [
72
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)("label", {
73
+ htmlFor: "editor-input",
74
+ children: "ErnieVariable2 editor"
75
+ }),
76
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)("input", {
77
+ type: "text",
78
+ id: "editor-input",
79
+ value: value.variableOption2,
80
+ onChange: (e)=>onChange({
81
+ ...value,
82
+ variableOption2: e.target.value
83
+ })
84
+ })
85
+ ]
86
+ });
87
+ },
88
+ createInitialOptions: ()=>({
89
+ variableOption2: ''
90
+ })
91
+ };
@@ -60,7 +60,10 @@ function mockPluginRegistry(...mockPlugins) {
60
60
  }
61
61
  };
62
62
  return {
63
- pluginLoader
63
+ pluginLoader,
64
+ defaultPluginKinds: {
65
+ TimeSeriesQuery: 'PrometheusTimeSeriesQuery'
66
+ }
64
67
  };
65
68
  }
66
69
  function getMockPluginName(pluginType, kind) {
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { PanelDefinition, QueryDefinition, UnknownSpec } from '@perses-dev/core';
3
+ export interface PanelSpecEditorProps {
4
+ panelDefinition: PanelDefinition;
5
+ onQueriesChange: (queries: QueryDefinition[]) => void;
6
+ onPluginSpecChange: (spec: UnknownSpec) => void;
7
+ onJSONChange: (panelDefinition: PanelDefinition) => void;
8
+ }
9
+ export declare function PanelSpecEditor(props: PanelSpecEditorProps): JSX.Element | null;
10
+ //# sourceMappingURL=PanelSpecEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PanelSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAMjF,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;IACtD,kBAAkB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IAChD,YAAY,EAAE,CAAC,eAAe,EAAE,eAAe,KAAK,IAAI,CAAC;CAC1D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,sBA0C1D"}
@@ -0,0 +1,69 @@
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 { ErrorAlert, JSONEditor } from '@perses-dev/components';
15
+ import { usePlugin } from '../../runtime';
16
+ import { OptionsEditorTabs } from '../OptionsEditorTabs';
17
+ import { TimeSeriesQueryEditor } from '../TimeSeriesQueryEditor';
18
+ export function PanelSpecEditor(props) {
19
+ const { panelDefinition , onJSONChange , onQueriesChange , onPluginSpecChange } = props;
20
+ const { kind } = panelDefinition.spec.plugin;
21
+ const { data: plugin , isLoading , error } = usePlugin('Panel', kind);
22
+ if (error) {
23
+ return /*#__PURE__*/ _jsx(ErrorAlert, {
24
+ error: error
25
+ });
26
+ }
27
+ // TODO: Proper loading indicator
28
+ if (isLoading) {
29
+ return null;
30
+ }
31
+ if (plugin === undefined) {
32
+ throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);
33
+ }
34
+ const { panelOptionsEditorComponents , hideQueryEditor } = plugin;
35
+ let tabs = [];
36
+ if (!hideQueryEditor) {
37
+ var _queries;
38
+ // Since we only support TimeSeriesQuery for now, we will always show a TimeSeriesQueryEditor
39
+ tabs.push({
40
+ label: 'Query',
41
+ content: /*#__PURE__*/ _jsx(TimeSeriesQueryEditor, {
42
+ queries: (_queries = panelDefinition.spec.queries) !== null && _queries !== void 0 ? _queries : [],
43
+ onChange: onQueriesChange
44
+ })
45
+ });
46
+ }
47
+ if (panelOptionsEditorComponents !== undefined) {
48
+ tabs = tabs.concat(panelOptionsEditorComponents.map(({ label , content: OptionsEditorComponent })=>({
49
+ label,
50
+ content: /*#__PURE__*/ _jsx(OptionsEditorComponent, {
51
+ value: panelDefinition.spec.plugin.spec,
52
+ onChange: onPluginSpecChange
53
+ })
54
+ })));
55
+ }
56
+ // always show json editor by default
57
+ tabs.push({
58
+ label: 'JSON',
59
+ content: /*#__PURE__*/ _jsx(JSONEditor, {
60
+ value: panelDefinition,
61
+ onChange: onJSONChange
62
+ })
63
+ });
64
+ return /*#__PURE__*/ _jsx(OptionsEditorTabs, {
65
+ tabs: tabs
66
+ }, tabs.length);
67
+ }
68
+
69
+ //# sourceMappingURL=PanelSpecEditor.js.map