@perses-dev/plugin-system 0.21.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +1 -1
  2. package/dist/cjs/components/CalculationSelector/CalculationSelector.test.js +1 -1
  3. package/dist/cjs/components/CalculationSelector/index.js +1 -1
  4. package/dist/cjs/components/DatasourceSelect.js +1 -1
  5. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +1 -1
  6. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.test.js +1 -1
  7. package/dist/cjs/components/OptionsEditorTabs/TabPanel.js +1 -1
  8. package/dist/cjs/components/OptionsEditorTabs/index.js +1 -1
  9. package/dist/cjs/components/PluginEditor/PluginEditor.js +1 -1
  10. package/dist/cjs/components/PluginEditor/PluginEditor.test.js +1 -1
  11. package/dist/cjs/components/PluginEditor/index.js +1 -1
  12. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +1 -1
  13. package/dist/cjs/components/PluginKindSelect.js +1 -1
  14. package/dist/cjs/components/PluginKindSelect.test.js +1 -1
  15. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
  16. package/dist/cjs/components/PluginRegistry/PluginRegistry.test.js +1 -1
  17. package/dist/cjs/components/PluginRegistry/index.js +1 -1
  18. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +1 -1
  19. package/dist/cjs/components/PluginSpecEditor.js +1 -1
  20. package/dist/cjs/components/PluginSpecEditor.test.js +1 -1
  21. package/dist/cjs/components/TimeSeriesQueryEditor.js +1 -1
  22. package/dist/cjs/components/index.js +1 -1
  23. package/dist/cjs/index.js +1 -1
  24. package/dist/cjs/model/calculations.js +1 -1
  25. package/dist/cjs/model/datasource.js +1 -1
  26. package/dist/cjs/model/index.js +1 -1
  27. package/dist/cjs/model/panels.js +1 -1
  28. package/dist/cjs/model/plugin-base.js +1 -1
  29. package/dist/cjs/model/plugin-loading.js +1 -1
  30. package/dist/cjs/model/plugins.js +1 -1
  31. package/dist/cjs/model/time-series-queries.js +1 -1
  32. package/dist/cjs/model/variables.js +1 -1
  33. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
  34. package/dist/cjs/runtime/TimeRangeProvider/index.js +1 -1
  35. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +1 -1
  36. package/dist/cjs/runtime/datasources.js +10 -2
  37. package/dist/cjs/runtime/index.js +1 -1
  38. package/dist/cjs/runtime/plugin-registry.js +1 -1
  39. package/dist/cjs/runtime/template-variables.js +1 -1
  40. package/dist/cjs/runtime/time-series-queries.js +1 -1
  41. package/dist/cjs/test/index.js +1 -1
  42. package/dist/cjs/test/render.js +1 -1
  43. package/dist/cjs/test/setup-tests.js +1 -1
  44. package/dist/cjs/test/test-plugins/bert/index.js +1 -1
  45. package/dist/cjs/test/test-plugins/ernie/index.js +1 -1
  46. package/dist/cjs/test/test-plugins/index.js +1 -1
  47. package/dist/cjs/test-utils/index.js +1 -1
  48. package/dist/cjs/test-utils/mock-plugin-registry.js +1 -1
  49. package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
  50. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  51. package/dist/components/CalculationSelector/CalculationSelector.test.js +1 -1
  52. package/dist/components/CalculationSelector/CalculationSelector.test.js.map +1 -1
  53. package/dist/components/CalculationSelector/index.js +1 -1
  54. package/dist/components/CalculationSelector/index.js.map +1 -1
  55. package/dist/components/DatasourceSelect.js +1 -1
  56. package/dist/components/DatasourceSelect.js.map +1 -1
  57. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +1 -1
  58. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  59. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js +1 -1
  60. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.test.js.map +1 -1
  61. package/dist/components/OptionsEditorTabs/TabPanel.js +1 -1
  62. package/dist/components/OptionsEditorTabs/TabPanel.js.map +1 -1
  63. package/dist/components/OptionsEditorTabs/index.js +1 -1
  64. package/dist/components/OptionsEditorTabs/index.js.map +1 -1
  65. package/dist/components/PluginEditor/PluginEditor.js +1 -1
  66. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  67. package/dist/components/PluginEditor/PluginEditor.test.js +1 -1
  68. package/dist/components/PluginEditor/PluginEditor.test.js.map +1 -1
  69. package/dist/components/PluginEditor/index.js +1 -1
  70. package/dist/components/PluginEditor/index.js.map +1 -1
  71. package/dist/components/PluginEditor/plugin-editor-api.js +1 -1
  72. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  73. package/dist/components/PluginKindSelect.js +1 -1
  74. package/dist/components/PluginKindSelect.js.map +1 -1
  75. package/dist/components/PluginKindSelect.test.js +1 -1
  76. package/dist/components/PluginKindSelect.test.js.map +1 -1
  77. package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
  78. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  79. package/dist/components/PluginRegistry/PluginRegistry.test.js +1 -1
  80. package/dist/components/PluginRegistry/PluginRegistry.test.js.map +1 -1
  81. package/dist/components/PluginRegistry/index.js +1 -1
  82. package/dist/components/PluginRegistry/index.js.map +1 -1
  83. package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
  84. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  85. package/dist/components/PluginSpecEditor.js +1 -1
  86. package/dist/components/PluginSpecEditor.js.map +1 -1
  87. package/dist/components/PluginSpecEditor.test.js +1 -1
  88. package/dist/components/PluginSpecEditor.test.js.map +1 -1
  89. package/dist/components/TimeSeriesQueryEditor.js +1 -1
  90. package/dist/components/TimeSeriesQueryEditor.js.map +1 -1
  91. package/dist/components/index.js +1 -1
  92. package/dist/components/index.js.map +1 -1
  93. package/dist/index.js +1 -1
  94. package/dist/index.js.map +1 -1
  95. package/dist/model/calculations.js +1 -1
  96. package/dist/model/calculations.js.map +1 -1
  97. package/dist/model/datasource.js +1 -1
  98. package/dist/model/datasource.js.map +1 -1
  99. package/dist/model/index.js +1 -1
  100. package/dist/model/index.js.map +1 -1
  101. package/dist/model/panels.js +1 -1
  102. package/dist/model/panels.js.map +1 -1
  103. package/dist/model/plugin-base.js +1 -1
  104. package/dist/model/plugin-base.js.map +1 -1
  105. package/dist/model/plugin-loading.js +1 -1
  106. package/dist/model/plugin-loading.js.map +1 -1
  107. package/dist/model/plugins.js +1 -1
  108. package/dist/model/plugins.js.map +1 -1
  109. package/dist/model/time-series-queries.js +1 -1
  110. package/dist/model/time-series-queries.js.map +1 -1
  111. package/dist/model/variables.js +1 -1
  112. package/dist/model/variables.js.map +1 -1
  113. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
  114. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  115. package/dist/runtime/TimeRangeProvider/index.js +1 -1
  116. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  117. package/dist/runtime/TimeRangeProvider/query-params.js +1 -1
  118. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  119. package/dist/runtime/datasources.d.ts +4 -0
  120. package/dist/runtime/datasources.d.ts.map +1 -1
  121. package/dist/runtime/datasources.js +10 -1
  122. package/dist/runtime/datasources.js.map +1 -1
  123. package/dist/runtime/index.js +1 -1
  124. package/dist/runtime/index.js.map +1 -1
  125. package/dist/runtime/plugin-registry.js +1 -1
  126. package/dist/runtime/plugin-registry.js.map +1 -1
  127. package/dist/runtime/template-variables.js +1 -1
  128. package/dist/runtime/template-variables.js.map +1 -1
  129. package/dist/runtime/time-series-queries.js +1 -1
  130. package/dist/runtime/time-series-queries.js.map +1 -1
  131. package/dist/test/index.js +1 -1
  132. package/dist/test/index.js.map +1 -1
  133. package/dist/test/render.js +1 -1
  134. package/dist/test/render.js.map +1 -1
  135. package/dist/test/setup-tests.js +1 -1
  136. package/dist/test/setup-tests.js.map +1 -1
  137. package/dist/test/test-plugins/bert/index.js +1 -1
  138. package/dist/test/test-plugins/bert/index.js.map +1 -1
  139. package/dist/test/test-plugins/ernie/index.js +1 -1
  140. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  141. package/dist/test/test-plugins/index.js +1 -1
  142. package/dist/test/test-plugins/index.js.map +1 -1
  143. package/dist/test-utils/index.js +1 -1
  144. package/dist/test-utils/index.js.map +1 -1
  145. package/dist/test-utils/mock-plugin-registry.js +1 -1
  146. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  147. package/package.json +3 -3
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
package/dist/cjs/index.js CHANGED
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -23,7 +23,8 @@ function _export(target, all) {
23
23
  _export(exports, {
24
24
  DatasourceStoreContext: ()=>DatasourceStoreContext,
25
25
  useDatasourceStore: ()=>useDatasourceStore,
26
- useListDatasources: ()=>useListDatasources
26
+ useListDatasources: ()=>useListDatasources,
27
+ useDatasourceClient: ()=>useDatasourceClient
27
28
  });
28
29
  const _reactQuery = require("@tanstack/react-query");
29
30
  const _react = require("react");
@@ -42,3 +43,10 @@ function useListDatasources(datasourcePluginKind) {
42
43
  datasourcePluginKind
43
44
  ], ()=>listDatasourceMetadata(datasourcePluginKind));
44
45
  }
46
+ function useDatasourceClient(selector) {
47
+ const store = useDatasourceStore();
48
+ return (0, _reactQuery.useQuery)([
49
+ 'getDatasourceClient',
50
+ selector
51
+ ], ()=>store.getDatasourceClient(selector));
52
+ }
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.tsx"],"sourcesContent":["// Copyright 2022 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 { TextField, Autocomplete } from '@mui/material';\nimport { OptionsEditorControl } from '@perses-dev/components';\nimport { CALCULATIONS_CONFIG, CalculationConfig, CalculationType } from '../../model/calculations';\n\ntype AutocompleteCalculationOption = CalculationConfig & { id: CalculationType };\nconst CALC_OPTIONS: AutocompleteCalculationOption[] = Object.entries(CALCULATIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as CalculationType,\n ...config,\n };\n});\n\nexport interface CalculationSelectorProps {\n value: CalculationType;\n onChange: (unit: CalculationType) => void;\n}\n\nexport function CalculationSelector({ value, onChange }: CalculationSelectorProps) {\n const handleCalculationChange = (_: unknown, newValue: AutocompleteCalculationOption) => {\n onChange(newValue.id);\n };\n\n const calcConfig = CALCULATIONS_CONFIG[value];\n\n return (\n <OptionsEditorControl\n label=\"Calculation\"\n control={\n <Autocomplete\n value={{\n ...calcConfig,\n id: value,\n }}\n options={CALC_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleCalculationChange}\n disableClearable\n ></Autocomplete>\n }\n />\n );\n}\n"],"names":["TextField","Autocomplete","OptionsEditorControl","CALCULATIONS_CONFIG","CALC_OPTIONS","Object","entries","map","id","config","CalculationSelector","value","onChange","handleCalculationChange","_","newValue","calcConfig","label","control","options","isOptionEqualToValue","option","renderInput","params","disableClearable"],"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,SAAS,EAAEC,YAAY,QAAQ,eAAe,CAAC;AACxD,SAASC,oBAAoB,QAAQ,wBAAwB,CAAC;AAC9D,SAASC,mBAAmB,QAA4C,0BAA0B,CAAC;AAGnG,MAAMC,YAAY,GAAoCC,MAAM,CAACC,OAAO,CAACH,mBAAmB,CAAC,CAACI,GAAG,CAAC,CAAC,CAACC,EAAE,EAAEC,MAAM,CAAC,GAAK;IAC9G,OAAO;QACLD,EAAE,EAAEA,EAAE;QACN,GAAGC,MAAM;KACV,CAAC;AACJ,CAAC,CAAC,AAAC;AAOH,OAAO,SAASC,mBAAmB,CAAC,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAA4B,EAAE;IACjF,MAAMC,uBAAuB,GAAG,CAACC,CAAU,EAAEC,QAAuC,GAAK;QACvFH,QAAQ,CAACG,QAAQ,CAACP,EAAE,CAAC,CAAC;IACxB,CAAC,AAAC;IAEF,MAAMQ,UAAU,GAAGb,mBAAmB,CAACQ,KAAK,CAAC,AAAC;IAE9C,qBACE,KAACT,oBAAoB;QACnBe,KAAK,EAAC,aAAa;QACnBC,OAAO,gBACL,KAACjB,YAAY;YACXU,KAAK,EAAE;gBACL,GAAGK,UAAU;gBACbR,EAAE,EAAEG,KAAK;aACV;YACDQ,OAAO,EAAEf,YAAY;YACrBgB,oBAAoB,EAAE,CAACC,MAAM,EAAEV,KAAK,GAAKU,MAAM,CAACb,EAAE,KAAKG,KAAK,CAACH,EAAE;YAC/Dc,WAAW,EAAE,CAACC,MAAM,iBAAK,KAACvB,SAAS;oBAAE,GAAGuB,MAAM;kBAAI;YAClDX,QAAQ,EAAEC,uBAAuB;YACjCW,gBAAgB;UACF;MAElB,CACF;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.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 { TextField, Autocomplete } from '@mui/material';\nimport { OptionsEditorControl } from '@perses-dev/components';\nimport { CALCULATIONS_CONFIG, CalculationConfig, CalculationType } from '../../model/calculations';\n\ntype AutocompleteCalculationOption = CalculationConfig & { id: CalculationType };\nconst CALC_OPTIONS: AutocompleteCalculationOption[] = Object.entries(CALCULATIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as CalculationType,\n ...config,\n };\n});\n\nexport interface CalculationSelectorProps {\n value: CalculationType;\n onChange: (unit: CalculationType) => void;\n}\n\nexport function CalculationSelector({ value, onChange }: CalculationSelectorProps) {\n const handleCalculationChange = (_: unknown, newValue: AutocompleteCalculationOption) => {\n onChange(newValue.id);\n };\n\n const calcConfig = CALCULATIONS_CONFIG[value];\n\n return (\n <OptionsEditorControl\n label=\"Calculation\"\n control={\n <Autocomplete\n value={{\n ...calcConfig,\n id: value,\n }}\n options={CALC_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleCalculationChange}\n disableClearable\n ></Autocomplete>\n }\n />\n );\n}\n"],"names":["TextField","Autocomplete","OptionsEditorControl","CALCULATIONS_CONFIG","CALC_OPTIONS","Object","entries","map","id","config","CalculationSelector","value","onChange","handleCalculationChange","_","newValue","calcConfig","label","control","options","isOptionEqualToValue","option","renderInput","params","disableClearable"],"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,SAAS,EAAEC,YAAY,QAAQ,eAAe,CAAC;AACxD,SAASC,oBAAoB,QAAQ,wBAAwB,CAAC;AAC9D,SAASC,mBAAmB,QAA4C,0BAA0B,CAAC;AAGnG,MAAMC,YAAY,GAAoCC,MAAM,CAACC,OAAO,CAACH,mBAAmB,CAAC,CAACI,GAAG,CAAC,CAAC,CAACC,EAAE,EAAEC,MAAM,CAAC,GAAK;IAC9G,OAAO;QACLD,EAAE,EAAEA,EAAE;QACN,GAAGC,MAAM;KACV,CAAC;AACJ,CAAC,CAAC,AAAC;AAOH,OAAO,SAASC,mBAAmB,CAAC,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAA4B,EAAE;IACjF,MAAMC,uBAAuB,GAAG,CAACC,CAAU,EAAEC,QAAuC,GAAK;QACvFH,QAAQ,CAACG,QAAQ,CAACP,EAAE,CAAC,CAAC;IACxB,CAAC,AAAC;IAEF,MAAMQ,UAAU,GAAGb,mBAAmB,CAACQ,KAAK,CAAC,AAAC;IAE9C,qBACE,KAACT,oBAAoB;QACnBe,KAAK,EAAC,aAAa;QACnBC,OAAO,gBACL,KAACjB,YAAY;YACXU,KAAK,EAAE;gBACL,GAAGK,UAAU;gBACbR,EAAE,EAAEG,KAAK;aACV;YACDQ,OAAO,EAAEf,YAAY;YACrBgB,oBAAoB,EAAE,CAACC,MAAM,EAAEV,KAAK,GAAKU,MAAM,CAACb,EAAE,KAAKG,KAAK,CAACH,EAAE;YAC/Dc,WAAW,EAAE,CAACC,MAAM,iBAAK,KAACvB,SAAS;oBAAE,GAAGuB,MAAM;kBAAI;YAClDX,QAAQ,EAAEC,uBAAuB;YACjCW,gBAAgB;UACF;MAElB,CACF;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.test.tsx"],"sourcesContent":["// Copyright 2022 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, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { CalculationType } from '../../model/calculations';\nimport { CalculationSelector } from './CalculationSelector';\n\ndescribe('CalculationSelector', () => {\n const renderCalculationSelector = (value: CalculationType, onChange = jest.fn()) => {\n render(\n <div>\n <CalculationSelector value={value} onChange={onChange} />\n </div>\n );\n };\n\n const getCalculationSelector = () => {\n return screen.getByRole('combobox', { name: 'Calculation' });\n };\n\n it('can change the calculation by clicking', () => {\n const onChange = jest.fn();\n renderCalculationSelector('Last', onChange);\n\n const calcSelector = getCalculationSelector();\n userEvent.click(calcSelector);\n const sumOption = screen.getByRole('option', {\n name: 'Sum',\n });\n userEvent.click(sumOption);\n\n expect(onChange).toHaveBeenCalledWith('Sum');\n });\n\n it('can change the calculation using a keyboard', () => {\n const onChange = jest.fn();\n renderCalculationSelector('First', onChange);\n\n const calcSelector = getCalculationSelector();\n userEvent.tab();\n expect(calcSelector).toHaveFocus();\n\n userEvent.clear(calcSelector);\n userEvent.keyboard('first');\n screen.getByRole('option', {\n name: 'First',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith('First');\n });\n});\n"],"names":["render","screen","userEvent","CalculationSelector","describe","renderCalculationSelector","value","onChange","jest","fn","div","getCalculationSelector","getByRole","name","it","calcSelector","click","sumOption","expect","toHaveBeenCalledWith","tab","toHaveFocus","clear","keyboard"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,o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AAAC;QAC3BJ,yBAAyB,CAAC,OAAO,EAAEE,QAAQ,CAAC,CAAC;QAE7C,MAAMQ,YAAY,GAAGJ,sBAAsB,EAAE,AAAC;QAC9CT,SAAS,CAACkB,GAAG,EAAE,CAAC;QAChBF,MAAM,CAACH,YAAY,CAAC,CAACM,WAAW,EAAE,CAAC;QAEnCnB,SAAS,CAACoB,KAAK,CAACP,YAAY,CAAC,CAAC;QAC9Bb,SAAS,CAACqB,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC5BtB,MAAM,CAACW,SAAS,CAAC,QAAQ,EAAE;YACzBC,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QAEHX,SAAS,CAACqB,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QAEvCL,MAAM,CAACX,QAAQ,CAAC,CAACY,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/CalculationSelector/CalculationSelector.test.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, screen } from '@testing-library/react';\nimport userEvent from '@testing-library/user-event';\nimport { CalculationType } from '../../model/calculations';\nimport { CalculationSelector } from './CalculationSelector';\n\ndescribe('CalculationSelector', () => {\n const renderCalculationSelector = (value: CalculationType, onChange = jest.fn()) => {\n render(\n <div>\n <CalculationSelector value={value} onChange={onChange} />\n </div>\n );\n };\n\n const getCalculationSelector = () => {\n return screen.getByRole('combobox', { name: 'Calculation' });\n };\n\n it('can change the calculation by clicking', () => {\n const onChange = jest.fn();\n renderCalculationSelector('Last', onChange);\n\n const calcSelector = getCalculationSelector();\n userEvent.click(calcSelector);\n const sumOption = screen.getByRole('option', {\n name: 'Sum',\n });\n userEvent.click(sumOption);\n\n expect(onChange).toHaveBeenCalledWith('Sum');\n });\n\n it('can change the calculation using a keyboard', () => {\n const onChange = jest.fn();\n renderCalculationSelector('First', onChange);\n\n const calcSelector = getCalculationSelector();\n userEvent.tab();\n expect(calcSelector).toHaveFocus();\n\n userEvent.clear(calcSelector);\n userEvent.keyboard('first');\n screen.getByRole('option', {\n name: 'First',\n });\n\n userEvent.keyboard('{arrowup}{enter}');\n\n expect(onChange).toHaveBeenCalledWith('First');\n });\n});\n"],"names":["render","screen","userEvent","CalculationSelector","describe","renderCalculationSelector","value","onChange","jest","fn","div","getCalculationSelector","getByRole","name","it","calcSelector","click","sumOption","expect","toHaveBeenCalledWith","tab","toHaveFocus","clear","keyboard"],"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,EAAEC,MAAM,QAAQ,wBAAwB,CAAC;AACxD,OAAOC,SAAS,MAAM,6BAA6B,CAAC;AAEpD,SAASC,mBAAmB,QAAQ,uBAAuB,CAAC;AAE5DC,QAAQ,CAAC,qBAAqB,EAAE,IAAM;IACpC,MAAMC,yBAAyB,GAAG,CAACC,KAAsB,EAAEC,QAAQ,GAAGC,IAAI,CAACC,EAAE,EAAE,GAAK;QAClFT,MAAM,eACJ,KAACU,KAAG;sBACF,cAAA,KAACP,mBAAmB;gBAACG,KAAK,EAAEA,KAAK;gBAAEC,QAAQ,EAAEA,QAAQ;cAAI;UACrD,CACP,CAAC;IACJ,CAAC,AAAC;IAEF,MAAMI,sBAAsB,GAAG,IAAM;QACnC,OAAOV,MAAM,CAACW,SA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C,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/CalculationSelector/index.ts"],"sourcesContent":["// Copyright 2022 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 './CalculationSelector';\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,uBAAuB,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/CalculationSelector/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 './CalculationSelector';\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,uBAAuB,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/DatasourceSelect.tsx"],"sourcesContent":["// Copyright 2022 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 { Select, SelectProps, MenuItem } from '@mui/material';\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { useMemo } from 'react';\nimport { useListDatasources } from '../runtime';\n\n// Props on MUI Select that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\nexport interface DatasourceSelectProps extends Omit<SelectProps<string>, OmittedMuiProps> {\n value: DatasourceSelector;\n onChange: (next: DatasourceSelector) => void;\n datasourcePluginKind: string;\n}\n\n/**\n * Displays a MUI input for selecting a Datasource of a particular kind. Note: The 'value' and `onChange` handler for\n * the input deal with a `DatasourceSelector`.\n */\nexport function DatasourceSelect(props: DatasourceSelectProps) {\n const { datasourcePluginKind, value, onChange, ...others } = props;\n const { data, isLoading } = useListDatasources(datasourcePluginKind);\n\n // Convert the datasource list into menu items with name/value strings that the Select input can work with\n const menuItems = useMemo(() => {\n if (data === undefined) return [];\n return data.map((ds) => ({ name: ds.name, value: selectorToOptionValue(ds.selector) }));\n }, [data]);\n\n // While loading available values, just use an empty string so MUI select doesn't warn about values out of range\n const optionValue = isLoading ? '' : selectorToOptionValue(value);\n\n // When the user makes a selection, convert the string option value back to a DatasourceSelector\n const handleChange: SelectProps<string>['onChange'] = (e) => {\n const next = optionValueToSelector(e.target.value);\n onChange(next);\n };\n\n // TODO: Does this need a loading indicator of some kind?\n return (\n <Select {...others} value={optionValue} onChange={handleChange}>\n {menuItems.map((menuItem) => (\n <MenuItem key={menuItem.value} value={menuItem.value}>\n {menuItem.name}\n </MenuItem>\n ))}\n </Select>\n );\n}\n\n// Delimiter used to stringify/parse option values\nconst OPTION_VALUE_DELIMITER = '_____';\n\n// Given a DatasourceSelector, returns a string value like `{kind}_____{name}` that can be used as a Select input value\nfunction selectorToOptionValue(selector: DatasourceSelector): string {\n return [selector.kind, selector.name ?? ''].join(OPTION_VALUE_DELIMITER);\n}\n\n// Given an option value name like `{kind}_____{name}`, returns a DatasourceSelector\nfunction optionValueToSelector(optionValue: string): DatasourceSelector {\n const [kind, name] = optionValue.split(OPTION_VALUE_DELIMITER);\n if (kind === undefined || name === undefined) {\n throw new Error('Invalid optionValue string');\n }\n return {\n kind,\n name: name === '' ? undefined : name,\n };\n}\n"],"names":["Select","MenuItem","useMemo","useListDatasources","DatasourceSelect","props","datasourcePluginKind","value","onChange","others","data","isLoading","menuItems","undefined","map","ds","name","selectorToOptionValue","selector","optionValue","handleChange","e","next","optionValueToSelector","target","menuItem","OPTION_VALUE_DELIMITER","kind","join","split","Error"],"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,EAAeC,QAAQ,QAAQ,eAAe,CAAC;AAE9D,SAASC,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,kBAAkB,QAAQ,YAAY,CAAC;AAYhD;;;CAGC,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ACJ,CAAC;AAED,kDAAkD;AAClD,MAAMmB,sBAAsB,GAAG,OAAO,AAAC;AAEvC,uHAAuH;AACvH,SAAST,qBAAqB,CAACC,QAA4B,EAAU;QAC5CA,KAAa;IAApC,OAAO;QAACA,QAAQ,CAACS,IAAI;QAAET,CAAAA,KAAa,GAAbA,QAAQ,CAACF,IAAI,cAAbE,KAAa,cAAbA,KAAa,GAAI,EAAE;KAAC,CAACU,IAAI,CAACF,sBAAsB,CAAC,CAAC;AAC3E,CAAC;AAED,oFAAoF;AACpF,SAASH,qBAAqB,CAACJ,WAAmB,EAAsB;IACtE,MAAM,CAACQ,IAAI,EAAEX,IAAI,CAAC,GAAGG,WAAW,CAACU,KAAK,CAACH,sBAAsB,CAAC,AAAC;IAC/D,IAAIC,IAAI,KAAKd,SAAS,IAAIG,IAAI,KAAKH,SAAS,EAAE;QAC5C,MAAM,IAAIiB,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IACD,OAAO;QACLH,IAAI;QACJX,IAAI,EAAEA,IAAI,KAAK,EAAE,GAAGH,SAAS,GAAGG,IAAI;KACrC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/components/DatasourceSelect.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 { Select, SelectProps, MenuItem } from '@mui/material';\nimport { DatasourceSelector } from '@perses-dev/core';\nimport { useMemo } from 'react';\nimport { useListDatasources } from '../runtime';\n\n// Props on MUI Select that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\nexport interface DatasourceSelectProps extends Omit<SelectProps<string>, OmittedMuiProps> {\n value: DatasourceSelector;\n onChange: (next: DatasourceSelector) => void;\n datasourcePluginKind: string;\n}\n\n/**\n * Displays a MUI input for selecting a Datasource of a particular kind. Note: The 'value' and `onChange` handler for\n * the input deal with a `DatasourceSelector`.\n */\nexport function DatasourceSelect(props: DatasourceSelectProps) {\n const { datasourcePluginKind, value, onChange, ...others } = props;\n const { data, isLoading } = useListDatasources(datasourcePluginKind);\n\n // Convert the datasource list into menu items with name/value strings that the Select input can work with\n const menuItems = useMemo(() => {\n if (data === undefined) return [];\n return data.map((ds) => ({ name: ds.name, value: selectorToOptionValue(ds.selector) }));\n }, [data]);\n\n // While loading available values, just use an empty string so MUI select doesn't warn about values out of range\n const optionValue = isLoading ? '' : selectorToOptionValue(value);\n\n // When the user makes a selection, convert the string option value back to a DatasourceSelector\n const handleChange: SelectProps<string>['onChange'] = (e) => {\n const next = optionValueToSelector(e.target.value);\n onChange(next);\n };\n\n // TODO: Does this need a loading indicator of some kind?\n return (\n <Select {...others} value={optionValue} onChange={handleChange}>\n {menuItems.map((menuItem) => (\n <MenuItem key={menuItem.value} value={menuItem.value}>\n {menuItem.name}\n </MenuItem>\n ))}\n </Select>\n );\n}\n\n// Delimiter used to stringify/parse option values\nconst OPTION_VALUE_DELIMITER = '_____';\n\n// Given a DatasourceSelector, returns a string value like `{kind}_____{name}` that can be used as a Select input value\nfunction selectorToOptionValue(selector: DatasourceSelector): string {\n return [selector.kind, selector.name ?? ''].join(OPTION_VALUE_DELIMITER);\n}\n\n// Given an option value name like `{kind}_____{name}`, returns a DatasourceSelector\nfunction optionValueToSelector(optionValue: string): DatasourceSelector {\n const [kind, name] = optionValue.split(OPTION_VALUE_DELIMITER);\n if (kind === undefined || name === undefined) {\n throw new Error('Invalid optionValue string');\n }\n return {\n kind,\n name: name === '' ? undefined : name,\n };\n}\n"],"names":["Select","MenuItem","useMemo","useListDatasources","DatasourceSelect","props","datasourcePluginKind","value","onChange","others","data","isLoading","menuItems","undefined","map","ds","name","selectorToOptionValue","selector","optionValue","handleChange","e","next","optionValueToSelector","target","menuItem","OPTION_VALUE_DELIMITER","kind","join","split","Error"],"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,EAAeC,QAAQ,QAAQ,eAAe,CAAC;AAE9D,SAASC,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,kBAAkB,QAAQ,YAAY,CAAC;AAYhD;;;CAGC,GACD,OAAO,SAASC,gBAAgB,CAACC,KAA4B,EAAE;IAC7D,MAAM,EAAEC,oBAAoB,CAAA,EAAEC,KAAK,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGC,MAAM,EAAE,GAAGJ,KAAK,AAAC;IACnE,MAAM,EAAEK,IAAI,CAAA,EAAEC,SAAS,CAAA,EAAE,GAAGR,kBAAkB,CAACG,oBAAoB,CAAC,AAAC;IAErE,0GAA0G;IAC1G,MAAMM,SAAS,GAAGV,OAAO,CAAC,IAAM;QAC9B,IAAIQ,IAAI,KAAKG,SAAS,EAAE,OAAO,EAAE,CAAC;QAClC,OAAOH,IAAI,CAACI,GAAG,CAAC,CAACC,EAAE,GAAM,CAAA;gBAAEC,IAAI,EAAED,EAAE,CAACC,IAAI;gBAAET,KAAK,EAAEU,qBAAqB,CAACF,EAAE,CAACG,QAAQ,CAAC;aAAE,CAAA,AAAC,CAAC,CAAC;IAC1F,CAAC,EAAE;QAACR,IAAI;KAAC,CAAC,AAAC;IAEX,gHAAgH;IAChH,MAAMS,WAAW,GAAGR,SAAS,GAAG,EAAE,GAAGM,qBAAqB,CAACV,KAAK,CAAC,AAAC;IAElE,gGAAgG;IAChG,MAAMa,YAAY,GAAoC,CAACC,CAAC,GAAK;QAC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
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/OptionsEditorTabs/OptionsEditorTabs.tsx"],"sourcesContent":["// Copyright 2022 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 { Tab, TabProps, Tabs, TabsProps, Box } from '@mui/material';\nimport { useState } from 'react';\nimport { TabPanel } from './TabPanel';\n\ninterface BaseTabConfig {\n /**\n * Content rendered when the tab is active.\n */\n content: React.ReactNode;\n}\n\ninterface OtherTabConfig extends BaseTabConfig {\n id: string;\n label: TabProps['label'];\n}\n\ntype CommonTabId = 'query' | 'settings' | 'json';\n\n/**\n * Common tabs that are frequently used in the options editor across multiple\n * plugins. The label and display order of these tabs is not configurable to\n * avoid user experience inconsistencies across plugins.\n */\ntype CommonTabs = { [property in CommonTabId]?: BaseTabConfig };\n\n/**\n * Custom tabs specified for a given plugin. They are displayed after common\n * tabs.\n */\ntype OtherTabs = {\n other?: OtherTabConfig[];\n};\n\nexport type OptionsEditorTabsProps = {\n tabs: CommonTabs & OtherTabs;\n};\n\n// Configuration of the order and labeling for tabs across plugins to enforce a\n// consistent UX.\nconst TAB_CONFIG = [\n { id: 'query', label: 'Query' },\n { id: 'settings', label: 'Settings' },\n\n // Custom tabs go between the visual common tabs and the raw JSON editor.\n 'other',\n\n { id: 'json', label: 'JSON' },\n] as const;\n\nexport const OptionsEditorTabs = ({ tabs }: OptionsEditorTabsProps) => {\n const [activeTab, setActiveTab] = useState(0);\n\n const handleChange: TabsProps['onChange'] = (_, newValue) => {\n setActiveTab(newValue);\n };\n\n // Normalize the common tabs that are managed via constants in this file\n // and custom tabs that bring their own config into a consistent shape for\n // rendering.\n const normalizedTabs = TAB_CONFIG.reduce((combinedTabs, tabConfig) => {\n // Custom tabs\n if (tabConfig === 'other') {\n const otherTabs = tabs?.other || [];\n return [...combinedTabs, ...otherTabs];\n }\n\n // Common tabs\n const commonTab = tabs[tabConfig.id];\n if (commonTab) {\n return [\n ...combinedTabs,\n {\n ...tabConfig,\n ...commonTab,\n },\n ];\n }\n\n return combinedTabs;\n }, [] as OtherTabConfig[]);\n\n return (\n <>\n <Box sx={{ borderBottom: 1, borderColor: (theme) => theme.palette.divider }}>\n <Tabs value={activeTab} onChange={handleChange} aria-label=\"Panel configuration tabs\">\n {normalizedTabs.map(({ id, label }, i) => {\n return (\n <Tab\n key={id}\n label={label}\n id={`options-editor-tab-${i}`}\n aria-controls={`options-editor-tabpanel-${i}`}\n />\n );\n })}\n </Tabs>\n </Box>\n {normalizedTabs.map(({ id, content }, i) => {\n return (\n <TabPanel key={id} value={activeTab} index={i}>\n {content}\n </TabPanel>\n );\n })}\n </>\n );\n};\n"],"names":["Tab","Tabs","Box","useState","TabPanel","TAB_CONFIG","id","label","OptionsEditorTabs","tabs","activeTab","setActiveTab","handleChange","_","newValue","normalizedTabs","reduce","combinedTabs","tabConfig","otherTabs","other","commonTab","sx","borderBottom","borderColor","theme","palette","divider","value","onChange","aria-label","map","i","aria-controls","content","index"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,EAAYC,IAAI,EAAaC,GAAG,QAAQ,eAAe,CAAC;AACpE,SAASC,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,QAAQ,QAAQ,YAAY,CAAC;AAm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EAAE,EAAE;oBAAEC,YAAY,EAAE,CAAC;oBAAEC,WAAW,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAACC,OAAO;iBAAE;0BACzE,cAAA,KAAC1B,IAAI;oBAAC2B,KAAK,EAAElB,SAAS;oBAAEmB,QAAQ,EAAEjB,YAAY;oBAAEkB,YAAU,EAAC,0BAA0B;8BAClFf,cAAc,CAACgB,GAAG,CAAC,CAAC,EAAEzB,EAAE,CAAA,EAAEC,KAAK,CAAA,EAAE,EAAEyB,CAAC,GAAK;wBACxC,qBACE,KAAChC,GAAG;4BAEFO,KAAK,EAAEA,KAAK;4BACZD,EAAE,EAAE,CAAC,mBAAmB,EAAE0B,CAAC,CAAC,CAAC;4BAC7BC,eAAa,EAAE,CAAC,wBAAwB,EAAED,CAAC,CAAC,CAAC;2BAHxC1B,EAAE,CAIP,CACF;oBACJ,CAAC,CAAC;kBACG;cACH;YACLS,cAAc,CAACgB,GAAG,CAAC,CAAC,EAAEzB,EAAE,CAAA,EAAE4B,OAAO,CAAA,EAAE,EAAEF,CAAC,GAAK;gBAC1C,qBACE,KAAC5B,QAAQ;oBAAUwB,KAAK,EAAElB,SAAS;oBAAEyB,KAAK,EAAEH,CAAC;8BAC1CE,OAAO;mBADK5B,EAAE,CAEN,CACX;YACJ,CAAC,CAAC;;MACD,CACH;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/OptionsEditorTabs/OptionsEditorTabs.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 { Tab, TabProps, Tabs, TabsProps, Box } from '@mui/material';\nimport { useState } from 'react';\nimport { TabPanel } from './TabPanel';\n\ninterface BaseTabConfig {\n /**\n * Content rendered when the tab is active.\n */\n content: React.ReactNode;\n}\n\ninterface OtherTabConfig extends BaseTabConfig {\n id: string;\n label: TabProps['label'];\n}\n\ntype CommonTabId = 'query' | 'settings' | 'json';\n\n/**\n * Common tabs that are frequently used in the options editor across multiple\n * plugins. The label and display order of these tabs is not configurable to\n * avoid user experience inconsistencies across plugins.\n */\ntype CommonTabs = { [property in CommonTabId]?: BaseTabConfig };\n\n/**\n * Custom tabs specified for a given plugin. They are displayed after common\n * tabs.\n */\ntype OtherTabs = {\n other?: OtherTabConfig[];\n};\n\nexport type OptionsEditorTabsProps = {\n tabs: CommonTabs & OtherTabs;\n};\n\n// Configuration of the order and labeling for tabs across plugins to enforce a\n// consistent UX.\nconst TAB_CONFIG = [\n { id: 'query', label: 'Query' },\n { id: 'settings', label: 'Settings' },\n\n // Custom tabs go between the visual common tabs and the raw JSON editor.\n 'other',\n\n { id: 'json', label: 'JSON' },\n] as const;\n\nexport const OptionsEditorTabs = ({ tabs }: OptionsEditorTabsProps) => {\n const [activeTab, setActiveTab] = useState(0);\n\n const handleChange: TabsProps['onChange'] = (_, newValue) => {\n setActiveTab(newValue);\n };\n\n // Normalize the common tabs that are managed via constants in this file\n // and custom tabs that bring their own config into a consistent shape for\n // rendering.\n const normalizedTabs = TAB_CONFIG.reduce((combinedTabs, tabConfig) => {\n // Custom tabs\n if (tabConfig === 'other') {\n const otherTabs = tabs?.other || [];\n return [...combinedTabs, ...otherTabs];\n }\n\n // Common tabs\n const commonTab = tabs[tabConfig.id];\n if (commonTab) {\n return [\n ...combinedTabs,\n {\n ...tabConfig,\n ...commonTab,\n },\n ];\n }\n\n return combinedTabs;\n }, [] as OtherTabConfig[]);\n\n return (\n <>\n <Box sx={{ borderBottom: 1, borderColor: (theme) => theme.palette.divider }}>\n <Tabs value={activeTab} onChange={handleChange} aria-label=\"Panel configuration tabs\">\n {normalizedTabs.map(({ id, label }, i) => {\n return (\n <Tab\n key={id}\n label={label}\n id={`options-editor-tab-${i}`}\n aria-controls={`options-editor-tabpanel-${i}`}\n />\n );\n })}\n </Tabs>\n </Box>\n {normalizedTabs.map(({ id, content }, i) => {\n return (\n <TabPanel key={id} value={activeTab} index={i}>\n {content}\n </TabPanel>\n );\n })}\n </>\n );\n};\n"],"names":["Tab","Tabs","Box","useState","TabPanel","TAB_CONFIG","id","label","OptionsEditorTabs","tabs","activeTab","setActiveTab","handleChange","_","newValue","normalizedTabs","reduce","combinedTabs","tabConfig","otherTabs","other","commonTab","sx","borderBottom","borderColor","theme","palette","divider","value","onChange","aria-label","map","i","aria-controls","content","index"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,EAAYC,IAAI,EAAaC,GAAG,QAAQ,eAAe,CAAC;AACpE,SAASC,QAAQ,QAAQ,OAAO,CAAC;AACjC,SAASC,QAAQ,QAAQ,YAAY,CAAC;AAmCtC,+EAA+E;AAC/E,iBAAiB;AACjB,MAAMC,UAAU,GAAG;IACjB;QAAEC,EAAE,EAAE,OAAO;QAAEC,KAAK,EAAE,OAAO;KAAE;IAC/B;QAAED,EAAE,EAAE,UAAU;QAAEC,KAAK,EAAE,UAAU;KAAE;IAErC,yEAAyE;IACzE,OAAO;IAEP;QAAED,EAAE,EAAE,MAAM;QAAEC,KAAK,EAAE,MAAM;KAAE;CAC9B,AAAS,AAAC;AAEX,OAAO,MAAMC,iBAAiB,GAAG,CAAC,EAAEC,IAAI,CAAA,EAA0B,GAAK;IACrE,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGR,QAAQ,CAAC,CAAC,CAAC,AAAC;IAE9C,MAAMS,YAAY,GAA0B,CAACC,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,CAAC,wBAAwB,EAAED,CAAC,CAAC,CAAC;2BAHxC1B,EAAE,CAIP,CACF;oBACJ,CAAC,CAAC;kBACG;cACH;YACLS,cAAc,CAACgB,GAAG,CAAC,CAAC,EAAEzB,EAAE,CAAA,EAAE4B,OAAO,CAAA,EAAE,EAAEF,CAAC,GAAK;gBAC1C,qBACE,KAAC5B,QAAQ;oBAAUwB,KAAK,EAAElB,SAAS;oBAAEyB,KAAK,EAAEH,CAAC;8BAC1CE,OAAO;mBADK5B,EAAE,CAEN,CACX;YACJ,CAAC,CAAC;;MACD,CACH;AACJ,CAAC,CAAC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2022 The Perses Authors
1
+ // Copyright 2023 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at