@perses-dev/plugin-system 0.55.0-beta.2 → 0.55.0-beta.3

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 (331) hide show
  1. package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +4 -4
  2. package/dist/cjs/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +1 -1
  3. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +3 -2
  4. package/dist/cjs/components/DatasourceSelect/DatasourceSelect.js +1 -1
  5. package/dist/cjs/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js +53 -0
  6. package/dist/cjs/components/DatasourceTestConnectionButton/index.js +30 -0
  7. package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +49 -24
  8. package/dist/cjs/components/LayoutEditor/LayoutEditor.js +123 -0
  9. package/dist/cjs/components/LayoutEditor/RepeatLayoutPreview.js +105 -0
  10. package/dist/cjs/components/LayoutEditor/RepeatVariableEditor.js +176 -0
  11. package/dist/cjs/components/LayoutEditor/index.js +32 -0
  12. package/dist/cjs/components/LinksEditor/LinksEditor.js +4 -4
  13. package/dist/cjs/components/MultiQueryEditor/MultiQueryEditor.js +8 -5
  14. package/dist/cjs/components/MultiQueryEditor/QueryEditorContainer.js +7 -7
  15. package/dist/cjs/components/PanelSpecEditor/PanelAnnotationsEditor.js +4 -4
  16. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +14 -5
  17. package/dist/cjs/components/PluginEditor/PluginEditor.js +4 -3
  18. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +1 -1
  19. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
  20. package/dist/cjs/components/PluginSpecEditor/DatasourceSpecEditor.js +70 -0
  21. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +17 -3
  22. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +6 -7
  23. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +5 -5
  24. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
  25. package/dist/cjs/components/index.js +2 -0
  26. package/dist/cjs/constants/index.js +1 -0
  27. package/dist/cjs/constants/repeat.js +32 -0
  28. package/dist/cjs/context/ValidationProvider.js +2 -2
  29. package/dist/cjs/model/index.js +1 -0
  30. package/dist/cjs/model/json-queries.js +16 -0
  31. package/dist/cjs/remote/PluginRuntime.js +12 -20
  32. package/dist/cjs/remote/remotePluginLoader.js +1 -1
  33. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +14 -6
  34. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +18 -4
  35. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviders.js +2 -2
  36. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +14 -1
  37. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +2 -2
  38. package/dist/cjs/runtime/alerts-queries.js +1 -1
  39. package/dist/cjs/runtime/annotations.js +2 -2
  40. package/dist/cjs/runtime/index.js +1 -0
  41. package/dist/cjs/runtime/item-actions.js +1 -1
  42. package/dist/cjs/runtime/json-queries.js +70 -0
  43. package/dist/cjs/runtime/silences-queries.js +1 -1
  44. package/dist/cjs/runtime/time-series-queries.js +1 -1
  45. package/dist/cjs/runtime/trace-queries.js +1 -1
  46. package/dist/cjs/schema/panel.js +17 -3
  47. package/dist/cjs/test/mock-data.js +9 -0
  48. package/dist/cjs/test/setup-tests.js +9 -3
  49. package/dist/cjs/test/test-plugins/ernie/index.js +58 -1
  50. package/dist/cjs/utils/csv-export.js +1 -1
  51. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts +2 -2
  52. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.d.ts.map +1 -1
  53. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js +4 -4
  54. package/dist/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.js.map +1 -1
  55. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts +2 -2
  56. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.d.ts.map +1 -1
  57. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js +1 -1
  58. package/dist/components/Annotations/AnnotationEditorForm/AnnotationPreview.js.map +1 -1
  59. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  60. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  61. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +2 -1
  62. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  63. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +3 -2
  64. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  65. package/dist/components/DatasourceSelect/DatasourceSelect.d.ts.map +1 -1
  66. package/dist/components/DatasourceSelect/DatasourceSelect.js +1 -1
  67. package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
  68. package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.d.ts +8 -0
  69. package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.d.ts.map +1 -0
  70. package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js +45 -0
  71. package/dist/components/DatasourceTestConnectionButton/DatasourceTestConnectionButton.js.map +1 -0
  72. package/dist/components/DatasourceTestConnectionButton/index.d.ts +2 -0
  73. package/dist/components/DatasourceTestConnectionButton/index.d.ts.map +1 -0
  74. package/dist/components/DatasourceTestConnectionButton/index.js +15 -0
  75. package/dist/components/DatasourceTestConnectionButton/index.js.map +1 -0
  76. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +2 -1
  77. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -1
  78. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +50 -25
  79. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
  80. package/dist/components/ItemSelectionActionsOptionsEditor/ItemSelectionActionsOptionsEditor.js.map +1 -1
  81. package/dist/components/LayoutEditor/LayoutEditor.d.ts +16 -0
  82. package/dist/components/LayoutEditor/LayoutEditor.d.ts.map +1 -0
  83. package/dist/components/LayoutEditor/LayoutEditor.js +115 -0
  84. package/dist/components/LayoutEditor/LayoutEditor.js.map +1 -0
  85. package/dist/components/LayoutEditor/RepeatLayoutPreview.d.ts +7 -0
  86. package/dist/components/LayoutEditor/RepeatLayoutPreview.d.ts.map +1 -0
  87. package/dist/components/LayoutEditor/RepeatLayoutPreview.js +92 -0
  88. package/dist/components/LayoutEditor/RepeatLayoutPreview.js.map +1 -0
  89. package/dist/components/LayoutEditor/RepeatVariableEditor.d.ts +18 -0
  90. package/dist/components/LayoutEditor/RepeatVariableEditor.d.ts.map +1 -0
  91. package/dist/components/LayoutEditor/RepeatVariableEditor.js +168 -0
  92. package/dist/components/LayoutEditor/RepeatVariableEditor.js.map +1 -0
  93. package/dist/components/LayoutEditor/index.d.ts +4 -0
  94. package/dist/components/LayoutEditor/index.d.ts.map +1 -0
  95. package/dist/components/LayoutEditor/index.js +17 -0
  96. package/dist/components/LayoutEditor/index.js.map +1 -0
  97. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  98. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  99. package/dist/components/LinksEditor/LinksEditor.d.ts.map +1 -1
  100. package/dist/components/LinksEditor/LinksEditor.js +4 -4
  101. package/dist/components/LinksEditor/LinksEditor.js.map +1 -1
  102. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +0 -1
  103. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -1
  104. package/dist/components/MultiQueryEditor/MultiQueryEditor.js +8 -5
  105. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -1
  106. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +0 -1
  107. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -1
  108. package/dist/components/MultiQueryEditor/QueryEditorContainer.js +7 -7
  109. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
  110. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
  111. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  112. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
  113. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  114. package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.d.ts +1 -1
  115. package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.d.ts.map +1 -1
  116. package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.js +4 -4
  117. package/dist/components/PanelSpecEditor/PanelAnnotationsEditor.js.map +1 -1
  118. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +3 -1
  119. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  120. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +14 -5
  121. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  122. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  123. package/dist/components/PluginEditor/PluginEditor.js +4 -3
  124. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  125. package/dist/components/PluginEditor/plugin-editor-api.d.ts +2 -1
  126. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  127. package/dist/components/PluginEditor/plugin-editor-api.js +1 -1
  128. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  129. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +0 -1
  130. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  131. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  132. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  133. package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
  134. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  135. package/dist/components/PluginRegistry/getPluginSearchHelper.d.ts.map +1 -1
  136. package/dist/components/PluginRegistry/getPluginSearchHelper.js.map +1 -1
  137. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  138. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  139. package/dist/components/PluginSpecEditor/DatasourceSpecEditor.d.ts +10 -0
  140. package/dist/components/PluginSpecEditor/DatasourceSpecEditor.d.ts.map +1 -0
  141. package/dist/components/PluginSpecEditor/DatasourceSpecEditor.js +62 -0
  142. package/dist/components/PluginSpecEditor/DatasourceSpecEditor.js.map +1 -0
  143. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +2 -1
  144. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  145. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +17 -3
  146. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  147. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  148. package/dist/components/TimeRangeControls/TimeRangeControls.js +9 -10
  149. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  150. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +2 -2
  151. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  152. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +5 -5
  153. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  154. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +1 -1
  155. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  156. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +1 -1
  157. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  158. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  159. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  160. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  161. package/dist/components/Variables/variable-model.js.map +1 -1
  162. package/dist/components/index.d.ts +2 -0
  163. package/dist/components/index.d.ts.map +1 -1
  164. package/dist/components/index.js +2 -0
  165. package/dist/components/index.js.map +1 -1
  166. package/dist/constants/index.d.ts +1 -0
  167. package/dist/constants/index.d.ts.map +1 -1
  168. package/dist/constants/index.js +1 -0
  169. package/dist/constants/index.js.map +1 -1
  170. package/dist/constants/repeat.d.ts +3 -0
  171. package/dist/constants/repeat.d.ts.map +1 -0
  172. package/dist/constants/repeat.js +16 -0
  173. package/dist/constants/repeat.js.map +1 -0
  174. package/dist/context/ValidationProvider.d.ts +2 -2
  175. package/dist/context/ValidationProvider.d.ts.map +1 -1
  176. package/dist/context/ValidationProvider.js +2 -2
  177. package/dist/context/ValidationProvider.js.map +1 -1
  178. package/dist/model/alerts-queries.d.ts +1 -1
  179. package/dist/model/alerts-queries.d.ts.map +1 -1
  180. package/dist/model/alerts-queries.js.map +1 -1
  181. package/dist/model/annotations.d.ts.map +1 -1
  182. package/dist/model/annotations.js.map +1 -1
  183. package/dist/model/calculations.js.map +1 -1
  184. package/dist/model/datasource.d.ts +9 -2
  185. package/dist/model/datasource.d.ts.map +1 -1
  186. package/dist/model/datasource.js +1 -1
  187. package/dist/model/datasource.js.map +1 -1
  188. package/dist/model/explore.d.ts +0 -1
  189. package/dist/model/explore.d.ts.map +1 -1
  190. package/dist/model/explore.js.map +1 -1
  191. package/dist/model/index.d.ts +1 -0
  192. package/dist/model/index.d.ts.map +1 -1
  193. package/dist/model/index.js +1 -0
  194. package/dist/model/index.js.map +1 -1
  195. package/dist/model/json-queries.d.ts +29 -0
  196. package/dist/model/json-queries.d.ts.map +1 -0
  197. package/dist/model/json-queries.js +17 -0
  198. package/dist/model/json-queries.js.map +1 -0
  199. package/dist/model/legend.d.ts.map +1 -1
  200. package/dist/model/legend.js.map +1 -1
  201. package/dist/model/log-queries.d.ts.map +1 -1
  202. package/dist/model/log-queries.js.map +1 -1
  203. package/dist/model/panels.d.ts +10 -1
  204. package/dist/model/panels.d.ts.map +1 -1
  205. package/dist/model/panels.js.map +1 -1
  206. package/dist/model/plugin-base.d.ts +2 -2
  207. package/dist/model/plugin-base.d.ts.map +1 -1
  208. package/dist/model/plugin-base.js.map +1 -1
  209. package/dist/model/plugins.d.ts +8 -6
  210. package/dist/model/plugins.d.ts.map +1 -1
  211. package/dist/model/plugins.js.map +1 -1
  212. package/dist/model/profile-queries.d.ts +1 -1
  213. package/dist/model/profile-queries.d.ts.map +1 -1
  214. package/dist/model/profile-queries.js.map +1 -1
  215. package/dist/model/silences-queries.d.ts +1 -1
  216. package/dist/model/silences-queries.d.ts.map +1 -1
  217. package/dist/model/silences-queries.js.map +1 -1
  218. package/dist/model/time-series-queries.d.ts +1 -1
  219. package/dist/model/time-series-queries.d.ts.map +1 -1
  220. package/dist/model/time-series-queries.js.map +1 -1
  221. package/dist/model/trace-queries.d.ts +1 -1
  222. package/dist/model/trace-queries.d.ts.map +1 -1
  223. package/dist/model/trace-queries.js.map +1 -1
  224. package/dist/model/variables.d.ts +5 -1
  225. package/dist/model/variables.d.ts.map +1 -1
  226. package/dist/model/variables.js +1 -3
  227. package/dist/model/variables.js.map +1 -1
  228. package/dist/remote/PluginLoaderComponent.d.ts +0 -1
  229. package/dist/remote/PluginLoaderComponent.d.ts.map +1 -1
  230. package/dist/remote/PluginLoaderComponent.js.map +1 -1
  231. package/dist/remote/PluginRuntime.d.ts.map +1 -1
  232. package/dist/remote/PluginRuntime.js +12 -20
  233. package/dist/remote/PluginRuntime.js.map +1 -1
  234. package/dist/remote/remotePluginLoader.d.ts +1 -1
  235. package/dist/remote/remotePluginLoader.d.ts.map +1 -1
  236. package/dist/remote/remotePluginLoader.js +1 -1
  237. package/dist/remote/remotePluginLoader.js.map +1 -1
  238. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +2 -2
  239. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  240. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +15 -7
  241. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  242. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +1 -1
  243. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  244. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +18 -4
  245. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  246. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts.map +1 -1
  247. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js +3 -3
  248. package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js.map +1 -1
  249. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +8 -1
  250. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -1
  251. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +14 -1
  252. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
  253. package/dist/runtime/TimeRangeProvider/query-params.d.ts +1 -1
  254. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  255. package/dist/runtime/TimeRangeProvider/query-params.js +2 -2
  256. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  257. package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -1
  258. package/dist/runtime/alerts-queries.d.ts.map +1 -1
  259. package/dist/runtime/alerts-queries.js +1 -1
  260. package/dist/runtime/alerts-queries.js.map +1 -1
  261. package/dist/runtime/annotations.d.ts.map +1 -1
  262. package/dist/runtime/annotations.js +2 -2
  263. package/dist/runtime/annotations.js.map +1 -1
  264. package/dist/runtime/builtin-variables.d.ts +0 -1
  265. package/dist/runtime/builtin-variables.d.ts.map +1 -1
  266. package/dist/runtime/builtin-variables.js.map +1 -1
  267. package/dist/runtime/datasources.d.ts +0 -1
  268. package/dist/runtime/datasources.d.ts.map +1 -1
  269. package/dist/runtime/datasources.js.map +1 -1
  270. package/dist/runtime/index.d.ts +1 -0
  271. package/dist/runtime/index.d.ts.map +1 -1
  272. package/dist/runtime/index.js +1 -0
  273. package/dist/runtime/index.js.map +1 -1
  274. package/dist/runtime/item-actions.d.ts +1 -1
  275. package/dist/runtime/item-actions.d.ts.map +1 -1
  276. package/dist/runtime/item-actions.js +1 -1
  277. package/dist/runtime/item-actions.js.map +1 -1
  278. package/dist/runtime/json-queries.d.ts +11 -0
  279. package/dist/runtime/json-queries.d.ts.map +1 -0
  280. package/dist/runtime/json-queries.js +58 -0
  281. package/dist/runtime/json-queries.js.map +1 -0
  282. package/dist/runtime/log-queries.d.ts.map +1 -1
  283. package/dist/runtime/log-queries.js.map +1 -1
  284. package/dist/runtime/plugin-registry.d.ts +0 -1
  285. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  286. package/dist/runtime/plugin-registry.js.map +1 -1
  287. package/dist/runtime/profile-queries.d.ts.map +1 -1
  288. package/dist/runtime/profile-queries.js.map +1 -1
  289. package/dist/runtime/silences-queries.d.ts.map +1 -1
  290. package/dist/runtime/silences-queries.js +1 -1
  291. package/dist/runtime/silences-queries.js.map +1 -1
  292. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  293. package/dist/runtime/time-series-queries.js +1 -1
  294. package/dist/runtime/time-series-queries.js.map +1 -1
  295. package/dist/runtime/trace-queries.d.ts.map +1 -1
  296. package/dist/runtime/trace-queries.js +1 -1
  297. package/dist/runtime/trace-queries.js.map +1 -1
  298. package/dist/runtime/variables.d.ts +0 -1
  299. package/dist/runtime/variables.d.ts.map +1 -1
  300. package/dist/runtime/variables.js.map +1 -1
  301. package/dist/schema/panel.d.ts +1 -1
  302. package/dist/schema/panel.d.ts.map +1 -1
  303. package/dist/schema/panel.js +17 -3
  304. package/dist/schema/panel.js.map +1 -1
  305. package/dist/test/mock-data.d.ts +2 -1
  306. package/dist/test/mock-data.d.ts.map +1 -1
  307. package/dist/test/mock-data.js +6 -0
  308. package/dist/test/mock-data.js.map +1 -1
  309. package/dist/test/render-hook.d.ts.map +1 -1
  310. package/dist/test/render-hook.js.map +1 -1
  311. package/dist/test/render.d.ts.map +1 -1
  312. package/dist/test/render.js.map +1 -1
  313. package/dist/test/setup-tests.d.ts +1 -1
  314. package/dist/test/setup-tests.d.ts.map +1 -1
  315. package/dist/test/setup-tests.js +3 -2
  316. package/dist/test/setup-tests.js.map +1 -1
  317. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  318. package/dist/test/test-plugins/bert/index.js.map +1 -1
  319. package/dist/test/test-plugins/ernie/index.d.ts +7 -1
  320. package/dist/test/test-plugins/ernie/index.d.ts.map +1 -1
  321. package/dist/test/test-plugins/ernie/index.js +58 -1
  322. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  323. package/dist/test/utils.d.ts.map +1 -1
  324. package/dist/test/utils.js +1 -1
  325. package/dist/test/utils.js.map +1 -1
  326. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  327. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  328. package/dist/utils/csv-export.d.ts.map +1 -1
  329. package/dist/utils/csv-export.js +1 -1
  330. package/dist/utils/csv-export.js.map +1 -1
  331. package/package.json +8 -8
@@ -36,13 +36,14 @@ _export(exports, {
36
36
  });
37
37
  const _jsxruntime = require("react/jsx-runtime");
38
38
  const _react = require("react");
39
- const _timeseriesqueries = require("../time-series-queries");
40
- const _tracequeries = require("../trace-queries");
41
- const _profilequeries = require("../profile-queries");
42
39
  const _alertsqueries = require("../alerts-queries");
40
+ const _jsonqueries = require("../json-queries");
41
+ const _logqueries = require("../log-queries");
42
+ const _profilequeries = require("../profile-queries");
43
43
  const _silencesqueries = require("../silences-queries");
44
+ const _timeseriesqueries = require("../time-series-queries");
45
+ const _tracequeries = require("../trace-queries");
44
46
  const _UsageMetricsProvider = require("../UsageMetricsProvider");
45
- const _logqueries = require("../log-queries");
46
47
  const _model = require("./model");
47
48
  const DataQueriesContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
48
49
  function useDataQueriesContext() {
@@ -86,6 +87,8 @@ function DataQueriesProvider(props) {
86
87
  const alertsResults = (0, _alertsqueries.useAlertsQueries)(alertsQueries);
87
88
  const silencesQueries = definitions.filter((definition)=>definition.kind === 'SilencesQuery');
88
89
  const silencesResults = (0, _silencesqueries.useSilencesQueries)(silencesQueries);
90
+ const jsonQueries = definitions.filter((definition)=>definition.kind === 'JsonQuery');
91
+ const jsonResults = (0, _jsonqueries.useJsonQueries)(jsonQueries);
89
92
  const refetchAll = (0, _react.useCallback)(()=>{
90
93
  timeSeriesResults.forEach((result)=>result.refetch());
91
94
  traceResults.forEach((result)=>result.refetch());
@@ -93,13 +96,15 @@ function DataQueriesProvider(props) {
93
96
  logResults.forEach((result)=>result.refetch());
94
97
  alertsResults.forEach((result)=>result.refetch());
95
98
  silencesResults.forEach((result)=>result.refetch());
99
+ jsonResults.forEach((result)=>result.refetch());
96
100
  }, [
97
101
  timeSeriesResults,
98
102
  traceResults,
99
103
  profileResults,
100
104
  logResults,
101
105
  alertsResults,
102
- silencesResults
106
+ silencesResults,
107
+ jsonResults
103
108
  ]);
104
109
  const ctx = (0, _react.useMemo)(()=>{
105
110
  const mergedQueryResults = [
@@ -108,7 +113,8 @@ function DataQueriesProvider(props) {
108
113
  ...(0, _model.transformQueryResults)(profileResults, profileQueries),
109
114
  ...(0, _model.transformQueryResults)(logResults, logQueries),
110
115
  ...(0, _model.transformQueryResults)(alertsResults, alertsQueries),
111
- ...(0, _model.transformQueryResults)(silencesResults, silencesQueries)
116
+ ...(0, _model.transformQueryResults)(silencesResults, silencesQueries),
117
+ ...(0, _model.transformQueryResults)(jsonResults, jsonQueries)
112
118
  ];
113
119
  if (queryOptions?.enabled) {
114
120
  for (const result of mergedQueryResults){
@@ -138,6 +144,8 @@ function DataQueriesProvider(props) {
138
144
  profileResults,
139
145
  silencesQueries,
140
146
  silencesResults,
147
+ jsonQueries,
148
+ jsonResults,
141
149
  timeSeriesQueries,
142
150
  timeSeriesResults,
143
151
  traceQueries,
@@ -38,10 +38,11 @@ _export(exports, {
38
38
  }
39
39
  });
40
40
  const _jsxruntime = require("react/jsx-runtime");
41
- const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
42
41
  const _spec = require("@perses-dev/spec");
43
42
  const _reactquery = require("@tanstack/react-query");
43
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
44
44
  const _refreshinterval = require("./refresh-interval");
45
+ const _TimeRangeSettingsProvider = require("./TimeRangeSettingsProvider");
45
46
  function _getRequireWildcardCache(nodeInterop) {
46
47
  if (typeof WeakMap !== "function") return null;
47
48
  var cacheBabelInterop = new WeakMap();
@@ -101,6 +102,7 @@ function useSuggestedStepMs(width) {
101
102
  }
102
103
  function TimeRangeProvider(props) {
103
104
  const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;
105
+ const disableAutoRefresh = (0, _TimeRangeSettingsProvider.useDisableAutoRefreshSetting)();
104
106
  const queryClient = (0, _reactquery.useQueryClient)();
105
107
  const [absoluteTimeRange, setAbsoluteTimeRange] = (0, _react.useState)((0, _spec.isRelativeTimeRange)(timeRange) ? (0, _spec.toAbsoluteTimeRange)(timeRange) : timeRange);
106
108
  const handleSetTimeRange = (0, _react.useCallback)((value)=>{
@@ -109,6 +111,16 @@ function TimeRangeProvider(props) {
109
111
  }, [
110
112
  setTimeRange
111
113
  ]);
114
+ // When auto-refresh is disabled by admin, leave URL/spec values untouched and no-op changes.
115
+ const handleSetRefreshInterval = (0, _react.useCallback)((value)=>{
116
+ if (disableAutoRefresh) {
117
+ return;
118
+ }
119
+ setRefreshInterval(value);
120
+ }, [
121
+ disableAutoRefresh,
122
+ setRefreshInterval
123
+ ]);
112
124
  // Refresh is called when clicking on the refresh button, it refreshes all queries including variables
113
125
  const refresh = (0, _react.useCallback)(()=>{
114
126
  setAbsoluteTimeRange((0, _spec.isRelativeTimeRange)(timeRange) ? (0, _spec.toAbsoluteTimeRange)(timeRange) : timeRange);
@@ -161,7 +173,9 @@ function TimeRangeProvider(props) {
161
173
  queryClient,
162
174
  timeRange
163
175
  ]);
164
- const refreshIntervalInMs = (0, _react.useMemo)(()=>(0, _refreshinterval.getRefreshIntervalInMs)(refreshInterval), [
176
+ // Gate the timer only — do not rewrite refreshInterval / ?refresh= so re-enabling restores them.
177
+ const refreshIntervalInMs = (0, _react.useMemo)(()=>disableAutoRefresh ? 0 : (0, _refreshinterval.getRefreshIntervalInMs)(refreshInterval), [
178
+ disableAutoRefresh,
165
179
  refreshInterval
166
180
  ]);
167
181
  (0, _react.useEffect)(()=>{
@@ -183,7 +197,7 @@ function TimeRangeProvider(props) {
183
197
  refresh,
184
198
  refreshInterval: refreshInterval,
185
199
  refreshIntervalInMs: refreshIntervalInMs,
186
- setRefreshInterval: setRefreshInterval
200
+ setRefreshInterval: handleSetRefreshInterval
187
201
  };
188
202
  }, [
189
203
  absoluteTimeRange,
@@ -191,7 +205,7 @@ function TimeRangeProvider(props) {
191
205
  refresh,
192
206
  refreshInterval,
193
207
  refreshIntervalInMs,
194
- setRefreshInterval,
208
+ handleSetRefreshInterval,
195
209
  timeRange
196
210
  ]);
197
211
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(TimeRangeContext.Provider, {
@@ -29,10 +29,10 @@ _export(exports, {
29
29
  }
30
30
  });
31
31
  const _jsxruntime = require("react/jsx-runtime");
32
- const _react = /*#__PURE__*/ _interop_require_default(require("react"));
33
32
  const _components = require("@perses-dev/components");
34
- const _TimeRangeProvider = require("./TimeRangeProvider");
33
+ const _react = /*#__PURE__*/ _interop_require_default(require("react"));
35
34
  const _queryparams = require("./query-params");
35
+ const _TimeRangeProvider = require("./TimeRangeProvider");
36
36
  function _interop_require_default(obj) {
37
37
  return obj && obj.__esModule ? obj : {
38
38
  default: obj
@@ -27,6 +27,9 @@ _export(exports, {
27
27
  get TimeRangeSettingsProvider () {
28
28
  return TimeRangeSettingsProvider;
29
29
  },
30
+ get useDisableAutoRefreshSetting () {
31
+ return useDisableAutoRefreshSetting;
32
+ },
30
33
  get useShowCustomTimeRangeSetting () {
31
34
  return useShowCustomTimeRangeSetting;
32
35
  },
@@ -44,8 +47,8 @@ _export(exports, {
44
47
  }
45
48
  });
46
49
  const _jsxruntime = require("react/jsx-runtime");
47
- const _react = require("react");
48
50
  const _components = require("@perses-dev/components");
51
+ const _react = require("react");
49
52
  const DEFAULT_OPTIONS = [
50
53
  '5m',
51
54
  '15m',
@@ -60,6 +63,7 @@ const DEFAULT_OPTIONS = [
60
63
  const defaultTimeRangeSettings = {
61
64
  showCustom: true,
62
65
  showZoomButtons: true,
66
+ disableAutoRefresh: false,
63
67
  options: DEFAULT_OPTIONS.map((duration)=>(0, _components.buildRelativeTimeOption)(duration))
64
68
  };
65
69
  const TimeRangeSettingsContext = /*#__PURE__*/ (0, _react.createContext)(defaultTimeRangeSettings);
@@ -94,16 +98,25 @@ function useTimeRangeOptionsSetting(override) {
94
98
  }
95
99
  return showCustomTimeRange;
96
100
  }
101
+ function useDisableAutoRefreshSetting(override) {
102
+ const disableAutoRefresh = useTimeRangeSettings().disableAutoRefresh;
103
+ if (override !== undefined) {
104
+ return override;
105
+ }
106
+ return disableAutoRefresh;
107
+ }
97
108
  function TimeRangeSettingsProvider(props) {
98
109
  const ctx = (0, _react.useMemo)(()=>{
99
110
  return {
100
111
  showCustom: props.showCustom === undefined ? defaultTimeRangeSettings.showCustom : props.showCustom,
101
112
  showZoomButtons: props.showZoomButtons === undefined ? defaultTimeRangeSettings.showZoomButtons : props.showZoomButtons,
113
+ disableAutoRefresh: props.disableAutoRefresh === undefined ? defaultTimeRangeSettings.disableAutoRefresh : props.disableAutoRefresh,
102
114
  options: props.options === undefined ? defaultTimeRangeSettings.options : props.options
103
115
  };
104
116
  }, [
105
117
  props.showCustom,
106
118
  props.showZoomButtons,
119
+ props.disableAutoRefresh,
107
120
  props.options
108
121
  ]);
109
122
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(TimeRangeSettingsContext.Provider, {
@@ -55,10 +55,10 @@ _export(exports, {
55
55
  return useTimeZoneParams;
56
56
  }
57
57
  });
58
+ const _spec = require("@perses-dev/spec");
59
+ const _datefns = require("date-fns");
58
60
  const _react = require("react");
59
61
  const _usequeryparams = require("use-query-params");
60
- const _datefns = require("date-fns");
61
- const _spec = require("@perses-dev/spec");
62
62
  /* Interprets an encoded string and returns either the string or null/undefined if not available */ function getEncodedValue(input, allowEmptyString) {
63
63
  // '' or []
64
64
  if (!input || input.length === 0 && (!allowEmptyString || allowEmptyString && input !== '')) {
@@ -31,8 +31,8 @@ _export(exports, {
31
31
  const _reactquery = require("@tanstack/react-query");
32
32
  const _datasources = require("./datasources");
33
33
  const _pluginregistry = require("./plugin-registry");
34
- const _variables = require("./variables");
35
34
  const _utils = require("./utils");
35
+ const _variables = require("./variables");
36
36
  const ALERTS_QUERY_KEY = 'AlertsQuery';
37
37
  function useAlertsQueries(definitions) {
38
38
  const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
@@ -32,11 +32,11 @@ _export(exports, {
32
32
  }
33
33
  });
34
34
  const _reactquery = require("@tanstack/react-query");
35
+ const _datasources = require("./datasources");
35
36
  const _pluginregistry = require("./plugin-registry");
36
37
  const _TimeRangeProvider = require("./TimeRangeProvider");
37
- const _variables = require("./variables");
38
- const _datasources = require("./datasources");
39
38
  const _utils = require("./utils");
39
+ const _variables = require("./variables");
40
40
  const ANNOTATION_KEY = 'Annotation';
41
41
  function useAnnotationContext() {
42
42
  const { absoluteTimeRange } = (0, _TimeRangeProvider.useTimeRange)();
@@ -24,6 +24,7 @@ _export_star(require("./time-series-queries"), exports);
24
24
  _export_star(require("./trace-queries"), exports);
25
25
  _export_star(require("./profile-queries"), exports);
26
26
  _export_star(require("./alerts-queries"), exports);
27
+ _export_star(require("./json-queries"), exports);
27
28
  _export_star(require("./silences-queries"), exports);
28
29
  _export_star(require("./item-actions"), exports);
29
30
  _export_star(require("./DataQueriesProvider"), exports);
@@ -28,7 +28,7 @@ const BODY_METHODS = new Set([
28
28
  ]);
29
29
  function buildWebhookHeaders(action) {
30
30
  const headers = {
31
- ...action.headers ?? {}
31
+ ...action.headers
32
32
  };
33
33
  const contentType = action.contentType ?? 'none';
34
34
  const supportsBody = BODY_METHODS.has(action.method);
@@ -0,0 +1,70 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get JSON_QUERY_KEY () {
25
+ return JSON_QUERY_KEY;
26
+ },
27
+ get useJsonQueries () {
28
+ return useJsonQueries;
29
+ }
30
+ });
31
+ const _reactquery = require("@tanstack/react-query");
32
+ const _datasources = require("./datasources");
33
+ const _pluginregistry = require("./plugin-registry");
34
+ const _variables = require("./variables");
35
+ const JSON_QUERY_KEY = 'JsonQuery';
36
+ function useJsonQueries(definitions) {
37
+ const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
38
+ const datasourceStore = (0, _datasources.useDatasourceStore)();
39
+ const variableValues = (0, _variables.useVariableValues)();
40
+ const context = {
41
+ variableState: variableValues,
42
+ datasourceStore
43
+ };
44
+ return (0, _reactquery.useQueries)({
45
+ queries: definitions.map((definition)=>{
46
+ const queryKey = [
47
+ 'query',
48
+ JSON_QUERY_KEY,
49
+ definition,
50
+ variableValues
51
+ ];
52
+ const jsonQueryKind = definition?.spec?.plugin?.kind;
53
+ return {
54
+ queryKey,
55
+ refetchOnMount: false,
56
+ refetchOnWindowFocus: false,
57
+ refetchOnReconnect: false,
58
+ staleTime: Infinity,
59
+ queryFn: async ({ signal })=>{
60
+ const plugin = await getPlugin({
61
+ kind: JSON_QUERY_KEY,
62
+ name: jsonQueryKind
63
+ });
64
+ return plugin.getJsonData(definition.spec.plugin.spec, context, signal);
65
+ },
66
+ structuralSharing: false
67
+ };
68
+ })
69
+ });
70
+ }
@@ -31,8 +31,8 @@ _export(exports, {
31
31
  const _reactquery = require("@tanstack/react-query");
32
32
  const _datasources = require("./datasources");
33
33
  const _pluginregistry = require("./plugin-registry");
34
- const _variables = require("./variables");
35
34
  const _utils = require("./utils");
35
+ const _variables = require("./variables");
36
36
  const SILENCES_QUERY_KEY = 'SilencesQuery';
37
37
  function useSilencesQueries(definitions) {
38
38
  const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
@@ -38,9 +38,9 @@ _export(exports, {
38
38
  }
39
39
  });
40
40
  const _reactquery = require("@tanstack/react-query");
41
- const _TimeRangeProvider = require("./TimeRangeProvider");
42
41
  const _datasources = require("./datasources");
43
42
  const _pluginregistry = require("./plugin-registry");
43
+ const _TimeRangeProvider = require("./TimeRangeProvider");
44
44
  const _utils = require("./utils");
45
45
  const _variables = require("./variables");
46
46
  const TIME_SERIES_QUERY_KEY = 'TimeSeriesQuery';
@@ -32,8 +32,8 @@ const _reactquery = require("@tanstack/react-query");
32
32
  const _datasources = require("./datasources");
33
33
  const _pluginregistry = require("./plugin-registry");
34
34
  const _TimeRangeProvider = require("./TimeRangeProvider");
35
- const _variables = require("./variables");
36
35
  const _utils = require("./utils");
36
+ const _variables = require("./variables");
37
37
  const TRACE_QUERY_KEY = 'TraceQuery';
38
38
  function useTraceQueries(definitions) {
39
39
  const { getPlugin } = (0, _pluginregistry.usePluginRegistry)();
@@ -28,15 +28,29 @@ _export(exports, {
28
28
  return panelEditorSchema;
29
29
  }
30
30
  });
31
- const _zod = require("zod");
32
31
  const _spec = require("@perses-dev/spec");
32
+ const _zod = require("zod");
33
+ const layoutDefinitionSchema = _zod.z.object({
34
+ width: _zod.z.number(),
35
+ height: _zod.z.number(),
36
+ repeatVariable: _zod.z.object({
37
+ value: _zod.z.string(),
38
+ maxPer: _zod.z.number().min(1).max(12).optional(),
39
+ alignment: _zod.z.enum([
40
+ 'horizontal',
41
+ 'vertical'
42
+ ]).optional()
43
+ }).optional()
44
+ }).optional();
33
45
  const panelEditorSchema = _zod.z.object({
34
46
  groupId: _zod.z.number(),
35
- panelDefinition: _spec.panelDefinitionSchema
47
+ panelDefinition: _spec.panelDefinitionSchema,
48
+ layoutDefinition: layoutDefinitionSchema
36
49
  });
37
50
  function buildPanelEditorSchema(pluginSchema) {
38
51
  return _zod.z.object({
39
52
  groupId: _zod.z.number(),
40
- panelDefinition: (0, _spec.buildPanelDefinitionSchema)(pluginSchema)
53
+ panelDefinition: (0, _spec.buildPanelDefinitionSchema)(pluginSchema),
54
+ layoutDefinition: layoutDefinitionSchema
41
55
  });
42
56
  }
@@ -30,6 +30,9 @@ _export(exports, {
30
30
  get MOCK_INVALID_PLUGIN_MODULE () {
31
31
  return MOCK_INVALID_PLUGIN_MODULE;
32
32
  },
33
+ get MOCK_JSON_DATA () {
34
+ return MOCK_JSON_DATA;
35
+ },
33
36
  get MOCK_LOG_DATA () {
34
37
  return MOCK_LOG_DATA;
35
38
  },
@@ -221,6 +224,12 @@ const MOCK_SILENCES_DATA = {
221
224
  }
222
225
  ]
223
226
  };
227
+ const MOCK_JSON_DATA = {
228
+ data: {
229
+ status: 'ok',
230
+ value: 42
231
+ }
232
+ };
224
233
  const MOCK_VALID_PLUGIN_METADATA = {
225
234
  kind: 'Panel',
226
235
  spec: {
@@ -10,11 +10,17 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- // Add testing library assertions
14
13
  "use strict";
15
14
  Object.defineProperty(exports, "__esModule", {
16
15
  value: true
17
16
  });
18
- require("@testing-library/jest-dom/extend-expect");
17
+ const _matchers = /*#__PURE__*/ _interop_require_default(require("@testing-library/jest-dom/matchers"));
18
+ function _interop_require_default(obj) {
19
+ return obj && obj.__esModule ? obj : {
20
+ default: obj
21
+ };
22
+ }
23
+ // Add testing library assertions
24
+ expect.extend(_matchers.default);
19
25
  // Always mock e-charts during tests since we don't have a proper canvas in jsdom
20
- jest.mock('echarts/core');
26
+ vi.mock('echarts/core');
@@ -86,7 +86,64 @@ const ErnieVariable2 = {
86
86
  variableOption2: ''
87
87
  })
88
88
  };
89
+ const ErnieDatasource = {
90
+ createClient: ()=>({}),
91
+ createInitialOptions: ()=>({}),
92
+ healthCheckPath: '/api/v1/query',
93
+ OptionsEditorComponent: function ErnieDatasourceEditor({ value, onChange, testConnection }) {
94
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
95
+ children: [
96
+ /*#__PURE__*/ (0, _jsxruntime.jsx)("label", {
97
+ htmlFor: "datasource-url",
98
+ children: "ErnieDatasource editor"
99
+ }),
100
+ /*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
101
+ type: "text",
102
+ id: "datasource-url",
103
+ value: value.url ?? '',
104
+ onChange: (e)=>onChange({
105
+ ...value,
106
+ url: e.target.value
107
+ })
108
+ }),
109
+ testConnection && /*#__PURE__*/ (0, _jsxruntime.jsx)("button", {
110
+ onClick: testConnection,
111
+ children: "test-connection-trigger"
112
+ })
113
+ ]
114
+ });
115
+ }
116
+ };
117
+ const ErnieDatasourceNoHealthCheck = {
118
+ createClient: ()=>({}),
119
+ createInitialOptions: ()=>({}),
120
+ OptionsEditorComponent: function ErnieDatasourceNoHealthCheckEditor({ value, onChange, testConnection }) {
121
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
122
+ children: [
123
+ /*#__PURE__*/ (0, _jsxruntime.jsx)("label", {
124
+ htmlFor: "datasource-url",
125
+ children: "ErnieDatasourceNoHealthCheck editor"
126
+ }),
127
+ /*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
128
+ type: "text",
129
+ id: "datasource-url",
130
+ value: value.url ?? '',
131
+ onChange: (e)=>onChange({
132
+ ...value,
133
+ url: e.target.value
134
+ })
135
+ }),
136
+ testConnection && /*#__PURE__*/ (0, _jsxruntime.jsx)("button", {
137
+ onClick: testConnection,
138
+ children: "test-connection-trigger"
139
+ })
140
+ ]
141
+ });
142
+ }
143
+ };
89
144
  const plugins = {
90
145
  'Variable:ErnieVariable1::1.0.0': ErnieVariable1,
91
- 'Variable:ErnieVariable2::1.0.0': ErnieVariable2
146
+ 'Variable:ErnieVariable2::1.0.0': ErnieVariable2,
147
+ 'Datasource:ErnieDatasource::1.0.0': ErnieDatasource,
148
+ 'Datasource:ErnieDatasourceNoHealthCheck::1.0.0': ErnieDatasourceNoHealthCheck
92
149
  };
@@ -200,7 +200,7 @@ const exportDataAsCSV = ({ data })=>{
200
200
  if (!result[dateTime]) {
201
201
  result[dateTime] = {};
202
202
  }
203
- /* linter complains, so assert result[dateTime]
203
+ /* linter complains, so assert result[dateTime]
204
204
  It has already been checked by the if statement
205
205
  */ result[dateTime][currentSeriesInfo.columnName] = value;
206
206
  }
@@ -1,6 +1,6 @@
1
- import { DispatchWithoutAction, ReactElement } from 'react';
2
- import { AnnotationSpec } from '@perses-dev/spec';
3
1
  import { Action } from '@perses-dev/client';
2
+ import { AnnotationSpec } from '@perses-dev/spec';
3
+ import { DispatchWithoutAction, ReactElement } from 'react';
4
4
  interface AnnotationEditorFormProps {
5
5
  initialAnnotationSpec: AnnotationSpec;
6
6
  action: Action;
@@ -1 +1 @@
1
- {"version":3,"file":"AnnotationEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAclD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAmD5C,UAAU,yBAAyB;IACjC,qBAAqB,EAAE,cAAc,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;IACtC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,EACnC,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,UAAU,EACV,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,yBAAyB,GAAG,YAAY,CAuK1C"}
1
+ {"version":3,"file":"AnnotationEditorForm.d.ts","sourceRoot":"","sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAU5C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAyB,MAAM,OAAO,CAAC;AAqDnF,UAAU,yBAAyB;IACjC,qBAAqB,EAAE,cAAc,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,MAAM,EAAE,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;IACtC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC;AAED,wBAAgB,oBAAoB,CAAC,EACnC,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,UAAU,EACV,cAAc,EACd,MAAM,EACN,OAAO,EACP,QAAQ,GACT,EAAE,yBAAyB,GAAG,YAAY,CAuK1C"}
@@ -11,15 +11,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import { useCallback, useState } from 'react';
14
+ import { zodResolver } from '@hookform/resolvers/zod';
15
15
  import { Box, Typography, TextField, Grid, Divider, Stack, IconButton } from '@mui/material';
16
16
  import { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary, FormActions, OptionsColorPicker, getSubmitText, getTitleAction } from '@perses-dev/components';
17
- import { Controller, FormProvider, useForm, useWatch } from 'react-hook-form';
18
- import { zodResolver } from '@hookform/resolvers/zod';
19
17
  import { useQueryClient } from '@tanstack/react-query';
20
18
  import InvertColorsIcon from 'mdi-material-ui/InvertColors';
21
- import { PluginEditor } from '../../PluginEditor';
19
+ import { useCallback, useState } from 'react';
20
+ import { Controller, FormProvider, useForm, useWatch } from 'react-hook-form';
22
21
  import { useValidationSchemas } from '../../../context';
22
+ import { PluginEditor } from '../../PluginEditor';
23
23
  import { DEFAULT_ANNOTATION_COLOR } from '../constants';
24
24
  import { AnnotationPreview } from './AnnotationPreview';
25
25
  function FallbackPreview() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.tsx"],"sourcesContent":["// Copyright 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 { DispatchWithoutAction, ReactElement, useCallback, useState } from 'react';\nimport { Box, Typography, TextField, Grid, Divider, Stack, IconButton } from '@mui/material';\nimport { AnnotationSpec } from '@perses-dev/spec';\nimport {\n DiscardChangesConfirmationDialog,\n ErrorAlert,\n ErrorBoundary,\n FormActions,\n OptionsColorPicker,\n getSubmitText,\n getTitleAction,\n} from '@perses-dev/components';\nimport { Control, Controller, FormProvider, SubmitHandler, useForm, useWatch } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useQueryClient } from '@tanstack/react-query';\nimport InvertColorsIcon from 'mdi-material-ui/InvertColors';\nimport { Action } from '@perses-dev/client';\nimport { PluginEditor } from '../../PluginEditor';\nimport { useValidationSchemas } from '../../../context';\nimport { DEFAULT_ANNOTATION_COLOR } from '../constants';\nimport { AnnotationPreview } from './AnnotationPreview';\n\nfunction FallbackPreview(): ReactElement {\n return <div>Error previewing annotations</div>;\n}\n\ninterface KindAnnotationEditorFormProps {\n action: Action;\n control: Control<AnnotationSpec>;\n onRunQuery: () => void;\n}\n\nfunction AnnotationPluginControl({ action, control, onRunQuery }: KindAnnotationEditorFormProps): ReactElement {\n const plugin = useWatch<AnnotationSpec, 'plugin'>({ control, name: 'plugin' });\n const kind = plugin?.kind;\n const pluginSpec = plugin?.spec;\n\n return (\n <Controller\n control={control}\n name=\"plugin\"\n render={({ field }) => {\n return (\n <PluginEditor\n withRunQueryButton\n width=\"100%\"\n pluginTypes={['Annotation']}\n pluginKindLabel=\"Source\"\n value={{\n selection: {\n type: 'Annotation',\n kind: kind ?? 'StaticListAnnotation',\n },\n spec: pluginSpec ?? {},\n }}\n isReadonly={action === 'read'}\n onChange={(v) => {\n field.onChange({ kind: v.selection.kind, spec: v.spec });\n }}\n onRunQuery={onRunQuery}\n />\n );\n }}\n />\n );\n}\n\ninterface AnnotationEditorFormProps {\n initialAnnotationSpec: AnnotationSpec;\n action: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onActionChange?: (action: Action) => void;\n onSave: (def: AnnotationSpec) => void;\n onClose: () => void;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function AnnotationEditorForm({\n initialAnnotationSpec,\n action,\n isDraft,\n isReadonly,\n onActionChange,\n onSave,\n onClose,\n onDelete,\n}: AnnotationEditorFormProps): ReactElement {\n const queryClient = useQueryClient();\n\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const { annotationEditorSchema } = useValidationSchemas();\n const form = useForm<AnnotationSpec>({\n resolver: zodResolver(annotationEditorSchema),\n mode: 'onBlur',\n defaultValues: initialAnnotationSpec,\n });\n\n /* We use `previewDefinition` to explicitly update the spec\n * that will be used for preview when running query. The reason why we do this is to avoid\n * having to re-fetch the values when the user is still editing the spec.\n * Using structuredClone to not have reference issues with nested objects.\n */\n const [previewSpec, setPreviewSpec] = useState(structuredClone(form.getValues()));\n\n const handleRunQuery = useCallback(async () => {\n const values = form.getValues();\n if (JSON.stringify(previewSpec) === JSON.stringify(values)) {\n await queryClient.invalidateQueries({ queryKey: ['annotation', previewSpec] });\n } else {\n setPreviewSpec(structuredClone(values));\n }\n }, [form, previewSpec, queryClient]);\n\n const processForm: SubmitHandler<AnnotationSpec> = (data: AnnotationSpec) => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(data);\n };\n\n function handleCancel(): void {\n if (JSON.stringify(initialAnnotationSpec) !== JSON.stringify(form.getValues())) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Annotation</Typography>\n <FormActions\n action={action}\n submitText={submitText}\n isReadonly={isReadonly}\n isValid={form.formState.isValid}\n onActionChange={onActionChange}\n onSubmit={form.handleSubmit(processForm)}\n onDelete={onDelete}\n onCancel={handleCancel}\n />\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={12}>\n <Controller\n control={form.control}\n name=\"display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Stack direction=\"row\" gap={1}>\n <Controller\n control={form.control}\n name=\"display.color\"\n render={({ field }) => {\n const isEnabled = field.value !== undefined;\n return (\n <>\n {isEnabled ? (\n <OptionsColorPicker\n size=\"medium\"\n label=\"annotation\"\n color={field.value ?? DEFAULT_ANNOTATION_COLOR}\n onColorChange={(color) => field.onChange(color)}\n onClear={() => field.onChange(undefined)}\n />\n ) : (\n <IconButton size=\"medium\" onClick={() => field.onChange(DEFAULT_ANNOTATION_COLOR)}>\n <InvertColorsIcon />\n </IconButton>\n )}\n </>\n );\n }}\n />\n\n <Controller\n control={form.control}\n name=\"display.description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Stack>\n </Grid>\n </Grid>\n\n <Divider />\n\n <ErrorBoundary FallbackComponent={FallbackPreview} resetKeys={[previewSpec]}>\n <AnnotationPreview spec={previewSpec} sx={{ marginY: 2 }} />\n </ErrorBoundary>\n\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <AnnotationPluginControl action={action} control={form.control} onRunQuery={handleRunQuery} />\n </ErrorBoundary>\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["useCallback","useState","Box","Typography","TextField","Grid","Divider","Stack","IconButton","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","FormActions","OptionsColorPicker","getSubmitText","getTitleAction","Controller","FormProvider","useForm","useWatch","zodResolver","useQueryClient","InvertColorsIcon","PluginEditor","useValidationSchemas","DEFAULT_ANNOTATION_COLOR","AnnotationPreview","FallbackPreview","div","AnnotationPluginControl","action","control","onRunQuery","plugin","name","kind","pluginSpec","spec","render","field","withRunQueryButton","width","pluginTypes","pluginKindLabel","value","selection","type","isReadonly","onChange","v","AnnotationEditorForm","initialAnnotationSpec","isDraft","onActionChange","onSave","onClose","onDelete","queryClient","isDiscardDialogOpened","setDiscardDialogOpened","titleAction","submitText","annotationEditorSchema","form","resolver","mode","defaultValues","previewSpec","setPreviewSpec","structuredClone","getValues","handleRunQuery","values","JSON","stringify","invalidateQueries","queryKey","processForm","data","handleCancel","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","isValid","formState","onSubmit","handleSubmit","onCancel","overflowY","container","mb","item","xs","fieldState","required","fullWidth","label","InputLabelProps","shrink","undefined","InputProps","disabled","readOnly","error","helperText","message","event","direction","gap","isEnabled","size","color","onColorChange","onClear","onClick","FallbackComponent","resetKeys","marginY","description","isOpen","onDiscardChanges"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE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ACRoC,UAAU;oBACRnC,uBAAuB;gBACzB;gBACAoE,kBAAkB;oBAChBpE,uBAAuB;oBACvBJ;gBACF;;;;AAIR"}
1
+ {"version":3,"sources":["../../../../src/components/Annotations/AnnotationEditorForm/AnnotationEditorForm.tsx"],"sourcesContent":["// Copyright 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 { zodResolver } from '@hookform/resolvers/zod';\nimport { Box, Typography, TextField, Grid, Divider, Stack, IconButton } from '@mui/material';\nimport { Action } from '@perses-dev/client';\nimport {\n DiscardChangesConfirmationDialog,\n ErrorAlert,\n ErrorBoundary,\n FormActions,\n OptionsColorPicker,\n getSubmitText,\n getTitleAction,\n} from '@perses-dev/components';\nimport { AnnotationSpec } from '@perses-dev/spec';\nimport { useQueryClient } from '@tanstack/react-query';\nimport InvertColorsIcon from 'mdi-material-ui/InvertColors';\nimport { DispatchWithoutAction, ReactElement, useCallback, useState } from 'react';\nimport { Control, Controller, FormProvider, SubmitHandler, useForm, useWatch } from 'react-hook-form';\n\nimport { useValidationSchemas } from '../../../context';\nimport { PluginEditor } from '../../PluginEditor';\nimport { DEFAULT_ANNOTATION_COLOR } from '../constants';\nimport { AnnotationPreview } from './AnnotationPreview';\n\nfunction FallbackPreview(): ReactElement {\n return <div>Error previewing annotations</div>;\n}\n\ninterface KindAnnotationEditorFormProps {\n action: Action;\n control: Control<AnnotationSpec>;\n onRunQuery: () => void;\n}\n\nfunction AnnotationPluginControl({ action, control, onRunQuery }: KindAnnotationEditorFormProps): ReactElement {\n const plugin = useWatch<AnnotationSpec, 'plugin'>({ control, name: 'plugin' });\n const kind = plugin?.kind;\n const pluginSpec = plugin?.spec;\n\n return (\n <Controller\n control={control}\n name=\"plugin\"\n render={({ field }) => {\n return (\n <PluginEditor\n withRunQueryButton\n width=\"100%\"\n pluginTypes={['Annotation']}\n pluginKindLabel=\"Source\"\n value={{\n selection: {\n type: 'Annotation',\n kind: kind ?? 'StaticListAnnotation',\n },\n spec: pluginSpec ?? {},\n }}\n isReadonly={action === 'read'}\n onChange={(v) => {\n field.onChange({ kind: v.selection.kind, spec: v.spec });\n }}\n onRunQuery={onRunQuery}\n />\n );\n }}\n />\n );\n}\n\ninterface AnnotationEditorFormProps {\n initialAnnotationSpec: AnnotationSpec;\n action: Action;\n isDraft: boolean;\n isReadonly?: boolean;\n onActionChange?: (action: Action) => void;\n onSave: (def: AnnotationSpec) => void;\n onClose: () => void;\n onDelete?: DispatchWithoutAction;\n}\n\nexport function AnnotationEditorForm({\n initialAnnotationSpec,\n action,\n isDraft,\n isReadonly,\n onActionChange,\n onSave,\n onClose,\n onDelete,\n}: AnnotationEditorFormProps): ReactElement {\n const queryClient = useQueryClient();\n\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n const titleAction = getTitleAction(action, isDraft);\n const submitText = getSubmitText(action, isDraft);\n\n const { annotationEditorSchema } = useValidationSchemas();\n const form = useForm<AnnotationSpec>({\n resolver: zodResolver(annotationEditorSchema),\n mode: 'onBlur',\n defaultValues: initialAnnotationSpec,\n });\n\n /* We use `previewDefinition` to explicitly update the spec\n * that will be used for preview when running query. The reason why we do this is to avoid\n * having to re-fetch the values when the user is still editing the spec.\n * Using structuredClone to not have reference issues with nested objects.\n */\n const [previewSpec, setPreviewSpec] = useState(structuredClone(form.getValues()));\n\n const handleRunQuery = useCallback(async () => {\n const values = form.getValues();\n if (JSON.stringify(previewSpec) === JSON.stringify(values)) {\n await queryClient.invalidateQueries({ queryKey: ['annotation', previewSpec] });\n } else {\n setPreviewSpec(structuredClone(values));\n }\n }, [form, previewSpec, queryClient]);\n\n const processForm: SubmitHandler<AnnotationSpec> = (data: AnnotationSpec) => {\n // reset display attributes to undefined when empty, because we don't want to save empty strings\n onSave(data);\n };\n\n function handleCancel(): void {\n if (JSON.stringify(initialAnnotationSpec) !== JSON.stringify(form.getValues())) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Annotation</Typography>\n <FormActions\n action={action}\n submitText={submitText}\n isReadonly={isReadonly}\n isValid={form.formState.isValid}\n onActionChange={onActionChange}\n onSubmit={form.handleSubmit(processForm)}\n onDelete={onDelete}\n onCancel={handleCancel}\n />\n </Box>\n <Box padding={2} sx={{ overflowY: 'scroll' }}>\n <Grid container spacing={2} mb={2}>\n <Grid item xs={12}>\n <Controller\n control={form.control}\n name=\"display.name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n disabled: action === 'update' && !isDraft,\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Stack direction=\"row\" gap={1}>\n <Controller\n control={form.control}\n name=\"display.color\"\n render={({ field }) => {\n const isEnabled = field.value !== undefined;\n return (\n <>\n {isEnabled ? (\n <OptionsColorPicker\n size=\"medium\"\n label=\"annotation\"\n color={field.value ?? DEFAULT_ANNOTATION_COLOR}\n onColorChange={(color) => field.onChange(color)}\n onClear={() => field.onChange(undefined)}\n />\n ) : (\n <IconButton size=\"medium\" onClick={() => field.onChange(DEFAULT_ANNOTATION_COLOR)}>\n <InvertColorsIcon />\n </IconButton>\n )}\n </>\n );\n }}\n />\n\n <Controller\n control={form.control}\n name=\"display.description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n InputLabelProps={{ shrink: action === 'read' ? true : undefined }}\n InputProps={{\n readOnly: action === 'read',\n }}\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n value={field.value ?? ''}\n onChange={(event) => {\n field.onChange(event);\n }}\n />\n )}\n />\n </Stack>\n </Grid>\n </Grid>\n\n <Divider />\n\n <ErrorBoundary FallbackComponent={FallbackPreview} resetKeys={[previewSpec]}>\n <AnnotationPreview spec={previewSpec} sx={{ marginY: 2 }} />\n </ErrorBoundary>\n\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <AnnotationPluginControl action={action} control={form.control} onRunQuery={handleRunQuery} />\n </ErrorBoundary>\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n"],"names":["zodResolver","Box","Typography","TextField","Grid","Divider","Stack","IconButton","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","FormActions","OptionsColorPicker","getSubmitText","getTitleAction","useQueryClient","InvertColorsIcon","useCallback","useState","Controller","FormProvider","useForm","useWatch","useValidationSchemas","PluginEditor","DEFAULT_ANNOTATION_COLOR","AnnotationPreview","FallbackPreview","div","AnnotationPluginControl","action","control","onRunQuery","plugin","name","kind","pluginSpec","spec","render","field","withRunQueryButton","width","pluginTypes","pluginKindLabel","value","selection","type","isReadonly","onChange","v","AnnotationEditorForm","initialAnnotationSpec","isDraft","onActionChange","onSave","onClose","onDelete","queryClient","isDiscardDialogOpened","setDiscardDialogOpened","titleAction","submitText","annotationEditorSchema","form","resolver","mode","defaultValues","previewSpec","setPreviewSpec","structuredClone","getValues","handleRunQuery","values","JSON","stringify","invalidateQueries","queryKey","processForm","data","handleCancel","sx","display","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","isValid","formState","onSubmit","handleSubmit","onCancel","overflowY","container","mb","item","xs","fieldState","required","fullWidth","label","InputLabelProps","shrink","undefined","InputProps","disabled","readOnly","error","helperText","message","event","direction","gap","isEnabled","size","color","onColorChange","onClear","onClick","FallbackComponent","resetKeys","marginY","description","isOpen","onDiscardChanges"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAAQ,0BAA0B;AACtD,SAASC,GAAG,EAAEC,UAAU,EAAEC,SAAS,EAAEC,IAAI,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAE7F,SACEC,gCAAgC,EAChCC,UAAU,EACVC,aAAa,EACbC,WAAW,EACXC,kBAAkB,EAClBC,aAAa,EACbC,cAAc,QACT,yBAAyB;AAEhC,SAASC,cAAc,QAAQ,wBAAwB;AACvD,OAAOC,sBAAsB,+BAA+B;AAC5D,SAA8CC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AACnF,SAAkBC,UAAU,EAAEC,YAAY,EAAiBC,OAAO,EAAEC,QAAQ,QAAQ,kBAAkB;AAEtG,SAASC,oBAAoB,QAAQ,mBAAmB;AACxD,SAASC,YAAY,QAAQ,qBAAqB;AAClD,SAASC,wBAAwB,QAAQ,eAAe;AACxD,SAASC,iBAAiB,QAAQ,sBAAsB;AAExD,SAASC;IACP,qBAAO,KAACC;kBAAI;;AACd;AAQA,SAASC,wBAAwB,EAAEC,MAAM,EAAEC,OAAO,EAAEC,UAAU,EAAiC;IAC7F,MAAMC,SAASX,SAAmC;QAAES;QAASG,MAAM;IAAS;IAC5E,MAAMC,OAAOF,QAAQE;IACrB,MAAMC,aAAaH,QA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