@perses-dev/plugin-system 0.0.0-snapshot-scatter-chart-embed-8efdfab → 0.0.0-snapshot-scatterplot-fix-imports-95e1b59

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 (290) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +1 -1
  2. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +16 -16
  3. package/dist/cjs/components/DatasourceSelect.js +11 -9
  4. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
  5. package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +3 -3
  6. package/dist/cjs/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  7. package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +3 -3
  8. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +5 -5
  9. package/dist/cjs/components/PluginEditor/PluginEditor.js +2 -2
  10. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +3 -3
  11. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +2 -2
  12. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +1 -1
  13. package/dist/cjs/components/PluginRegistry/plugin-indexes.js +4 -4
  14. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
  15. package/dist/cjs/components/ProjectSelect.js +2 -2
  16. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +192 -0
  17. package/dist/cjs/components/TimeRangeControls/index.js +30 -0
  18. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +23 -31
  19. package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +3 -3
  20. package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +2 -2
  21. package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +3 -3
  22. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +29 -23
  23. package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +10 -8
  24. package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +1 -1
  25. package/dist/cjs/components/Variables/variable-model.js +12 -13
  26. package/dist/cjs/components/index.js +1 -0
  27. package/dist/cjs/constants/user-interface-text.js +4 -1
  28. package/dist/cjs/context/ProjectStoreProvider.js +5 -5
  29. package/dist/cjs/model/legend.js +5 -5
  30. package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +6 -6
  31. package/dist/cjs/runtime/DataQueriesProvider/model.js +3 -3
  32. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +21 -10
  33. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +3 -3
  34. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +16 -16
  35. package/dist/cjs/runtime/builtin-variables.js +5 -5
  36. package/dist/cjs/runtime/datasources.js +7 -7
  37. package/dist/cjs/runtime/plugin-registry.js +12 -12
  38. package/dist/cjs/runtime/template-variables.js +15 -7
  39. package/dist/cjs/runtime/time-series-queries.js +14 -14
  40. package/dist/cjs/runtime/trace-queries.js +4 -4
  41. package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +3 -1
  42. package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +1 -1
  43. package/dist/cjs/test/test-plugins/bert/index.js +2 -2
  44. package/dist/cjs/test/test-plugins/ernie/index.js +2 -2
  45. package/dist/cjs/test/test-plugins/index.js +3 -1
  46. package/dist/cjs/test-utils/mock-plugin-registry.js +4 -4
  47. package/dist/cjs/utils/action.js +3 -3
  48. package/dist/cjs/utils/variables.js +4 -4
  49. package/dist/cjs/validation/duration.js +25 -0
  50. package/dist/cjs/validation/index.js +1 -0
  51. package/dist/cjs/validation/resource.js +1 -1
  52. package/dist/cjs/validation/role.js +4 -3
  53. package/dist/cjs/validation/secret.js +3 -3
  54. package/dist/cjs/validation/user.js +46 -0
  55. package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -2
  56. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  57. package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
  58. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  59. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +3 -4
  60. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  61. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +16 -16
  62. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  63. package/dist/components/DatasourceSelect.d.ts +3 -4
  64. package/dist/components/DatasourceSelect.d.ts.map +1 -1
  65. package/dist/components/DatasourceSelect.js +8 -6
  66. package/dist/components/DatasourceSelect.js.map +1 -1
  67. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +1 -2
  68. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  69. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
  70. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  71. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +3 -3
  72. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
  73. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +3 -3
  74. package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
  75. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +1 -1
  76. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
  77. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
  78. package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
  79. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -3
  80. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
  81. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +3 -3
  82. package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
  83. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +1 -2
  84. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  85. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +5 -5
  86. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  87. package/dist/components/PluginEditor/PluginEditor.d.ts +1 -2
  88. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  89. package/dist/components/PluginEditor/PluginEditor.js +2 -2
  90. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  91. package/dist/components/PluginEditor/plugin-editor-api.d.ts +3 -4
  92. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  93. package/dist/components/PluginEditor/plugin-editor-api.js +3 -3
  94. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  95. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +1 -1
  96. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  97. package/dist/components/PluginKindSelect/PluginKindSelect.js +2 -2
  98. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  99. package/dist/components/PluginRegistry/PluginRegistry.d.ts +4 -4
  100. package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
  101. package/dist/components/PluginRegistry/PluginRegistry.js +1 -1
  102. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  103. package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
  104. package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
  105. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +1 -2
  106. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  107. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
  108. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  109. package/dist/components/ProjectSelect.d.ts +2 -3
  110. package/dist/components/ProjectSelect.d.ts.map +1 -1
  111. package/dist/components/ProjectSelect.js +2 -2
  112. package/dist/components/ProjectSelect.js.map +1 -1
  113. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +13 -0
  114. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
  115. package/dist/components/TimeRangeControls/TimeRangeControls.js +168 -0
  116. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
  117. package/dist/components/TimeRangeControls/index.d.ts +2 -0
  118. package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
  119. package/dist/components/TimeRangeControls/index.js +15 -0
  120. package/dist/components/TimeRangeControls/index.js.map +1 -0
  121. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +1 -2
  122. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -1
  123. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +24 -32
  124. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -1
  125. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +1 -2
  126. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +1 -1
  127. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +3 -3
  128. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -1
  129. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +1 -2
  130. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +1 -1
  131. package/dist/components/TraceQueryEditor/TraceQueryEditor.js +2 -2
  132. package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +1 -1
  133. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +1 -2
  134. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +1 -1
  135. package/dist/components/TraceQueryEditor/TraceQueryInput.js +3 -3
  136. package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +1 -1
  137. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +1 -1
  138. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  139. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +26 -22
  140. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  141. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +2 -3
  142. package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
  143. package/dist/components/Variables/VariableEditorForm/VariablePreview.js +4 -4
  144. package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
  145. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -1
  146. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
  147. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +1 -1
  148. package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
  149. package/dist/components/Variables/variable-model.d.ts.map +1 -1
  150. package/dist/components/Variables/variable-model.js +6 -7
  151. package/dist/components/Variables/variable-model.js.map +1 -1
  152. package/dist/components/index.d.ts +1 -0
  153. package/dist/components/index.d.ts.map +1 -1
  154. package/dist/components/index.js +1 -0
  155. package/dist/components/index.js.map +1 -1
  156. package/dist/constants/user-interface-text.d.ts +2 -0
  157. package/dist/constants/user-interface-text.d.ts.map +1 -1
  158. package/dist/constants/user-interface-text.js +4 -1
  159. package/dist/constants/user-interface-text.js.map +1 -1
  160. package/dist/context/ProjectStoreProvider.d.ts +1 -1
  161. package/dist/context/ProjectStoreProvider.d.ts.map +1 -1
  162. package/dist/context/ProjectStoreProvider.js +2 -2
  163. package/dist/context/ProjectStoreProvider.js.map +1 -1
  164. package/dist/context/query-params.js.map +1 -1
  165. package/dist/model/datasource.js +3 -1
  166. package/dist/model/datasource.js.map +1 -1
  167. package/dist/model/legend.d.ts +2 -2
  168. package/dist/model/legend.d.ts.map +1 -1
  169. package/dist/model/legend.js.map +1 -1
  170. package/dist/model/panels.d.ts +1 -1
  171. package/dist/model/panels.d.ts.map +1 -1
  172. package/dist/model/plugin-base.d.ts +0 -1
  173. package/dist/model/plugin-base.d.ts.map +1 -1
  174. package/dist/model/plugin-base.js.map +1 -1
  175. package/dist/model/plugin-loading.js.map +1 -1
  176. package/dist/model/plugins.d.ts +4 -4
  177. package/dist/model/plugins.d.ts.map +1 -1
  178. package/dist/model/plugins.js.map +1 -1
  179. package/dist/model/time-series-queries.d.ts +2 -2
  180. package/dist/model/time-series-queries.d.ts.map +1 -1
  181. package/dist/model/time-series-queries.js.map +1 -1
  182. package/dist/model/trace-queries.d.ts +1 -1
  183. package/dist/model/trace-queries.d.ts.map +1 -1
  184. package/dist/model/trace-queries.js.map +1 -1
  185. package/dist/model/variables.d.ts +2 -2
  186. package/dist/model/variables.d.ts.map +1 -1
  187. package/dist/model/variables.js +3 -1
  188. package/dist/model/variables.js.map +1 -1
  189. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +1 -1
  190. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
  191. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +2 -2
  192. package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
  193. package/dist/runtime/DataQueriesProvider/model.d.ts +2 -2
  194. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  195. package/dist/runtime/DataQueriesProvider/model.js +3 -3
  196. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  197. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +5 -1
  198. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  199. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +14 -6
  200. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  201. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +1 -1
  202. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -1
  203. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +3 -3
  204. package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -1
  205. package/dist/runtime/TimeRangeProvider/query-params.d.ts +1 -1
  206. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  207. package/dist/runtime/TimeRangeProvider/query-params.js +4 -4
  208. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  209. package/dist/runtime/builtin-variables.d.ts +1 -1
  210. package/dist/runtime/builtin-variables.d.ts.map +1 -1
  211. package/dist/runtime/builtin-variables.js +2 -2
  212. package/dist/runtime/builtin-variables.js.map +1 -1
  213. package/dist/runtime/datasources.js +1 -1
  214. package/dist/runtime/datasources.js.map +1 -1
  215. package/dist/runtime/plugin-registry.d.ts +3 -3
  216. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  217. package/dist/runtime/plugin-registry.js +4 -4
  218. package/dist/runtime/plugin-registry.js.map +1 -1
  219. package/dist/runtime/template-variables.d.ts +4 -4
  220. package/dist/runtime/template-variables.d.ts.map +1 -1
  221. package/dist/runtime/template-variables.js +10 -2
  222. package/dist/runtime/template-variables.js.map +1 -1
  223. package/dist/runtime/time-series-queries.js +7 -7
  224. package/dist/runtime/time-series-queries.js.map +1 -1
  225. package/dist/runtime/trace-queries.d.ts +1 -1
  226. package/dist/runtime/trace-queries.d.ts.map +1 -1
  227. package/dist/runtime/trace-queries.js +4 -4
  228. package/dist/runtime/trace-queries.js.map +1 -1
  229. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +2 -3
  230. package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -1
  231. package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
  232. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +1 -2
  233. package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
  234. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +2 -3
  235. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -1
  236. package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -1
  237. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +2 -3
  238. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
  239. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +1 -1
  240. package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
  241. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +2 -3
  242. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +1 -1
  243. package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +1 -1
  244. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +2 -3
  245. package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
  246. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  247. package/dist/test/render.d.ts +1 -1
  248. package/dist/test/render.d.ts.map +1 -1
  249. package/dist/test/render.js.map +1 -1
  250. package/dist/test/setup-tests.js.map +1 -1
  251. package/dist/test/test-plugins/bert/index.js +2 -2
  252. package/dist/test/test-plugins/bert/index.js.map +1 -1
  253. package/dist/test/test-plugins/ernie/index.js +2 -2
  254. package/dist/test/test-plugins/ernie/index.js.map +1 -1
  255. package/dist/test-utils/mock-plugin-registry.d.ts +1 -1
  256. package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
  257. package/dist/test-utils/mock-plugin-registry.js +1 -1
  258. package/dist/test-utils/mock-plugin-registry.js.map +1 -1
  259. package/dist/utils/variables.js.map +1 -1
  260. package/dist/validation/datasource.d.ts +1 -1
  261. package/dist/validation/datasource.d.ts.map +1 -1
  262. package/dist/validation/datasource.js.map +1 -1
  263. package/dist/validation/duration.d.ts +3 -0
  264. package/dist/validation/duration.d.ts.map +1 -0
  265. package/dist/validation/duration.js +17 -0
  266. package/dist/validation/duration.js.map +1 -0
  267. package/dist/validation/index.d.ts +1 -0
  268. package/dist/validation/index.d.ts.map +1 -1
  269. package/dist/validation/index.js +1 -0
  270. package/dist/validation/index.js.map +1 -1
  271. package/dist/validation/resource.js +1 -1
  272. package/dist/validation/resource.js.map +1 -1
  273. package/dist/validation/role.d.ts +47 -47
  274. package/dist/validation/role.d.ts.map +1 -1
  275. package/dist/validation/role.js +1 -0
  276. package/dist/validation/role.js.map +1 -1
  277. package/dist/validation/rolebinding.d.ts +10 -10
  278. package/dist/validation/rolebinding.d.ts.map +1 -1
  279. package/dist/validation/rolebinding.js.map +1 -1
  280. package/dist/validation/secret.d.ts +19 -19
  281. package/dist/validation/secret.d.ts.map +1 -1
  282. package/dist/validation/secret.js.map +1 -1
  283. package/dist/validation/user.d.ts +93 -0
  284. package/dist/validation/user.d.ts.map +1 -0
  285. package/dist/validation/user.js +38 -0
  286. package/dist/validation/user.js.map +1 -0
  287. package/dist/validation/variable.d.ts +1 -1
  288. package/dist/validation/variable.d.ts.map +1 -1
  289. package/dist/validation/variable.js.map +1 -1
  290. package/package.json +4 -4
@@ -29,7 +29,7 @@ const CALC_OPTIONS = Object.entries(_core.CALCULATIONS_CONFIG).map(([id, config]
29
29
  ...config
30
30
  };
31
31
  });
32
- function CalculationSelector({ value , onChange }) {
32
+ function CalculationSelector({ value, onChange }) {
33
33
  const handleCalculationChange = (_, newValue)=>{
34
34
  onChange(newValue.id);
35
35
  };
@@ -33,25 +33,25 @@ const _validation = require("../../validation");
33
33
  /**
34
34
  * This preprocessing ensures that we always have a defined object for the `display` property
35
35
  * @param datasource
36
- */ function getInitialState(name, spec) {
37
- var _spec_display, _spec_display1;
38
- var _spec_display_name, _spec_display_description;
36
+ */ function getInitialState(datasourceDefinition) {
37
+ var _datasourceDefinition_spec_display, _datasourceDefinition_spec_display1;
38
+ var _datasourceDefinition_spec_display_name, _datasourceDefinition_spec_display_description;
39
39
  const patchedDisplay = {
40
- name: (_spec_display_name = (_spec_display = spec.display) === null || _spec_display === void 0 ? void 0 : _spec_display.name) !== null && _spec_display_name !== void 0 ? _spec_display_name : '',
41
- description: (_spec_display_description = (_spec_display1 = spec.display) === null || _spec_display1 === void 0 ? void 0 : _spec_display1.description) !== null && _spec_display_description !== void 0 ? _spec_display_description : ''
40
+ name: (_datasourceDefinition_spec_display_name = (_datasourceDefinition_spec_display = datasourceDefinition.spec.display) === null || _datasourceDefinition_spec_display === void 0 ? void 0 : _datasourceDefinition_spec_display.name) !== null && _datasourceDefinition_spec_display_name !== void 0 ? _datasourceDefinition_spec_display_name : '',
41
+ description: (_datasourceDefinition_spec_display_description = (_datasourceDefinition_spec_display1 = datasourceDefinition.spec.display) === null || _datasourceDefinition_spec_display1 === void 0 ? void 0 : _datasourceDefinition_spec_display1.description) !== null && _datasourceDefinition_spec_display_description !== void 0 ? _datasourceDefinition_spec_display_description : ''
42
42
  };
43
43
  return {
44
- name: name,
44
+ name: datasourceDefinition.name,
45
45
  spec: {
46
- ...spec,
46
+ ...datasourceDefinition.spec,
47
47
  display: patchedDisplay
48
48
  }
49
49
  };
50
50
  }
51
51
  function DatasourceEditorForm(props) {
52
52
  var _state_spec_display, _state_spec_display1;
53
- const { initialName , initialSpec , initialAction , isDraft , isReadonly , onSave , onClose , onDelete } = props;
54
- const initialState = getInitialState(initialName, initialSpec);
53
+ const { initialDatasourceDefinition, initialAction, isDraft, isReadonly, onSave, onClose, onDelete } = props;
54
+ const initialState = getInitialState(initialDatasourceDefinition);
55
55
  const [state, setState] = (0, _useimmer.useImmer)(initialState);
56
56
  const [isDiscardDialogOpened, setDiscardDialogOpened] = (0, _react.useState)(false);
57
57
  const [action, setAction] = (0, _react.useState)(initialAction);
@@ -186,9 +186,9 @@ function DatasourceEditorForm(props) {
186
186
  xs: 4,
187
187
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
188
188
  name: "name",
189
- render: ({ field , fieldState })=>{
189
+ render: ({ field, fieldState })=>{
190
190
  var _fieldState_error;
191
- /*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
191
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
192
192
  ...field,
193
193
  required: true,
194
194
  fullWidth: true,
@@ -218,9 +218,9 @@ function DatasourceEditorForm(props) {
218
218
  xs: 8,
219
219
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
220
220
  name: "title",
221
- render: ({ field , fieldState })=>{
221
+ render: ({ field, fieldState })=>{
222
222
  var _fieldState_error;
223
- /*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
223
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
224
224
  ...field,
225
225
  fullWidth: true,
226
226
  name: "title",
@@ -250,9 +250,9 @@ function DatasourceEditorForm(props) {
250
250
  xs: 12,
251
251
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
252
252
  name: "description",
253
- render: ({ field , fieldState })=>{
253
+ render: ({ field, fieldState })=>{
254
254
  var _fieldState_error;
255
- /*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
255
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
256
256
  ...field,
257
257
  fullWidth: true,
258
258
  name: "description",
@@ -287,7 +287,7 @@ function DatasourceEditorForm(props) {
287
287
  children: [
288
288
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
289
289
  name: "default",
290
- render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
290
+ render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
291
291
  ...field,
292
292
  control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
293
293
  checked: state.spec.default,
@@ -21,11 +21,11 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- DatasourceSelect: function() {
25
- return DatasourceSelect;
26
- },
27
24
  DatasourceName: function() {
28
25
  return DatasourceName;
26
+ },
27
+ DatasourceSelect: function() {
28
+ return DatasourceSelect;
29
29
  }
30
30
  });
31
31
  const _jsxruntime = require("react/jsx-runtime");
@@ -39,8 +39,8 @@ function _interop_require_default(obj) {
39
39
  };
40
40
  }
41
41
  function DatasourceSelect(props) {
42
- const { datasourcePluginKind , value , project , onChange , ...others } = props;
43
- const { data , isLoading } = (0, _runtime.useListDatasourceSelectItems)(datasourcePluginKind, project);
42
+ const { datasourcePluginKind, value, project, onChange, ...others } = props;
43
+ const { data, isLoading } = (0, _runtime.useListDatasourceSelectItems)(datasourcePluginKind, project);
44
44
  // Rebuild the group of the value if not provided
45
45
  const defaultValue = (0, _react.useMemo)(()=>{
46
46
  var _flatMap_find;
@@ -57,18 +57,20 @@ function DatasourceSelect(props) {
57
57
  ]);
58
58
  // Convert the datasource list into menu items with name/group?/value strings that the Select input can work with
59
59
  const menuItems = (0, _react.useMemo)(()=>{
60
- var _item_saved;
61
60
  return (data !== null && data !== void 0 ? data : []).map((itemGroup)=>({
62
61
  group: itemGroup.group,
63
62
  editLink: itemGroup.editLink,
64
- items: itemGroup.items.map((item)=>({
63
+ items: itemGroup.items.map((item)=>{
64
+ var _item_saved;
65
+ return {
65
66
  name: item.name,
66
67
  overriding: item.overriding,
67
68
  overridden: item.overridden,
68
69
  saved: (_item_saved = item.saved) !== null && _item_saved !== void 0 ? _item_saved : true,
69
70
  group: item.selector.group,
70
71
  value: selectorToOptionValue(item.selector)
71
- }))
72
+ };
73
+ })
72
74
  }));
73
75
  }, [
74
76
  data
@@ -140,7 +142,7 @@ function DatasourceSelect(props) {
140
142
  });
141
143
  }
142
144
  function DatasourceName(props) {
143
- const { name , overridden , overriding } = props;
145
+ const { name, overridden, overriding } = props;
144
146
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
145
147
  children: [
146
148
  `${name} `,
@@ -49,7 +49,7 @@ const VALUE_OPTIONS = Object.entries(_model.LEGEND_VALUE_CONFIG).map(([id, confi
49
49
  ...config
50
50
  };
51
51
  });
52
- function LegendOptionsEditor({ value , onChange }) {
52
+ function LegendOptionsEditor({ value, onChange }) {
53
53
  const handleLegendShowChange = (_, checked)=>{
54
54
  // legend is hidden when legend obj is undefined
55
55
  const legendValue = checked === true ? {
@@ -25,7 +25,7 @@ const _material = require("@mui/material");
25
25
  const _react = require("react");
26
26
  const _OptionsEditorTabPanel = require("../OptionsEditorTabPanel");
27
27
  const OptionsEditorRadios = (props)=>{
28
- const { tabs , defaultTab , onModeChange , isReadonly } = props;
28
+ const { tabs, defaultTab, onModeChange, isReadonly } = props;
29
29
  const [activeTab, setActiveTab] = (0, _react.useState)(defaultTab);
30
30
  const handleChange = (_, value)=>{
31
31
  const v = parseInt(value);
@@ -46,7 +46,7 @@ const OptionsEditorRadios = (props)=>{
46
46
  value: activeTab,
47
47
  onChange: handleChange,
48
48
  "aria-labelledby": "Configuration radio",
49
- children: tabs.map(({ label }, i)=>{
49
+ children: tabs.map(({ label }, i)=>{
50
50
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
51
51
  disabled: isReadonly,
52
52
  value: i,
@@ -57,7 +57,7 @@ const OptionsEditorRadios = (props)=>{
57
57
  })
58
58
  })
59
59
  }),
60
- tabs.map(({ label , content }, i)=>{
60
+ tabs.map(({ label, content }, i)=>{
61
61
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorTabPanel.OptionsEditorTabPanel, {
62
62
  value: activeTab,
63
63
  index: i,
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "OptionsEditorTabPanel", {
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
25
  function OptionsEditorTabPanel(props) {
26
- const { children , value , index , ...other } = props;
26
+ const { children, value, index, ...other } = props;
27
27
  const isActive = value === index;
28
28
  return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
29
29
  role: "tabpanel",
@@ -24,7 +24,7 @@ const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
25
  const _react = require("react");
26
26
  const _OptionsEditorTabPanel = require("../OptionsEditorTabPanel");
27
- const OptionsEditorTabs = ({ tabs })=>{
27
+ const OptionsEditorTabs = ({ tabs })=>{
28
28
  const [activeTab, setActiveTab] = (0, _react.useState)(0);
29
29
  const handleChange = (_, newValue)=>{
30
30
  setActiveTab(newValue);
@@ -40,7 +40,7 @@ const OptionsEditorTabs = ({ tabs })=>{
40
40
  value: activeTab,
41
41
  onChange: handleChange,
42
42
  "aria-label": "Panel configuration tabs",
43
- children: tabs.map(({ label }, i)=>{
43
+ children: tabs.map(({ label }, i)=>{
44
44
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tab, {
45
45
  label: label,
46
46
  id: `options-editor-tab-${i}`,
@@ -49,7 +49,7 @@ const OptionsEditorTabs = ({ tabs })=>{
49
49
  })
50
50
  })
51
51
  }),
52
- tabs.map(({ label , content }, i)=>{
52
+ tabs.map(({ label, content }, i)=>{
53
53
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsEditorTabPanel.OptionsEditorTabPanel, {
54
54
  value: activeTab,
55
55
  index: i,
@@ -27,9 +27,9 @@ const _OptionsEditorTabs = require("../OptionsEditorTabs");
27
27
  const _TimeSeriesQueryEditor = require("../TimeSeriesQueryEditor");
28
28
  const _TraceQueryEditor = require("../TraceQueryEditor");
29
29
  function PanelSpecEditor(props) {
30
- const { panelDefinition , onJSONChange , onQueriesChange , onPluginSpecChange } = props;
31
- const { kind } = panelDefinition.spec.plugin;
32
- const { data: plugin , isLoading , error } = (0, _runtime.usePlugin)('Panel', kind);
30
+ const { panelDefinition, onJSONChange, onQueriesChange, onPluginSpecChange } = props;
31
+ const { kind } = panelDefinition.spec.plugin;
32
+ const { data: plugin, isLoading, error } = (0, _runtime.usePlugin)('Panel', kind);
33
33
  if (error) {
34
34
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorAlert, {
35
35
  error: error
@@ -84,7 +84,7 @@ function PanelSpecEditor(props) {
84
84
  });
85
85
  }
86
86
  };
87
- const { panelOptionsEditorComponents , hideQueryEditor } = plugin;
87
+ const { panelOptionsEditorComponents, hideQueryEditor } = plugin;
88
88
  let tabs = [];
89
89
  if (!hideQueryEditor) {
90
90
  tabs.push({
@@ -93,7 +93,7 @@ function PanelSpecEditor(props) {
93
93
  });
94
94
  }
95
95
  if (panelOptionsEditorComponents !== undefined) {
96
- tabs = tabs.concat(panelOptionsEditorComponents.map(({ label , content: OptionsEditorComponent })=>({
96
+ tabs = tabs.concat(panelOptionsEditorComponents.map(({ label, content: OptionsEditorComponent })=>({
97
97
  label,
98
98
  content: /*#__PURE__*/ (0, _jsxruntime.jsx)(OptionsEditorComponent, {
99
99
  value: panelDefinition.spec.plugin.spec,
@@ -27,8 +27,8 @@ const _PluginSpecEditor = require("../PluginSpecEditor");
27
27
  const _plugineditorapi = require("./plugin-editor-api");
28
28
  function PluginEditor(props) {
29
29
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
- const { value , pluginType , pluginKindLabel , onChange: _ , isReadonly , ...others } = props;
31
- const { pendingKind , isLoading , error , onKindChange , onSpecChange } = (0, _plugineditorapi.usePluginEditor)(props);
30
+ const { value, pluginType, pluginKindLabel, onChange: _, isReadonly, ...others } = props;
31
+ const { pendingKind, isLoading, error, onKindChange, onSpecChange } = (0, _plugineditorapi.usePluginEditor)(props);
32
32
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
33
33
  ...others,
34
34
  children: [
@@ -26,7 +26,7 @@ const _immer = require("immer");
26
26
  const _runtime = require("../../runtime");
27
27
  function usePluginEditor(props) {
28
28
  // eslint-disable-next-line @typescript-eslint/no-empty-function
29
- const { pluginType , value , onHideQueryEditorChange =()=>{} } = props; // setting onHideQueryEditorChange to empty function here because useEvent requires a function
29
+ const { pluginType, value, onHideQueryEditorChange = ()=>{} } = props; // setting onHideQueryEditorChange to empty function here because useEvent requires a function
30
30
  // Keep a stable reference so we don't run the effect below when we don't need to
31
31
  const onChange = (0, _core.useEvent)(props.onChange);
32
32
  const onHideQuery = (0, _core.useEvent)(onHideQueryEditorChange);
@@ -48,13 +48,13 @@ function usePluginEditor(props) {
48
48
  const hideQueryState = (0, _react.useRef)({
49
49
  [value.kind]: false
50
50
  });
51
- const { defaultPluginKinds } = (0, _runtime.usePluginRegistry)();
51
+ const { defaultPluginKinds } = (0, _runtime.usePluginRegistry)();
52
52
  const defaultPluginKind = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds[pluginType];
53
53
  const initPendingKind = !value.kind && defaultPluginKind ? defaultPluginKind : '';
54
54
  // When kind changes and we haven't loaded that plugin before, we will need to enter a "pending" state so that we
55
55
  // can generate proper initial spec values that match the new plugin kind
56
56
  const [pendingKind, setPendingKind] = (0, _react.useState)(initPendingKind);
57
- const { data: plugin , isFetching , error } = (0, _runtime.usePlugin)(pluginType, pendingKind);
57
+ const { data: plugin, isFetching, error } = (0, _runtime.usePlugin)(pluginType, pendingKind);
58
58
  (0, _react.useEffect)(()=>{
59
59
  // Nothing to do if no new plugin kind is pending
60
60
  if (pendingKind === '') return;
@@ -25,8 +25,8 @@ const _material = require("@mui/material");
25
25
  const _react = require("react");
26
26
  const _runtime = require("../../runtime");
27
27
  const PluginKindSelect = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
28
- const { pluginType , value: propValue , ...others } = props;
29
- const { data , isLoading } = (0, _runtime.useListPluginMetadata)(pluginType);
28
+ const { pluginType, value: propValue, ...others } = props;
29
+ const { data, isLoading } = (0, _runtime.useListPluginMetadata)(pluginType);
30
30
  // Pass an empty value while options are still loading so MUI doesn't complain about us using an "out of range" value
31
31
  const value = propValue !== '' && isLoading ? '' : propValue;
32
32
  // TODO: Does this need a loading indicator of some kind?
@@ -26,7 +26,7 @@ const _react = require("react");
26
26
  const _runtime = require("../../runtime");
27
27
  const _pluginindexes = require("./plugin-indexes");
28
28
  function PluginRegistry(props) {
29
- const { pluginLoader: { getInstalledPlugins , importPluginModule } , children , defaultPluginKinds } = props;
29
+ const { pluginLoader: { getInstalledPlugins, importPluginModule }, children, defaultPluginKinds } = props;
30
30
  const getPluginIndexes = (0, _pluginindexes.usePluginIndexes)(getInstalledPlugins);
31
31
  // De-dupe calls to import plugin modules
32
32
  const importCache = (0, _react.useRef)(new Map());
@@ -21,11 +21,11 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- usePluginIndexes: function() {
25
- return usePluginIndexes;
26
- },
27
24
  getTypeAndKindKey: function() {
28
25
  return getTypeAndKindKey;
26
+ },
27
+ usePluginIndexes: function() {
28
+ return usePluginIndexes;
29
29
  }
30
30
  });
31
31
  const _core = require("@perses-dev/core");
@@ -40,7 +40,7 @@ function usePluginIndexes(getInstalledPlugins) {
40
40
  const pluginMetadataByType = new Map();
41
41
  for (const resource of installedPlugins){
42
42
  for (const pluginMetadata of resource.spec.plugins){
43
- const { pluginType , kind } = pluginMetadata;
43
+ const { pluginType, kind } = pluginMetadata;
44
44
  // Index the plugin by type and kind to point at the module that contains it
45
45
  const key = getTypeAndKindKey(pluginType, kind);
46
46
  if (pluginResourcesByTypeAndKind.has(key)) {
@@ -24,8 +24,8 @@ const _jsxruntime = require("react/jsx-runtime");
24
24
  const _components = require("@perses-dev/components");
25
25
  const _runtime = require("../../runtime");
26
26
  function PluginSpecEditor(props) {
27
- const { pluginType , pluginKind , ...others } = props;
28
- const { data: plugin , isLoading , error } = (0, _runtime.usePlugin)(pluginType, pluginKind);
27
+ const { pluginType, pluginKind, ...others } = props;
28
+ const { data: plugin, isLoading, error } = (0, _runtime.usePlugin)(pluginType, pluginKind);
29
29
  if (error) {
30
30
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorAlert, {
31
31
  error: error
@@ -41,7 +41,7 @@ function PluginSpecEditor(props) {
41
41
  if (pluginType === 'Panel') {
42
42
  throw new Error('This editor should not be used for panel type. Please use Panel Spec Editor instead.');
43
43
  }
44
- const { OptionsEditorComponent } = plugin;
44
+ const { OptionsEditorComponent } = plugin;
45
45
  if (OptionsEditorComponent !== undefined) {
46
46
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(OptionsEditorComponent, {
47
47
  ...others
@@ -24,8 +24,8 @@ const _jsxruntime = require("react/jsx-runtime");
24
24
  const _material = require("@mui/material");
25
25
  const _context = require("../context");
26
26
  function ProjectSelect(props) {
27
- const { onChange , value , ...others } = props;
28
- const { data , isLoading } = (0, _context.useProjectList)();
27
+ const { onChange, value, ...others } = props;
28
+ const { data, isLoading } = (0, _context.useProjectList)();
29
29
  // While loading available values, just use an empty string so MUI select doesn't warn about values out of range
30
30
  const optionValue = isLoading ? '' : projectToOptionValue(value);
31
31
  // When the user makes a selection, convert the string option value back to a DatasourceSelector
@@ -0,0 +1,192 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ DEFAULT_REFRESH_INTERVAL_OPTIONS: function() {
25
+ return DEFAULT_REFRESH_INTERVAL_OPTIONS;
26
+ },
27
+ DEFAULT_TIME_RANGE_OPTIONS: function() {
28
+ return DEFAULT_TIME_RANGE_OPTIONS;
29
+ },
30
+ TimeRangeControls: function() {
31
+ return TimeRangeControls;
32
+ }
33
+ });
34
+ const _jsxruntime = require("react/jsx-runtime");
35
+ const _Refresh = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Refresh"));
36
+ const _material = require("@mui/material");
37
+ const _components = require("@perses-dev/components");
38
+ const _react = require("react");
39
+ const _constants = require("../../constants");
40
+ const _runtime = require("../../runtime");
41
+ function _interop_require_default(obj) {
42
+ return obj && obj.__esModule ? obj : {
43
+ default: obj
44
+ };
45
+ }
46
+ const DEFAULT_TIME_RANGE_OPTIONS = [
47
+ {
48
+ value: {
49
+ pastDuration: '5m'
50
+ },
51
+ display: 'Last 5 minutes'
52
+ },
53
+ {
54
+ value: {
55
+ pastDuration: '15m'
56
+ },
57
+ display: 'Last 15 minutes'
58
+ },
59
+ {
60
+ value: {
61
+ pastDuration: '30m'
62
+ },
63
+ display: 'Last 30 minutes'
64
+ },
65
+ {
66
+ value: {
67
+ pastDuration: '1h'
68
+ },
69
+ display: 'Last 1 hour'
70
+ },
71
+ {
72
+ value: {
73
+ pastDuration: '6h'
74
+ },
75
+ display: 'Last 6 hours'
76
+ },
77
+ {
78
+ value: {
79
+ pastDuration: '12h'
80
+ },
81
+ display: 'Last 12 hours'
82
+ },
83
+ {
84
+ value: {
85
+ pastDuration: '24h'
86
+ },
87
+ display: 'Last 1 day'
88
+ },
89
+ {
90
+ value: {
91
+ pastDuration: '7d'
92
+ },
93
+ display: 'Last 7 days'
94
+ },
95
+ {
96
+ value: {
97
+ pastDuration: '14d'
98
+ },
99
+ display: 'Last 14 days'
100
+ }
101
+ ];
102
+ const DEFAULT_REFRESH_INTERVAL_OPTIONS = [
103
+ {
104
+ value: {
105
+ pastDuration: '0s'
106
+ },
107
+ display: 'Off'
108
+ },
109
+ {
110
+ value: {
111
+ pastDuration: '5s'
112
+ },
113
+ display: '5s'
114
+ },
115
+ {
116
+ value: {
117
+ pastDuration: '10s'
118
+ },
119
+ display: '10s'
120
+ },
121
+ {
122
+ value: {
123
+ pastDuration: '15s'
124
+ },
125
+ display: '15s'
126
+ },
127
+ {
128
+ value: {
129
+ pastDuration: '30s'
130
+ },
131
+ display: '30s'
132
+ },
133
+ {
134
+ value: {
135
+ pastDuration: '60s'
136
+ },
137
+ display: '1m'
138
+ }
139
+ ];
140
+ const DEFAULT_HEIGHT = '34px';
141
+ function TimeRangeControls({ heightPx, showTimeRangeSelector = true, showRefreshButton = true, showRefreshInterval = true, timePresets = DEFAULT_TIME_RANGE_OPTIONS }) {
142
+ const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = (0, _runtime.useTimeRange)();
143
+ // Convert height to a string, then use the string for styling
144
+ const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
145
+ // add time preset if one does not match duration given in time range
146
+ if ('pastDuration' in timeRange && !timePresets.some((option)=>option.value.pastDuration === timeRange['pastDuration'])) {
147
+ timePresets.push({
148
+ value: {
149
+ pastDuration: timeRange['pastDuration']
150
+ },
151
+ display: `Last ${timeRange['pastDuration']}`
152
+ });
153
+ }
154
+ // set the new refresh interval both in the dashboard context & as query param
155
+ const handleRefreshIntervalChange = (0, _react.useCallback)((duration)=>{
156
+ setRefreshInterval(duration);
157
+ }, [
158
+ setRefreshInterval
159
+ ]);
160
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
161
+ direction: "row",
162
+ spacing: 1,
163
+ children: [
164
+ showTimeRangeSelector && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.DateTimeRangePicker, {
165
+ timeOptions: timePresets,
166
+ value: timeRange,
167
+ onChange: setTimeRange,
168
+ height: height
169
+ }),
170
+ showRefreshButton && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
171
+ description: _constants.TOOLTIP_TEXT.refresh,
172
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ToolbarIconButton, {
173
+ "aria-label": _constants.TOOLTIP_TEXT.refresh,
174
+ onClick: refresh,
175
+ sx: {
176
+ height
177
+ },
178
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Refresh.default, {})
179
+ })
180
+ }),
181
+ showRefreshInterval && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
182
+ description: _constants.TOOLTIP_TEXT.refreshInterval,
183
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.RefreshIntervalPicker, {
184
+ timeOptions: DEFAULT_REFRESH_INTERVAL_OPTIONS,
185
+ value: refreshInterval,
186
+ onChange: handleRefreshIntervalChange,
187
+ height: height
188
+ })
189
+ })
190
+ ]
191
+ });
192
+ }
@@ -0,0 +1,30 @@
1
+ // Copyright 2023 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _export_star(require("./TimeRangeControls"), exports);
18
+ function _export_star(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
+ Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ }
28
+ });
29
+ return from;
30
+ }