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