@perses-dev/plugin-system 0.0.0-snapshot-scatter-chart-embed-8efdfab → 0.0.0-snapshot-explorer-plugin-c4a7621

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 (431) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +1 -1
  2. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +83 -163
  3. package/dist/cjs/components/DatasourceSelect.js +12 -15
  4. package/dist/cjs/components/HTTPSettingsEditor/HTTPSettingsEditor.js +528 -0
  5. package/dist/cjs/components/{TimeSeriesQueryEditor → HTTPSettingsEditor}/index.js +2 -2
  6. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +8 -7
  7. package/dist/cjs/components/MetricLabelInput/MetricLabelInput.js +41 -0
  8. package/dist/cjs/{validation/resource.js → components/MetricLabelInput/index.js} +15 -9
  9. package/dist/cjs/components/{TraceQueryEditor/TraceQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +39 -40
  10. package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +23 -11
  11. package/dist/cjs/components/MultiQueryEditor/index.js +30 -0
  12. package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +3 -3
  13. package/dist/cjs/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  14. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +3 -3
  15. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +54 -62
  16. package/dist/cjs/components/PluginEditor/PluginEditor.js +16 -13
  17. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +44 -33
  18. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +55 -7
  19. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +9 -10
  20. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +20 -17
  21. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
  22. package/dist/cjs/components/ProjectSelect.js +7 -7
  23. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +131 -0
  24. package/dist/cjs/components/{TraceQueryEditor → TimeRangeControls}/index.js +1 -1
  25. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +394 -439
  26. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +17 -15
  27. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -12
  28. package/dist/cjs/components/Variables/variable-model.js +35 -37
  29. package/dist/cjs/components/index.js +4 -1
  30. package/dist/cjs/constants/user-interface-text.js +4 -1
  31. package/dist/cjs/context/ProjectStoreProvider.js +12 -9
  32. package/dist/cjs/context/ValidationProvider.js +69 -0
  33. package/dist/cjs/context/index.js +1 -0
  34. package/dist/cjs/index.js +1 -1
  35. package/dist/{components/TimeSeriesQueryEditor/index.js → cjs/model/explore.js} +4 -3
  36. package/dist/cjs/model/legend.js +5 -5
  37. package/dist/cjs/remote/PersesPlugin.types.js +16 -0
  38. package/dist/cjs/remote/PluginLoaderComponent.js +75 -0
  39. package/dist/cjs/remote/PluginRuntime.js +267 -0
  40. package/dist/cjs/{validation → remote}/index.js +2 -4
  41. package/dist/cjs/remote/remotePluginLoader.js +61 -0
  42. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +23 -14
  43. package/dist/cjs/runtime/DataQueriesProvider/model.js +10 -9
  44. package/dist/cjs/runtime/QueryCountProvider.js +83 -0
  45. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +37 -13
  46. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +3 -3
  47. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +100 -0
  48. package/dist/cjs/runtime/TimeRangeProvider/index.js +2 -1
  49. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +20 -23
  50. package/dist/cjs/runtime/UsageMetricsProvider.js +99 -0
  51. package/dist/cjs/runtime/builtin-variables.js +7 -7
  52. package/dist/cjs/runtime/datasources.js +30 -21
  53. package/dist/cjs/runtime/index.js +4 -2
  54. package/dist/cjs/runtime/plugin-registry.js +48 -36
  55. package/dist/cjs/runtime/time-series-queries.js +35 -40
  56. package/dist/cjs/runtime/trace-queries.js +9 -6
  57. package/dist/cjs/runtime/{template-variables.js → variables.js} +38 -48
  58. package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  59. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +1 -65
  60. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  61. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +5 -5
  62. package/dist/cjs/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +9 -9
  63. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  64. package/dist/cjs/stories/shared-utils/decorators/index.js +2 -2
  65. package/dist/cjs/test/mock-data.js +25 -4
  66. package/dist/cjs/test/render.js +2 -11
  67. package/dist/cjs/test/test-plugins/bert/index.js +21 -20
  68. package/dist/cjs/test/test-plugins/ernie/index.js +2 -2
  69. package/dist/cjs/test/test-plugins/index.js +3 -1
  70. package/dist/cjs/test-utils/mock-plugin-registry.js +13 -13
  71. package/dist/cjs/utils/action.js +3 -3
  72. package/dist/cjs/utils/variables.js +24 -24
  73. package/dist/components/CalculationSelector/CalculationSelector.d.ts +2 -2
  74. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  75. package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
  76. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  77. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +7 -7
  78. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  79. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +86 -166
  80. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  81. package/dist/components/DatasourceSelect.d.ts +4 -4
  82. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  83. package/dist/components/DatasourceSelect.js +9 -12
  84. package/dist/components/DatasourceSelect.js.map +1 -1
  85. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts +11 -0
  86. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.d.ts.map +1 -0
  87. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js +474 -0
  88. package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -0
  89. package/dist/components/HTTPSettingsEditor/index.d.ts +2 -0
  90. package/dist/components/HTTPSettingsEditor/index.d.ts.map +1 -0
  91. package/dist/components/HTTPSettingsEditor/index.js +15 -0
  92. package/dist/components/HTTPSettingsEditor/index.js.map +1 -0
  93. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +3 -2
  94. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  95. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +10 -9
  96. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  97. package/dist/components/MetricLabelInput/MetricLabelInput.d.ts +7 -0
  98. package/dist/components/MetricLabelInput/MetricLabelInput.d.ts.map +1 -0
  99. package/dist/components/MetricLabelInput/MetricLabelInput.js +33 -0
  100. package/dist/components/MetricLabelInput/MetricLabelInput.js.map +1 -0
  101. package/dist/components/MetricLabelInput/index.d.ts +2 -0
  102. package/dist/components/MetricLabelInput/index.d.ts.map +1 -0
  103. package/dist/components/MetricLabelInput/index.js +15 -0
  104. package/dist/components/MetricLabelInput/index.js.map +1 -0
  105. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +17 -0
  106. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -0
  107. package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +42 -39
  108. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -0
  109. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +29 -0
  110. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -0
  111. package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +33 -10
  112. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -0
  113. package/dist/components/MultiQueryEditor/index.d.ts +2 -0
  114. package/dist/components/MultiQueryEditor/index.d.ts.map +1 -0
  115. package/dist/components/MultiQueryEditor/index.js +15 -0
  116. package/dist/components/{TraceQueryEditor → MultiQueryEditor}/index.js.map +1 -1
  117. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +4 -4
  118. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
  119. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +3 -3
  120. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  121. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +2 -2
  122. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
  123. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  124. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  125. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +5 -5
  126. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
  127. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +3 -3
  128. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  129. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +5 -3
  130. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  131. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +56 -64
  132. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  133. package/dist/components/PluginEditor/PluginEditor.d.ts +2 -2
  134. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  135. package/dist/components/PluginEditor/PluginEditor.js +16 -13
  136. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  137. package/dist/components/PluginEditor/plugin-editor-api.d.ts +16 -10
  138. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  139. package/dist/components/PluginEditor/plugin-editor-api.js +44 -33
  140. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  141. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +11 -5
  142. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  143. package/dist/components/PluginKindSelect/PluginKindSelect.js +61 -10
  144. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  145. package/dist/components/PluginRegistry/PluginRegistry.d.ts +4 -4
  146. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  147. package/dist/components/PluginRegistry/PluginRegistry.js +9 -10
  148. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  149. package/dist/components/PluginRegistry/plugin-indexes.d.ts +4 -4
  150. package/dist/components/PluginRegistry/plugin-indexes.d.ts.map +1 -1
  151. package/dist/components/PluginRegistry/plugin-indexes.js +17 -14
  152. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  153. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +5 -5
  154. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  155. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
  156. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  157. package/dist/components/ProjectSelect.d.ts +3 -3
  158. package/dist/components/ProjectSelect.d.ts.map +1 -1
  159. package/dist/components/ProjectSelect.js +7 -7
  160. package/dist/components/ProjectSelect.js.map +1 -1
  161. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +14 -0
  162. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
  163. package/dist/components/TimeRangeControls/TimeRangeControls.js +110 -0
  164. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
  165. package/dist/components/TimeRangeControls/index.d.ts +2 -0
  166. package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
  167. package/dist/components/{TraceQueryEditor → TimeRangeControls}/index.js +1 -1
  168. package/dist/components/TimeRangeControls/index.js.map +1 -0
  169. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +4 -3
  170. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  171. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +395 -442
  172. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  173. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +3 -3
  174. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  175. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +11 -11
  176. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  177. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +3 -3
  178. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  179. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +7 -12
  180. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  181. package/dist/components/Variables/variable-model.d.ts +2 -1
  182. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  183. package/dist/components/Variables/variable-model.js +29 -31
  184. package/dist/components/Variables/variable-model.js.map +1 -1
  185. package/dist/components/index.d.ts +4 -1
  186. package/dist/components/index.d.ts.map +1 -1
  187. package/dist/components/index.js +4 -1
  188. package/dist/components/index.js.map +1 -1
  189. package/dist/constants/user-interface-text.d.ts +2 -0
  190. package/dist/constants/user-interface-text.d.ts.map +1 -1
  191. package/dist/constants/user-interface-text.js +4 -1
  192. package/dist/constants/user-interface-text.js.map +1 -1
  193. package/dist/context/ProjectStoreProvider.d.ts +4 -4
  194. package/dist/context/ProjectStoreProvider.d.ts.map +1 -1
  195. package/dist/context/ProjectStoreProvider.js +9 -6
  196. package/dist/context/ProjectStoreProvider.js.map +1 -1
  197. package/dist/context/ValidationProvider.d.ts +19 -0
  198. package/dist/context/ValidationProvider.d.ts.map +1 -0
  199. package/dist/context/ValidationProvider.js +52 -0
  200. package/dist/context/ValidationProvider.js.map +1 -0
  201. package/dist/context/index.d.ts +1 -0
  202. package/dist/context/index.d.ts.map +1 -1
  203. package/dist/context/index.js +1 -0
  204. package/dist/context/index.js.map +1 -1
  205. package/dist/context/query-params.d.ts.map +1 -1
  206. package/dist/context/query-params.js.map +1 -1
  207. package/dist/index.d.ts +1 -1
  208. package/dist/index.d.ts.map +1 -1
  209. package/dist/index.js +1 -1
  210. package/dist/index.js.map +1 -1
  211. package/dist/model/datasource.js +3 -1
  212. package/dist/model/datasource.js.map +1 -1
  213. package/dist/model/explore.d.ts +13 -0
  214. package/dist/model/explore.d.ts.map +1 -0
  215. package/dist/{validation/resource.js → model/explore.js} +4 -3
  216. package/dist/model/explore.js.map +1 -0
  217. package/dist/model/legend.d.ts +2 -2
  218. package/dist/model/legend.d.ts.map +1 -1
  219. package/dist/model/legend.js.map +1 -1
  220. package/dist/model/panels.d.ts +17 -5
  221. package/dist/model/panels.d.ts.map +1 -1
  222. package/dist/model/panels.js.map +1 -1
  223. package/dist/model/plugin-base.d.ts +0 -1
  224. package/dist/model/plugin-base.d.ts.map +1 -1
  225. package/dist/model/plugin-base.js.map +1 -1
  226. package/dist/model/plugin-loading.js.map +1 -1
  227. package/dist/model/plugins.d.ts +35 -21
  228. package/dist/model/plugins.d.ts.map +1 -1
  229. package/dist/model/plugins.js.map +1 -1
  230. package/dist/model/time-series-queries.d.ts +4 -3
  231. package/dist/model/time-series-queries.d.ts.map +1 -1
  232. package/dist/model/time-series-queries.js.map +1 -1
  233. package/dist/model/trace-queries.d.ts +1 -1
  234. package/dist/model/trace-queries.d.ts.map +1 -1
  235. package/dist/model/trace-queries.js.map +1 -1
  236. package/dist/model/variables.d.ts +2 -2
  237. package/dist/model/variables.d.ts.map +1 -1
  238. package/dist/model/variables.js +3 -1
  239. package/dist/model/variables.js.map +1 -1
  240. package/dist/remote/PersesPlugin.types.d.ts +7 -0
  241. package/dist/remote/PersesPlugin.types.d.ts.map +1 -0
  242. package/dist/remote/PersesPlugin.types.js +15 -0
  243. package/dist/remote/PersesPlugin.types.js.map +1 -0
  244. package/dist/remote/PluginLoaderComponent.d.ts +10 -0
  245. package/dist/remote/PluginLoaderComponent.d.ts.map +1 -0
  246. package/dist/remote/PluginLoaderComponent.js +67 -0
  247. package/dist/remote/PluginLoaderComponent.js.map +1 -0
  248. package/dist/remote/PluginRuntime.d.ts +11 -0
  249. package/dist/remote/PluginRuntime.d.ts.map +1 -0
  250. package/dist/remote/PluginRuntime.js +202 -0
  251. package/dist/remote/PluginRuntime.js.map +1 -0
  252. package/dist/remote/index.d.ts +3 -0
  253. package/dist/remote/index.d.ts.map +1 -0
  254. package/dist/{validation → remote}/index.js +2 -4
  255. package/dist/remote/index.js.map +1 -0
  256. package/dist/remote/remotePluginLoader.d.ts +3 -0
  257. package/dist/remote/remotePluginLoader.d.ts.map +1 -0
  258. package/dist/remote/remotePluginLoader.js +53 -0
  259. package/dist/remote/remotePluginLoader.js.map +1 -0
  260. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +2 -2
  261. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  262. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +19 -10
  263. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  264. package/dist/runtime/DataQueriesProvider/model.d.ts +6 -7
  265. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  266. package/dist/runtime/DataQueriesProvider/model.js +10 -9
  267. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  268. package/dist/runtime/QueryCountProvider.d.ts +9 -0
  269. package/dist/runtime/QueryCountProvider.d.ts.map +1 -0
  270. package/dist/{validation/datasource.js → runtime/QueryCountProvider.js} +14 -10
  271. package/dist/runtime/QueryCountProvider.js.map +1 -0
  272. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +6 -2
  273. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  274. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +30 -9
  275. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  276. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +2 -2
  277. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -1
  278. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +3 -3
  279. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -1
  280. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts +32 -0
  281. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.d.ts.map +1 -0
  282. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js +82 -0
  283. package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -0
  284. package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
  285. package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
  286. package/dist/runtime/TimeRangeProvider/index.js +2 -1
  287. package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
  288. package/dist/runtime/TimeRangeProvider/query-params.d.ts +1 -1
  289. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  290. package/dist/runtime/TimeRangeProvider/query-params.js +8 -11
  291. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  292. package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -1
  293. package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -1
  294. package/dist/runtime/UsageMetricsProvider.d.ts +25 -0
  295. package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -0
  296. package/dist/runtime/UsageMetricsProvider.js +77 -0
  297. package/dist/runtime/UsageMetricsProvider.js.map +1 -0
  298. package/dist/runtime/builtin-variables.d.ts +2 -2
  299. package/dist/runtime/builtin-variables.d.ts.map +1 -1
  300. package/dist/runtime/builtin-variables.js +4 -4
  301. package/dist/runtime/builtin-variables.js.map +1 -1
  302. package/dist/runtime/datasources.d.ts +5 -4
  303. package/dist/runtime/datasources.d.ts.map +1 -1
  304. package/dist/runtime/datasources.js +24 -15
  305. package/dist/runtime/datasources.js.map +1 -1
  306. package/dist/runtime/index.d.ts +3 -1
  307. package/dist/runtime/index.d.ts.map +1 -1
  308. package/dist/runtime/index.js +4 -2
  309. package/dist/runtime/index.js.map +1 -1
  310. package/dist/runtime/plugin-registry.d.ts +11 -11
  311. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  312. package/dist/runtime/plugin-registry.js +40 -28
  313. package/dist/runtime/plugin-registry.js.map +1 -1
  314. package/dist/runtime/time-series-queries.d.ts +5 -4
  315. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  316. package/dist/runtime/time-series-queries.js +28 -33
  317. package/dist/runtime/time-series-queries.js.map +1 -1
  318. package/dist/runtime/trace-queries.d.ts +5 -4
  319. package/dist/runtime/trace-queries.d.ts.map +1 -1
  320. package/dist/runtime/trace-queries.js +10 -7
  321. package/dist/runtime/trace-queries.js.map +1 -1
  322. package/dist/runtime/{template-variables.d.ts → variables.d.ts} +7 -7
  323. package/dist/runtime/variables.d.ts.map +1 -0
  324. package/dist/runtime/{template-variables.js → variables.js} +35 -44
  325. package/dist/runtime/variables.js.map +1 -0
  326. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +3 -3
  327. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -1
  328. package/dist/stories/shared-utils/decorators/WithDataQueries.js +1 -1
  329. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  330. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +2 -2
  331. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  332. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -22
  333. package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
  334. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +3 -3
  335. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -1
  336. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +1 -1
  337. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -1
  338. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +3 -3
  339. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
  340. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +5 -5
  341. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  342. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts +13 -0
  343. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.d.ts.map +1 -0
  344. package/dist/stories/shared-utils/decorators/{WithPluginSystemTemplateVariables.js → WithPluginSystemVariables.js} +10 -10
  345. package/dist/stories/shared-utils/decorators/WithPluginSystemVariables.js.map +1 -0
  346. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +3 -3
  347. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
  348. package/dist/stories/shared-utils/decorators/WithTimeRange.js +1 -1
  349. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  350. package/dist/stories/shared-utils/decorators/index.d.ts +1 -1
  351. package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
  352. package/dist/stories/shared-utils/decorators/index.js +2 -2
  353. package/dist/stories/shared-utils/decorators/index.js.map +1 -1
  354. package/dist/test/mock-data.d.ts.map +1 -1
  355. package/dist/test/mock-data.js +25 -4
  356. package/dist/test/mock-data.js.map +1 -1
  357. package/dist/test/render.d.ts +4 -4
  358. package/dist/test/render.d.ts.map +1 -1
  359. package/dist/test/render.js +2 -11
  360. package/dist/test/render.js.map +1 -1
  361. package/dist/test/setup-tests.js.map +1 -1
  362. package/dist/test/test-plugins/bert/index.d.ts.map +1 -1
  363. package/dist/test/test-plugins/bert/index.js +21 -20
  364. package/dist/test/test-plugins/bert/index.js.map +1 -1
  365. package/dist/test/test-plugins/ernie/index.js +2 -2
  366. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  367. package/dist/test-utils/mock-plugin-registry.d.ts +6 -4
  368. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  369. package/dist/test-utils/mock-plugin-registry.js +10 -10
  370. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  371. package/dist/utils/variables.d.ts +4 -4
  372. package/dist/utils/variables.d.ts.map +1 -1
  373. package/dist/utils/variables.js +19 -19
  374. package/dist/utils/variables.js.map +1 -1
  375. package/package.json +7 -6
  376. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +0 -146
  377. package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +0 -96
  378. package/dist/cjs/validation/datasource.js +0 -30
  379. package/dist/cjs/validation/role.js +0 -85
  380. package/dist/cjs/validation/rolebinding.js +0 -55
  381. package/dist/cjs/validation/secret.js +0 -176
  382. package/dist/cjs/validation/variable.js +0 -48
  383. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +0 -8
  384. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +0 -1
  385. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +0 -1
  386. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +0 -13
  387. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +0 -1
  388. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +0 -1
  389. package/dist/components/TimeSeriesQueryEditor/index.d.ts +0 -2
  390. package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +0 -1
  391. package/dist/components/TimeSeriesQueryEditor/index.js.map +0 -1
  392. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +0 -9
  393. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +0 -1
  394. package/dist/components/TraceQueryEditor/TraceQueryEditor.js +0 -130
  395. package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +0 -1
  396. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +0 -13
  397. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +0 -1
  398. package/dist/components/TraceQueryEditor/TraceQueryInput.js +0 -83
  399. package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +0 -1
  400. package/dist/components/TraceQueryEditor/index.d.ts +0 -2
  401. package/dist/components/TraceQueryEditor/index.d.ts.map +0 -1
  402. package/dist/runtime/template-variables.d.ts.map +0 -1
  403. package/dist/runtime/template-variables.js.map +0 -1
  404. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +0 -13
  405. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +0 -1
  406. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +0 -1
  407. package/dist/validation/datasource.d.ts +0 -19
  408. package/dist/validation/datasource.d.ts.map +0 -1
  409. package/dist/validation/datasource.js.map +0 -1
  410. package/dist/validation/index.d.ts +0 -5
  411. package/dist/validation/index.d.ts.map +0 -1
  412. package/dist/validation/index.js.map +0 -1
  413. package/dist/validation/resource.d.ts +0 -3
  414. package/dist/validation/resource.d.ts.map +0 -1
  415. package/dist/validation/resource.js.map +0 -1
  416. package/dist/validation/role.d.ts +0 -228
  417. package/dist/validation/role.d.ts.map +0 -1
  418. package/dist/validation/role.js +0 -66
  419. package/dist/validation/role.js.map +0 -1
  420. package/dist/validation/rolebinding.d.ts +0 -137
  421. package/dist/validation/rolebinding.d.ts.map +0 -1
  422. package/dist/validation/rolebinding.js +0 -47
  423. package/dist/validation/rolebinding.js.map +0 -1
  424. package/dist/validation/secret.d.ts +0 -964
  425. package/dist/validation/secret.d.ts.map +0 -1
  426. package/dist/validation/secret.js +0 -157
  427. package/dist/validation/secret.js.map +0 -1
  428. package/dist/validation/variable.d.ts +0 -96
  429. package/dist/validation/variable.d.ts.map +0 -1
  430. package/dist/validation/variable.js +0 -40
  431. package/dist/validation/variable.js.map +0 -1
@@ -11,73 +11,384 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
- import React, { useCallback, useMemo, useState } from 'react';
15
- import { Box, Typography, Switch, TextField, Grid, FormControlLabel, MenuItem, Button, Stack, ClickAwayListener, Divider } from '@mui/material';
16
- import { DiscardChangesConfirmationDialog, ErrorBoundary } from '@perses-dev/components';
17
- import { Controller, FormProvider, useForm } from 'react-hook-form';
14
+ import React, { useState } from 'react';
15
+ import { Box, Typography, Switch, TextField, Grid, FormControlLabel, MenuItem, Stack, ClickAwayListener, Divider } from '@mui/material';
16
+ import { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary, FormActions } from '@perses-dev/components';
17
+ import { Controller, FormProvider, useForm, useFormContext, useWatch } from 'react-hook-form';
18
18
  import { zodResolver } from '@hookform/resolvers/zod';
19
- import { useImmer } from 'use-immer';
20
19
  import { getSubmitText, getTitleAction } from '../../../utils';
21
20
  import { VARIABLE_TYPES } from '../variable-model';
22
21
  import { PluginEditor } from '../../PluginEditor';
23
- import { variableEditorValidationSchema } from '../../../validation';
22
+ import { useValidationSchemas } from '../../../context';
24
23
  import { VariableListPreview, VariablePreview } from './VariablePreview';
25
- import { getVariableDefinitionFromState, getInitialState } from './variable-editor-form-model';
26
24
  function FallbackPreview() {
27
25
  return /*#__PURE__*/ _jsx("div", {
28
26
  children: "Error previewing values"
29
27
  });
30
28
  }
31
- export function VariableEditorForm(props) {
32
- const { initialVariableDefinition , initialAction , isDraft , isReadonly , onSave , onClose , onDelete } = props;
33
- const initialState = getInitialState(initialVariableDefinition);
34
- const [state, setState] = useImmer(initialState);
35
- const [isDiscardDialogOpened, setDiscardDialogOpened] = useState(false);
36
- const [previewKey, setPreviewKey] = useState(0);
37
- const [action, setAction] = useState(initialAction);
38
- const refreshPreview = ()=>{
39
- setPreviewKey((prev)=>prev + 1);
40
- };
41
- /** We use the `previewKey` that we increment to know when to explicitly update the
29
+ function TextVariableEditorForm({ action, control }) {
30
+ return /*#__PURE__*/ _jsxs(_Fragment, {
31
+ children: [
32
+ /*#__PURE__*/ _jsx(Typography, {
33
+ py: 1,
34
+ variant: "subtitle1",
35
+ children: "Text Options"
36
+ }),
37
+ /*#__PURE__*/ _jsxs(Stack, {
38
+ spacing: 2,
39
+ children: [
40
+ /*#__PURE__*/ _jsx(Controller, {
41
+ control: control,
42
+ name: "spec.value",
43
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsxs(_Fragment, {
44
+ children: [
45
+ /*#__PURE__*/ _jsx(Box, {
46
+ children: /*#__PURE__*/ _jsx(VariablePreview, {
47
+ values: [
48
+ field.value
49
+ ]
50
+ })
51
+ }),
52
+ /*#__PURE__*/ _jsx(TextField, {
53
+ ...field,
54
+ label: "Value",
55
+ InputLabelProps: {
56
+ shrink: action === 'read' ? true : undefined
57
+ },
58
+ InputProps: {
59
+ readOnly: action === 'read'
60
+ },
61
+ error: !!fieldState.error,
62
+ helperText: fieldState.error?.message,
63
+ value: field.value ?? '',
64
+ onChange: (event)=>{
65
+ field.onChange(event);
66
+ }
67
+ })
68
+ ]
69
+ })
70
+ }),
71
+ /*#__PURE__*/ _jsx(Controller, {
72
+ control: control,
73
+ name: "spec.constant",
74
+ render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
75
+ label: "Constant",
76
+ control: /*#__PURE__*/ _jsx(Switch, {
77
+ ...field,
78
+ checked: !!field.value,
79
+ readOnly: action === 'read',
80
+ value: field.value ?? false,
81
+ onChange: (event)=>{
82
+ if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
83
+ field.onChange(event);
84
+ }
85
+ })
86
+ })
87
+ })
88
+ ]
89
+ })
90
+ ]
91
+ });
92
+ }
93
+ function ListVariableEditorForm({ action, control }) {
94
+ const form = useFormContext();
95
+ /** We use `previewSpec` to know when to explicitly update the
42
96
  * spec that will be used for preview. The reason why we do this is to avoid
43
97
  * having to re-fetch the values when the user is still editing the spec.
44
- */ const previewSpec = useMemo(()=>{
45
- return getVariableDefinitionFromState(state);
46
- // eslint-disable-next-line react-hooks/exhaustive-deps
47
- }, [
48
- previewKey
49
- ]);
98
+ */ const [previewSpec, setPreviewSpec] = useState(form.getValues());
99
+ const refreshPreview = ()=>{
100
+ setPreviewSpec(form.getValues());
101
+ };
102
+ const kind = useWatch({
103
+ control: control,
104
+ name: 'spec.plugin.kind'
105
+ });
106
+ const _allowAllValue = useWatch({
107
+ control: control,
108
+ name: 'spec.allowAllValue'
109
+ });
110
+ // When variable kind is selected we need to provide default values
111
+ // TODO: check if react-hook-form has a better way to do this
112
+ const values = form.getValues();
113
+ if (values.spec.allowAllValue === undefined) {
114
+ form.setValue('spec.allowAllValue', false);
115
+ }
116
+ if (values.spec.allowMultiple === undefined) {
117
+ form.setValue('spec.allowMultiple', false);
118
+ }
119
+ return /*#__PURE__*/ _jsxs(_Fragment, {
120
+ children: [
121
+ /*#__PURE__*/ _jsx(Typography, {
122
+ py: 1,
123
+ variant: "subtitle1",
124
+ children: "List Options"
125
+ }),
126
+ /*#__PURE__*/ _jsxs(Stack, {
127
+ spacing: 2,
128
+ mb: 2,
129
+ children: [
130
+ kind ? /*#__PURE__*/ _jsx(Box, {
131
+ children: /*#__PURE__*/ _jsx(ErrorBoundary, {
132
+ FallbackComponent: FallbackPreview,
133
+ resetKeys: [
134
+ previewSpec
135
+ ],
136
+ children: /*#__PURE__*/ _jsx(VariableListPreview, {
137
+ definition: previewSpec,
138
+ onRefresh: refreshPreview
139
+ })
140
+ })
141
+ }) : /*#__PURE__*/ _jsx(VariablePreview, {
142
+ isLoading: true
143
+ }),
144
+ /*#__PURE__*/ _jsxs(Stack, {
145
+ children: [
146
+ /*#__PURE__*/ _jsx(ClickAwayListener, {
147
+ onClickAway: ()=>refreshPreview(),
148
+ children: /*#__PURE__*/ _jsx(Box, {})
149
+ }),
150
+ /*#__PURE__*/ _jsx(ErrorBoundary, {
151
+ FallbackComponent: ErrorAlert,
152
+ children: /*#__PURE__*/ _jsx(Controller, {
153
+ control: control,
154
+ name: "spec.plugin",
155
+ render: ({ field })=>/*#__PURE__*/ _jsx(PluginEditor, {
156
+ width: "100%",
157
+ pluginTypes: [
158
+ 'Variable'
159
+ ],
160
+ pluginKindLabel: "Source",
161
+ value: {
162
+ selection: {
163
+ type: 'Variable',
164
+ kind: field.value?.kind ?? 'StaticListVariable'
165
+ },
166
+ spec: field.value?.spec ?? {
167
+ values: []
168
+ }
169
+ },
170
+ isReadonly: action === 'read',
171
+ onChange: (v)=>{
172
+ field.onChange({
173
+ kind: v.selection.kind,
174
+ spec: v.spec
175
+ });
176
+ }
177
+ })
178
+ })
179
+ })
180
+ ]
181
+ }),
182
+ /*#__PURE__*/ _jsx(Stack, {
183
+ children: /*#__PURE__*/ _jsx(Controller, {
184
+ control: control,
185
+ name: "spec.capturingRegexp",
186
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
187
+ ...field,
188
+ label: "Capturing Regexp Filter",
189
+ InputLabelProps: {
190
+ shrink: action === 'read' ? true : undefined
191
+ },
192
+ InputProps: {
193
+ readOnly: action === 'read'
194
+ },
195
+ error: !!fieldState.error,
196
+ value: field.value ?? '',
197
+ onChange: (event)=>{
198
+ if (event.target.value === '') {
199
+ field.onChange(undefined);
200
+ } else {
201
+ field.onChange(event);
202
+ }
203
+ },
204
+ helperText: fieldState.error?.message ? fieldState.error.message : 'Optional, if you want to filter on captured result.'
205
+ })
206
+ })
207
+ }),
208
+ /*#__PURE__*/ _jsx(Stack, {
209
+ children: /*#__PURE__*/ _jsx(Controller, {
210
+ control: control,
211
+ name: "spec.sort",
212
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsxs(TextField, {
213
+ select: true,
214
+ ...field,
215
+ fullWidth: true,
216
+ label: "Sort",
217
+ InputLabelProps: {
218
+ shrink: action === 'read' ? true : undefined
219
+ },
220
+ InputProps: {
221
+ readOnly: action === 'read'
222
+ },
223
+ error: !!fieldState.error,
224
+ helperText: fieldState.error?.message,
225
+ value: field.value ?? 'none',
226
+ onChange: (event)=>{
227
+ field.onChange(event);
228
+ },
229
+ children: [
230
+ /*#__PURE__*/ _jsx(MenuItem, {
231
+ value: "none",
232
+ children: "None"
233
+ }),
234
+ /*#__PURE__*/ _jsx(MenuItem, {
235
+ value: "alphabetical-asc",
236
+ children: "Alphabetical, asc"
237
+ }),
238
+ /*#__PURE__*/ _jsx(MenuItem, {
239
+ value: "alphabetical-desc",
240
+ children: "Alphabetical, desc"
241
+ }),
242
+ /*#__PURE__*/ _jsx(MenuItem, {
243
+ value: "numerical-asc",
244
+ children: "Numerical, asc"
245
+ }),
246
+ /*#__PURE__*/ _jsx(MenuItem, {
247
+ value: "numerical-desc",
248
+ children: "Numerical, desc"
249
+ }),
250
+ /*#__PURE__*/ _jsx(MenuItem, {
251
+ value: "alphabetical-ci-asc",
252
+ children: "Alphabetical, case-insensitive, asc"
253
+ }),
254
+ /*#__PURE__*/ _jsx(MenuItem, {
255
+ value: "alphabetical-ci-desc",
256
+ children: "Alphabetical, case-insensitive, desc"
257
+ })
258
+ ]
259
+ })
260
+ })
261
+ })
262
+ ]
263
+ }),
264
+ /*#__PURE__*/ _jsx(Divider, {}),
265
+ /*#__PURE__*/ _jsx(Typography, {
266
+ py: 1,
267
+ variant: "subtitle1",
268
+ children: "Dropdown Options"
269
+ }),
270
+ /*#__PURE__*/ _jsxs(Stack, {
271
+ spacing: "2",
272
+ children: [
273
+ /*#__PURE__*/ _jsxs(Stack, {
274
+ children: [
275
+ /*#__PURE__*/ _jsx(Controller, {
276
+ control: control,
277
+ name: "spec.allowMultiple",
278
+ render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
279
+ label: "Allow Multiple Values",
280
+ control: /*#__PURE__*/ _jsx(Switch, {
281
+ ...field,
282
+ checked: !!field.value,
283
+ readOnly: action === 'read',
284
+ value: field.value ?? false,
285
+ onChange: (event)=>{
286
+ if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
287
+ field.onChange(event);
288
+ }
289
+ })
290
+ })
291
+ }),
292
+ /*#__PURE__*/ _jsx(Typography, {
293
+ variant: "caption",
294
+ children: "Enables multiple values to be selected at the same time"
295
+ })
296
+ ]
297
+ }),
298
+ /*#__PURE__*/ _jsxs(Stack, {
299
+ children: [
300
+ /*#__PURE__*/ _jsx(Controller, {
301
+ control: control,
302
+ name: "spec.allowAllValue",
303
+ render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
304
+ label: "Allow All option",
305
+ control: /*#__PURE__*/ _jsx(Switch, {
306
+ ...field,
307
+ checked: !!field.value,
308
+ readOnly: action === 'read',
309
+ value: field.value ?? false,
310
+ onChange: (event)=>{
311
+ if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
312
+ field.onChange(event);
313
+ }
314
+ })
315
+ })
316
+ }),
317
+ /*#__PURE__*/ _jsx(Typography, {
318
+ mb: 1,
319
+ variant: "caption",
320
+ children: "Enables an option to include all variable values"
321
+ }),
322
+ _allowAllValue && /*#__PURE__*/ _jsx(Controller, {
323
+ control: control,
324
+ name: "spec.customAllValue",
325
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
326
+ ...field,
327
+ fullWidth: true,
328
+ label: "Custom All Value",
329
+ InputLabelProps: {
330
+ shrink: action === 'read' ? true : undefined
331
+ },
332
+ InputProps: {
333
+ readOnly: action === 'read'
334
+ },
335
+ error: !!fieldState.error,
336
+ helperText: fieldState.error?.message ? fieldState.error.message : 'When All is selected, this value will be used',
337
+ value: field.value ?? '',
338
+ onChange: (event)=>{
339
+ if (event.target.value === '') {
340
+ field.onChange(undefined);
341
+ } else {
342
+ field.onChange(event);
343
+ }
344
+ }
345
+ })
346
+ })
347
+ ]
348
+ })
349
+ ]
350
+ })
351
+ ]
352
+ });
353
+ }
354
+ export function VariableEditorForm({ initialVariableDefinition, action, isDraft, isReadonly, onActionChange, onSave, onClose, onDelete }) {
355
+ const [isDiscardDialogOpened, setDiscardDialogOpened] = useState(false);
50
356
  const titleAction = getTitleAction(action, isDraft);
51
357
  const submitText = getSubmitText(action, isDraft);
358
+ const { variableEditorSchema } = useValidationSchemas();
52
359
  const form = useForm({
53
- resolver: zodResolver(variableEditorValidationSchema),
360
+ resolver: zodResolver(variableEditorSchema),
54
361
  mode: 'onBlur',
55
- defaultValues: initialState
362
+ defaultValues: initialVariableDefinition
56
363
  });
57
- const processForm = ()=>{
364
+ const kind = useWatch({
365
+ control: form.control,
366
+ name: 'kind'
367
+ });
368
+ function clearFormData(data) {
369
+ const result = {
370
+ ...data
371
+ };
372
+ if (result.spec.display?.name === undefined && result.spec.display?.description === undefined && result.spec.display?.hidden === undefined) {
373
+ delete result.spec.display;
374
+ }
375
+ return result;
376
+ }
377
+ const processForm = (data)=>{
58
378
  // reset display attributes to undefined when empty, because we don't want to save empty strings
59
- onSave(getVariableDefinitionFromState({
60
- ...state,
61
- title: state.title === '' ? undefined : state.title,
62
- description: state.description === '' ? undefined : state.description
63
- }));
379
+ onSave(clearFormData(data));
64
380
  };
65
381
  // When user click on cancel, several possibilities:
66
382
  // - create action: ask for discard approval
67
383
  // - update action: ask for discard approval if changed
68
384
  // - read action: don´t ask for discard approval
69
- const handleCancel = useCallback(()=>{
70
- if (JSON.stringify(initialState) !== JSON.stringify(state)) {
385
+ function handleCancel() {
386
+ if (JSON.stringify(initialVariableDefinition) !== JSON.stringify(clearFormData(form.getValues()))) {
71
387
  setDiscardDialogOpened(true);
72
388
  } else {
73
389
  onClose();
74
390
  }
75
- }, [
76
- initialState,
77
- state,
78
- onClose
79
- ]);
80
- var _state_title, _state_description, _state_listVariableFields_capturingRegexp, _state_listVariableFields_sort, _state_listVariableFields_customAllValue;
391
+ }
81
392
  return /*#__PURE__*/ _jsxs(FormProvider, {
82
393
  ...form,
83
394
  children: [
@@ -96,62 +407,15 @@ export function VariableEditorForm(props) {
96
407
  " Variable"
97
408
  ]
98
409
  }),
99
- /*#__PURE__*/ _jsx(Stack, {
100
- direction: "row",
101
- spacing: 1,
102
- sx: {
103
- marginLeft: 'auto'
104
- },
105
- children: action === 'read' ? /*#__PURE__*/ _jsxs(_Fragment, {
106
- children: [
107
- /*#__PURE__*/ _jsx(Button, {
108
- disabled: isReadonly,
109
- variant: "contained",
110
- onClick: ()=>setAction('update'),
111
- children: "Edit"
112
- }),
113
- /*#__PURE__*/ _jsx(Button, {
114
- color: "error",
115
- disabled: isReadonly,
116
- variant: "outlined",
117
- onClick: onDelete,
118
- children: "Delete"
119
- }),
120
- /*#__PURE__*/ _jsx(Divider, {
121
- orientation: "vertical",
122
- flexItem: true,
123
- sx: (theme)=>({
124
- borderColor: theme.palette.grey['500'],
125
- '&.MuiDivider-root': {
126
- marginLeft: 2,
127
- marginRight: 1
128
- }
129
- })
130
- }),
131
- /*#__PURE__*/ _jsx(Button, {
132
- color: "secondary",
133
- variant: "outlined",
134
- onClick: onClose,
135
- children: "Close"
136
- })
137
- ]
138
- }) : /*#__PURE__*/ _jsxs(_Fragment, {
139
- children: [
140
- /*#__PURE__*/ _jsx(Button, {
141
- type: "submit",
142
- variant: "contained",
143
- disabled: !form.formState.isValid,
144
- onClick: form.handleSubmit(processForm),
145
- children: submitText
146
- }),
147
- /*#__PURE__*/ _jsx(Button, {
148
- color: "secondary",
149
- variant: "outlined",
150
- onClick: handleCancel,
151
- children: "Cancel"
152
- })
153
- ]
154
- })
410
+ /*#__PURE__*/ _jsx(FormActions, {
411
+ action: action,
412
+ submitText: submitText,
413
+ isReadonly: isReadonly,
414
+ isValid: form.formState.isValid,
415
+ onActionChange: onActionChange,
416
+ onSubmit: form.handleSubmit(processForm),
417
+ onDelete: onDelete,
418
+ onCancel: handleCancel
155
419
  })
156
420
  ]
157
421
  }),
@@ -170,10 +434,9 @@ export function VariableEditorForm(props) {
170
434
  item: true,
171
435
  xs: 8,
172
436
  children: /*#__PURE__*/ _jsx(Controller, {
173
- name: "name",
174
- render: ({ field , fieldState })=>{
175
- var _fieldState_error;
176
- /*#__PURE__*/ return _jsx(TextField, {
437
+ control: form.control,
438
+ name: "spec.name",
439
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
177
440
  ...field,
178
441
  required: true,
179
442
  fullWidth: true,
@@ -186,26 +449,21 @@ export function VariableEditorForm(props) {
186
449
  readOnly: action === 'read'
187
450
  },
188
451
  error: !!fieldState.error,
189
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
190
- value: state.name,
452
+ helperText: fieldState.error?.message,
453
+ value: field.value ?? '',
191
454
  onChange: (event)=>{
192
455
  field.onChange(event);
193
- setState((draft)=>{
194
- draft.name = event.target.value;
195
- });
196
456
  }
197
- });
198
- }
457
+ })
199
458
  })
200
459
  }),
201
460
  /*#__PURE__*/ _jsx(Grid, {
202
461
  item: true,
203
462
  xs: 4,
204
463
  children: /*#__PURE__*/ _jsx(Controller, {
205
- name: "title",
206
- render: ({ field , fieldState })=>{
207
- var _fieldState_error;
208
- /*#__PURE__*/ return _jsx(TextField, {
464
+ control: form.control,
465
+ name: "spec.display.name",
466
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
209
467
  ...field,
210
468
  fullWidth: true,
211
469
  label: "Display Label",
@@ -216,26 +474,21 @@ export function VariableEditorForm(props) {
216
474
  readOnly: action === 'read'
217
475
  },
218
476
  error: !!fieldState.error,
219
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
220
- value: (_state_title = state.title) !== null && _state_title !== void 0 ? _state_title : '',
477
+ helperText: fieldState.error?.message,
478
+ value: field.value ?? '',
221
479
  onChange: (event)=>{
222
480
  field.onChange(event);
223
- setState((draft)=>{
224
- draft.title = event.target.value;
225
- });
226
481
  }
227
- });
228
- }
482
+ })
229
483
  })
230
484
  }),
231
485
  /*#__PURE__*/ _jsx(Grid, {
232
486
  item: true,
233
487
  xs: 8,
234
488
  children: /*#__PURE__*/ _jsx(Controller, {
235
- name: "description",
236
- render: ({ field , fieldState })=>{
237
- var _fieldState_error;
238
- /*#__PURE__*/ return _jsx(TextField, {
489
+ control: form.control,
490
+ name: "spec.display.description",
491
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
239
492
  ...field,
240
493
  fullWidth: true,
241
494
  label: "Description",
@@ -246,26 +499,21 @@ export function VariableEditorForm(props) {
246
499
  readOnly: action === 'read'
247
500
  },
248
501
  error: !!fieldState.error,
249
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
250
- value: (_state_description = state.description) !== null && _state_description !== void 0 ? _state_description : '',
502
+ helperText: fieldState.error?.message,
503
+ value: field.value ?? '',
251
504
  onChange: (event)=>{
252
505
  field.onChange(event);
253
- setState((draft)=>{
254
- draft.description = event.target.value;
255
- });
256
506
  }
257
- });
258
- }
507
+ })
259
508
  })
260
509
  }),
261
510
  /*#__PURE__*/ _jsx(Grid, {
262
511
  item: true,
263
512
  xs: 4,
264
513
  children: /*#__PURE__*/ _jsx(Controller, {
514
+ control: form.control,
265
515
  name: "kind",
266
- render: ({ field , fieldState })=>{
267
- var _fieldState_error;
268
- /*#__PURE__*/ return _jsx(TextField, {
516
+ render: ({ field, fieldState })=>/*#__PURE__*/ _jsx(TextField, {
269
517
  select: true,
270
518
  ...field,
271
519
  fullWidth: true,
@@ -277,329 +525,34 @@ export function VariableEditorForm(props) {
277
525
  readOnly: action === 'read'
278
526
  },
279
527
  error: !!fieldState.error,
280
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
281
- value: state.kind,
528
+ helperText: fieldState.error?.message,
529
+ value: field.value ?? 'TextVariable',
282
530
  onChange: (event)=>{
283
531
  field.onChange(event);
284
- setState((draft)=>{
285
- draft.kind = event.target.value;
286
- });
287
532
  },
288
533
  children: VARIABLE_TYPES.map((v)=>/*#__PURE__*/ _jsx(MenuItem, {
289
534
  value: v.kind,
290
535
  children: v.label
291
536
  }, v.kind))
292
- });
293
- }
537
+ })
294
538
  })
295
539
  })
296
540
  ]
297
541
  }),
298
542
  /*#__PURE__*/ _jsx(Divider, {}),
299
- state.kind === 'TextVariable' && /*#__PURE__*/ _jsxs(_Fragment, {
300
- children: [
301
- /*#__PURE__*/ _jsx(Typography, {
302
- py: 1,
303
- variant: "subtitle1",
304
- children: "Text Options"
305
- }),
306
- /*#__PURE__*/ _jsxs(Stack, {
307
- spacing: 2,
308
- children: [
309
- /*#__PURE__*/ _jsx(Box, {
310
- children: /*#__PURE__*/ _jsx(VariablePreview, {
311
- values: [
312
- state.textVariableFields.value
313
- ]
314
- })
315
- }),
316
- /*#__PURE__*/ _jsx(Controller, {
317
- name: "textVariableFields.value",
318
- render: ({ field , fieldState })=>{
319
- var _fieldState_error;
320
- /*#__PURE__*/ return _jsx(TextField, {
321
- ...field,
322
- label: "Value",
323
- InputLabelProps: {
324
- shrink: action === 'read' ? true : undefined
325
- },
326
- InputProps: {
327
- readOnly: action === 'read'
328
- },
329
- error: !!fieldState.error,
330
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
331
- value: state.textVariableFields.value,
332
- onChange: (event)=>{
333
- field.onChange(event);
334
- setState((draft)=>{
335
- draft.textVariableFields.value = event.target.value;
336
- });
337
- }
338
- });
339
- }
340
- }),
341
- /*#__PURE__*/ _jsx(Controller, {
342
- name: "textVariableFields.constant",
343
- render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
344
- label: "Constant",
345
- control: /*#__PURE__*/ _jsx(Switch, {
346
- ...field,
347
- checked: !!field.value,
348
- readOnly: action === 'read',
349
- value: state.textVariableFields.constant,
350
- onChange: (event)=>{
351
- if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
352
- field.onChange(event);
353
- setState((draft)=>{
354
- draft.textVariableFields.constant = event.target.checked;
355
- });
356
- }
357
- })
358
- })
359
- })
360
- ]
361
- })
362
- ]
543
+ kind === 'TextVariable' && /*#__PURE__*/ _jsx(ErrorBoundary, {
544
+ FallbackComponent: ErrorAlert,
545
+ children: /*#__PURE__*/ _jsx(TextVariableEditorForm, {
546
+ action: action,
547
+ control: form.control
548
+ })
363
549
  }),
364
- state.kind === 'ListVariable' && /*#__PURE__*/ _jsxs(_Fragment, {
365
- children: [
366
- /*#__PURE__*/ _jsx(Typography, {
367
- py: 1,
368
- variant: "subtitle1",
369
- children: "List Options"
370
- }),
371
- /*#__PURE__*/ _jsxs(Stack, {
372
- spacing: 2,
373
- mb: 2,
374
- children: [
375
- state.listVariableFields.plugin.kind ? /*#__PURE__*/ _jsx(Box, {
376
- children: /*#__PURE__*/ _jsx(ErrorBoundary, {
377
- FallbackComponent: FallbackPreview,
378
- resetKeys: [
379
- previewSpec
380
- ],
381
- children: /*#__PURE__*/ _jsx(VariableListPreview, {
382
- definition: previewSpec,
383
- onRefresh: refreshPreview
384
- })
385
- })
386
- }) : /*#__PURE__*/ _jsx(VariablePreview, {
387
- isLoading: true
388
- }),
389
- /*#__PURE__*/ _jsxs(Stack, {
390
- children: [
391
- /*#__PURE__*/ _jsx(ClickAwayListener, {
392
- onClickAway: ()=>refreshPreview(),
393
- children: /*#__PURE__*/ _jsx(Box, {})
394
- }),
395
- /*#__PURE__*/ _jsx(Controller, {
396
- name: "listVariableFields.plugin",
397
- render: ({ field })=>/*#__PURE__*/ _jsx(PluginEditor, {
398
- width: "100%",
399
- pluginType: "Variable",
400
- pluginKindLabel: "Source",
401
- isReadonly: action === 'read',
402
- value: state.listVariableFields.plugin,
403
- onChange: (val)=>{
404
- field.onChange(val);
405
- setState((draft)=>{
406
- draft.listVariableFields.plugin = val;
407
- });
408
- }
409
- })
410
- })
411
- ]
412
- }),
413
- /*#__PURE__*/ _jsx(Stack, {
414
- children: /*#__PURE__*/ _jsx(Controller, {
415
- name: "listVariableFields.capturingRegexp",
416
- render: ({ field , fieldState })=>{
417
- var _fieldState_error;
418
- /*#__PURE__*/ return _jsx(TextField, {
419
- ...field,
420
- label: "Capturing Regexp Filter",
421
- InputLabelProps: {
422
- shrink: action === 'read' ? true : undefined
423
- },
424
- InputProps: {
425
- readOnly: action === 'read'
426
- },
427
- error: !!fieldState.error,
428
- value: (_state_listVariableFields_capturingRegexp = state.listVariableFields.capturingRegexp) !== null && _state_listVariableFields_capturingRegexp !== void 0 ? _state_listVariableFields_capturingRegexp : '',
429
- onChange: (event)=>{
430
- field.onChange(event);
431
- setState((draft)=>{
432
- if (event.target.value) {
433
- // TODO: do a better fix, if empty string => it should skip the filter
434
- draft.listVariableFields.capturingRegexp = event.target.value;
435
- } else {
436
- draft.listVariableFields.capturingRegexp = undefined;
437
- }
438
- });
439
- },
440
- helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'Optional, if you want to filter on captured result.'
441
- });
442
- }
443
- })
444
- }),
445
- /*#__PURE__*/ _jsx(Stack, {
446
- children: /*#__PURE__*/ _jsx(Controller, {
447
- name: "listVariableFields.sort",
448
- render: ({ field , fieldState })=>{
449
- var _fieldState_error;
450
- /*#__PURE__*/ return _jsxs(TextField, {
451
- select: true,
452
- ...field,
453
- fullWidth: true,
454
- label: "Sort",
455
- InputLabelProps: {
456
- shrink: action === 'read' ? true : undefined
457
- },
458
- InputProps: {
459
- readOnly: action === 'read'
460
- },
461
- error: !!fieldState.error,
462
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
463
- value: (_state_listVariableFields_sort = state.listVariableFields.sort) !== null && _state_listVariableFields_sort !== void 0 ? _state_listVariableFields_sort : 'none',
464
- onChange: (event)=>{
465
- field.onChange(event);
466
- setState((draft)=>{
467
- draft.listVariableFields.sort = event.target.value;
468
- });
469
- },
470
- children: [
471
- /*#__PURE__*/ _jsx(MenuItem, {
472
- value: "none",
473
- children: "None"
474
- }),
475
- /*#__PURE__*/ _jsx(MenuItem, {
476
- value: "alphabetical-asc",
477
- children: "Alphabetical, asc"
478
- }),
479
- /*#__PURE__*/ _jsx(MenuItem, {
480
- value: "alphabetical-desc",
481
- children: "Alphabetical, desc"
482
- }),
483
- /*#__PURE__*/ _jsx(MenuItem, {
484
- value: "numerical-asc",
485
- children: "Numerical, asc"
486
- }),
487
- /*#__PURE__*/ _jsx(MenuItem, {
488
- value: "numerical-desc",
489
- children: "Numerical, desc"
490
- }),
491
- /*#__PURE__*/ _jsx(MenuItem, {
492
- value: "alphabetical-ci-asc",
493
- children: "Alphabetical, case-insensitive, asc"
494
- }),
495
- /*#__PURE__*/ _jsx(MenuItem, {
496
- value: "alphabetical-ci-desc",
497
- children: "Alphabetical, case-insensitive, desc"
498
- })
499
- ]
500
- });
501
- }
502
- })
503
- })
504
- ]
505
- }),
506
- /*#__PURE__*/ _jsx(Divider, {}),
507
- /*#__PURE__*/ _jsx(Typography, {
508
- py: 1,
509
- variant: "subtitle1",
510
- children: "Dropdown Options"
511
- }),
512
- /*#__PURE__*/ _jsxs(Stack, {
513
- spacing: "2",
514
- children: [
515
- /*#__PURE__*/ _jsxs(Stack, {
516
- children: [
517
- /*#__PURE__*/ _jsx(Controller, {
518
- name: "listVariableFields.allowMultiple",
519
- render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
520
- label: "Allow Multiple Values",
521
- control: /*#__PURE__*/ _jsx(Switch, {
522
- ...field,
523
- checked: !!field.value,
524
- readOnly: action === 'read',
525
- value: state.listVariableFields.allowMultiple,
526
- onChange: (event)=>{
527
- if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
528
- field.onChange(event);
529
- setState((draft)=>{
530
- draft.listVariableFields.allowMultiple = event.target.checked;
531
- });
532
- }
533
- })
534
- })
535
- }),
536
- /*#__PURE__*/ _jsx(Typography, {
537
- variant: "caption",
538
- children: "Enables multiple values to be selected at the same time"
539
- })
540
- ]
541
- }),
542
- /*#__PURE__*/ _jsxs(Stack, {
543
- children: [
544
- /*#__PURE__*/ _jsx(Controller, {
545
- name: "listVariableFields.allowAllValue",
546
- render: ({ field })=>/*#__PURE__*/ _jsx(FormControlLabel, {
547
- label: "Allow All option",
548
- control: /*#__PURE__*/ _jsx(Switch, {
549
- ...field,
550
- checked: !!field.value,
551
- readOnly: action === 'read',
552
- value: state.listVariableFields.allowAllValue,
553
- onChange: (event)=>{
554
- if (action === 'read') return; // ReadOnly prop is not blocking user interaction...
555
- field.onChange(event);
556
- setState((draft)=>{
557
- draft.listVariableFields.allowAllValue = event.target.checked;
558
- });
559
- }
560
- })
561
- })
562
- }),
563
- /*#__PURE__*/ _jsx(Typography, {
564
- mb: 1,
565
- variant: "caption",
566
- children: "Enables an option to include all variable values"
567
- }),
568
- state.listVariableFields.allowAllValue && /*#__PURE__*/ _jsx(Controller, {
569
- name: "listVariableFields.customAllValue",
570
- render: ({ field , fieldState })=>{
571
- var _fieldState_error;
572
- /*#__PURE__*/ return _jsx(TextField, {
573
- ...field,
574
- fullWidth: true,
575
- label: "Custom All Value",
576
- InputLabelProps: {
577
- shrink: action === 'read' ? true : undefined
578
- },
579
- InputProps: {
580
- readOnly: action === 'read'
581
- },
582
- error: !!fieldState.error,
583
- helperText: ((_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message) ? fieldState.error.message : 'When All is selected, this value will be used',
584
- value: (_state_listVariableFields_customAllValue = state.listVariableFields.customAllValue) !== null && _state_listVariableFields_customAllValue !== void 0 ? _state_listVariableFields_customAllValue : '',
585
- onChange: (event)=>{
586
- field.onChange(event);
587
- setState((draft)=>{
588
- if (event.target.value) {
589
- draft.listVariableFields.customAllValue = event.target.value;
590
- } else {
591
- draft.listVariableFields.customAllValue = undefined;
592
- }
593
- });
594
- }
595
- });
596
- }
597
- })
598
- ]
599
- })
600
- ]
601
- })
602
- ]
550
+ kind === 'ListVariable' && /*#__PURE__*/ _jsx(ErrorBoundary, {
551
+ FallbackComponent: ErrorAlert,
552
+ children: /*#__PURE__*/ _jsx(ListVariableEditorForm, {
553
+ action: action,
554
+ control: form.control
555
+ })
603
556
  })
604
557
  ]
605
558
  }),