@perses-dev/plugin-system 0.43.0 → 0.44.0-rc1

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 (255) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +1 -1
  2. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +8 -8
  3. package/dist/cjs/components/DatasourceSelect.js +11 -9
  4. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
  5. package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +3 -3
  6. package/dist/cjs/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  7. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +3 -3
  8. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +49 -11
  9. package/dist/cjs/components/PluginEditor/PluginEditor.js +2 -3
  10. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +3 -3
  11. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +2 -2
  12. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
  13. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +4 -4
  14. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
  15. package/dist/cjs/components/ProjectSelect.js +2 -2
  16. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +3 -3
  17. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +3 -3
  18. package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +143 -0
  19. package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +96 -0
  20. package/dist/cjs/components/TraceQueryEditor/index.js +30 -0
  21. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +29 -23
  22. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +10 -8
  23. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +1 -1
  24. package/dist/cjs/components/Variables/variable-model.js +12 -13
  25. package/dist/cjs/context/ProjectStoreProvider.js +5 -5
  26. package/dist/cjs/model/legend.js +5 -5
  27. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +6 -6
  28. package/dist/cjs/runtime/DataQueriesProvider/model.js +3 -3
  29. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +13 -10
  30. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +3 -3
  31. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +16 -16
  32. package/dist/cjs/runtime/builtin-variables.js +5 -5
  33. package/dist/cjs/runtime/datasources.js +7 -7
  34. package/dist/cjs/runtime/plugin-registry.js +12 -12
  35. package/dist/cjs/runtime/template-variables.js +15 -7
  36. package/dist/cjs/runtime/time-series-queries.js +14 -14
  37. package/dist/cjs/runtime/trace-queries.js +24 -7
  38. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +3 -1
  39. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +1 -1
  40. package/dist/cjs/test/test-plugins/bert/index.js +2 -2
  41. package/dist/cjs/test/test-plugins/ernie/index.js +2 -2
  42. package/dist/cjs/test/test-plugins/index.js +3 -1
  43. package/dist/cjs/test-utils/mock-plugin-registry.js +4 -4
  44. package/dist/cjs/utils/action.js +3 -3
  45. package/dist/cjs/utils/variables.js +4 -4
  46. package/dist/cjs/validation/role.js +3 -3
  47. package/dist/cjs/validation/secret.js +3 -3
  48. package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -2
  49. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  50. package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
  51. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  52. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +1 -1
  53. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  54. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +8 -8
  55. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  56. package/dist/components/DatasourceSelect.d.ts +3 -4
  57. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  58. package/dist/components/DatasourceSelect.js +8 -6
  59. package/dist/components/DatasourceSelect.js.map +1 -1
  60. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +1 -2
  61. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  62. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
  63. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  64. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +3 -3
  65. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
  66. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +3 -3
  67. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  68. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +1 -1
  69. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
  70. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  71. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  72. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -3
  73. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
  74. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +3 -3
  75. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  76. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +1 -2
  77. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  78. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +49 -11
  79. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  80. package/dist/components/PluginEditor/PluginEditor.d.ts +1 -2
  81. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  82. package/dist/components/PluginEditor/PluginEditor.js +2 -3
  83. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  84. package/dist/components/PluginEditor/plugin-editor-api.d.ts +3 -3
  85. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  86. package/dist/components/PluginEditor/plugin-editor-api.js +3 -3
  87. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  88. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +1 -1
  89. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  90. package/dist/components/PluginKindSelect/PluginKindSelect.js +2 -2
  91. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  92. package/dist/components/PluginRegistry/PluginRegistry.d.ts +1 -1
  93. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  94. package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
  95. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  96. package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
  97. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  98. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +1 -2
  99. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  100. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
  101. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  102. package/dist/components/ProjectSelect.d.ts +2 -3
  103. package/dist/components/ProjectSelect.d.ts.map +1 -1
  104. package/dist/components/ProjectSelect.js +2 -2
  105. package/dist/components/ProjectSelect.js.map +1 -1
  106. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +1 -2
  107. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -1
  108. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +3 -3
  109. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -1
  110. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +1 -2
  111. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +1 -1
  112. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +3 -3
  113. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -1
  114. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +8 -0
  115. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +1 -0
  116. package/dist/components/TraceQueryEditor/TraceQueryEditor.js +130 -0
  117. package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +1 -0
  118. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +12 -0
  119. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +1 -0
  120. package/dist/components/TraceQueryEditor/TraceQueryInput.js +83 -0
  121. package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +1 -0
  122. package/dist/components/TraceQueryEditor/index.d.ts +2 -0
  123. package/dist/components/TraceQueryEditor/index.d.ts.map +1 -0
  124. package/dist/components/TraceQueryEditor/index.js +15 -0
  125. package/dist/components/TraceQueryEditor/index.js.map +1 -0
  126. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -1
  127. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  128. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +26 -22
  129. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  130. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +2 -3
  131. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  132. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +4 -4
  133. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  134. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -1
  135. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  136. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +1 -1
  137. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  138. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  139. package/dist/components/Variables/variable-model.js +6 -7
  140. package/dist/components/Variables/variable-model.js.map +1 -1
  141. package/dist/context/ProjectStoreProvider.d.ts +1 -1
  142. package/dist/context/ProjectStoreProvider.d.ts.map +1 -1
  143. package/dist/context/ProjectStoreProvider.js +2 -2
  144. package/dist/context/ProjectStoreProvider.js.map +1 -1
  145. package/dist/context/query-params.js.map +1 -1
  146. package/dist/model/datasource.js +3 -1
  147. package/dist/model/datasource.js.map +1 -1
  148. package/dist/model/legend.d.ts +2 -2
  149. package/dist/model/legend.d.ts.map +1 -1
  150. package/dist/model/legend.js.map +1 -1
  151. package/dist/model/panels.d.ts +3 -2
  152. package/dist/model/panels.d.ts.map +1 -1
  153. package/dist/model/panels.js.map +1 -1
  154. package/dist/model/plugin-loading.js.map +1 -1
  155. package/dist/model/plugins.d.ts +4 -4
  156. package/dist/model/plugins.d.ts.map +1 -1
  157. package/dist/model/plugins.js.map +1 -1
  158. package/dist/model/time-series-queries.d.ts +2 -2
  159. package/dist/model/time-series-queries.d.ts.map +1 -1
  160. package/dist/model/time-series-queries.js.map +1 -1
  161. package/dist/model/trace-queries.d.ts +3 -2
  162. package/dist/model/trace-queries.d.ts.map +1 -1
  163. package/dist/model/trace-queries.js.map +1 -1
  164. package/dist/model/variables.d.ts +2 -2
  165. package/dist/model/variables.d.ts.map +1 -1
  166. package/dist/model/variables.js +3 -1
  167. package/dist/model/variables.js.map +1 -1
  168. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +1 -1
  169. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  170. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +2 -2
  171. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  172. package/dist/runtime/DataQueriesProvider/model.d.ts +2 -2
  173. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  174. package/dist/runtime/DataQueriesProvider/model.js +3 -3
  175. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  176. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +1 -1
  177. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  178. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +6 -5
  179. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  180. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +1 -1
  181. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -1
  182. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +3 -3
  183. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -1
  184. package/dist/runtime/TimeRangeProvider/query-params.d.ts +1 -1
  185. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  186. package/dist/runtime/TimeRangeProvider/query-params.js +4 -4
  187. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  188. package/dist/runtime/builtin-variables.d.ts +1 -1
  189. package/dist/runtime/builtin-variables.d.ts.map +1 -1
  190. package/dist/runtime/builtin-variables.js +2 -2
  191. package/dist/runtime/builtin-variables.js.map +1 -1
  192. package/dist/runtime/datasources.js +1 -1
  193. package/dist/runtime/datasources.js.map +1 -1
  194. package/dist/runtime/plugin-registry.d.ts +2 -2
  195. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  196. package/dist/runtime/plugin-registry.js +4 -4
  197. package/dist/runtime/plugin-registry.js.map +1 -1
  198. package/dist/runtime/template-variables.d.ts +4 -4
  199. package/dist/runtime/template-variables.d.ts.map +1 -1
  200. package/dist/runtime/template-variables.js +10 -2
  201. package/dist/runtime/template-variables.js.map +1 -1
  202. package/dist/runtime/time-series-queries.js +7 -7
  203. package/dist/runtime/time-series-queries.js.map +1 -1
  204. package/dist/runtime/trace-queries.d.ts +6 -2
  205. package/dist/runtime/trace-queries.d.ts.map +1 -1
  206. package/dist/runtime/trace-queries.js +21 -7
  207. package/dist/runtime/trace-queries.js.map +1 -1
  208. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +2 -3
  209. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -1
  210. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  211. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +1 -2
  212. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  213. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +2 -3
  214. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -1
  215. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -1
  216. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +2 -3
  217. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
  218. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +1 -1
  219. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  220. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +2 -3
  221. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +1 -1
  222. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +1 -1
  223. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +2 -3
  224. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
  225. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  226. package/dist/test/render.d.ts +1 -1
  227. package/dist/test/render.d.ts.map +1 -1
  228. package/dist/test/render.js.map +1 -1
  229. package/dist/test/setup-tests.js.map +1 -1
  230. package/dist/test/test-plugins/bert/index.js +2 -2
  231. package/dist/test/test-plugins/bert/index.js.map +1 -1
  232. package/dist/test/test-plugins/ernie/index.js +2 -2
  233. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  234. package/dist/test-utils/mock-plugin-registry.d.ts +1 -1
  235. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  236. package/dist/test-utils/mock-plugin-registry.js +1 -1
  237. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  238. package/dist/utils/variables.js.map +1 -1
  239. package/dist/validation/datasource.d.ts +1 -1
  240. package/dist/validation/datasource.d.ts.map +1 -1
  241. package/dist/validation/datasource.js.map +1 -1
  242. package/dist/validation/resource.js.map +1 -1
  243. package/dist/validation/role.d.ts +43 -43
  244. package/dist/validation/role.d.ts.map +1 -1
  245. package/dist/validation/role.js.map +1 -1
  246. package/dist/validation/rolebinding.d.ts +10 -10
  247. package/dist/validation/rolebinding.d.ts.map +1 -1
  248. package/dist/validation/rolebinding.js.map +1 -1
  249. package/dist/validation/secret.d.ts +19 -19
  250. package/dist/validation/secret.d.ts.map +1 -1
  251. package/dist/validation/secret.js.map +1 -1
  252. package/dist/validation/variable.d.ts +1 -1
  253. package/dist/validation/variable.d.ts.map +1 -1
  254. package/dist/validation/variable.js.map +1 -1
  255. package/package.json +4 -4
@@ -15,10 +15,11 @@ import { ErrorAlert, JSONEditor } from '@perses-dev/components';
15
15
  import { usePlugin } from '../../runtime';
16
16
  import { OptionsEditorTabs } from '../OptionsEditorTabs';
17
17
  import { TimeSeriesQueryEditor } from '../TimeSeriesQueryEditor';
18
+ import { TraceQueryEditor } from '../TraceQueryEditor';
18
19
  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);
20
+ const { panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;
21
+ const { kind } = panelDefinition.spec.plugin;
22
+ const { data: plugin, isLoading, error } = usePlugin('Panel', kind);
22
23
  if (error) {
23
24
  return /*#__PURE__*/ _jsx(ErrorAlert, {
24
25
  error: error
@@ -31,21 +32,58 @@ export function PanelSpecEditor(props) {
31
32
  if (plugin === undefined) {
32
33
  throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);
33
34
  }
34
- const { panelOptionsEditorComponents , hideQueryEditor } = plugin;
35
+ const getQueryType = ()=>{
36
+ var _panelDefinition_spec, _queriesList_;
37
+ const queriesList = panelDefinition === null || panelDefinition === void 0 ? void 0 : (_panelDefinition_spec = panelDefinition.spec) === null || _panelDefinition_spec === void 0 ? void 0 : _panelDefinition_spec.queries;
38
+ if (queriesList === undefined) {
39
+ return '';
40
+ }
41
+ const queryType = (_queriesList_ = queriesList[0]) === null || _queriesList_ === void 0 ? void 0 : _queriesList_.kind;
42
+ return queryType;
43
+ };
44
+ // Get the corresponding queryEditor depending on the queryType
45
+ const getQueryEditorComponent = ()=>{
46
+ const queryType = getQueryType();
47
+ // default case handles cause where there is no queryType yet (e.g. UI > 'editing' mode > 'Add Panel')
48
+ switch(queryType){
49
+ case 'TimeSeriesQuery':
50
+ var _panelDefinition_spec_queries;
51
+ return /*#__PURE__*/ _jsx(TimeSeriesQueryEditor, {
52
+ queries: (_panelDefinition_spec_queries = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries !== void 0 ? _panelDefinition_spec_queries : [],
53
+ onChange: onQueriesChange
54
+ });
55
+ case 'TraceQuery':
56
+ var _panelDefinition_spec_queries1;
57
+ return /*#__PURE__*/ _jsx(TraceQueryEditor, {
58
+ queries: (_panelDefinition_spec_queries1 = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries1 !== void 0 ? _panelDefinition_spec_queries1 : [],
59
+ onChange: onQueriesChange
60
+ });
61
+ default:
62
+ // ScatterChart only handles trace queries for now
63
+ if (kind === 'ScatterChart') {
64
+ var _panelDefinition_spec_queries2;
65
+ return /*#__PURE__*/ _jsx(TraceQueryEditor, {
66
+ queries: (_panelDefinition_spec_queries2 = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries2 !== void 0 ? _panelDefinition_spec_queries2 : [],
67
+ onChange: onQueriesChange
68
+ });
69
+ }
70
+ var _panelDefinition_spec_queries3;
71
+ return /*#__PURE__*/ _jsx(TimeSeriesQueryEditor, {
72
+ queries: (_panelDefinition_spec_queries3 = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries3 !== void 0 ? _panelDefinition_spec_queries3 : [],
73
+ onChange: onQueriesChange
74
+ });
75
+ }
76
+ };
77
+ const { panelOptionsEditorComponents, hideQueryEditor } = plugin;
35
78
  let tabs = [];
36
79
  if (!hideQueryEditor) {
37
- var _panelDefinition_spec_queries;
38
- // Since we only support TimeSeriesQuery for now, we will always show a TimeSeriesQueryEditor
39
80
  tabs.push({
40
81
  label: 'Query',
41
- content: /*#__PURE__*/ _jsx(TimeSeriesQueryEditor, {
42
- queries: (_panelDefinition_spec_queries = panelDefinition.spec.queries) !== null && _panelDefinition_spec_queries !== void 0 ? _panelDefinition_spec_queries : [],
43
- onChange: onQueriesChange
44
- })
82
+ content: getQueryEditorComponent()
45
83
  });
46
84
  }
47
85
  if (panelOptionsEditorComponents !== undefined) {
48
- tabs = tabs.concat(panelOptionsEditorComponents.map(({ label , content: OptionsEditorComponent })=>({
86
+ tabs = tabs.concat(panelOptionsEditorComponents.map(({ label, content: OptionsEditorComponent })=>({
49
87
  label,
50
88
  content: /*#__PURE__*/ _jsx(OptionsEditorComponent, {
51
89
  value: panelDefinition.spec.plugin.spec,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.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 { ErrorAlert, JSONEditor } from '@perses-dev/components';\nimport { PanelDefinition, QueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { usePlugin } from '../../runtime';\nimport { PanelPlugin } from '../../model';\nimport { OptionsEditorTabsProps, OptionsEditorTabs } from '../OptionsEditorTabs';\nimport { TimeSeriesQueryEditor } from '../TimeSeriesQueryEditor';\n\nexport interface PanelSpecEditorProps {\n panelDefinition: PanelDefinition;\n onQueriesChange: (queries: QueryDefinition[]) => void;\n onPluginSpecChange: (spec: UnknownSpec) => void;\n onJSONChange: (panelDefinitionStr: string) => void;\n}\n\nexport function PanelSpecEditor(props: PanelSpecEditorProps) {\n const { panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;\n const { kind } = panelDefinition.spec.plugin;\n const { data: plugin, isLoading, error } = usePlugin('Panel', kind);\n\n if (error) {\n return <ErrorAlert error={error} />;\n }\n\n // TODO: Proper loading indicator\n if (isLoading) {\n return null;\n }\n\n if (plugin === undefined) {\n throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);\n }\n\n const { panelOptionsEditorComponents, hideQueryEditor } = plugin as PanelPlugin;\n let tabs: OptionsEditorTabsProps['tabs'] = [];\n\n if (!hideQueryEditor) {\n // Since we only support TimeSeriesQuery for now, we will always show a TimeSeriesQueryEditor\n tabs.push({\n label: 'Query',\n content: <TimeSeriesQueryEditor queries={panelDefinition.spec.queries ?? []} onChange={onQueriesChange} />,\n });\n }\n\n if (panelOptionsEditorComponents !== undefined) {\n tabs = tabs.concat(\n panelOptionsEditorComponents.map(({ label, content: OptionsEditorComponent }) => ({\n label,\n content: <OptionsEditorComponent value={panelDefinition.spec.plugin.spec} onChange={onPluginSpecChange} />,\n }))\n );\n }\n\n // always show json editor by default\n tabs.push({\n label: 'JSON',\n content: <JSONEditor maxHeight=\"80vh\" value={panelDefinition} onChange={onJSONChange} />,\n });\n\n return <OptionsEditorTabs key={tabs.length} tabs={tabs} />;\n}\n"],"names":["ErrorAlert","JSONEditor","usePlugin","OptionsEditorTabs","TimeSeriesQueryEditor","PanelSpecEditor","props","panelDefinition","onJSONChange","onQueriesChange","onPluginSpecChange","kind","spec","plugin","data","isLoading","error","undefined","Error","panelOptionsEditorComponents","hideQueryEditor","tabs","push","label","content","queries","onChange","concat","map","OptionsEditorComponent","value","maxHeight","length"],"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,SAASA,UAAU,EAAEC,UAAU,QAAQ,yBAAyB;AAEhE,SAASC,SAAS,QAAQ,gBAAgB;AAE1C,SAAiCC,iBAAiB,QAAQ,uBAAuB;AACjF,SAASC,qBAAqB,QAAQ,2BAA2B;AASjE,OAAO,SAASC,gBAAgBC,KAA2B;IACzD,MAAM,EAAEC,gBAAe,EAAEC,aAAY,EAAEC,gBAAe,EAAEC,mBAAkB,EAAE,GAAGJ;IAC/E,MAAM,EAAEK,KAAI,EAAE,GAAGJ,gBAAgBK,KAAKC;IACtC,MAAM,EAAEC,MAAMD,OAAM,EAAEE,UAAS,EAAEC,MAAK,EAAE,GAAGd,UAAU,SAASS;IAE9D,IAAIK,OAAO;QACT,qBAAO,KAAChB;YAAWgB,OAAOA;;IAC5B;IAEA,iCAAiC;IACjC,IAAID,WAAW;QACb,OAAO;IACT;IAEA,IAAIF,WAAWI,WAAW;QACxB,MAAM,IAAIC,MAAM,CAAC,mDAAmD,EAAEP,KAAK,CAAC,CAAC;IAC/E;IAEA,MAAM,EAAEQ,6BAA4B,EAAEC,gBAAe,EAAE,GAAGP;IAC1D,IAAIQ,OAAuC,EAAE;IAE7C,IAAI,CAACD,iBAAiB;YAIuBb;QAH3C,6FAA6F;QAC7Fc,KAAKC,KAAK;YACRC,OAAO;YACPC,uBAAS,KAACpB;gBAAsBqB,SAASlB,CAAAA,gCAAAA,gBAAgBK,KAAKa,qBAArBlB,2CAAAA,gCAAgC,EAAE;gBAAEmB,UAAUjB;;QACzF;IACF;IAEA,IAAIU,iCAAiCF,WAAW;QAC9CI,OAAOA,KAAKM,OACVR,6BAA6BS,IAAI,CAAC,EAAEL,MAAK,EAAEC,SAASK,uBAAsB,EAAE,GAAM,CAAA;gBAChFN;gBACAC,uBAAS,KAACK;oBAAuBC,OAAOvB,gBAAgBK,KAAKC,OAAOD;oBAAMc,UAAUhB;;YACtF,CAAA;IAEJ;IAEA,qCAAqC;IACrCW,KAAKC,KAAK;QACRC,OAAO;QACPC,uBAAS,KAACvB;YAAW8B,WAAU;YAAOD,OAAOvB;YAAiBmB,UAAUlB;;IAC1E;IAEA,qBAAO,KAACL;QAAoCkB,MAAMA;OAAnBA,KAAKW;AACtC"}
1
+ {"version":3,"sources":["../../../src/components/PanelSpecEditor/PanelSpecEditor.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 { ErrorAlert, JSONEditor } from '@perses-dev/components';\nimport { PanelDefinition, QueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { usePlugin } from '../../runtime';\nimport { PanelPlugin } from '../../model';\nimport { OptionsEditorTabsProps, OptionsEditorTabs } from '../OptionsEditorTabs';\nimport { TimeSeriesQueryEditor } from '../TimeSeriesQueryEditor';\nimport { TraceQueryEditor } from '../TraceQueryEditor';\n\nexport interface PanelSpecEditorProps {\n panelDefinition: PanelDefinition;\n onQueriesChange: (queries: QueryDefinition[]) => void;\n onPluginSpecChange: (spec: UnknownSpec) => void;\n onJSONChange: (panelDefinitionStr: string) => void;\n}\n\nexport function PanelSpecEditor(props: PanelSpecEditorProps) {\n const { panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;\n const { kind } = panelDefinition.spec.plugin;\n const { data: plugin, isLoading, error } = usePlugin('Panel', kind);\n\n if (error) {\n return <ErrorAlert error={error} />;\n }\n\n // TODO: Proper loading indicator\n if (isLoading) {\n return null;\n }\n\n if (plugin === undefined) {\n throw new Error(`Missing implementation for panel plugin with kind '${kind}'`);\n }\n\n const getQueryType = (): string => {\n const queriesList = panelDefinition?.spec?.queries;\n if (queriesList === undefined) {\n return '';\n }\n const queryType: string = queriesList[0]?.kind;\n return queryType;\n };\n\n // Get the corresponding queryEditor depending on the queryType\n const getQueryEditorComponent = () => {\n const queryType = getQueryType();\n // default case handles cause where there is no queryType yet (e.g. UI > 'editing' mode > 'Add Panel')\n switch (queryType) {\n case 'TimeSeriesQuery':\n return <TimeSeriesQueryEditor queries={panelDefinition.spec.queries ?? []} onChange={onQueriesChange} />;\n case 'TraceQuery':\n return <TraceQueryEditor queries={panelDefinition.spec.queries ?? []} onChange={onQueriesChange} />;\n default:\n // ScatterChart only handles trace queries for now\n if (kind === 'ScatterChart') {\n return <TraceQueryEditor queries={panelDefinition.spec.queries ?? []} onChange={onQueriesChange} />;\n }\n return <TimeSeriesQueryEditor queries={panelDefinition.spec.queries ?? []} onChange={onQueriesChange} />;\n }\n };\n\n const { panelOptionsEditorComponents, hideQueryEditor } = plugin as PanelPlugin;\n let tabs: OptionsEditorTabsProps['tabs'] = [];\n\n if (!hideQueryEditor) {\n tabs.push({\n label: 'Query',\n content: getQueryEditorComponent(),\n });\n }\n\n if (panelOptionsEditorComponents !== undefined) {\n tabs = tabs.concat(\n panelOptionsEditorComponents.map(({ label, content: OptionsEditorComponent }) => ({\n label,\n content: <OptionsEditorComponent value={panelDefinition.spec.plugin.spec} onChange={onPluginSpecChange} />,\n }))\n );\n }\n\n // always show json editor by default\n tabs.push({\n label: 'JSON',\n content: <JSONEditor maxHeight=\"80vh\" value={panelDefinition} onChange={onJSONChange} />,\n });\n\n return <OptionsEditorTabs key={tabs.length} tabs={tabs} />;\n}\n"],"names":["ErrorAlert","JSONEditor","usePlugin","OptionsEditorTabs","TimeSeriesQueryEditor","TraceQueryEditor","PanelSpecEditor","props","panelDefinition","onJSONChange","onQueriesChange","onPluginSpecChange","kind","spec","plugin","data","isLoading","error","undefined","Error","getQueryType","queriesList","queries","queryType","getQueryEditorComponent","onChange","panelOptionsEditorComponents","hideQueryEditor","tabs","push","label","content","concat","map","OptionsEditorComponent","value","maxHeight","length"],"mappings":"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"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { PluginEditorProps } from './plugin-editor-api';
3
2
  /**
4
3
  * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property
@@ -8,5 +7,5 @@ import { PluginEditorProps } from './plugin-editor-api';
8
7
  * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the
9
8
  * `usePluginEditor` hook that powers this component.
10
9
  */
11
- export declare function PluginEditor(props: PluginEditorProps): JSX.Element;
10
+ export declare function PluginEditor(props: PluginEditorProps): import("react/jsx-runtime").JSX.Element;
12
11
  //# sourceMappingURL=PluginEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PluginEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,qBAAqB,CAAC;AAEzE;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,eA6BpD"}
1
+ {"version":3,"file":"PluginEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,iBAAiB,EAAmB,MAAM,qBAAqB,CAAC;AAEzE;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CA4BpD"}
@@ -24,8 +24,8 @@ import { usePluginEditor } from './plugin-editor-api';
24
24
  * `usePluginEditor` hook that powers this component.
25
25
  */ export function PluginEditor(props) {
26
26
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
27
- const { value , pluginType , pluginKindLabel , onChange: _ , isReadonly , isExplore , ...others } = props;
28
- const { pendingKind , isLoading , error , onKindChange , onSpecChange } = usePluginEditor(props);
27
+ const { value, pluginType, pluginKindLabel, onChange: _, isReadonly, ...others } = props;
28
+ const { pendingKind, isLoading, error, onKindChange, onSpecChange } = usePluginEditor(props);
29
29
  return /*#__PURE__*/ _jsxs(Box, {
30
30
  ...others,
31
31
  children: [
@@ -48,7 +48,6 @@ import { usePluginEditor } from './plugin-editor-api';
48
48
  onChange: onKindChange
49
49
  }),
50
50
  /*#__PURE__*/ _jsx(PluginSpecEditor, {
51
- isExplore: isExplore,
52
51
  pluginType: pluginType,
53
52
  pluginKind: value.kind,
54
53
  value: value.spec,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { PluginKindSelect } from '../PluginKindSelect';\nimport { PluginSpecEditor } from '../PluginSpecEditor';\nimport { PluginEditorProps, usePluginEditor } from './plugin-editor-api';\n\n/**\n * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property\n * that's common in our JSON specs where a user selects a plugin `kind` and then edits the `spec` via that plugin's\n * editor component. It takes care of transitioning from one plugin kind to another \"all at once\" so that when the\n * plugin's kind changes, the spec is also changed at the same time so those options editor components don't see a\n * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the\n * `usePluginEditor` hook that powers this component.\n */\nexport function PluginEditor(props: PluginEditorProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { value, pluginType, pluginKindLabel, onChange: _, isReadonly, isExplore, ...others } = props;\n const { pendingKind, isLoading, error, onKindChange, onSpecChange } = usePluginEditor(props);\n return (\n <Box {...others}>\n <PluginKindSelect\n fullWidth={false}\n sx={{ mb: 1, minWidth: 120 }}\n margin=\"dense\"\n label={pluginKindLabel}\n pluginType={pluginType}\n disabled={isLoading}\n value={pendingKind !== '' ? pendingKind : value.kind}\n InputProps={{ readOnly: isReadonly }}\n error={!!error}\n helperText={error?.message}\n onChange={onKindChange}\n />\n <PluginSpecEditor\n isExplore={isExplore}\n pluginType={pluginType}\n pluginKind={value.kind}\n value={value.spec}\n onChange={onSpecChange}\n isReadonly={isReadonly}\n />\n </Box>\n );\n}\n"],"names":["Box","PluginKindSelect","PluginSpecEditor","usePluginEditor","PluginEditor","props","value","pluginType","pluginKindLabel","onChange","_","isReadonly","isExplore","others","pendingKind","isLoading","error","onKindChange","onSpecChange","fullWidth","sx","mb","minWidth","margin","label","disabled","kind","InputProps","readOnly","helperText","message","pluginKind","spec"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAA4BC,eAAe,QAAQ,sBAAsB;AAEzE;;;;;;;CAOC,GACD,OAAO,SAASC,aAAaC,KAAwB;IACnD,6DAA6D;IAC7D,MAAM,EAAEC,MAAK,EAAEC,WAAU,EAAEC,gBAAe,EAAEC,UAAUC,EAAC,EAAEC,WAAU,EAAEC,UAAS,EAAE,GAAGC,QAAQ,GAAGR;IAC9F,MAAM,EAAES,YAAW,EAAEC,UAAS,EAAEC,MAAK,EAAEC,aAAY,EAAEC,aAAY,EAAE,GAAGf,gBAAgBE;IACtF,qBACE,MAACL;QAAK,GAAGa,MAAM;;0BACb,KAACZ;gBACCkB,WAAW;gBACXC,IAAI;oBAAEC,IAAI;oBAAGC,UAAU;gBAAI;gBAC3BC,QAAO;gBACPC,OAAOhB;gBACPD,YAAYA;gBACZkB,UAAUV;gBACVT,OAAOQ,gBAAgB,KAAKA,cAAcR,MAAMoB;gBAChDC,YAAY;oBAAEC,UAAUjB;gBAAW;gBACnCK,OAAO,CAAC,CAACA;gBACTa,YAAYb,kBAAAA,mBAAAA,KAAAA,IAAAA,MAAOc;gBACnBrB,UAAUQ;;0BAEZ,KAACf;gBACCU,WAAWA;gBACXL,YAAYA;gBACZwB,YAAYzB,MAAMoB;gBAClBpB,OAAOA,MAAM0B;gBACbvB,UAAUS;gBACVP,YAAYA;;;;AAIpB"}
1
+ {"version":3,"sources":["../../../src/components/PluginEditor/PluginEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { PluginKindSelect } from '../PluginKindSelect';\nimport { PluginSpecEditor } from '../PluginSpecEditor';\nimport { PluginEditorProps, usePluginEditor } from './plugin-editor-api';\n\n/**\n * A combination `PluginKindSelect` and `PluginSpecEditor` component. This is meant for editing the `plugin` property\n * that's common in our JSON specs where a user selects a plugin `kind` and then edits the `spec` via that plugin's\n * editor component. It takes care of transitioning from one plugin kind to another \"all at once\" so that when the\n * plugin's kind changes, the spec is also changed at the same time so those options editor components don't see a\n * previous plugin's spec state. If you just want this behavior, but in a different UI layout from this, try the\n * `usePluginEditor` hook that powers this component.\n */\nexport function PluginEditor(props: PluginEditorProps) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { value, pluginType, pluginKindLabel, onChange: _, isReadonly, ...others } = props;\n const { pendingKind, isLoading, error, onKindChange, onSpecChange } = usePluginEditor(props);\n return (\n <Box {...others}>\n <PluginKindSelect\n fullWidth={false}\n sx={{ mb: 1, minWidth: 120 }}\n margin=\"dense\"\n label={pluginKindLabel}\n pluginType={pluginType}\n disabled={isLoading}\n value={pendingKind !== '' ? pendingKind : value.kind}\n InputProps={{ readOnly: isReadonly }}\n error={!!error}\n helperText={error?.message}\n onChange={onKindChange}\n />\n <PluginSpecEditor\n pluginType={pluginType}\n pluginKind={value.kind}\n value={value.spec}\n onChange={onSpecChange}\n isReadonly={isReadonly}\n />\n </Box>\n );\n}\n"],"names":["Box","PluginKindSelect","PluginSpecEditor","usePluginEditor","PluginEditor","props","value","pluginType","pluginKindLabel","onChange","_","isReadonly","others","pendingKind","isLoading","error","onKindChange","onSpecChange","fullWidth","sx","mb","minWidth","margin","label","disabled","kind","InputProps","readOnly","helperText","message","pluginKind","spec"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAA4BC,eAAe,QAAQ,sBAAsB;AAEzE;;;;;;;CAOC,GACD,OAAO,SAASC,aAAaC,KAAwB;IACnD,6DAA6D;IAC7D,MAAM,EAAEC,KAAK,EAAEC,UAAU,EAAEC,eAAe,EAAEC,UAAUC,CAAC,EAAEC,UAAU,EAAE,GAAGC,QAAQ,GAAGP;IACnF,MAAM,EAAEQ,WAAW,EAAEC,SAAS,EAAEC,KAAK,EAAEC,YAAY,EAAEC,YAAY,EAAE,GAAGd,gBAAgBE;IACtF,qBACE,MAACL;QAAK,GAAGY,MAAM;;0BACb,KAACX;gBACCiB,WAAW;gBACXC,IAAI;oBAAEC,IAAI;oBAAGC,UAAU;gBAAI;gBAC3BC,QAAO;gBACPC,OAAOf;gBACPD,YAAYA;gBACZiB,UAAUV;gBACVR,OAAOO,gBAAgB,KAAKA,cAAcP,MAAMmB,IAAI;gBACpDC,YAAY;oBAAEC,UAAUhB;gBAAW;gBACnCI,OAAO,CAAC,CAACA;gBACTa,UAAU,EAAEb,kBAAAA,4BAAAA,MAAOc,OAAO;gBAC1BpB,UAAUO;;0BAEZ,KAACd;gBACCK,YAAYA;gBACZuB,YAAYxB,MAAMmB,IAAI;gBACtBnB,OAAOA,MAAMyB,IAAI;gBACjBtB,UAAUQ;gBACVN,YAAYA;;;;AAIpB"}
@@ -2,7 +2,7 @@
2
2
  import { BoxProps } from '@mui/material';
3
3
  import { Definition, UnknownSpec } from '@perses-dev/core';
4
4
  import { PluginType } from '../../model';
5
- declare type OmittedMuiProps = 'children' | 'value' | 'onChange';
5
+ type OmittedMuiProps = 'children' | 'value' | 'onChange';
6
6
  export interface PluginEditorProps extends Omit<BoxProps, OmittedMuiProps> {
7
7
  pluginType: PluginType;
8
8
  pluginKindLabel: string;
@@ -14,7 +14,7 @@ export interface PluginEditorProps extends Omit<BoxProps, OmittedMuiProps> {
14
14
  /**
15
15
  * Props needed by the usePluginEditor hook.
16
16
  */
17
- export declare type UsePluginEditorProps = Pick<PluginEditorProps, 'pluginType' | 'value' | 'onChange'> & {
17
+ export type UsePluginEditorProps = Pick<PluginEditorProps, 'pluginType' | 'value' | 'onChange'> & {
18
18
  onHideQueryEditorChange?: (isHidden: boolean) => void;
19
19
  };
20
20
  /**
@@ -27,7 +27,7 @@ export declare function usePluginEditor(props: UsePluginEditorProps): {
27
27
  pendingKind: string;
28
28
  isLoading: boolean;
29
29
  error: Error | null;
30
- onKindChange: import("react").ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement>;
30
+ onKindChange: import("react").ChangeEventHandler<HTMLTextAreaElement | HTMLInputElement>;
31
31
  onSpecChange: (next: UnknownSpec) => void;
32
32
  rememberCurrentSpecState: () => void;
33
33
  };
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-editor-api.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/plugin-editor-api.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAY,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EAAe,UAAU,EAAE,MAAM,aAAa,CAAC;AAOtD,aAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC;IACxE,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACnD;AAKD;;GAEG;AACH,oBAAY,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC,GAAG;IAChG,uBAAuB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CACvD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB;;;;;;;EAqG1D"}
1
+ {"version":3,"file":"plugin-editor-api.d.ts","sourceRoot":"","sources":["../../../src/components/PluginEditor/plugin-editor-api.ts"],"names":[],"mappings":";AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAY,MAAM,kBAAkB,CAAC;AAGrE,OAAO,EAAe,UAAU,EAAE,MAAM,aAAa,CAAC;AAOtD,KAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC;IACxE,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CACnD;AAKD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,GAAG,OAAO,GAAG,UAAU,CAAC,GAAG;IAChG,uBAAuB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;CACvD,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB;;;;;;;EAqG1D"}
@@ -21,7 +21,7 @@ import { usePlugin, usePluginRegistry } from '../../runtime';
21
21
  * kind back.
22
22
  */ export function usePluginEditor(props) {
23
23
  // eslint-disable-next-line @typescript-eslint/no-empty-function
24
- const { pluginType , value , onHideQueryEditorChange =()=>{} } = props; // setting onHideQueryEditorChange to empty function here because useEvent requires a function
24
+ const { pluginType, value, onHideQueryEditorChange = ()=>{} } = props; // setting onHideQueryEditorChange to empty function here because useEvent requires a function
25
25
  // Keep a stable reference so we don't run the effect below when we don't need to
26
26
  const onChange = useEvent(props.onChange);
27
27
  const onHideQuery = useEvent(onHideQueryEditorChange);
@@ -43,13 +43,13 @@ import { usePlugin, usePluginRegistry } from '../../runtime';
43
43
  const hideQueryState = useRef({
44
44
  [value.kind]: false
45
45
  });
46
- const { defaultPluginKinds } = usePluginRegistry();
46
+ const { defaultPluginKinds } = usePluginRegistry();
47
47
  const defaultPluginKind = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds[pluginType];
48
48
  const initPendingKind = !value.kind && defaultPluginKind ? defaultPluginKind : '';
49
49
  // When kind changes and we haven't loaded that plugin before, we will need to enter a "pending" state so that we
50
50
  // can generate proper initial spec values that match the new plugin kind
51
51
  const [pendingKind, setPendingKind] = useState(initPendingKind);
52
- const { data: plugin , isFetching , error } = usePlugin(pluginType, pendingKind);
52
+ const { data: plugin, isFetching, error } = usePlugin(pluginType, pendingKind);
53
53
  useEffect(()=>{
54
54
  // Nothing to do if no new plugin kind is pending
55
55
  if (pendingKind === '') return;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PluginEditor/plugin-editor-api.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\nimport { BoxProps } from '@mui/material';\nimport { Definition, UnknownSpec, useEvent } from '@perses-dev/core';\nimport { useState, useRef, useEffect } from 'react';\nimport { produce } from 'immer';\nimport { PanelPlugin, PluginType } from '../../model';\nimport { PluginKindSelectProps } from '../PluginKindSelect/PluginKindSelect';\nimport { PluginSpecEditorProps } from '../PluginSpecEditor/PluginSpecEditor';\nimport { usePlugin, usePluginRegistry } from '../../runtime';\n\n// Props on MUI Box 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 PluginEditorProps extends Omit<BoxProps, OmittedMuiProps> {\n pluginType: PluginType;\n pluginKindLabel: string;\n value: Definition<UnknownSpec>;\n isReadonly?: boolean;\n isExplore?: boolean;\n onChange: (next: Definition<UnknownSpec>) => void;\n}\n\ntype PreviousSpecState = Record<string, Record<string, UnknownSpec>>;\ntype HideQueryEditorState = Record<string, boolean>;\n\n/**\n * Props needed by the usePluginEditor hook.\n */\nexport type UsePluginEditorProps = Pick<PluginEditorProps, 'pluginType' | 'value' | 'onChange'> & {\n onHideQueryEditorChange?: (isHidden: boolean) => void;\n};\n\n/**\n * Returns the state/handlers that power the `PluginEditor` component. Useful for custom components that want to provide\n * a different UI, but want the same behavior of changing `kind` and `spec` together on plugin kind changes. Also\n * remembers previous `spec` values that it's seen, allowing and restores those values if a user switches the plugin\n * kind back.\n */\nexport function usePluginEditor(props: UsePluginEditorProps) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const { pluginType, value, onHideQueryEditorChange = () => {} } = props; // setting onHideQueryEditorChange to empty function here because useEvent requires a function\n\n // Keep a stable reference so we don't run the effect below when we don't need to\n const onChange = useEvent(props.onChange);\n const onHideQuery = useEvent(onHideQueryEditorChange);\n\n // The previous spec state for PluginType and kind and a helper function for remembering current values\n const prevSpecState = useRef<PreviousSpecState>({\n [pluginType]: { [value.kind]: value.spec },\n });\n const rememberCurrentSpecState = useEvent(() => {\n let byPluginType = prevSpecState.current[pluginType];\n if (byPluginType === undefined) {\n byPluginType = {};\n prevSpecState.current[pluginType] = byPluginType;\n }\n byPluginType[value.kind] = value.spec;\n });\n\n // The previous hide query state for each panel kind\n const hideQueryState = useRef<HideQueryEditorState>({\n [value.kind]: false,\n });\n\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPluginKind = defaultPluginKinds?.[pluginType];\n const initPendingKind = !value.kind && defaultPluginKind ? defaultPluginKind : '';\n\n // When kind changes and we haven't loaded that plugin before, we will need to enter a \"pending\" state so that we\n // can generate proper initial spec values that match the new plugin kind\n const [pendingKind, setPendingKind] = useState(initPendingKind);\n const { data: plugin, isFetching, error } = usePlugin(pluginType, pendingKind);\n\n useEffect(() => {\n // Nothing to do if no new plugin kind is pending\n if (pendingKind === '') return;\n\n // Can't get spec value until we have a plugin\n if (plugin === undefined) return;\n\n // Fire an onChange to change to the pending kind with initial values from the plugin\n rememberCurrentSpecState();\n onChange({\n kind: pendingKind,\n spec: plugin.createInitialOptions(),\n });\n\n if (pluginType === 'Panel') {\n const panelPlugin = plugin as PanelPlugin;\n hideQueryState.current[pendingKind] = !!panelPlugin.hideQueryEditor;\n if (!!panelPlugin.hideQueryEditor !== hideQueryState.current[value.kind]) {\n onHideQuery(!!panelPlugin.hideQueryEditor);\n }\n }\n\n setPendingKind('');\n }, [pendingKind, plugin, rememberCurrentSpecState, onChange, onHideQuery, hideQueryState, pluginType, value.kind]);\n\n /**\n * When the user tries to change the plugin kind, make sure we have the correct spec for that plugin kind before we\n * make the switch.\n */\n const onKindChange: PluginKindSelectProps['onChange'] = (e) => {\n const nextKind = e.target.value;\n\n // If we already have state for this plugin type/kind from a previous selection, just use it\n const previousState = prevSpecState.current[pluginType]?.[nextKind];\n if (previousState !== undefined) {\n rememberCurrentSpecState();\n onChange({\n kind: nextKind,\n spec: previousState,\n });\n } else {\n // Otherwise, kick off the async loading process\n setPendingKind(nextKind);\n }\n\n if (\n pluginType === 'Panel' &&\n hideQueryState.current[nextKind] !== undefined &&\n hideQueryState.current[value.kind] !== hideQueryState.current[nextKind]\n ) {\n onHideQuery(!!hideQueryState.current[nextKind]);\n }\n };\n\n /**\n * Spec changes are independent and always just set the spec state.\n */\n const onSpecChange: PluginSpecEditorProps['onChange'] = (next) => {\n onChange(\n produce(value, (draft) => {\n draft.spec = next;\n })\n );\n };\n\n return { pendingKind, isLoading: isFetching, error, onKindChange, onSpecChange, rememberCurrentSpecState };\n}\n"],"names":["useEvent","useState","useRef","useEffect","produce","usePlugin","usePluginRegistry","usePluginEditor","props","pluginType","value","onHideQueryEditorChange","onChange","onHideQuery","prevSpecState","kind","spec","rememberCurrentSpecState","byPluginType","current","undefined","hideQueryState","defaultPluginKinds","defaultPluginKind","initPendingKind","pendingKind","setPendingKind","data","plugin","isFetching","error","createInitialOptions","panelPlugin","hideQueryEditor","onKindChange","e","nextKind","target","previousState","onSpecChange","next","draft","isLoading"],"mappings":"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"}
1
+ {"version":3,"sources":["../../../src/components/PluginEditor/plugin-editor-api.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\nimport { BoxProps } from '@mui/material';\nimport { Definition, UnknownSpec, useEvent } from '@perses-dev/core';\nimport { useState, useRef, useEffect } from 'react';\nimport { produce } from 'immer';\nimport { PanelPlugin, PluginType } from '../../model';\nimport { PluginKindSelectProps } from '../PluginKindSelect/PluginKindSelect';\nimport { PluginSpecEditorProps } from '../PluginSpecEditor/PluginSpecEditor';\nimport { usePlugin, usePluginRegistry } from '../../runtime';\n\n// Props on MUI Box 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 PluginEditorProps extends Omit<BoxProps, OmittedMuiProps> {\n pluginType: PluginType;\n pluginKindLabel: string;\n value: Definition<UnknownSpec>;\n isReadonly?: boolean;\n isExplore?: boolean;\n onChange: (next: Definition<UnknownSpec>) => void;\n}\n\ntype PreviousSpecState = Record<string, Record<string, UnknownSpec>>;\ntype HideQueryEditorState = Record<string, boolean>;\n\n/**\n * Props needed by the usePluginEditor hook.\n */\nexport type UsePluginEditorProps = Pick<PluginEditorProps, 'pluginType' | 'value' | 'onChange'> & {\n onHideQueryEditorChange?: (isHidden: boolean) => void;\n};\n\n/**\n * Returns the state/handlers that power the `PluginEditor` component. Useful for custom components that want to provide\n * a different UI, but want the same behavior of changing `kind` and `spec` together on plugin kind changes. Also\n * remembers previous `spec` values that it's seen, allowing and restores those values if a user switches the plugin\n * kind back.\n */\nexport function usePluginEditor(props: UsePluginEditorProps) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n const { pluginType, value, onHideQueryEditorChange = () => {} } = props; // setting onHideQueryEditorChange to empty function here because useEvent requires a function\n\n // Keep a stable reference so we don't run the effect below when we don't need to\n const onChange = useEvent(props.onChange);\n const onHideQuery = useEvent(onHideQueryEditorChange);\n\n // The previous spec state for PluginType and kind and a helper function for remembering current values\n const prevSpecState = useRef<PreviousSpecState>({\n [pluginType]: { [value.kind]: value.spec },\n });\n const rememberCurrentSpecState = useEvent(() => {\n let byPluginType = prevSpecState.current[pluginType];\n if (byPluginType === undefined) {\n byPluginType = {};\n prevSpecState.current[pluginType] = byPluginType;\n }\n byPluginType[value.kind] = value.spec;\n });\n\n // The previous hide query state for each panel kind\n const hideQueryState = useRef<HideQueryEditorState>({\n [value.kind]: false,\n });\n\n const { defaultPluginKinds } = usePluginRegistry();\n const defaultPluginKind = defaultPluginKinds?.[pluginType];\n const initPendingKind = !value.kind && defaultPluginKind ? defaultPluginKind : '';\n\n // When kind changes and we haven't loaded that plugin before, we will need to enter a \"pending\" state so that we\n // can generate proper initial spec values that match the new plugin kind\n const [pendingKind, setPendingKind] = useState(initPendingKind);\n const { data: plugin, isFetching, error } = usePlugin(pluginType, pendingKind);\n\n useEffect(() => {\n // Nothing to do if no new plugin kind is pending\n if (pendingKind === '') return;\n\n // Can't get spec value until we have a plugin\n if (plugin === undefined) return;\n\n // Fire an onChange to change to the pending kind with initial values from the plugin\n rememberCurrentSpecState();\n onChange({\n kind: pendingKind,\n spec: plugin.createInitialOptions(),\n });\n\n if (pluginType === 'Panel') {\n const panelPlugin = plugin as PanelPlugin;\n hideQueryState.current[pendingKind] = !!panelPlugin.hideQueryEditor;\n if (!!panelPlugin.hideQueryEditor !== hideQueryState.current[value.kind]) {\n onHideQuery(!!panelPlugin.hideQueryEditor);\n }\n }\n\n setPendingKind('');\n }, [pendingKind, plugin, rememberCurrentSpecState, onChange, onHideQuery, hideQueryState, pluginType, value.kind]);\n\n /**\n * When the user tries to change the plugin kind, make sure we have the correct spec for that plugin kind before we\n * make the switch.\n */\n const onKindChange: PluginKindSelectProps['onChange'] = (e) => {\n const nextKind = e.target.value;\n\n // If we already have state for this plugin type/kind from a previous selection, just use it\n const previousState = prevSpecState.current[pluginType]?.[nextKind];\n if (previousState !== undefined) {\n rememberCurrentSpecState();\n onChange({\n kind: nextKind,\n spec: previousState,\n });\n } else {\n // Otherwise, kick off the async loading process\n setPendingKind(nextKind);\n }\n\n if (\n pluginType === 'Panel' &&\n hideQueryState.current[nextKind] !== undefined &&\n hideQueryState.current[value.kind] !== hideQueryState.current[nextKind]\n ) {\n onHideQuery(!!hideQueryState.current[nextKind]);\n }\n };\n\n /**\n * Spec changes are independent and always just set the spec state.\n */\n const onSpecChange: PluginSpecEditorProps['onChange'] = (next) => {\n onChange(\n produce(value, (draft) => {\n draft.spec = next;\n })\n );\n };\n\n return { pendingKind, isLoading: isFetching, error, onKindChange, onSpecChange, rememberCurrentSpecState };\n}\n"],"names":["useEvent","useState","useRef","useEffect","produce","usePlugin","usePluginRegistry","usePluginEditor","props","pluginType","value","onHideQueryEditorChange","onChange","onHideQuery","prevSpecState","kind","spec","rememberCurrentSpecState","byPluginType","current","undefined","hideQueryState","defaultPluginKinds","defaultPluginKind","initPendingKind","pendingKind","setPendingKind","data","plugin","isFetching","error","createInitialOptions","panelPlugin","hideQueryEditor","onKindChange","e","nextKind","target","previousState","onSpecChange","next","draft","isLoading"],"mappings":"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"}
@@ -8,5 +8,5 @@ export interface PluginKindSelectProps extends Omit<TextFieldProps, 'children'>
8
8
  * Displays a MUI Select input for selecting a plugin's kind from a list of all the available plugins of a specific
9
9
  * plugin type. (e.g. "Show a list of all the Panel plugins" or "Show a list of all the Variable plugins").
10
10
  */
11
- export declare const PluginKindSelect: import("react").ForwardRefExoticComponent<Pick<PluginKindSelectProps, "onChange" | "placeholder" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "className" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "value" | "autoFocus" | "label" | "select" | "classes" | "disabled" | "fullWidth" | "size" | "sx" | "autoComplete" | "error" | "name" | "type" | "focused" | "hiddenLabel" | "margin" | "required" | "variant" | "key" | "InputProps" | "FormHelperTextProps" | "helperText" | "InputLabelProps" | "inputProps" | "inputRef" | "multiline" | "rows" | "maxRows" | "minRows" | "SelectProps" | "pluginType"> & import("react").RefAttributes<unknown>>;
11
+ export declare const PluginKindSelect: import("react").ForwardRefExoticComponent<Omit<PluginKindSelectProps, "ref"> & import("react").RefAttributes<unknown>>;
12
12
  //# sourceMappingURL=PluginKindSelect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PluginKindSelect.d.ts","sourceRoot":"","sources":["../../../src/components/PluginKindSelect/PluginKindSelect.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAuB,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC;IAC7E,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,+9JAkB3B,CAAC"}
1
+ {"version":3,"file":"PluginKindSelect.d.ts","sourceRoot":"","sources":["../../../src/components/PluginKindSelect/PluginKindSelect.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAuB,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC;IAC7E,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,wHAkB3B,CAAC"}
@@ -18,8 +18,8 @@ import { useListPluginMetadata } from '../../runtime';
18
18
  * Displays a MUI Select input for selecting a plugin's kind from a list of all the available plugins of a specific
19
19
  * plugin type. (e.g. "Show a list of all the Panel plugins" or "Show a list of all the Variable plugins").
20
20
  */ export const PluginKindSelect = /*#__PURE__*/ forwardRef((props, ref)=>{
21
- const { pluginType , value: propValue , ...others } = props;
22
- const { data , isLoading } = useListPluginMetadata(pluginType);
21
+ const { pluginType, value: propValue, ...others } = props;
22
+ const { data, isLoading } = useListPluginMetadata(pluginType);
23
23
  // Pass an empty value while options are still loading so MUI doesn't complain about us using an "out of range" value
24
24
  const value = propValue !== '' && isLoading ? '' : propValue;
25
25
  // TODO: Does this need a loading indicator of some kind?
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PluginKindSelect/PluginKindSelect.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 { MenuItem, TextField, TextFieldProps } from '@mui/material';\nimport { forwardRef } from 'react';\nimport { PluginType } from '../../model';\nimport { useListPluginMetadata } from '../../runtime';\n\nexport interface PluginKindSelectProps extends Omit<TextFieldProps, 'children'> {\n pluginType: PluginType;\n}\n\n/**\n * Displays a MUI Select input for selecting a plugin's kind from a list of all the available plugins of a specific\n * plugin type. (e.g. \"Show a list of all the Panel plugins\" or \"Show a list of all the Variable plugins\").\n */\nexport const PluginKindSelect = forwardRef((props: PluginKindSelectProps, ref) => {\n const { pluginType, value: propValue, ...others } = props;\n const { data, isLoading } = useListPluginMetadata(pluginType);\n\n // Pass an empty value while options are still loading so MUI doesn't complain about us using an \"out of range\" value\n const value = propValue !== '' && isLoading ? '' : propValue;\n\n // TODO: Does this need a loading indicator of some kind?\n return (\n <TextField select inputRef={ref} {...others} value={value} data-testid=\"plugin-kind-select\">\n {isLoading && <MenuItem value=\"\">Loading...</MenuItem>}\n {data?.map((metadata) => (\n <MenuItem data-testid=\"option\" key={metadata.kind} value={metadata.kind}>\n {metadata.display.name}\n </MenuItem>\n ))}\n </TextField>\n );\n});\nPluginKindSelect.displayName = 'PluginKindSelect';\n"],"names":["MenuItem","TextField","forwardRef","useListPluginMetadata","PluginKindSelect","props","ref","pluginType","value","propValue","others","data","isLoading","select","inputRef","data-testid","map","metadata","kind","display","name","displayName"],"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,SAASA,QAAQ,EAAEC,SAAS,QAAwB,gBAAgB;AACpE,SAASC,UAAU,QAAQ,QAAQ;AAEnC,SAASC,qBAAqB,QAAQ,gBAAgB;AAMtD;;;CAGC,GACD,OAAO,MAAMC,iCAAmBF,WAAW,CAACG,OAA8BC;IACxE,MAAM,EAAEC,WAAU,EAAEC,OAAOC,UAAS,EAAE,GAAGC,QAAQ,GAAGL;IACpD,MAAM,EAAEM,KAAI,EAAEC,UAAS,EAAE,GAAGT,sBAAsBI;IAElD,qHAAqH;IACrH,MAAMC,QAAQC,cAAc,MAAMG,YAAY,KAAKH;IAEnD,yDAAyD;IACzD,qBACE,MAACR;QAAUY,MAAM;QAACC,UAAUR;QAAM,GAAGI,MAAM;QAAEF,OAAOA;QAAOO,eAAY;;YACpEH,2BAAa,KAACZ;gBAASQ,OAAM;0BAAG;;YAChCG,iBAAAA,kBAAAA,KAAAA,IAAAA,KAAMK,IAAI,CAACC,yBACV,KAACjB;oBAASe,eAAY;oBAA6BP,OAAOS,SAASC;8BAChED,SAASE,QAAQC;mBADgBH,SAASC;;;AAMrD,GAAG;AACHd,iBAAiBiB,cAAc"}
1
+ {"version":3,"sources":["../../../src/components/PluginKindSelect/PluginKindSelect.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 { MenuItem, TextField, TextFieldProps } from '@mui/material';\nimport { forwardRef } from 'react';\nimport { PluginType } from '../../model';\nimport { useListPluginMetadata } from '../../runtime';\n\nexport interface PluginKindSelectProps extends Omit<TextFieldProps, 'children'> {\n pluginType: PluginType;\n}\n\n/**\n * Displays a MUI Select input for selecting a plugin's kind from a list of all the available plugins of a specific\n * plugin type. (e.g. \"Show a list of all the Panel plugins\" or \"Show a list of all the Variable plugins\").\n */\nexport const PluginKindSelect = forwardRef((props: PluginKindSelectProps, ref) => {\n const { pluginType, value: propValue, ...others } = props;\n const { data, isLoading } = useListPluginMetadata(pluginType);\n\n // Pass an empty value while options are still loading so MUI doesn't complain about us using an \"out of range\" value\n const value = propValue !== '' && isLoading ? '' : propValue;\n\n // TODO: Does this need a loading indicator of some kind?\n return (\n <TextField select inputRef={ref} {...others} value={value} data-testid=\"plugin-kind-select\">\n {isLoading && <MenuItem value=\"\">Loading...</MenuItem>}\n {data?.map((metadata) => (\n <MenuItem data-testid=\"option\" key={metadata.kind} value={metadata.kind}>\n {metadata.display.name}\n </MenuItem>\n ))}\n </TextField>\n );\n});\nPluginKindSelect.displayName = 'PluginKindSelect';\n"],"names":["MenuItem","TextField","forwardRef","useListPluginMetadata","PluginKindSelect","props","ref","pluginType","value","propValue","others","data","isLoading","select","inputRef","data-testid","map","metadata","kind","display","name","displayName"],"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,SAASA,QAAQ,EAAEC,SAAS,QAAwB,gBAAgB;AACpE,SAASC,UAAU,QAAQ,QAAQ;AAEnC,SAASC,qBAAqB,QAAQ,gBAAgB;AAMtD;;;CAGC,GACD,OAAO,MAAMC,iCAAmBF,WAAW,CAACG,OAA8BC;IACxE,MAAM,EAAEC,UAAU,EAAEC,OAAOC,SAAS,EAAE,GAAGC,QAAQ,GAAGL;IACpD,MAAM,EAAEM,IAAI,EAAEC,SAAS,EAAE,GAAGT,sBAAsBI;IAElD,qHAAqH;IACrH,MAAMC,QAAQC,cAAc,MAAMG,YAAY,KAAKH;IAEnD,yDAAyD;IACzD,qBACE,MAACR;QAAUY,MAAM;QAACC,UAAUR;QAAM,GAAGI,MAAM;QAAEF,OAAOA;QAAOO,eAAY;;YACpEH,2BAAa,KAACZ;gBAASQ,OAAM;0BAAG;;YAChCG,iBAAAA,2BAAAA,KAAMK,GAAG,CAAC,CAACC,yBACV,KAACjB;oBAASe,eAAY;oBAA6BP,OAAOS,SAASC,IAAI;8BACpED,SAASE,OAAO,CAACC,IAAI;mBADYH,SAASC,IAAI;;;AAMzD,GAAG;AACHd,iBAAiBiB,WAAW,GAAG"}
@@ -9,5 +9,5 @@ export interface PluginRegistryProps {
9
9
  * PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or
10
10
  * querying the metadata about them.
11
11
  */
12
- export declare function PluginRegistry(props: PluginRegistryProps): JSX.Element;
12
+ export declare function PluginRegistry(props: PluginRegistryProps): import("react/jsx-runtime").JSX.Element;
13
13
  //# sourceMappingURL=PluginRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PluginRegistry.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"names":[],"mappings":";AAeA,OAAO,EAKL,YAAY,EACZ,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,eAoExD"}
1
+ {"version":3,"file":"PluginRegistry.d.ts","sourceRoot":"","sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"names":[],"mappings":";AAeA,OAAO,EAKL,YAAY,EACZ,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,2CAoExD"}
@@ -19,7 +19,7 @@ import { usePluginIndexes, getTypeAndKindKey } from './plugin-indexes';
19
19
  * PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or
20
20
  * querying the metadata about them.
21
21
  */ export function PluginRegistry(props) {
22
- const { pluginLoader: { getInstalledPlugins , importPluginModule } , children , defaultPluginKinds } = props;
22
+ const { pluginLoader: { getInstalledPlugins, importPluginModule }, children, defaultPluginKinds } = props;
23
23
  const getPluginIndexes = usePluginIndexes(getInstalledPlugins);
24
24
  // De-dupe calls to import plugin modules
25
25
  const importCache = useRef(new Map());
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec, useEvent } from '@perses-dev/core';\nimport { useRef, useCallback, useMemo } from 'react';\nimport {\n PluginModuleResource,\n PluginType,\n PluginImplementation,\n Plugin,\n PluginLoader,\n DefaultPluginKinds,\n} from '../../model';\nimport { PluginRegistryContext } from '../../runtime';\nimport { usePluginIndexes, getTypeAndKindKey } from './plugin-indexes';\n\nexport interface PluginRegistryProps {\n pluginLoader: PluginLoader;\n defaultPluginKinds: DefaultPluginKinds;\n children?: React.ReactNode;\n}\n\n/**\n * PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or\n * querying the metadata about them.\n */\nexport function PluginRegistry(props: PluginRegistryProps) {\n const {\n pluginLoader: { getInstalledPlugins, importPluginModule },\n children,\n defaultPluginKinds,\n } = props;\n\n const getPluginIndexes = usePluginIndexes(getInstalledPlugins);\n\n // De-dupe calls to import plugin modules\n const importCache = useRef(new Map<PluginModuleResource, Promise<unknown>>());\n\n // Do useEvent here since this accesses the importPluginModule prop and we want a stable reference to it for the\n // callback below\n const loadPluginModule = useEvent((resource: PluginModuleResource) => {\n let request = importCache.current.get(resource);\n if (request === undefined) {\n request = importPluginModule(resource);\n importCache.current.set(resource, request);\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => importCache.current.delete(resource));\n }\n return request;\n });\n\n const getPlugin = useCallback(\n async <T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>> => {\n // Get the indexes of the installed plugins\n const pluginIndexes = await getPluginIndexes();\n\n // Figure out what module the plugin is in by looking in the index\n const typeAndKindKey = getTypeAndKindKey(pluginType, kind);\n const resource = pluginIndexes.pluginResourcesByTypeAndKind.get(typeAndKindKey);\n if (resource === undefined) {\n throw new Error(`A ${pluginType} plugin for kind '${kind}' is not installed`);\n }\n\n // Treat the plugin module as a bunch of named exports that have plugins\n const pluginModule = (await loadPluginModule(resource)) as Record<string, Plugin<UnknownSpec>>;\n\n // We currently assume that plugin modules will have named exports that match the kinds they handle\n const plugin = pluginModule[kind];\n if (plugin === undefined) {\n throw new Error(\n `The ${pluginType} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`\n );\n }\n\n return plugin as PluginImplementation<T>;\n },\n [getPluginIndexes, loadPluginModule]\n );\n\n const listPluginMetadata = useCallback(\n async (pluginType: PluginType) => {\n const pluginIndexes = await getPluginIndexes();\n return pluginIndexes.pluginMetadataByType.get(pluginType) ?? [];\n },\n [getPluginIndexes]\n );\n\n // Create the registry's context value and render\n const context = useMemo(\n () => ({ getPlugin, listPluginMetadata, defaultPluginKinds }),\n [getPlugin, listPluginMetadata, defaultPluginKinds]\n );\n return <PluginRegistryContext.Provider value={context}>{children}</PluginRegistryContext.Provider>;\n}\n"],"names":["useEvent","useRef","useCallback","useMemo","PluginRegistryContext","usePluginIndexes","getTypeAndKindKey","PluginRegistry","props","pluginLoader","getInstalledPlugins","importPluginModule","children","defaultPluginKinds","getPluginIndexes","importCache","Map","loadPluginModule","resource","request","current","get","undefined","set","catch","delete","getPlugin","pluginType","kind","pluginIndexes","typeAndKindKey","pluginResourcesByTypeAndKind","Error","pluginModule","plugin","metadata","name","listPluginMetadata","pluginMetadataByType","context","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAsBA,QAAQ,QAAQ,mBAAmB;AACzD,SAASC,MAAM,EAAEC,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AASrD,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,mBAAmB;AAQvE;;;CAGC,GACD,OAAO,SAASC,eAAeC,KAA0B;IACvD,MAAM,EACJC,cAAc,EAAEC,oBAAmB,EAAEC,mBAAkB,EAAE,CAAA,EACzDC,SAAQ,EACRC,mBAAkB,EACnB,GAAGL;IAEJ,MAAMM,mBAAmBT,iBAAiBK;IAE1C,yCAAyC;IACzC,MAAMK,cAAcd,OAAO,IAAIe;IAE/B,gHAAgH;IAChH,iBAAiB;IACjB,MAAMC,mBAAmBjB,SAAS,CAACkB;QACjC,IAAIC,UAAUJ,YAAYK,QAAQC,IAAIH;QACtC,IAAIC,YAAYG,WAAW;YACzBH,UAAUR,mBAAmBO;YAC7BH,YAAYK,QAAQG,IAAIL,UAAUC;YAElC,2EAA2E;YAC3EA,QAAQK,MAAM,IAAMT,YAAYK,QAAQK,OAAOP;QACjD;QACA,OAAOC;IACT;IAEA,MAAMO,YAAYxB,YAChB,OAA6ByB,YAAeC;QAC1C,2CAA2C;QAC3C,MAAMC,gBAAgB,MAAMf;QAE5B,kEAAkE;QAClE,MAAMgB,iBAAiBxB,kBAAkBqB,YAAYC;QACrD,MAAMV,WAAWW,cAAcE,6BAA6BV,IAAIS;QAChE,IAAIZ,aAAaI,WAAW;YAC1B,MAAM,IAAIU,MAAM,CAAC,EAAE,EAAEL,WAAW,kBAAkB,EAAEC,KAAK,kBAAkB,CAAC;QAC9E;QAEA,wEAAwE;QACxE,MAAMK,eAAgB,MAAMhB,iBAAiBC;QAE7C,mGAAmG;QACnG,MAAMgB,SAASD,YAAY,CAACL,KAAK;QACjC,IAAIM,WAAWZ,WAAW;YACxB,MAAM,IAAIU,MACR,CAAC,IAAI,EAAEL,WAAW,kBAAkB,EAAEC,KAAK,sBAAsB,EAAEV,SAASiB,SAASC,KAAK,cAAc,CAAC;QAE7G;QAEA,OAAOF;IACT,GACA;QAACpB;QAAkBG;KAAiB;IAGtC,MAAMoB,qBAAqBnC,YACzB,OAAOyB;QACL,MAAME,gBAAgB,MAAMf;YACrBe;QAAP,OAAOA,CAAAA,0CAAAA,cAAcS,qBAAqBjB,IAAIM,yBAAvCE,qDAAAA,0CAAsD,EAAE;IACjE,GACA;QAACf;KAAiB;IAGpB,iDAAiD;IACjD,MAAMyB,UAAUpC,QACd,IAAO,CAAA;YAAEuB;YAAWW;YAAoBxB;QAAmB,CAAA,GAC3D;QAACa;QAAWW;QAAoBxB;KAAmB;IAErD,qBAAO,KAACT,sBAAsBoC;QAASC,OAAOF;kBAAU3B;;AAC1D"}
1
+ {"version":3,"sources":["../../../src/components/PluginRegistry/PluginRegistry.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnknownSpec, useEvent } from '@perses-dev/core';\nimport { useRef, useCallback, useMemo } from 'react';\nimport {\n PluginModuleResource,\n PluginType,\n PluginImplementation,\n Plugin,\n PluginLoader,\n DefaultPluginKinds,\n} from '../../model';\nimport { PluginRegistryContext } from '../../runtime';\nimport { usePluginIndexes, getTypeAndKindKey } from './plugin-indexes';\n\nexport interface PluginRegistryProps {\n pluginLoader: PluginLoader;\n defaultPluginKinds: DefaultPluginKinds;\n children?: React.ReactNode;\n}\n\n/**\n * PluginRegistryContext provider that keeps track of all available plugins and provides an API for getting them or\n * querying the metadata about them.\n */\nexport function PluginRegistry(props: PluginRegistryProps) {\n const {\n pluginLoader: { getInstalledPlugins, importPluginModule },\n children,\n defaultPluginKinds,\n } = props;\n\n const getPluginIndexes = usePluginIndexes(getInstalledPlugins);\n\n // De-dupe calls to import plugin modules\n const importCache = useRef(new Map<PluginModuleResource, Promise<unknown>>());\n\n // Do useEvent here since this accesses the importPluginModule prop and we want a stable reference to it for the\n // callback below\n const loadPluginModule = useEvent((resource: PluginModuleResource) => {\n let request = importCache.current.get(resource);\n if (request === undefined) {\n request = importPluginModule(resource);\n importCache.current.set(resource, request);\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => importCache.current.delete(resource));\n }\n return request;\n });\n\n const getPlugin = useCallback(\n async <T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>> => {\n // Get the indexes of the installed plugins\n const pluginIndexes = await getPluginIndexes();\n\n // Figure out what module the plugin is in by looking in the index\n const typeAndKindKey = getTypeAndKindKey(pluginType, kind);\n const resource = pluginIndexes.pluginResourcesByTypeAndKind.get(typeAndKindKey);\n if (resource === undefined) {\n throw new Error(`A ${pluginType} plugin for kind '${kind}' is not installed`);\n }\n\n // Treat the plugin module as a bunch of named exports that have plugins\n const pluginModule = (await loadPluginModule(resource)) as Record<string, Plugin<UnknownSpec>>;\n\n // We currently assume that plugin modules will have named exports that match the kinds they handle\n const plugin = pluginModule[kind];\n if (plugin === undefined) {\n throw new Error(\n `The ${pluginType} plugin for kind '${kind}' is missing from the ${resource.metadata.name} plugin module`\n );\n }\n\n return plugin as PluginImplementation<T>;\n },\n [getPluginIndexes, loadPluginModule]\n );\n\n const listPluginMetadata = useCallback(\n async (pluginType: PluginType) => {\n const pluginIndexes = await getPluginIndexes();\n return pluginIndexes.pluginMetadataByType.get(pluginType) ?? [];\n },\n [getPluginIndexes]\n );\n\n // Create the registry's context value and render\n const context = useMemo(\n () => ({ getPlugin, listPluginMetadata, defaultPluginKinds }),\n [getPlugin, listPluginMetadata, defaultPluginKinds]\n );\n return <PluginRegistryContext.Provider value={context}>{children}</PluginRegistryContext.Provider>;\n}\n"],"names":["useEvent","useRef","useCallback","useMemo","PluginRegistryContext","usePluginIndexes","getTypeAndKindKey","PluginRegistry","props","pluginLoader","getInstalledPlugins","importPluginModule","children","defaultPluginKinds","getPluginIndexes","importCache","Map","loadPluginModule","resource","request","current","get","undefined","set","catch","delete","getPlugin","pluginType","kind","pluginIndexes","typeAndKindKey","pluginResourcesByTypeAndKind","Error","pluginModule","plugin","metadata","name","listPluginMetadata","pluginMetadataByType","context","Provider","value"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAAsBA,QAAQ,QAAQ,mBAAmB;AACzD,SAASC,MAAM,EAAEC,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AASrD,SAASC,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,mBAAmB;AAQvE;;;CAGC,GACD,OAAO,SAASC,eAAeC,KAA0B;IACvD,MAAM,EACJC,cAAc,EAAEC,mBAAmB,EAAEC,kBAAkB,EAAE,EACzDC,QAAQ,EACRC,kBAAkB,EACnB,GAAGL;IAEJ,MAAMM,mBAAmBT,iBAAiBK;IAE1C,yCAAyC;IACzC,MAAMK,cAAcd,OAAO,IAAIe;IAE/B,gHAAgH;IAChH,iBAAiB;IACjB,MAAMC,mBAAmBjB,SAAS,CAACkB;QACjC,IAAIC,UAAUJ,YAAYK,OAAO,CAACC,GAAG,CAACH;QACtC,IAAIC,YAAYG,WAAW;YACzBH,UAAUR,mBAAmBO;YAC7BH,YAAYK,OAAO,CAACG,GAAG,CAACL,UAAUC;YAElC,2EAA2E;YAC3EA,QAAQK,KAAK,CAAC,IAAMT,YAAYK,OAAO,CAACK,MAAM,CAACP;QACjD;QACA,OAAOC;IACT;IAEA,MAAMO,YAAYxB,YAChB,OAA6ByB,YAAeC;QAC1C,2CAA2C;QAC3C,MAAMC,gBAAgB,MAAMf;QAE5B,kEAAkE;QAClE,MAAMgB,iBAAiBxB,kBAAkBqB,YAAYC;QACrD,MAAMV,WAAWW,cAAcE,4BAA4B,CAACV,GAAG,CAACS;QAChE,IAAIZ,aAAaI,WAAW;YAC1B,MAAM,IAAIU,MAAM,CAAC,EAAE,EAAEL,WAAW,kBAAkB,EAAEC,KAAK,kBAAkB,CAAC;QAC9E;QAEA,wEAAwE;QACxE,MAAMK,eAAgB,MAAMhB,iBAAiBC;QAE7C,mGAAmG;QACnG,MAAMgB,SAASD,YAAY,CAACL,KAAK;QACjC,IAAIM,WAAWZ,WAAW;YACxB,MAAM,IAAIU,MACR,CAAC,IAAI,EAAEL,WAAW,kBAAkB,EAAEC,KAAK,sBAAsB,EAAEV,SAASiB,QAAQ,CAACC,IAAI,CAAC,cAAc,CAAC;QAE7G;QAEA,OAAOF;IACT,GACA;QAACpB;QAAkBG;KAAiB;IAGtC,MAAMoB,qBAAqBnC,YACzB,OAAOyB;QACL,MAAME,gBAAgB,MAAMf;YACrBe;QAAP,OAAOA,CAAAA,0CAAAA,cAAcS,oBAAoB,CAACjB,GAAG,CAACM,yBAAvCE,qDAAAA,0CAAsD,EAAE;IACjE,GACA;QAACf;KAAiB;IAGpB,iDAAiD;IACjD,MAAMyB,UAAUpC,QACd,IAAO,CAAA;YAAEuB;YAAWW;YAAoBxB;QAAmB,CAAA,GAC3D;QAACa;QAAWW;QAAoBxB;KAAmB;IAErD,qBAAO,KAACT,sBAAsBoC,QAAQ;QAACC,OAAOF;kBAAU3B;;AAC1D"}
@@ -24,7 +24,7 @@ import { useCallback, useRef } from 'react';
24
24
  const pluginMetadataByType = new Map();
25
25
  for (const resource of installedPlugins){
26
26
  for (const pluginMetadata of resource.spec.plugins){
27
- const { pluginType , kind } = pluginMetadata;
27
+ const { pluginType, kind } = pluginMetadata;
28
28
  // Index the plugin by type and kind to point at the module that contains it
29
29
  const key = getTypeAndKindKey(pluginType, kind);
30
30
  if (pluginResourcesByTypeAndKind.has(key)) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PluginRegistry/plugin-indexes.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\nimport { useEvent } from '@perses-dev/core';\nimport { useCallback, useRef } from 'react';\nimport { PluginLoader, PluginMetadata, PluginModuleResource, PluginType } from '../../model';\n\nexport interface PluginIndexes {\n // Plugin resources by plugin type and kind (i.e. look up what module a plugin type and kind is in)\n pluginResourcesByTypeAndKind: Map<string, PluginModuleResource>;\n // Plugin metadata by plugin type\n pluginMetadataByType: Map<PluginType, PluginMetadata[]>;\n}\n\n/**\n * Returns an async callback for getting indexes of the installed plugin data.\n */\nexport function usePluginIndexes(getInstalledPlugins: PluginLoader['getInstalledPlugins']) {\n // Creates indexes from the installed plugins data (does useEvent because this accesses the getInstalledPlugins prop\n // and we want a stable reference for the callback below)\n const createPluginIndexes = useEvent(async (): Promise<PluginIndexes> => {\n const installedPlugins = await getInstalledPlugins();\n\n // Create the two indexes from the installed plugins\n const pluginResourcesByTypeAndKind = new Map<string, PluginModuleResource>();\n const pluginMetadataByType = new Map<PluginType, PluginMetadata[]>();\n\n for (const resource of installedPlugins) {\n for (const pluginMetadata of resource.spec.plugins) {\n const { pluginType, kind } = pluginMetadata;\n\n // Index the plugin by type and kind to point at the module that contains it\n const key = getTypeAndKindKey(pluginType, kind);\n if (pluginResourcesByTypeAndKind.has(key)) {\n console.warn(`Got more than one ${pluginType} plugin for kind ${kind}`);\n }\n pluginResourcesByTypeAndKind.set(key, resource);\n\n // Index the metadata by plugin type\n let list = pluginMetadataByType.get(pluginType);\n if (list === undefined) {\n list = [];\n pluginMetadataByType.set(pluginType, list);\n }\n list.push(pluginMetadata);\n }\n }\n\n return {\n pluginResourcesByTypeAndKind,\n pluginMetadataByType,\n };\n });\n\n // De-dupe creating plugin indexes (i.e. requests to get installed plugins)\n const pluginIndexesCache = useRef<Promise<PluginIndexes> | undefined>(undefined);\n const getPluginIndexes = useCallback(() => {\n let request = pluginIndexesCache.current;\n if (request === undefined) {\n request = createPluginIndexes();\n pluginIndexesCache.current = request;\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => pluginIndexesCache.current === undefined);\n }\n return request;\n }, [createPluginIndexes]);\n\n return getPluginIndexes;\n}\n\n/**\n * Gets a unique key for a plugin type/kind that can be used as a cache key.\n */\nexport function getTypeAndKindKey(pluginType: PluginType, kind: string) {\n return `${pluginType}:${kind}`;\n}\n"],"names":["useEvent","useCallback","useRef","usePluginIndexes","getInstalledPlugins","createPluginIndexes","installedPlugins","pluginResourcesByTypeAndKind","Map","pluginMetadataByType","resource","pluginMetadata","spec","plugins","pluginType","kind","key","getTypeAndKindKey","has","console","warn","set","list","get","undefined","push","pluginIndexesCache","getPluginIndexes","request","current","catch"],"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,SAASA,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,WAAW,EAAEC,MAAM,QAAQ,QAAQ;AAU5C;;CAEC,GACD,OAAO,SAASC,iBAAiBC,mBAAwD;IACvF,oHAAoH;IACpH,yDAAyD;IACzD,MAAMC,sBAAsBL,SAAS;QACnC,MAAMM,mBAAmB,MAAMF;QAE/B,oDAAoD;QACpD,MAAMG,+BAA+B,IAAIC;QACzC,MAAMC,uBAAuB,IAAID;QAEjC,KAAK,MAAME,YAAYJ,iBAAkB;YACvC,KAAK,MAAMK,kBAAkBD,SAASE,KAAKC,QAAS;gBAClD,MAAM,EAAEC,WAAU,EAAEC,KAAI,EAAE,GAAGJ;gBAE7B,4EAA4E;gBAC5E,MAAMK,MAAMC,kBAAkBH,YAAYC;gBAC1C,IAAIR,6BAA6BW,IAAIF,MAAM;oBACzCG,QAAQC,KAAK,CAAC,kBAAkB,EAAEN,WAAW,iBAAiB,EAAEC,KAAK,CAAC;gBACxE;gBACAR,6BAA6Bc,IAAIL,KAAKN;gBAEtC,oCAAoC;gBACpC,IAAIY,OAAOb,qBAAqBc,IAAIT;gBACpC,IAAIQ,SAASE,WAAW;oBACtBF,OAAO,EAAE;oBACTb,qBAAqBY,IAAIP,YAAYQ;gBACvC;gBACAA,KAAKG,KAAKd;YACZ;QACF;QAEA,OAAO;YACLJ;YACAE;QACF;IACF;IAEA,2EAA2E;IAC3E,MAAMiB,qBAAqBxB,OAA2CsB;IACtE,MAAMG,mBAAmB1B,YAAY;QACnC,IAAI2B,UAAUF,mBAAmBG;QACjC,IAAID,YAAYJ,WAAW;YACzBI,UAAUvB;YACVqB,mBAAmBG,UAAUD;YAE7B,2EAA2E;YAC3EA,QAAQE,MAAM,IAAMJ,mBAAmBG,YAAYL;QACrD;QACA,OAAOI;IACT,GAAG;QAACvB;KAAoB;IAExB,OAAOsB;AACT;AAEA;;CAEC,GACD,OAAO,SAASV,kBAAkBH,UAAsB,EAAEC,IAAY;IACpE,OAAO,CAAC,EAAED,WAAW,CAAC,EAAEC,KAAK,CAAC;AAChC"}
1
+ {"version":3,"sources":["../../../src/components/PluginRegistry/plugin-indexes.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\nimport { useEvent } from '@perses-dev/core';\nimport { useCallback, useRef } from 'react';\nimport { PluginLoader, PluginMetadata, PluginModuleResource, PluginType } from '../../model';\n\nexport interface PluginIndexes {\n // Plugin resources by plugin type and kind (i.e. look up what module a plugin type and kind is in)\n pluginResourcesByTypeAndKind: Map<string, PluginModuleResource>;\n // Plugin metadata by plugin type\n pluginMetadataByType: Map<PluginType, PluginMetadata[]>;\n}\n\n/**\n * Returns an async callback for getting indexes of the installed plugin data.\n */\nexport function usePluginIndexes(getInstalledPlugins: PluginLoader['getInstalledPlugins']) {\n // Creates indexes from the installed plugins data (does useEvent because this accesses the getInstalledPlugins prop\n // and we want a stable reference for the callback below)\n const createPluginIndexes = useEvent(async (): Promise<PluginIndexes> => {\n const installedPlugins = await getInstalledPlugins();\n\n // Create the two indexes from the installed plugins\n const pluginResourcesByTypeAndKind = new Map<string, PluginModuleResource>();\n const pluginMetadataByType = new Map<PluginType, PluginMetadata[]>();\n\n for (const resource of installedPlugins) {\n for (const pluginMetadata of resource.spec.plugins) {\n const { pluginType, kind } = pluginMetadata;\n\n // Index the plugin by type and kind to point at the module that contains it\n const key = getTypeAndKindKey(pluginType, kind);\n if (pluginResourcesByTypeAndKind.has(key)) {\n console.warn(`Got more than one ${pluginType} plugin for kind ${kind}`);\n }\n pluginResourcesByTypeAndKind.set(key, resource);\n\n // Index the metadata by plugin type\n let list = pluginMetadataByType.get(pluginType);\n if (list === undefined) {\n list = [];\n pluginMetadataByType.set(pluginType, list);\n }\n list.push(pluginMetadata);\n }\n }\n\n return {\n pluginResourcesByTypeAndKind,\n pluginMetadataByType,\n };\n });\n\n // De-dupe creating plugin indexes (i.e. requests to get installed plugins)\n const pluginIndexesCache = useRef<Promise<PluginIndexes> | undefined>(undefined);\n const getPluginIndexes = useCallback(() => {\n let request = pluginIndexesCache.current;\n if (request === undefined) {\n request = createPluginIndexes();\n pluginIndexesCache.current = request;\n\n // Remove failed requests from the cache so they can potentially be retried\n request.catch(() => pluginIndexesCache.current === undefined);\n }\n return request;\n }, [createPluginIndexes]);\n\n return getPluginIndexes;\n}\n\n/**\n * Gets a unique key for a plugin type/kind that can be used as a cache key.\n */\nexport function getTypeAndKindKey(pluginType: PluginType, kind: string) {\n return `${pluginType}:${kind}`;\n}\n"],"names":["useEvent","useCallback","useRef","usePluginIndexes","getInstalledPlugins","createPluginIndexes","installedPlugins","pluginResourcesByTypeAndKind","Map","pluginMetadataByType","resource","pluginMetadata","spec","plugins","pluginType","kind","key","getTypeAndKindKey","has","console","warn","set","list","get","undefined","push","pluginIndexesCache","getPluginIndexes","request","current","catch"],"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,SAASA,QAAQ,QAAQ,mBAAmB;AAC5C,SAASC,WAAW,EAAEC,MAAM,QAAQ,QAAQ;AAU5C;;CAEC,GACD,OAAO,SAASC,iBAAiBC,mBAAwD;IACvF,oHAAoH;IACpH,yDAAyD;IACzD,MAAMC,sBAAsBL,SAAS;QACnC,MAAMM,mBAAmB,MAAMF;QAE/B,oDAAoD;QACpD,MAAMG,+BAA+B,IAAIC;QACzC,MAAMC,uBAAuB,IAAID;QAEjC,KAAK,MAAME,YAAYJ,iBAAkB;YACvC,KAAK,MAAMK,kBAAkBD,SAASE,IAAI,CAACC,OAAO,CAAE;gBAClD,MAAM,EAAEC,UAAU,EAAEC,IAAI,EAAE,GAAGJ;gBAE7B,4EAA4E;gBAC5E,MAAMK,MAAMC,kBAAkBH,YAAYC;gBAC1C,IAAIR,6BAA6BW,GAAG,CAACF,MAAM;oBACzCG,QAAQC,IAAI,CAAC,CAAC,kBAAkB,EAAEN,WAAW,iBAAiB,EAAEC,KAAK,CAAC;gBACxE;gBACAR,6BAA6Bc,GAAG,CAACL,KAAKN;gBAEtC,oCAAoC;gBACpC,IAAIY,OAAOb,qBAAqBc,GAAG,CAACT;gBACpC,IAAIQ,SAASE,WAAW;oBACtBF,OAAO,EAAE;oBACTb,qBAAqBY,GAAG,CAACP,YAAYQ;gBACvC;gBACAA,KAAKG,IAAI,CAACd;YACZ;QACF;QAEA,OAAO;YACLJ;YACAE;QACF;IACF;IAEA,2EAA2E;IAC3E,MAAMiB,qBAAqBxB,OAA2CsB;IACtE,MAAMG,mBAAmB1B,YAAY;QACnC,IAAI2B,UAAUF,mBAAmBG,OAAO;QACxC,IAAID,YAAYJ,WAAW;YACzBI,UAAUvB;YACVqB,mBAAmBG,OAAO,GAAGD;YAE7B,2EAA2E;YAC3EA,QAAQE,KAAK,CAAC,IAAMJ,mBAAmBG,OAAO,KAAKL;QACrD;QACA,OAAOI;IACT,GAAG;QAACvB;KAAoB;IAExB,OAAOsB;AACT;AAEA;;CAEC,GACD,OAAO,SAASV,kBAAkBH,UAAsB,EAAEC,IAAY;IACpE,OAAO,CAAC,EAAED,WAAW,CAAC,EAAEC,KAAK,CAAC;AAChC"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { UnknownSpec } from '@perses-dev/core';
3
2
  import { OptionsEditorProps, PluginType } from '../../model';
4
3
  export interface PluginSpecEditorProps extends OptionsEditorProps<UnknownSpec> {
@@ -6,5 +5,5 @@ export interface PluginSpecEditorProps extends OptionsEditorProps<UnknownSpec> {
6
5
  pluginKind: string;
7
6
  isEditor?: boolean;
8
7
  }
9
- export declare function PluginSpecEditor(props: PluginSpecEditorProps): JSX.Element | null;
8
+ export declare function PluginSpecEditor(props: PluginSpecEditorProps): import("react/jsx-runtime").JSX.Element | null;
10
9
  //# sourceMappingURL=PluginSpecEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PluginSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginSpecEditor/PluginSpecEditor.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG7D,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB,CAAC,WAAW,CAAC;IAC5E,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,sBA4B5D"}
1
+ {"version":3,"file":"PluginSpecEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PluginSpecEditor/PluginSpecEditor.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG7D,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB,CAAC,WAAW,CAAC;IAC5E,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,kDA4B5D"}
@@ -14,8 +14,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { ErrorAlert } from '@perses-dev/components';
15
15
  import { usePlugin } from '../../runtime';
16
16
  export function PluginSpecEditor(props) {
17
- const { pluginType , pluginKind , ...others } = props;
18
- const { data: plugin , isLoading , error } = usePlugin(pluginType, pluginKind);
17
+ const { pluginType, pluginKind, ...others } = props;
18
+ const { data: plugin, isLoading, error } = usePlugin(pluginType, pluginKind);
19
19
  if (error) {
20
20
  return /*#__PURE__*/ _jsx(ErrorAlert, {
21
21
  error: error
@@ -31,7 +31,7 @@ export function PluginSpecEditor(props) {
31
31
  if (pluginType === 'Panel') {
32
32
  throw new Error('This editor should not be used for panel type. Please use Panel Spec Editor instead.');
33
33
  }
34
- const { OptionsEditorComponent } = plugin;
34
+ const { OptionsEditorComponent } = plugin;
35
35
  if (OptionsEditorComponent !== undefined) {
36
36
  return /*#__PURE__*/ _jsx(OptionsEditorComponent, {
37
37
  ...others
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/PluginSpecEditor/PluginSpecEditor.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 { ErrorAlert } from '@perses-dev/components';\nimport { UnknownSpec } from '@perses-dev/core';\nimport { OptionsEditorProps, PluginType } from '../../model';\nimport { usePlugin } from '../../runtime';\n\nexport interface PluginSpecEditorProps extends OptionsEditorProps<UnknownSpec> {\n pluginType: PluginType;\n pluginKind: string;\n isEditor?: boolean;\n}\n\nexport function PluginSpecEditor(props: PluginSpecEditorProps) {\n const { pluginType, pluginKind, ...others } = props;\n const { data: plugin, isLoading, error } = usePlugin(pluginType, pluginKind);\n\n if (error) {\n return <ErrorAlert error={error} />;\n }\n\n // TODO: Proper loading indicator\n if (isLoading) {\n return null;\n }\n\n if (plugin === undefined) {\n throw new Error(`Missing implementation for ${pluginType} plugin with kind '${pluginKind}'`);\n }\n\n if (pluginType === 'Panel') {\n throw new Error('This editor should not be used for panel type. Please use Panel Spec Editor instead.');\n }\n\n const { OptionsEditorComponent } = plugin;\n\n if (OptionsEditorComponent !== undefined) {\n return <OptionsEditorComponent {...others} />;\n }\n\n return null;\n}\n"],"names":["ErrorAlert","usePlugin","PluginSpecEditor","props","pluginType","pluginKind","others","data","plugin","isLoading","error","undefined","Error","OptionsEditorComponent"],"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,SAASA,UAAU,QAAQ,yBAAyB;AAGpD,SAASC,SAAS,QAAQ,gBAAgB;AAQ1C,OAAO,SAASC,iBAAiBC,KAA4B;IAC3D,MAAM,EAAEC,WAAU,EAAEC,WAAU,EAAE,GAAGC,QAAQ,GAAGH;IAC9C,MAAM,EAAEI,MAAMC,OAAM,EAAEC,UAAS,EAAEC,MAAK,EAAE,GAAGT,UAAUG,YAAYC;IAEjE,IAAIK,OAAO;QACT,qBAAO,KAACV;YAAWU,OAAOA;;IAC5B;IAEA,iCAAiC;IACjC,IAAID,WAAW;QACb,OAAO;IACT;IAEA,IAAID,WAAWG,WAAW;QACxB,MAAM,IAAIC,MAAM,CAAC,2BAA2B,EAAER,WAAW,mBAAmB,EAAEC,WAAW,CAAC,CAAC;IAC7F;IAEA,IAAID,eAAe,SAAS;QAC1B,MAAM,IAAIQ,MAAM;IAClB;IAEA,MAAM,EAAEC,uBAAsB,EAAE,GAAGL;IAEnC,IAAIK,2BAA2BF,WAAW;QACxC,qBAAO,KAACE;YAAwB,GAAGP,MAAM;;IAC3C;IAEA,OAAO;AACT"}
1
+ {"version":3,"sources":["../../../src/components/PluginSpecEditor/PluginSpecEditor.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 { ErrorAlert } from '@perses-dev/components';\nimport { UnknownSpec } from '@perses-dev/core';\nimport { OptionsEditorProps, PluginType } from '../../model';\nimport { usePlugin } from '../../runtime';\n\nexport interface PluginSpecEditorProps extends OptionsEditorProps<UnknownSpec> {\n pluginType: PluginType;\n pluginKind: string;\n isEditor?: boolean;\n}\n\nexport function PluginSpecEditor(props: PluginSpecEditorProps) {\n const { pluginType, pluginKind, ...others } = props;\n const { data: plugin, isLoading, error } = usePlugin(pluginType, pluginKind);\n\n if (error) {\n return <ErrorAlert error={error} />;\n }\n\n // TODO: Proper loading indicator\n if (isLoading) {\n return null;\n }\n\n if (plugin === undefined) {\n throw new Error(`Missing implementation for ${pluginType} plugin with kind '${pluginKind}'`);\n }\n\n if (pluginType === 'Panel') {\n throw new Error('This editor should not be used for panel type. Please use Panel Spec Editor instead.');\n }\n\n const { OptionsEditorComponent } = plugin;\n\n if (OptionsEditorComponent !== undefined) {\n return <OptionsEditorComponent {...others} />;\n }\n\n return null;\n}\n"],"names":["ErrorAlert","usePlugin","PluginSpecEditor","props","pluginType","pluginKind","others","data","plugin","isLoading","error","undefined","Error","OptionsEditorComponent"],"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,SAASA,UAAU,QAAQ,yBAAyB;AAGpD,SAASC,SAAS,QAAQ,gBAAgB;AAQ1C,OAAO,SAASC,iBAAiBC,KAA4B;IAC3D,MAAM,EAAEC,UAAU,EAAEC,UAAU,EAAE,GAAGC,QAAQ,GAAGH;IAC9C,MAAM,EAAEI,MAAMC,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAE,GAAGT,UAAUG,YAAYC;IAEjE,IAAIK,OAAO;QACT,qBAAO,KAACV;YAAWU,OAAOA;;IAC5B;IAEA,iCAAiC;IACjC,IAAID,WAAW;QACb,OAAO;IACT;IAEA,IAAID,WAAWG,WAAW;QACxB,MAAM,IAAIC,MAAM,CAAC,2BAA2B,EAAER,WAAW,mBAAmB,EAAEC,WAAW,CAAC,CAAC;IAC7F;IAEA,IAAID,eAAe,SAAS;QAC1B,MAAM,IAAIQ,MAAM;IAClB;IAEA,MAAM,EAAEC,sBAAsB,EAAE,GAAGL;IAEnC,IAAIK,2BAA2BF,WAAW;QACxC,qBAAO,KAACE;YAAwB,GAAGP,MAAM;;IAC3C;IAEA,OAAO;AACT"}
@@ -1,7 +1,6 @@
1
- /// <reference types="react" />
2
1
  import { SelectProps } from '@mui/material';
3
2
  import { ProjectResource } from '@perses-dev/core';
4
- declare type OmittedMuiProps = 'children' | 'value' | 'onChange';
3
+ type OmittedMuiProps = 'children' | 'value' | 'onChange';
5
4
  export interface ProjectSelectProps extends Omit<SelectProps<string>, OmittedMuiProps> {
6
5
  onChange: (next: ProjectResource) => void;
7
6
  value: ProjectResource;
@@ -10,6 +9,6 @@ export interface ProjectSelectProps extends Omit<SelectProps<string>, OmittedMui
10
9
  * Displays a MUI input for selecting a Project of a particular kind. Note: The 'value' and `onChange` handler for
11
10
  * the input deal with a `ProjectSelector`.
12
11
  */
13
- export declare function ProjectSelect(props: ProjectSelectProps): JSX.Element;
12
+ export declare function ProjectSelect(props: ProjectSelectProps): import("react/jsx-runtime").JSX.Element;
14
13
  export {};
15
14
  //# sourceMappingURL=ProjectSelect.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectSelect.d.ts","sourceRoot":"","sources":["../../src/components/ProjectSelect.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,WAAW,EAAiC,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKnD,aAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IACpF,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1C,KAAK,EAAE,eAAe,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eAmCtD"}
1
+ {"version":3,"file":"ProjectSelect.d.ts","sourceRoot":"","sources":["../../src/components/ProjectSelect.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAU,WAAW,EAAiC,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKnD,KAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IACpF,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1C,KAAK,EAAE,eAAe,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAmCtD"}
@@ -17,8 +17,8 @@ import { useProjectList } from '../context';
17
17
  * Displays a MUI input for selecting a Project of a particular kind. Note: The 'value' and `onChange` handler for
18
18
  * the input deal with a `ProjectSelector`.
19
19
  */ export function ProjectSelect(props) {
20
- const { onChange , value , ...others } = props;
21
- const { data , isLoading } = useProjectList();
20
+ const { onChange, value, ...others } = props;
21
+ const { data, isLoading } = useProjectList();
22
22
  // While loading available values, just use an empty string so MUI select doesn't warn about values out of range
23
23
  const optionValue = isLoading ? '' : projectToOptionValue(value);
24
24
  // When the user makes a selection, convert the string option value back to a DatasourceSelector